Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2006, 5:28:10 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: compiles again, BUT well…. i do not expect it to run anymore

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/parser/ini_parser/ini_parser.h

    r6981 r7203  
    1515
    1616#include <list>
     17#include <string>
    1718
    1819//! ini-file parser
     
    2728    struct IniEntry
    2829    {
    29       char*               comment;  //!< A Comment that is appendet to the Top of this Entry.
    30       char*               name;     //!< name of a given Entry
    31       char*               value;    //!< value of a given Entry
     30      std::string         comment;  //!< A Comment that is appendet to the Top of this Entry.
     31      std::string         name;     //!< name of a given Entry
     32      std::string         value;    //!< value of a given Entry
    3233    };
    3334
     
    3536    struct IniSection
    3637    {
    37       char*               comment;  //!< A Comment that is appendet to the Top of this Section.
    38       char*               name;     //!< name of a given section
     38      std::string         comment;  //!< A Comment that is appendet to the Top of this Section.
     39      std::string         name;     //!< name of a given section
    3940      std::list<IniEntry> entries;  //!< a list of entries for this section
    4041    };
     
    4243
    4344  public:
    44     IniParser (const char* filename = NULL);
     45    IniParser (const std::string& filename = "");
    4546    virtual ~IniParser ();
    4647
    4748    /** @returns true if the file is opened, false otherwise*/
    48     bool isOpen() const { return (this->fileName != NULL)? true : false; };
     49    bool isOpen() const { return (!this->fileName.empty())? true : false; };
    4950    /** @returns the fileName we have opened. */
    50     const char* getFileName() const { return this->fileName; };
     51    const std::string& getFileName() const { return this->fileName; };
    5152
    52     bool readFile(const char* fileName);
    53     bool writeFile(const char* fileName) const;
     53    bool readFile(const std::string& fileName);
     54    bool writeFile(const std::string& fileName) const;
    5455
    55     void setFileComment(const char* fileComment);
    56     const char* getFileComment() const { return this->comment; };
     56    void setFileComment(const std::string& fileComment);
     57    const std::string& getFileComment() const { return this->comment; };
    5758
    58     bool addSection(const char* sectionName);
    59     bool getSection(const char* sectionName);
    60     void setSectionComment(const char* comment, const char* sectionName);
    61     const char* getSectionComment(const char* sectionNane) const;
     59    bool addSection(const std::string& sectionName);
     60    bool getSection(const std::string& sectionName);
     61    void setSectionComment(const std::string& comment, const std::string& sectionName);
     62    const std::string& getSectionComment(const std::string& sectionNane) const;
    6263
    6364    // iterate through sections with these Functions
    6465    void firstSection();
    65     const char* nextSection();
     66    const std::string& nextSection();
    6667
    6768
    68     bool addVar(const char* entryName, const char* value, const char* sectionName = NULL);
    69     const char* getVar(const char* entryName, const char* sectionName, const char* defaultValue = "") const;
    70     void setEntryComment(const char* comment, const char* entryName, const char* sectionName);
    71     const char* getEntryComment(const char* entryName, const char* sectionName) const;
     69    bool addVar(const std::string& entryName, const std::string& value, const std::string& sectionName = NULL);
     70    const std::string& getVar(const std::string& entryName, const std::string& sectionName, const std::string& defaultValue = "") const;
     71    void setEntryComment(const std::string& comment, const std::string& entryName, const std::string& sectionName);
     72    const std::string& getEntryComment(const std::string& entryName, const std::string& sectionName) const;
    7273
    7374    // iterate Through Variables with these Functions.
     
    7778
    7879    // retrieving functions when iterating.
    79     const char* getCurrentSection() const;
    80     const char* getCurrentName() const;
    81     const char* getCurrentValue() const;
     80    const std::string& getCurrentSection() const;
     81    const std::string& getCurrentName() const;
     82    const std::string& getCurrentValue() const;
    8283
    8384
     
    8889  private:
    8990    void deleteSections();
    90     void setFileName(const char* fileName);
     91    void setFileName(const std::string& fileName);
    9192
    9293    void setFileComment();
     
    9495    void setEntryComment();
    9596
    96     std::list<IniSection>::const_iterator getSectionIT(const char* sectionName) const;
    97     std::list<IniSection>::iterator getSectionIT(const char* sectionName);
     97    std::list<IniSection>::const_iterator getSectionIT(const std::string& sectionName) const;
     98    std::list<IniSection>::iterator getSectionIT(const std::string& sectionName);
    9899
    99     std::list<IniEntry>::const_iterator getEntryIT(const char* entryName, const char* sectionName = NULL) const;
    100     std::list<IniEntry>::iterator getEntryIT(const char* entryName, const char* sectionName = NULL);
     100    std::list<IniEntry>::const_iterator getEntryIT(const std::string& entryName, const std::string& sectionName = NULL) const;
     101    std::list<IniEntry>::iterator getEntryIT(const std::string& entryName, const std::string& sectionName = NULL);
    101102
    102103  private:
    103     char*                            fileName;        //!< The name of the File that was parsed.
    104     char*                            comment;         //!< A Comment for the header of this File.
     104    std::string                      fileName;        //!< The name of the File that was parsed.
     105    std::string                      comment;         //!< A Comment for the header of this File.
    105106    std::list<IniSection>            sections;        //!< a list of all stored Sections of the Parser
    106107    std::list<IniSection>::iterator  currentSection;  //!< the current selected Section
    107108    std::list<IniEntry>::iterator    currentEntry;    //!< the current selected entry (in currentSection)
    108109
    109     std::list<char*>                 commentList;     //!< A list of Comments. (this is for temporary saving of Comments, that are inserted in front of Sections/Entries.)
     110    std::list<std::string>           commentList;     //!< A list of Comments. (this is for temporary saving of Comments, that are inserted in front of Sections/Entries.)
     111
     112
     113    static const std::string         emptyString;
    110114};
    111115
Note: See TracChangeset for help on using the changeset viewer.