cxxtools::IniFile Class Reference

#include <cxxtools/inifile.h>

Public Member Functions

 IniFile ()
 IniFile (const std::string &filename)
 IniFile (std::istream &in)
bool exists (const std::string &section) const
 Returns true, if section exists.
bool exists (const std::string &section, const std::string &token) const
 Returns true, if key exists in section exists.
std::string getValue (const std::string &section, const std::string &token, const std::string &def=std::string()) const
 Returns associated value from section-key-pair or default-value.
template<typename T >
getValueT (const std::string &section, const std::string &token, const T &def) const
 Get the value and convert it with istream-operator.
void setValue (const std::string &section, const std::string &key, const std::string &value)
 setting a new value
template<typename T >
void setValueT (const std::string &section, const std::string &key, const T &value)
 setting a new value with a type (need output-operator for ostream).
template<typename OutputIterator >
void getSections (OutputIterator oi)
 Get the names of sections.
template<typename OutputIterator >
void getKeys (const std::string &section, OutputIterator oi)
 Get the keys of a section.

Friends

std::ostream & operator<< (std::ostream &out, const IniFile &ini)
 Outputs ini-file to a output-stream.

Constructor & Destructor Documentation

cxxtools::IniFile::IniFile ( )
inline
cxxtools::IniFile::IniFile ( const std::string &  filename)
explicit
cxxtools::IniFile::IniFile ( std::istream &  in)
explicit

Member Function Documentation

bool cxxtools::IniFile::exists ( const std::string &  section) const
inline

Returns true, if section exists.

bool cxxtools::IniFile::exists ( const std::string &  section,
const std::string &  token 
) const
inline

Returns true, if key exists in section exists.

template<typename OutputIterator >
void cxxtools::IniFile::getKeys ( const std::string &  section,
OutputIterator  oi 
)
inline

Get the keys of a section.

example1: cxxtools::IniFile ini("my.ini");

// copy keys into a container std::set<std::string> keys; ini.getKeys("section2", std::inserter(s, s.begin());

// or printing the keys: ini.getKeys("section2", std::ostream_iterator(std::cout, "\n"));

template<typename OutputIterator >
void cxxtools::IniFile::getSections ( OutputIterator  oi)
inline

Get the names of sections.

example1: cxxtools::IniFile ini("my.ini");

// copy names of sections into a container std::set<std::string> keys; ini.getSections(std::inserter(s, s.begin());

// or printing the names: ini.getSections(std::ostream_iterator(std::cout, "\n"));

std::string cxxtools::IniFile::getValue ( const std::string &  section,
const std::string &  token,
const std::string &  def = std::string() 
) const
inline

Returns associated value from section-key-pair or default-value.

template<typename T >
T cxxtools::IniFile::getValueT ( const std::string &  section,
const std::string &  token,
const T &  def 
) const
inline

Get the value and convert it with istream-operator.

The return-type is identified by the default-value-type.

void cxxtools::IniFile::setValue ( const std::string &  section,
const std::string &  key,
const std::string &  value 
)
inline

setting a new value

template<typename T >
void cxxtools::IniFile::setValueT ( const std::string &  section,
const std::string &  key,
const T &  value 
)
inline

setting a new value with a type (need output-operator for ostream).

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const IniFile ini 
)
friend

Outputs ini-file to a output-stream.


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