#include <sbuild-keyfile.h>
Public Types | |
typedef runtime_error_custom< keyfile > | error |
Exception type. | |
Public Member Functions | |
keyfile (const std::string &file) | |
The constructor. | |
keyfile (std::istream &stream) | |
The constructor. | |
virtual | ~keyfile () |
The destructor. | |
string_list | get_groups () const |
Get a list of groups. | |
string_list | get_keys (const std::string &group) const |
Get a list of keys in a group. | |
bool | has_group (const std::string &group) const |
Check if a group exists. | |
bool | has_key (const std::string &group, const std::string &key) const |
Check if a key exists. | |
template<typename T> | |
bool | get_value (const std::string &group, const std::string &key, T &value) const |
Get a key value. | |
template<typename T, template< typename T > class C> | |
bool | get_list_value (const std::string &group, const std::string &key, C< T > &value) const |
Get a key value as a list. | |
template<typename T> | |
void | set_value (const std::string &group, const std::string &key, const T &value) |
Set a key value. | |
template<typename T, template< typename T > class C> | |
void | set_list_value (const std::string &group, const std::string &key, const C< T > &value) |
Set a key value from a list. | |
void | remove_group (const std::string &group) |
Remove a group. | |
void | remove_key (const std::string &group, const std::string &key) |
Remove a key. | |
Private Types | |
typedef std::tr1::tuple< std::string, std::string, std::string > | item_type |
Key-value-comment tuple. | |
typedef std::map< std::string, item_type > | item_map_type |
Map between key name and key-value-comment tuple. | |
typedef std::tr1::tuple< std::string, item_map_type, std::string > | group_type |
Group-items-comment tuple. | |
typedef std::map< std::string, group_type > | group_map_type |
Map between group name and group-items-comment tuple. | |
Private Member Functions | |
void | print_comment (const std::string &comment, std::ostream &stream) const |
Print a comment to a stream. | |
const group_type * | find_group (const std::string &group) const |
Find a group by it's name. | |
group_type * | find_group (const std::string &group) |
Find a group by it's name. | |
const item_type * | find_item (const std::string &group, const std::string &key) const |
Find a key by it's group and name. | |
item_type * | find_item (const std::string &group, const std::string &key) |
Find a key by it's group and name. | |
Private Attributes | |
group_map_type | groups |
The top-level groups. | |
char | separator |
The separator used as a list item delimiter. | |
Friends | |
template<class charT, class traits> | |
std::basic_istream< charT, traits > & | operator>> (std::basic_istream< charT, traits > &stream, keyfile &kf) |
keyfile initialisation from an istream. | |
template<class charT, class traits> | |
std::basic_ostream< charT, traits > & | operator<< (std::basic_ostream< charT, traits > &stream, const keyfile &kf) |
keyfile output to an ostream. |
This class loads an INI-style configuration file from disk. The format is documented in schroot.conf(5). It is based upon the Glib GKeyFile class, which it is intended to replace.
Add support for comments.
|
The constructor.
|
|
The constructor.
|
|
Find a group by it's name.
|
|
Find a group by it's name.
|
|
Find a key by it's group and name.
|
|
Find a key by it's group and name.
|
|
Get a list of groups.
|
|
Get a list of keys in a group.
|
|
Get a key value as a list.
Here is the call graph for this function: ![]() |
|
Get a key value.
Here is the call graph for this function: ![]() |
|
Check if a group exists.
|
|
Check if a key exists.
|
|
Print a comment to a stream. The comment will have hash ('#') marks printed at the start of each line.
|
|
Remove a group.
|
|
Remove a key.
|
|
Set a key value from a list.
|
|
Set a key value.
Here is the call graph for this function: ![]() |