ARC SDK
|
#include <ArcConfigIni.h>
Public Member Functions | |
ConfigIni (const char *filename) | |
ConfigIni (ConfigFile &f) | |
~ConfigIni (void) | |
Ordinary destructor. More... | |
operator bool (void) const | |
Returns true if proper configuration file is associated. More... | |
bool | AddSection (const char *name) |
void | SetSectionIndicator (const char *ind=NULL) |
bool | ReadNext (std::string &line) |
bool | ReadNext (std::string &name, std::string &value) |
const char * | Section (void) const |
bool | SectionNew (void) const |
Returns true if last ReadNext() switched to next section. More... | |
int | SectionNum (void) const |
const char * | SectionMatch (void) const |
const char * | SubSection (void) const |
Returns name of subsection to which last read line belongs. More... | |
const char * | SubSectionMatch (const char *name) |
const char * | SectionIdentifier (void) const |
Return identifier of the section to which last read line belongs. More... | |
Static Public Member Functions | |
static int | NextArg (const char *line, std::string &str, char separator=' ', char quotes='\0') |
static std::string | NextArg (std::string &rest, char separator=' ', char quotes='\0') |
This class is used to process ini-like configuration files. Those files consist of sections which have folloving format:
[section/subsection:identifier] key=value key=value
The section names are enclosed in [] and consist of multiple parts separated by /. The section may have optional identifier separated from rest of then name by :. The section name parts may not contain : character. Hence if : is present in name all characters to the right are treated as identifier.
Arc::ConfigIni::ConfigIni | ( | const char * | filename | ) |
Creates object associated with file located at filename. File is kept open and is closed in destructor.
Arc::ConfigIni::ConfigIni | ( | ConfigFile & | f | ) |
Creates object associated with already open file f. Associated file will not be closed in destructor and corresponding ConfigFile object must be valid during whole lifetime of this object.
Arc::ConfigIni::~ConfigIni | ( | void | ) |
Ordinary destructor.
bool Arc::ConfigIni::AddSection | ( | const char * | name | ) |
Specifies section name which will be processed. Unspecified sections will be skipped by ReadNext() methods.
|
static |
Helper method which reads keyword from string at 'line' separated by 'separator' and stores it in 'str'. If separator is set to \0 then whole line is consumed. If quotes are not \0 keyword may be enclosed in specified character. Returns position of first character in 'line', which is not in read keyword.
|
static |
Reads keyword from string at 'rest' and reduces 'rest' by removing keyword from it. The way it processes keyword is similar to static NextArg method.
|
inline |
Returns true if proper configuration file is associated.
bool Arc::ConfigIni::ReadNext | ( | std::string & | line | ) |
Read next line of configuration from sesction(s) specified by AddSection(). Returns true in case of success and fills content of line into line.
bool Arc::ConfigIni::ReadNext | ( | std::string & | name, |
std::string & | value | ||
) |
Read next line of configuration from sesction(s) specified by AddSection(). Returns true in case of success and fills split content of line into command and value.
|
inline |
Return full name of the section to which last read line belongs. This name also includes subsection name.
|
inline |
Return identifier of the section to which last read line belongs.
|
inline |
Returns name of the section to which last read line matched. It is similar to Section() method but name is as specified in AddSection() and hence does not contain subsection(s).
|
inline |
Returns true if last ReadNext() switched to next section.
|
inline |
Return number of the section to which last read line belongs. Numbers are assigned in order they are passed to AddSection() method starting from 0.
|
inline |
By default ReadNext does not inform about presence of the section. Only commands from sections are returned. If section indicator is set ReadNext returns immediately when new section is started with indicator reported as read line. Note: indicator can't be empty string.
|
inline |
Returns name of subsection to which last read line belongs.
const char* Arc::ConfigIni::SubSectionMatch | ( | const char * | name | ) |
Return name of subsubsection to which last read line belongs relative to subsection given by name. If current subsection does not match specified name then NULL is returned.