ARC SDK
Public Member Functions | Static Public Member Functions
Arc::ConfigIni Class Reference

#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')
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ConfigIni() [1/2]

Arc::ConfigIni::ConfigIni ( const char *  filename)

Creates object associated with file located at filename. File is kept open and is closed in destructor.

◆ ConfigIni() [2/2]

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.

◆ ~ConfigIni()

Arc::ConfigIni::~ConfigIni ( void  )

Ordinary destructor.

Member Function Documentation

◆ AddSection()

bool Arc::ConfigIni::AddSection ( const char *  name)

Specifies section name which will be processed. Unspecified sections will be skipped by ReadNext() methods.

◆ NextArg() [1/2]

static int Arc::ConfigIni::NextArg ( const char *  line,
std::string &  str,
char  separator = ' ',
char  quotes = '\0' 
)
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.

◆ NextArg() [2/2]

static std::string Arc::ConfigIni::NextArg ( std::string &  rest,
char  separator = ' ',
char  quotes = '\0' 
)
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.

◆ operator bool()

Arc::ConfigIni::operator bool ( void  ) const
inline

Returns true if proper configuration file is associated.

◆ ReadNext() [1/2]

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.

◆ ReadNext() [2/2]

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.

◆ Section()

const char* Arc::ConfigIni::Section ( void  ) const
inline

Return full name of the section to which last read line belongs. This name also includes subsection name.

◆ SectionIdentifier()

const char* Arc::ConfigIni::SectionIdentifier ( void  ) const
inline

Return identifier of the section to which last read line belongs.

◆ SectionMatch()

const char* Arc::ConfigIni::SectionMatch ( void  ) const
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).

◆ SectionNew()

bool Arc::ConfigIni::SectionNew ( void  ) const
inline

Returns true if last ReadNext() switched to next section.

◆ SectionNum()

int Arc::ConfigIni::SectionNum ( void  ) const
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.

◆ SetSectionIndicator()

void Arc::ConfigIni::SetSectionIndicator ( const char *  ind = NULL)
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.

◆ SubSection()

const char* Arc::ConfigIni::SubSection ( void  ) const
inline

Returns name of subsection to which last read line belongs.

◆ SubSectionMatch()

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.


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