Changeset 9884 in orxonox.OLD for trunk/src/lib/parser
- Timestamp:
- Oct 12, 2006, 9:51:45 AM (18 years ago)
- Location:
- trunk/src/lib/parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/parser/ini_parser/ini_parser.cc
r9883 r9884 20 20 Elements as Nodes 21 21 */ 22 22 /*! 23 * @file ini_parser.cc 24 */ 23 25 24 26 #include "ini_parser.h" -
trunk/src/lib/parser/preferences/preferences.h
r9869 r9884 15 15 class IniFilePrefsReader; 16 16 17 typedef struct { 18 std::string name; 19 MultiType value; 20 bool modified; 21 } prefItem; 17 //! A default singleton class. 18 class Preferences : public BaseObject 19 { 20 ObjectListDeclaration(Preferences); 21 public: 22 virtual ~Preferences(void); 23 /** @returns a Pointer to the only object of this Class */ 24 inline static Preferences* getInstance(void) { if (!singletonRef) singletonRef = new Preferences(); return singletonRef; }; 22 25 23 typedef struct { 24 std::string sectionName; 25 std::list<prefItem> items; 26 } prefSection ; 26 //check if this entry exists 27 bool sectionExists(const std::string& section ); 28 bool exists(const std::string& section, const std::string& name); 29 30 void setString(const std::string& section, const std::string& name, const std::string& value, bool dontSetModified = false); 31 void setInt(const std::string& section, const std::string& name, int value, bool dontSetModified = false); 32 void setFloat(const std::string& section, const std::string& name, float value, bool dontSetModified = false); 33 void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false); 34 35 std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue); 36 int getInt(const std::string& section, const std::string& name, int defaultValue); 37 float getFloat(const std::string& section, const std::string& name, float defaultValue); 38 MultiType getMultiType(const std::string& section, const std::string& name, const MultiType& defaultValue); 39 40 void setUserIni(const std::string& fileName); 41 42 bool save(); 43 44 void debug(); 45 46 std::list<std::string> listKeys( const std::string section ); 47 48 private: 49 typedef struct 50 { 51 std::string name; 52 MultiType value; 53 bool modified; 54 } 55 prefItem; 56 57 typedef struct 58 { 59 std::string sectionName; 60 std::list<prefItem> items; 61 } 62 prefSection ; 27 63 28 64 29 //! A default singleton class. 30 class Preferences : public BaseObject { 31 ObjectListDeclaration(Preferences); 32 public: 33 virtual ~Preferences(void); 34 /** @returns a Pointer to the only object of this Class */ 35 inline static Preferences* getInstance(void) { if (!singletonRef) singletonRef = new Preferences(); return singletonRef; }; 65 private: 66 Preferences(void); 36 67 37 //check if this entry exists 38 bool sectionExists(const std::string& section ); 39 bool exists(const std::string& section, const std::string& name); 68 private: 69 static Preferences* singletonRef; 40 70 41 void setString(const std::string& section, const std::string& name, const std::string& value, bool dontSetModified = false); 42 void setInt(const std::string& section, const std::string& name, int value, bool dontSetModified = false); 43 void setFloat(const std::string& section, const std::string& name, float value, bool dontSetModified = false); 44 void setMultiType(const std::string& section, const std::string& name, const MultiType& value, bool dontSetModified = false); 71 std::list<prefSection> data; 45 72 46 std::string getString(const std::string& section, const std::string& name, const std::string& defaultValue); 47 int getInt(const std::string& section, const std::string& name, int defaultValue); 48 float getFloat(const std::string& section, const std::string& name, float defaultValue); 49 MultiType getMultiType(const std::string& section, const std::string& name, const MultiType& defaultValue); 73 std::list<IniFilePrefsReader*> iniFilePrefsReaders; 50 74 51 void setUserIni(const std::string& fileName); 52 53 bool save(); 54 55 void debug(); 56 57 std::list<std::string> listKeys( const std::string section ); 58 59 60 private: 61 Preferences(void); 62 static Preferences* singletonRef; 63 64 std::list<prefSection> data; 65 66 std::list<IniFilePrefsReader*> iniFilePrefsReaders; 67 68 std::string fileName; 75 std::string fileName; 69 76 70 77 };
Note: See TracChangeset
for help on using the changeset viewer.