Ignore:
Timestamp:
09/26/2008 11:32:18 AM (4 years ago)
Author:
guyru
Message:
  • Import settings and highscores to new configuration class.
  • Fix segementation fault caused by trying to close an unopened db in DBwrapper destructor.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/configuration.h

    r158 r159  
    2222#define OPENYAHTZEE_CONFIGURATION_INC 
    2323 
     24#include "DBwrapper.h" // used in the back-compatibility code 
    2425#include <string> 
    2526#include <fstream> 
     
    3334typedef std::list<HighscoreItem> HighscoreList; 
    3435 
     36static const char* DEFAULT_HIGHSCORE_SIZE = "20"; 
     37 
    3538class Configuration { 
    3639public: 
     
    4144        void load(std::string file); 
    4245 
     46        /** 
     47         * Saves the configurations (setting and highscores) to the file 
     48         * specified when the class was constructed 
     49         */ 
    4350        void save(); 
     51 
     52        /** 
     53         * \return the value associated with the specified key, or empty 
     54         * string if that key is missing 
     55         */ 
     56        std::string get(std::string key); 
     57        /** 
     58         * Associates the given value with the given key. You must call 
     59         * save() in order to make the change permanent. 
     60         * \return pointer to self. 
     61         */ 
     62        Configuration *set(std::string key, std::string value); 
    4463private: 
    4564        /** 
     
    5372        void saveSettings(std::ofstream *file); 
    5473        void saveHighscores(std::ofstream *file); 
     74 
     75        /** 
     76         * Loads default settings 
     77         */ 
     78        void loadDefaultSettings(); 
    5579         
    5680        std::map<std::string, std::string> m_settings; 
     
    5882 
    5983        std::string m_file; 
     84 
     85        /* The following functions and variables are used for legacy SQLite 
     86         * configuration file, and could be dropped. 
     87         */ 
     88        DBwrapper old_db; 
     89        std::string getKeyFromDb(std::string key); 
     90        void importSettings(); 
     91        void importHighscores(); 
    6092}; 
    6193 
Note: See TracChangeset for help on using the changeset viewer.