Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2006, 9:21:29 AM (18 years ago)
Author:
bensch
Message:

trunk: completely doxygened and finalized IniParser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/parser/ini_parser/ini_parser.cc

    r9881 r9883  
    1616               now the File is parsed at the initialisation,
    1717               and informations is gathered there.
     18   2006-10-10: Complete reimplementation again :)
     19               New STL-like style. The Parser has no state itself
     20               Elements as Nodes
    1821*/
    1922
     
    264267 * @return True on success (section was found).
    265268 */
    266 bool IniParser::Document::setSectionComment(const std::string& sectionName, const std::string& comment)
     269bool IniParser::Document::setSectionsComment(const std::string& sectionName, const std::string& comment)
    267270{
    268271  Section::iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
     
    276279}
    277280
    278 
     281/**
     282 * @brief Retrieves the comment for a specified section
     283 * @param sectionName The name of the section
     284 * @returns The Comment of the section.
     285 */
     286const std::string& IniParser::Document::getSectionsComment(const std::string& sectionName) const
     287{
     288  Section::const_iterator section = std::find(this->_sections.begin(), this->_sections.end(), sectionName);
     289  if (section != this->_sections.end())
     290  {
     291    return (*section).comment();
     292  }
     293  else
     294    return IniParser::_emptyString;
     295}
    279296
    280297/**
     
    607624}
    608625
    609 void IniParser::setFileComment(const std::string& fileComment)
    610 {
    611   this->_document.setComment(fileComment);
    612 }
    613 
    614 /**
    615  * @brief adds a section to the list of Sections,
    616  * if no Section list is availiable, it will create it
    617  * @param sectionName the Name of the section to add
    618  * @return true on success... there is only success or segfault :)
    619  */
    620 IniParser::Section& IniParser::addSection(const std::string& sectionName)
    621 {
    622   return this->_document.addSection(sectionName);
    623 }
    624 
    625 
    626 /**
    627  * @brief adds a new Entry to either the currentSection or the section called by sectionName
    628  * @param entryName the Name of the Entry to add
    629  * @param value the value to assign to this entry
    630  * @param sectionName if NULL then this entry will be set to the currentSection
    631  * otherwise to the section refered to by sectionName.
    632  * If both are NULL no entry will be added
    633  * @return The Entry, that was added.
    634  */
    635 bool IniParser::addEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, const std::string& comment)
    636 {
    637   return this->_document.addEntry(sectionName, entryName, value, comment);
    638 }
    639 
    640 /**
    641  * @brief edits the entry speciefied by entryName in sectionName/currentSection or creates it if it doesn't exist
    642  * @param entryName the Name of the Entry to add
    643  * @param value the value to assign to this entry
    644  * @param sectionName if NULL then this entry will be set to the currentSection
    645  * otherwise to the section refered to by sectionName.
    646  * If both are NULL no entry will be added
    647  * @return true if everything is ok false on error
    648  */
    649 bool IniParser::editEntry(const std::string& sectionName, const std::string& entryName, const std::string& value, bool createMissing)
    650 {
    651   return this->_document.editEntry(sectionName, entryName, value, createMissing);
    652 }
    653 
    654 
    655 /**
    656  * @brief directly acesses an entry in a section
    657  * @param sectionName: the section where the entry is to be found
    658  * @param entryName: the name of the entry to find
    659  * @param defaultValue: what should be returned in case the entry cannot be found
    660  * @return The Value of the Entry.
    661  */
    662 const std::string& IniParser::getValue(const std::string& sectionName, const std::string& entryName, const std::string& defaultValue) const
    663 {
    664   return this->_document.getValue(sectionName, entryName, defaultValue);
    665 }
    666 
    667 /**
    668  * Set the Comment of a specified Entry.
    669  * @param comment the Comment to set
    670  * @param entryName the Name of the Entry
    671  * @param sectionName the Name of the Section
    672  */
    673 void IniParser::setEntryComment(const std::string& sectionName, const std::string& entryName, const std::string& comment)
    674 {
    675   this->_document.setEntryComment(sectionName, entryName, comment);
    676 }
    677 
    678 /**
    679  * @param entryName the Entry to query for
    680  * @param sectionName the Section to Query for
    681  * @returns the queried Comment.
    682  */
    683 const std::string& IniParser::getEntryComment(const std::string& sectionName, const std::string& entryName) const
    684 {
    685   return this->_document.getEntryComment(sectionName, entryName);
    686 }
    687626
    688627/**
Note: See TracChangeset for help on using the changeset viewer.