NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nds::IniFileParser Class Reference

Detailed Description

Parses an INI file and stores all the found sections and keys for future retrieval via getString().

#include <iniFileParser.h>

Public Member Functions

 IniFileParser (std::istream &inputStream)
 Parses the INI file in the input stream and stores all the found sections and keys with the corresponding values. More...
 
const std::string & getString (const std::string &section, const std::string &key, const std::string &defaultValue) const
 Retrieve the value for a specific key in the parsed INI file. More...
 
bool keyExists (const std::string &section, const std::string &key) const
 Return true if the requested key exists and has a value (even an empty one), false otherwise. More...
 

Constructor & Destructor Documentation

nds::IniFileParser::IniFileParser ( std::istream &  inputStream)

Parses the INI file in the input stream and stores all the found sections and keys with the corresponding values.

Parameters
inputStreamthe stream to parse

Member Function Documentation

const std::string& nds::IniFileParser::getString ( const std::string &  section,
const std::string &  key,
const std::string &  defaultValue 
) const

Retrieve the value for a specific key in the parsed INI file.

Throws INIParserMissingSection if the specified section cannot be found.

Parameters
sectionthe section to which the key belongs
keythe key to retrieve
defaultValuethe default value to return in the case that the key cannot be found
Returns
the value related to the key or defaultValue if the key doesn't exist
bool nds::IniFileParser::keyExists ( const std::string &  section,
const std::string &  key 
) const

Return true if the requested key exists and has a value (even an empty one), false otherwise.

Throws INIParserMissingSection if the specified section cannot be found.

Parameters
sectionthe section to which the key belongs
keythe key
Returns
true if the key exists in the INI file, false otherwise

The documentation for this class was generated from the following file: