|
libassa
3.5.1
|
#include <IniFile.h>
Public Types | |
| typedef pair< string, string > | tuple_type |
| A tuple is a name/value pair. More... | |
| typedef pair< string, list< tuple_type > > | sect_type |
| A section is a logical subcategory of related configuration information. More... | |
| typedef list< sect_type > | config_type |
| INI configuration is the collection of sections. More... | |
| typedef config_type::iterator | config_iterator |
| Mutable iterator over the list of configuration sections. More... | |
| typedef config_type::const_iterator | const_config_iterator |
| Constant iterator over the list of configuration sections. More... | |
| typedef list< tuple_type >::iterator | tuple_iterator |
| Mutable iterator over name/value pairs in a section. More... | |
| typedef list< tuple_type >::const_iterator | const_tuple_iterator |
| Constant iterator over name/value pairs in a section. More... | |
Public Member Functions | |
| IniFile (const string &fname_) | |
| Do-nothing constructor. More... | |
| ~IniFile () | |
| Destructor does not save cache data to the file. More... | |
| bool | operator== (const IniFile &rhs_) const |
| Compare two configurations. More... | |
| bool | operator!= (const IniFile &rhs_) const |
| Compare two configurations. More... | |
| int | load () |
| Load configuration data from the file. More... | |
| void | drop_all () |
| Clear up configuration cache. More... | |
| int | sync () |
| Write cached configuration to the file. More... | |
| int | sync (const string &fname_) |
| Write cached configuration to the file fname_. More... | |
| void | add_section (const string §ion_) |
| Add new section. More... | |
| int | drop_section (const string §ion_) |
| Remove section from cache. More... | |
| int | set_pair (const string §ion_, const tuple_type &newkey_) |
| Add or change name/value pair in the section. More... | |
| int | drop_pair (const string §ion_, const string &name_) |
| Remove name/value pair from the section in cache. More... | |
| string | get_value (const string §ion_, const string &name_) const |
| Find and return a value of the name/value pair in the section section_. More... | |
| config_iterator | find_section (const string §ion_) |
| Find section by its name. More... | |
| const_config_iterator | find_section (const string §ion_) const |
| Find section by its name. More... | |
| const_config_iterator | sect_begin () const |
| Return iterator to the first section. More... | |
| config_iterator | sect_end () |
| Return iterator past the last section. More... | |
| unsigned int | size () const |
| Return number of sections in the cache. More... | |
| void | dump () const |
| Dump cache to the log file. More... | |
Private Member Functions | |
| int | trim_section_name (string &text_) |
| Remove square brakets around section name. More... | |
Private Attributes | |
| string | m_fname |
| INI file name. More... | |
| std::fstream | m_stream |
| File stream. More... | |
| config_type | m_config |
| Cache holds the entire INI file in memory. More... | |
| Regexp | m_section_pttrn |
| Section header match. More... | |
| Regexp | m_tuple_pttrn |
| Name/value pair match. More... | |
| Regexp | m_comment_pttrn |
| Comment match. More... | |
| typedef config_type::iterator ASSA::IniFile::config_iterator |
| typedef list<sect_type> ASSA::IniFile::config_type |
| typedef config_type::const_iterator ASSA::IniFile::const_config_iterator |
| typedef list<tuple_type>::const_iterator ASSA::IniFile::const_tuple_iterator |
| typedef pair<string, list<tuple_type> > ASSA::IniFile::sect_type |
| typedef list<tuple_type>::iterator ASSA::IniFile::tuple_iterator |
| typedef pair<string, string> ASSA::IniFile::tuple_type |
| ASSA::IniFile::IniFile | ( | const string & | fname_ | ) |
Do-nothing constructor.
| fname_ | Name of the INI file |
| ASSA::IniFile::~IniFile | ( | ) |
Destructor does not save cache data to the file.
You should explicitly call sync() if you want your data to be saved to the file.
| void ASSA::IniFile::add_section | ( | const string & | section_ | ) |
Add new section.
| section_ | Section name to add |
|
inline |
Clear up configuration cache.
Definition at line 100 of file IniFile.h.
References m_config.
| int ASSA::IniFile::drop_pair | ( | const string & | section_, |
| const string & | name_ | ||
| ) |
Remove name/value pair from the section in cache.
| section_ | Section that holds name/value pair. |
| name_ | Name part of name/value pair. |
| int ASSA::IniFile::drop_section | ( | const string & | section_ | ) |
Remove section from cache.
| section_ | Section to remove |
| void ASSA::IniFile::dump | ( | ) | const |
Dump cache to the log file.
| config_iterator ASSA::IniFile::find_section | ( | const string & | section_ | ) |
Find section by its name.
| section_ | Section name to earch for |
Referenced by ASSA::CmdLineOpts::parse_config_file().
| const_config_iterator ASSA::IniFile::find_section | ( | const string & | section_ | ) | const |
Find section by its name.
| section_ | Section name to earch for |
| string ASSA::IniFile::get_value | ( | const string & | section_, |
| const string & | name_ | ||
| ) | const |
Find and return a value of the name/value pair in the section section_.
| section_ | Section name to search for name/value |
| name_ | Name part of name/value pair |
Referenced by ASSA::CmdLineOpts::parse_config_file().
| int ASSA::IniFile::load | ( | ) |
Load configuration data from the file.
The file name is specified in the constructor.
|
inline |
|
inline |
|
inline |
|
inline |
Return iterator past the last section.
Definition at line 174 of file IniFile.h.
References m_config.
Referenced by ASSA::CmdLineOpts::parse_config_file().
| int ASSA::IniFile::set_pair | ( | const string & | section_, |
| const tuple_type & | newkey_ | ||
| ) |
Add or change name/value pair in the section.
| section_ | Section name |
| newkey_ | Name/value pair |
|
inline |
|
inline |
Write cached configuration to the file.
Filename used is the one given in the constructor.
Definition at line 218 of file IniFile.h.
References ASSA::INIFILE, m_fname, and trace_with_mask.
| int ASSA::IniFile::sync | ( | const string & | fname_ | ) |
Write cached configuration to the file fname_.
| fname_ | Name of the output file. |
|
inlineprivate |
Remove square brakets around section name.
| text_ | (IN/OUT) String to work on |
Definition at line 211 of file IniFile.h.
References ASSA::Utils::ltrim(), and ASSA::Utils::rtrim().
|
private |
|
private |
Cache holds the entire INI file in memory.
Definition at line 199 of file IniFile.h.
Referenced by drop_all(), operator==(), sect_begin(), sect_end(), and size().
|
private |
|
private |
|
private |