26 m_section_pttrn (
"\\[[a-zA-Z0-9]+.*] *$"),
27 m_tuple_pttrn (
"^[ \t]*[a-zA-Z0-9]+.* *= *.*"),
28 m_comment_pttrn (
"^#.*$")
46 const int size = 1024;
101 DL((
INIFILE,
"Parse error: illegal syntax!\n"));
124 m_stream <<
"[" << (*i).first <<
"]\n";
125 j = (*i).second.begin ();
127 while (
j != (*i).second.end ()) {
128 m_stream << (*j).first <<
"=" << (*j).second <<
"\n";
148 DL((
INIFILE,
"============= Start =================\n"));
151 DL((
INIFILE,
"[%s]\n", (*i).first.c_str ()));
152 j = (*i).second.begin ();
153 while (
j != (*i).second.end ()) {
155 (*j).first.c_str (), (*j).second.c_str ()));
160 DL((
INIFILE,
"============== End =================\n"));
173 j = (*i).second.begin ();
174 while (
j != (*i).second.end ()) {
175 if ((*j).first ==
name_) {
239 while (
j != (*i).second.end ()) {
240 if ((*j).first ==
newkey_.first) {
246 (*i).second.push_back (
newkey_);
278 while (
j != (*i).second.end ()) {
279 if ((*j).first ==
name_) {
280 (*i).second.erase (
j);
A collection of assert function wrappers.
A Windows-style INI configuration file management class.
#define EL(X)
A macro for writing error message to the Logger.
#define DL(X)
A macro for writing debug message to the Logger.
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
A wrapper class to provide AutoPtr with reference semantics.
Regexp m_tuple_pttrn
Name/value pair match.
std::fstream m_stream
File stream.
IniFile(const string &fname_)
Do-nothing constructor.
int trim_section_name(string &text_)
Remove square brakets around section name.
pair< string, string > tuple_type
A tuple is a name/value pair.
config_type m_config
Cache holds the entire INI file in memory.
config_type::iterator config_iterator
Mutable iterator over the list of configuration sections.
void add_section(const string §ion_)
Add new section.
void dump() const
Dump cache to the log file.
config_type::const_iterator const_config_iterator
Constant iterator over the list of configuration sections.
int set_pair(const string §ion_, const tuple_type &newkey_)
Add or change name/value pair in the section.
~IniFile()
Destructor does not save cache data to the file.
config_iterator find_section(const string §ion_)
Find section by its name.
int load()
Load configuration data from the file.
int drop_section(const string §ion_)
Remove section from cache.
string get_value(const string §ion_, const string &name_) const
Find and return a value of the name/value pair in the section section_.
Regexp m_comment_pttrn
Comment match.
Regexp m_section_pttrn
Section header match.
config_iterator sect_end()
Return iterator past the last section.
int sync()
Write cached configuration to the file.
list< tuple_type >::iterator tuple_iterator
Mutable iterator over name/value pairs in a section.
unsigned int size() const
Return number of sections in the cache.
list< tuple_type >::const_iterator const_tuple_iterator
Constant iterator over name/value pairs in a section.
string m_fname
INI file name.
int drop_pair(const string §ion_, const string &name_)
Remove name/value pair from the section in cache.
int match(const char *text_)
Match an ASCII character string agains the pattern this class wraps.
int split_pair(const string &text_, char sep_, string &lhs_, string &rhs_)
Split input string into two parts separated by the separator character.
void trim_sides(std::string &text_)
Trim white spaces and tabs from the beginning and the end of the text string.
@ INIFILE
Class IniFile messages