liblcf
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
INIReader Class Reference

#include <inireader.h>

+ Collaboration diagram for INIReader:

Public Member Functions

 INIReader (std::string filename)
 
int ParseError () const
 
std::string Get (std::string section, std::string name, std::string default_value)
 
long GetInteger (std::string section, std::string name, long default_value)
 

Static Private Member Functions

static std::string MakeKey (std::string section, std::string name)
 
static int ValueHandler (void *user, const char *section, const char *name, const char *value)
 

Private Attributes

int _error
 
std::map< std::string,
std::string > 
_values
 

Detailed Description

Read an INI file into easy-to-access name/value pairs. (Note that I've gone for simplicity here rather than speed, but it should be pretty decent.)

Definition at line 45 of file inireader.h.

Constructor & Destructor Documentation

INIReader::INIReader ( std::string  filename)

Construct INIReader and parse given filename. See ini.h for more info about the parsing.

Definition at line 42 of file inireader.cpp.

References _error, ini_parse(), and ValueHandler().

+ Here is the call graph for this function:

Member Function Documentation

string INIReader::Get ( std::string  section,
std::string  name,
std::string  default_value 
)

Get a string value from INI file, returning default_value if not found.

Definition at line 52 of file inireader.cpp.

References _values, and MakeKey().

Referenced by ReaderUtil::GetEncoding(), and GetInteger().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

long INIReader::GetInteger ( std::string  section,
std::string  name,
long  default_value 
)

Get an integer (long) value from INI file, returning default_value if not found.

Definition at line 58 of file inireader.cpp.

References Get().

+ Here is the call graph for this function:

string INIReader::MakeKey ( std::string  section,
std::string  name 
)
staticprivate

Definition at line 68 of file inireader.cpp.

Referenced by Get(), and ValueHandler().

+ Here is the caller graph for this function:

int INIReader::ParseError ( ) const

Return the result of ini_parse(), i.e., 0 on success, line number of first error on parse error, or -1 on file open error.

Definition at line 47 of file inireader.cpp.

References _error.

Referenced by ReaderUtil::GetEncoding().

+ Here is the caller graph for this function:

int INIReader::ValueHandler ( void *  user,
const char *  section,
const char *  name,
const char *  value 
)
staticprivate

Definition at line 77 of file inireader.cpp.

References _values, and MakeKey().

Referenced by INIReader().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

int INIReader::_error
private

Definition at line 73 of file inireader.h.

Referenced by INIReader(), and ParseError().

std::map<std::string, std::string> INIReader::_values
private

Definition at line 74 of file inireader.h.

Referenced by Get(), and ValueHandler().


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