#include <SysConfig.h>
Public Member Functions | |
| SysConfig (const char *path) | |
| SysConfig (const std::string &path) | |
| SysConfig (const Pathname &path) | |
| ~SysConfig () | |
| bool | load () |
| bool | save () |
| std::string | readEntry (const std::string &key, const std::string &defaultValue=std::string()) |
| bool | readBoolEntry (const std::string &key, bool defaultValue=false) |
| int | readIntEntry (const std::string &key, int defaultValue=0) |
| void | writeEntry (const std::string &key, const char *value) |
| void | writeEntry (const std::string &key, const std::string &value) |
| void | writeEntry (const std::string &key, bool value) |
| void | writeEntry (const std::string &key, int value) |
Protected Member Functions | |
| std::string | createLine (const std::string &key, const std::string &value) |
Private Types | |
| typedef std::map < std::string, std::string > | EntryMap |
Private Attributes | |
| Pathname | _path |
| EntryMap | _entryMap |
| bool | mDirty |
A sysconfig file consists of lines of key/value pairs. It can also contain empty lines and comments (lines starting with '#").
Keys are case-sensitive. Values can be quoted like 'value' or "value". Whitesspace at the beginning or end of keys and values (outside of quotes) is removed.
typedef std::map<std::string, std::string> SysConfig::EntryMap [private] |
| SysConfig::SysConfig | ( | const char * | path | ) |
Construct a sysconfig object. Reads the given file.
Path to sysconfig file. This can either be an absolute path or a path relative to /etc/sysconfig.
| SysConfig::SysConfig | ( | const std::string & | path | ) |
Construct a sysconfig object. Reads the given file.
Path to sysconfig file. This can either be an absolute path or a path relative to /etc/sysconfig.
| SysConfig::SysConfig | ( | const Pathname & | path | ) |
Construct a sysconfig object. Reads the given file.
Path to sysconfig file. This can either be an absolute path or a path relative to /etc/sysconfig.
| SysConfig::~SysConfig | ( | ) |
| bool SysConfig::load | ( | ) |
Load sysconfig file into memory. This function is automatically called from the constructor.
| bool SysConfig::save | ( | ) |
Save file to disk.
| std::string SysConfig::readEntry | ( | const std::string & | key, | |
| const std::string & | defaultValue = std::string() | |||
| ) |
Return string entry.
| key | Key of entry. | |
| defaultValue | Default return value, if key doesn't exit. |
| bool SysConfig::readBoolEntry | ( | const std::string & | key, | |
| bool | defaultValue = false | |||
| ) |
Return boolean entry. The values "true", "yes" and "1" are considered as true, all other values as false.
| key | Key of entry. | |
| defaultValue | Default return value, if key doesn't exit. |
| int SysConfig::readIntEntry | ( | const std::string & | key, | |
| int | defaultValue = 0 | |||
| ) |
Return integer entry. If the entry can't be converted to an int, 0 is returned.
| key | Key of entry. | |
| defaultValue | Default return value, if key doesn't exit. |
| void SysConfig::writeEntry | ( | const std::string & | key, | |
| const char * | value | |||
| ) |
Write string entry.
| key | Key of entry | |
| value | Value of entry. |
| void SysConfig::writeEntry | ( | const std::string & | key, | |
| const std::string & | value | |||
| ) |
Write string entry.
| key | Key of entry | |
| value | Value of entry. |
| void SysConfig::writeEntry | ( | const std::string & | key, | |
| bool | value | |||
| ) |
Write string entry.
| key | Key of entry | |
| value | Value of entry. |
| void SysConfig::writeEntry | ( | const std::string & | key, | |
| int | value | |||
| ) |
Write string entry.
| key | Key of entry | |
| value | Value of entry. |
| std::string SysConfig::createLine | ( | const std::string & | key, | |
| const std::string & | value | |||
| ) | [protected] |
Pathname SysConfig::_path [private] |
EntryMap SysConfig::_entryMap [private] |
bool SysConfig::mDirty [private] |
1.5.3