Changeset 9881 in orxonox.OLD for trunk/src/lib/parser/ini_parser/ini_parser.h
- Timestamp:
- Oct 10, 2006, 4:23:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/parser/ini_parser/ini_parser.h
r9880 r9881 8 8 #ifndef _INI_PARSER_H 9 9 #define _INI_PARSER_H 10 11 #define PARSELINELENGHT 512 //!< how many chars to read at once12 10 13 11 #include <string> … … 22 20 public: 23 21 //////////////////////////////////// 24 /// A Nodefor a Ini-Node. The base of all INI-elements.22 /// A class for a Ini-Node. The base of all INI-elements. 25 23 class Node 26 24 { 27 25 public: 28 26 Node(const std::string& name, const std::string& comment = ""); 27 //! Simple destructor 29 28 virtual ~Node() {}; 29 /** @returns the name of the Node */ 30 30 const std::string& name() const { return _name; }; 31 /** @returns the Comment of the Node */ 31 32 const std::string& comment() const { return _comment; }; 33 /** @param name the name to set for this node */ 32 34 void setName(const std::string& name) { this->_name = name; }; 35 /** @param comment the Comment to set for this node */ 33 36 void setComment(const std::string& comment) { this->_comment = comment; }; 34 37 38 /** @param name the name to compare against this nodes name @returns true on match */ 35 39 bool operator==(const std::string& name) const { return _name == name; }; 36 bool operator==(const Node& node) const { return this->_name == node._name; }; 37 40 41 /** @brief displays some debug information about the node */ 38 42 virtual void debug() const = 0; 39 43 … … 48 52 public: 49 53 Entry(const std::string& name, const std::string& value = "", const std::string& comment = ""); 54 /** @returns the Value of the Entry */ 50 55 const std::string& value() const { return _value; }; 56 /** @param value sets the value of the Entry */ 51 57 void setValue (const std::string& value) { _value = value; }; 52 58 … … 54 60 55 61 public: 56 typedef std::list<Entry> list;57 typedef list::iterator iterator;58 typedef list::const_iterator const_iterator;59 60 private: 61 std::string _value;//!< value of a given Entry62 typedef std::list<Entry> list; //!< A Type definition for lists of Entries. 63 typedef list::iterator iterator; //!< A Type definition for iterators of Entries. 64 typedef list::const_iterator const_iterator; //!< A Type definition for constant iterators of Entries. 65 66 private: 67 std::string _value; //!< value of a given Entry 62 68 }; 63 69 … … 75 81 const std::string& getEntryComment(const std::string& entryName) const; 76 82 83 /** @returns the List of Entries */ 77 84 const Entry::list& entries() const { return _entries; } 78 85 Entry* getEntry(const std::string& entryName); 79 86 80 87 Entry::const_iterator getEntryIt(const std::string& entryName) const; 88 /** @returns an Iterator pointing to the beginning of the entries. */ 81 89 Entry::iterator begin() { return _entries.begin(); }; 90 /** @returns a constant Iterator pointing to the beginning of the entries */ 82 91 Entry::const_iterator begin() const { return _entries.begin(); }; 92 /** @returns an Iterator pointing to the end of the entries */ 83 93 Entry::iterator end() { return _entries.end(); }; 94 /** @returns a constant Iterator pointing to the end of the entries */ 84 95 Entry::const_iterator end() const { return _entries.end(); }; 85 96 … … 89 100 90 101 public: 91 typedef std::list<Section> list;92 typedef list::iterator iterator;93 typedef list::const_iterator const_iterator;94 95 private: 96 Entry::list _entries;//!< a list of entries for this section102 typedef std::list<Section> list; //!< A Type definition for lists of Sections 103 typedef list::iterator iterator; //!< A Type definition for iterators of Sectionlists. 104 typedef list::const_iterator const_iterator; //!< A Type definition for constant iterators of Sectionlists. 105 106 private: 107 Entry::list _entries; //!< a list of entries for this section 97 108 }; 98 109 … … 107 118 bool setSectionComment(const std::string& sectionName, const std::string& comment); 108 119 120 /** @returns list of all sections */ 109 121 const Section::list& sections() const { return _sections; } 110 122 Section* getSection(const std::string& sectionName); 111 123 112 124 Section::const_iterator getSectionIt(const std::string& sectionName) const; 125 /** @returns an Iterator poining to the beginning of the Sections List */ 113 126 Section::iterator begin() { return _sections.begin(); }; 127 /** @returns a constant Iterator poining to the beginning of the Sections List */ 114 128 Section::const_iterator begin() const { return _sections.begin(); }; 129 /** @returns an Iterator poining to the end of the Sections List */ 115 130 Section::iterator end() { return _sections.end(); }; 131 /** @returns a constant Iterator poining to the end of the Sections List */ 116 132 Section::const_iterator end() const { return _sections.end(); }; 117 133 … … 128 144 129 145 private: 130 Section::list 146 Section::list _sections; //!< a list of all stored Sections of the Parser. 131 147 }; 132 148 … … 142 158 /// Read and Write the File 143 159 bool readFile(const std::string& fileName, bool keepSettings = false); 144 bool writeFile(const std::string& fileName ) const;160 bool writeFile(const std::string& fileName = "") const; 145 161 146 162 void setFileComment(const std::string& fileComment); 163 /** @returns comments for the File. */ 147 164 const std::string& getFileComment() const { return this->_document.comment(); }; 148 165 … … 150 167 Section& addSection(const std::string& sectionName); 151 168 // iterate through sections with these Functions 169 //! see Section::getSection() 152 170 Section* getSection(const std::string& sectionName) { return this->_document.getSection(sectionName); }; 153 171 Section::const_iterator getSectionIt(const std::string& sectionName) const; 154 172 173 //! see Section::begin() 155 174 Section::iterator begin() { return this->_document.begin(); }; 175 //! see Section::begin() 156 176 Section::const_iterator begin() const { return this->_document.begin(); }; 177 //! see Section::end() 157 178 Section::iterator end() { return this->_document.end(); }; 179 //! see Section::end() 158 180 Section::const_iterator end() const { return this->_document.end(); }; 159 181 … … 175 197 void setNodeComment(Node* node, std::list<std::string>* comments); 176 198 private: 177 std::string _fileName; 178 Document _document; 199 std::string _fileName; //!< The name of the File that is parsed here. 200 Document _document; //!< The Document inside of the file. 179 201 180 202 static const std::string _emptyString; //!< Just an Empty String that will be returned if nothing else is found.
Note: See TracChangeset
for help on using the changeset viewer.