Configuration file parser. More...
#include <sbuild-basic-keyfile.h>
Public Types | |
typedef K::group_name_type | group_name_type |
Group name. | |
typedef K::key_type | key_type |
Key name. | |
typedef K::value_type | value_type |
Value. | |
typedef K::comment_type | comment_type |
Comment. | |
typedef K::size_type | size_type |
Line number. | |
typedef std::vector < group_name_type > | group_list |
Vector of groups. | |
typedef std::vector< value_type > | value_list |
Vector of values. | |
Public Member Functions | |
basic_keyfile () | |
The constructor. | |
basic_keyfile (std::string const &file) | |
The constructor. | |
basic_keyfile (std::istream &stream) | |
The constructor. | |
virtual | ~basic_keyfile () |
The destructor. | |
group_list | get_groups () const |
Get a list of groups. | |
key_list | get_keys (group_name_type const &group) const |
Get a list of keys in a group. | |
void | check_keys (group_name_type const &group, key_list const &keys) const |
Check for unused keys in a group. | |
bool | has_group (group_name_type const &group) const |
Check if a group exists. | |
bool | has_key (group_name_type const &group, key_type const &key) const |
Check if a key exists. | |
void | set_group (group_name_type const &group, comment_type const &comment) |
Set a group. | |
void | set_group (group_name_type const &group, comment_type const &comment, size_type line) |
Set a group. | |
comment_type | get_comment (group_name_type const &group) const |
Get a group comment. | |
comment_type | get_comment (group_name_type const &group, key_type const &key) const |
Get a key comment. | |
size_type | get_line (group_name_type const &group) const |
Get a group line number. | |
size_type | get_line (group_name_type const &group, key_type const &key) const |
Get a key line number. | |
template<typename T > | |
bool | get_value (group_name_type const &group, key_type const &key, T &value) const |
Get a key value. | |
template<typename T > | |
bool | get_value (group_name_type const &group, key_type const &key, priority priority, T &value) const |
Get a key value. | |
bool | get_locale_string (group_name_type const &group, key_type const &key, value_type &value) const |
Get a localised key string value. | |
bool | get_locale_string (group_name_type const &group, key_type const &key, priority priority, value_type &value) const |
Get a localised key string value. | |
bool | get_locale_string (group_name_type const &group, key_type const &key, std::string const &locale, value_type &value) const |
Get a localised key string value for a specific locale. | |
bool | get_locale_string (group_name_type const &group, key_type const &key, std::string const &locale, priority priority, value_type &value) const |
Get a localised key string value for a specific locale. | |
template<typename C > | |
bool | get_list_value (group_name_type const &group, key_type const &key, C &container) const |
Get a key value as a list. | |
template<typename C > | |
bool | get_list_value (group_name_type const &group, key_type const &key, priority priority, C &container) const |
Get a key value as a list. | |
template<typename T > | |
void | set_value (group_name_type const &group, key_type const &key, T const &value) |
Set a key value. | |
template<typename T > | |
void | set_value (group_name_type const &group, key_type const &key, T const &value, comment_type const &comment) |
Set a key value. | |
template<typename T > | |
void | set_value (group_name_type const &group, key_type const &key, T const &value, comment_type const &comment, size_type line) |
Set a key value. | |
template<typename I > | |
void | set_list_value (group_name_type const &group, key_type const &key, I begin, I end) |
Set a key value from a list. | |
template<typename I > | |
void | set_list_value (group_name_type const &group, key_type const &key, I begin, I end, comment_type const &comment) |
Set a key value from a list. | |
template<typename I > | |
void | set_list_value (group_name_type const &group, key_type const &key, I begin, I end, comment_type const &comment, size_type line) |
Set a key value from a list. | |
void | remove_group (group_name_type const &group) |
Remove a group. | |
void | remove_key (group_name_type const &group, key_type const &key) |
Remove a key. | |
basic_keyfile & | operator+= (basic_keyfile const &rhs) |
Add a basic_keyfile to the basic_keyfile. | |
Static Public Member Functions | |
template<class C , typename T > | |
static void | set_object_value (C const &object, T(C::*method)() const, basic_keyfile &basic_keyfile, group_name_type const &group, key_type const &key) |
Set a key value from an object method return value. | |
template<class C , typename T > | |
static void | set_object_value (C const &object, T const &(C::*method)() const, basic_keyfile &basic_keyfile, group_name_type const &group, key_type const &key) |
Set a key value from an object method return value reference. | |
template<class C , typename T > | |
static void | set_object_list_value (C const &object, T(C::*method)() const, basic_keyfile &basic_keyfile, group_name_type const &group, key_type const &key) |
Set a key list value from an object method return value. | |
template<class C , typename T > | |
static void | set_object_list_value (C const &object, T const &(C::*method)() const, basic_keyfile &basic_keyfile, group_name_type const &group, key_type const &key) |
Set a key list value from an object method return value. | |
template<class C , typename T > | |
static void | get_object_value (C &object, void(C::*method)(T param), basic_keyfile const &basic_keyfile, group_name_type const &group, key_type const &key, basic_keyfile::priority priority) |
Get a key value and set it in an object using an object method. | |
template<class C , typename T > | |
static void | get_object_value (C &object, void(C::*method)(T const ¶m), basic_keyfile const &basic_keyfile, group_name_type const &group, key_type const &key, basic_keyfile::priority priority) |
Get a key value and set it by reference in an object using an object method. | |
template<class C , typename T > | |
static void | get_object_list_value (C &object, void(C::*method)(T param), basic_keyfile const &basic_keyfile, group_name_type const &group, key_type const &key, basic_keyfile::priority priority) |
Get a key list value and set it in an object using an object method. | |
template<class C , typename T > | |
static void | get_object_list_value (C &object, void(C::*method)(T const ¶m), basic_keyfile const &basic_keyfile, group_name_type const &group, key_type const &key, basic_keyfile::priority priority) |
Get a key list value and set it by reference in an object using an object method. | |
Private Types | |
typedef P | parse_type |
Parse type. | |
typedef std::tr1::tuple < key_type, value_type, comment_type, size_type > | item_type |
Key-value-comment-line tuple. | |
typedef std::map< key_type, item_type > | item_map_type |
Map between key name and key-value-comment tuple. | |
typedef std::tr1::tuple < group_name_type, item_map_type, comment_type, size_type > | group_type |
Group-items-comment-line tuple. | |
typedef std::map < group_name_type, group_type > | group_map_type |
Map between group name and group-items-comment tuple. | |
typedef std::vector< key_type > | key_list |
Vector of keys. | |
Private Member Functions | |
const group_type * | find_group (group_name_type const &group) const |
Find a group by it's name. | |
group_type * | find_group (group_name_type const &group) |
Find a group by it's name. | |
const item_type * | find_item (group_name_type const &group, key_type const &key) const |
Find a key by it's group and name. | |
item_type * | find_item (group_name_type const &group, key_type const &key) |
Find a key by it's group and name. | |
void | check_priority (group_name_type const &group, key_type const &key, priority priority, bool valid) const |
Check if a key is missing or present when not permitted. | |
Static Private Member Functions | |
static void | print_comment (comment_type const &comment, std::ostream &stream) |
Print a comment to a stream. | |
Private Attributes | |
group_map_type | groups |
The top-level groups. | |
value_type | separator |
The separator used as a list item delimiter. | |
Friends | |
template<typename _K , typename _P > | |
basic_keyfile< _K, _P > | operator+ (basic_keyfile< _K, _P > const &lhs, basic_keyfile< _K, _P > const &rhs) |
Add a basic_keyfile to the basic_keyfile. | |
template<class charT , class traits > | |
std::basic_istream< charT, traits > & | operator>> (std::basic_istream< charT, traits > &stream, basic_keyfile &kf) |
basic_keyfile initialisation from an istream. | |
template<class charT , class traits > | |
std::basic_ostream< charT, traits > & | operator<< (std::basic_ostream< charT, traits > &stream, basic_keyfile const &kf) |
basic_keyfile output to an ostream. |
Configuration file parser.
This class loads an INI-style configuration file from a file or stream. The format is documented in schroot.conf(5).
typedef K::comment_type sbuild::basic_keyfile< K, P >::comment_type |
Comment.
typedef std::vector<group_name_type> sbuild::basic_keyfile< K, P >::group_list |
Vector of groups.
typedef std::map<group_name_type,group_type> sbuild::basic_keyfile< K, P >::group_map_type [private] |
Map between group name and group-items-comment tuple.
typedef K::group_name_type sbuild::basic_keyfile< K, P >::group_name_type |
Group name.
typedef std::tr1::tuple<group_name_type,item_map_type,comment_type,size_type> sbuild::basic_keyfile< K, P >::group_type [private] |
Group-items-comment-line tuple.
typedef std::map<key_type,item_type> sbuild::basic_keyfile< K, P >::item_map_type [private] |
Map between key name and key-value-comment tuple.
typedef std::tr1::tuple<key_type,value_type,comment_type,size_type> sbuild::basic_keyfile< K, P >::item_type [private] |
Key-value-comment-line tuple.
typedef std::vector<key_type> sbuild::basic_keyfile< K, P >::key_list [private] |
Vector of keys.
typedef K::key_type sbuild::basic_keyfile< K, P >::key_type |
Key name.
typedef P sbuild::basic_keyfile< K, P >::parse_type [private] |
Parse type.
typedef K::size_type sbuild::basic_keyfile< K, P >::size_type |
Line number.
typedef std::vector<value_type> sbuild::basic_keyfile< K, P >::value_list |
Vector of values.
typedef K::value_type sbuild::basic_keyfile< K, P >::value_type |
Value.
sbuild::basic_keyfile< K, P >::basic_keyfile | ( | ) |
The constructor.
sbuild::basic_keyfile< K, P >::basic_keyfile | ( | std::string const & | file | ) |
The constructor.
file | the file to load the configuration from. |
References sbuild::keyfile_base::BAD_FILE.
sbuild::basic_keyfile< K, P >::basic_keyfile | ( | std::istream & | stream | ) |
The constructor.
stream | the stream to load the configuration from. |
sbuild::basic_keyfile< K, P >::~basic_keyfile | ( | ) | [virtual] |
The destructor.
void sbuild::basic_keyfile< K, P >::check_keys | ( | group_name_type const & | group, | |
key_list const & | keys | |||
) | const |
Check for unused keys in a group.
If keys other than the specified keys exist in the specified group, print a warning about unknown keys having been used.
group | the group to use. | |
keys | the keys which have been used. |
References sbuild::_(), sbuild::basic_keyfile< K, P >::get_keys(), sbuild::basic_keyfile< K, P >::get_line(), sbuild::log_exception_warning(), sbuild::error_base::set_reason(), and sbuild::keyfile_base::UNKNOWN_KEY.
void sbuild::basic_keyfile< K, P >::check_priority | ( | group_name_type const & | group, | |
key_type const & | key, | |||
priority | priority, | |||
bool | valid | |||
) | const [private] |
Check if a key is missing or present when not permitted.
group | the group the key is in. | |
key | the key to get. | |
priority | the key priority. | |
valid | true if key exists, false if not existing. |
References sbuild::_(), sbuild::keyfile_base::DEPRECATED_KEY, sbuild::keyfile_base::DEPRECATED_KEY_NL, sbuild::keyfile_base::DISALLOWED_KEY, sbuild::keyfile_base::DISALLOWED_KEY_NL, sbuild::basic_keyfile< K, P >::get_line(), sbuild::log_exception_warning(), sbuild::keyfile_base::MISSING_KEY, sbuild::keyfile_base::MISSING_KEY_NL, sbuild::keyfile_base::OBSOLETE_KEY, sbuild::keyfile_base::OBSOLETE_KEY_NL, sbuild::keyfile_base::PRIORITY_DEPRECATED, sbuild::keyfile_base::PRIORITY_DISALLOWED, sbuild::keyfile_base::PRIORITY_OBSOLETE, sbuild::keyfile_base::PRIORITY_REQUIRED, and sbuild::error_base::set_reason().
Referenced by sbuild::basic_keyfile< K, P >::get_list_value(), sbuild::basic_keyfile< K, P >::get_locale_string(), and sbuild::basic_keyfile< K, P >::get_value().
const sbuild::basic_keyfile< K, P >::group_type * sbuild::basic_keyfile< K, P >::find_group | ( | group_name_type const & | group | ) | const [private] |
Find a group by it's name.
group | the group to find. |
References sbuild::basic_keyfile< K, P >::groups.
Referenced by sbuild::basic_keyfile< K, P >::find_item(), sbuild::basic_keyfile< K, P >::get_comment(), sbuild::basic_keyfile< K, P >::get_keys(), sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::has_group(), sbuild::basic_keyfile< K, P >::remove_key(), and sbuild::basic_keyfile< K, P >::set_value().
sbuild::basic_keyfile< K, P >::group_type * sbuild::basic_keyfile< K, P >::find_group | ( | group_name_type const & | group | ) | [private] |
Find a group by it's name.
group | the group to find. |
References sbuild::basic_keyfile< K, P >::groups.
sbuild::basic_keyfile< K, P >::item_type * sbuild::basic_keyfile< K, P >::find_item | ( | group_name_type const & | group, | |
key_type const & | key | |||
) | [private] |
Find a key by it's group and name.
group | the group the key is in. | |
key | the key to find |
References sbuild::basic_keyfile< K, P >::find_group().
const sbuild::basic_keyfile< K, P >::item_type * sbuild::basic_keyfile< K, P >::find_item | ( | group_name_type const & | group, | |
key_type const & | key | |||
) | const [private] |
Find a key by it's group and name.
group | the group the key is in. | |
key | the key to find |
References sbuild::basic_keyfile< K, P >::find_group().
Referenced by sbuild::basic_keyfile< K, P >::get_comment(), sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_value(), and sbuild::basic_keyfile< K, P >::has_key().
sbuild::basic_keyfile< K, P >::comment_type sbuild::basic_keyfile< K, P >::get_comment | ( | group_name_type const & | group | ) | const |
Get a group comment.
group | the group to find. |
References sbuild::basic_keyfile< K, P >::find_group().
sbuild::basic_keyfile< K, P >::comment_type sbuild::basic_keyfile< K, P >::get_comment | ( | group_name_type const & | group, | |
key_type const & | key | |||
) | const |
Get a key comment.
group | the group to find. | |
key | the key to find. |
References sbuild::basic_keyfile< K, P >::find_item().
sbuild::basic_keyfile< K, P >::group_list sbuild::basic_keyfile< K, P >::get_groups | ( | ) | const |
Get a list of groups.
References sbuild::basic_keyfile< K, P >::groups.
Referenced by sbuild::chroot_config::load_keyfile().
sbuild::basic_keyfile< K, P >::key_list sbuild::basic_keyfile< K, P >::get_keys | ( | group_name_type const & | group | ) | const |
Get a list of keys in a group.
group | the group to use. |
References sbuild::basic_keyfile< K, P >::find_group().
Referenced by sbuild::basic_keyfile< K, P >::check_keys(), and sbuild::chroot::set_keyfile().
sbuild::basic_keyfile< K, P >::size_type sbuild::basic_keyfile< K, P >::get_line | ( | group_name_type const & | group | ) | const |
Get a group line number.
group | the group to find. |
References sbuild::basic_keyfile< K, P >::find_group().
Referenced by sbuild::chroot_config::add(), sbuild::basic_keyfile< K, P >::check_keys(), sbuild::basic_keyfile< K, P >::check_priority(), sbuild::basic_keyfile< K, P >::get_list_value(), sbuild::basic_keyfile< K, P >::get_object_list_value(), sbuild::basic_keyfile< K, P >::get_object_value(), and sbuild::basic_keyfile< K, P >::get_value().
sbuild::basic_keyfile< K, P >::size_type sbuild::basic_keyfile< K, P >::get_line | ( | group_name_type const & | group, | |
key_type const & | key | |||
) | const |
Get a key line number.
group | the group to find. | |
key | the key to find. |
References sbuild::basic_keyfile< K, P >::find_item().
bool sbuild::basic_keyfile< K, P >::get_list_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
C & | container | |||
) | const [inline] |
Get a key value as a list.
group | the group the key is in. | |
key | the key to get. | |
container | the container to store the key's value in. The value type must be settable from an istream and be copyable. The list must be a container with a standard insert method. |
References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_value(), sbuild::log_exception_warning(), sbuild::parse_value(), sbuild::keyfile_base::PASSTHROUGH_GK, sbuild::keyfile_base::PASSTHROUGH_LGK, sbuild::basic_keyfile< K, P >::separator, and sbuild::split_string().
Referenced by sbuild::basic_keyfile< K, P >::get_list_value(), and sbuild::basic_keyfile< K, P >::get_object_list_value().
bool sbuild::basic_keyfile< K, P >::get_list_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
priority | priority, | |||
C & | container | |||
) | const [inline] |
Get a key value as a list.
If the value does not exist, is deprecated or obsolete, warn appropriately.
group | the group the key is in. | |
key | the key to get. | |
priority | the priority of the option. | |
container | the container to store the key's value in. The value type must be settable from an istream and be copyable. The list must be a container with a standard insert method. |
References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_list_value().
bool sbuild::basic_keyfile< K, P >::get_locale_string | ( | group_name_type const & | group, | |
key_type const & | key, | |||
std::string const & | locale, | |||
value_type & | value | |||
) | const |
Get a localised key string value for a specific locale.
group | the group the key is in. | |
key | the key to get. | |
locale | the locale to use. | |
value | the string to store the key's localised value in. |
References sbuild::basic_keyfile< K, P >::get_value().
bool sbuild::basic_keyfile< K, P >::get_locale_string | ( | group_name_type const & | group, | |
key_type const & | key, | |||
std::string const & | locale, | |||
priority | priority, | |||
value_type & | value | |||
) | const |
Get a localised key string value for a specific locale.
If the value does not exist, is deprecated or obsolete, warn appropriately.
group | the group the key is in. | |
key | the key to get. | |
locale | the locale to use. | |
priority | the priority of the option. | |
value | the string to store the key's localised value in. |
References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_locale_string().
bool sbuild::basic_keyfile< K, P >::get_locale_string | ( | group_name_type const & | group, | |
key_type const & | key, | |||
value_type & | value | |||
) | const |
Get a localised key string value.
group | the group the key is in. | |
key | the key to get. | |
value | the string to store the key's localised value in. |
References sbuild::basic_keyfile< K, P >::get_value().
Referenced by sbuild::basic_keyfile< K, P >::get_locale_string().
bool sbuild::basic_keyfile< K, P >::get_locale_string | ( | group_name_type const & | group, | |
key_type const & | key, | |||
priority | priority, | |||
value_type & | value | |||
) | const |
Get a localised key string value.
If the value does not exist, is deprecated or obsolete, warn appropriately.
group | the group the key is in. | |
key | the key to get. | |
priority | the priority of the option. | |
value | the string to store the key's localised value in. |
References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_locale_string().
static void sbuild::basic_keyfile< K, P >::get_object_list_value | ( | C & | object, | |
void(C::*)(T param) | method, | |||
basic_keyfile< K, P > const & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key, | |||
basic_keyfile< K, P >::priority | priority | |||
) | [inline, static] |
Get a key list value and set it in an object using an object method.
This is the same as calling get_list_value directly, but handles exceptions being thrown by the object method, and deserialisation errors, which are turned into error exceptions pointing to the group, key and line number in the input file.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. | |
priority | the key priority. |
References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_list_value(), sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::keyfile_base::PASSTHROUGH_LGK.
Referenced by sbuild::chroot::set_keyfile(), sbuild::chroot_facet_source_clonable::set_keyfile(), and sbuild::chroot_facet_session::set_keyfile().
static void sbuild::basic_keyfile< K, P >::get_object_list_value | ( | C & | object, | |
void(C::*)(T const ¶m) | method, | |||
basic_keyfile< K, P > const & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key, | |||
basic_keyfile< K, P >::priority | priority | |||
) | [inline, static] |
Get a key list value and set it by reference in an object using an object method.
This is the same as calling get_list_value directly, but handles exceptions being thrown by the object method, and deserialisation errors, which are turned into error exceptions pointing to the group, key and line number in the input file.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. | |
priority | the key priority. |
References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_list_value(), sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::keyfile_base::PASSTHROUGH_LGK.
static void sbuild::basic_keyfile< K, P >::get_object_value | ( | C & | object, | |
void(C::*)(T param) | method, | |||
basic_keyfile< K, P > const & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key, | |||
basic_keyfile< K, P >::priority | priority | |||
) | [inline, static] |
Get a key value and set it in an object using an object method.
This is the same as calling get_value directly, but handles exceptions being thrown by the object method, and deserialisation errors, which are turned into error exceptions pointing to the group, key and line number in the input file.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. | |
priority | the key priority. |
References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_value(), sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::keyfile_base::PASSTHROUGH_LGK.
Referenced by sbuild::chroot::set_keyfile(), sbuild::chroot_lvm_snapshot::set_keyfile(), sbuild::chroot_loopback::set_keyfile(), sbuild::chroot_file::set_keyfile(), sbuild::chroot_facet_union::set_keyfile(), sbuild::chroot_facet_source_clonable::set_keyfile(), sbuild::chroot_facet_session::set_keyfile(), sbuild::chroot_facet_personality::set_keyfile(), sbuild::chroot_facet_mountable::set_keyfile(), sbuild::chroot_directory_base::set_keyfile(), sbuild::chroot_btrfs_snapshot::set_keyfile(), and sbuild::chroot_block_device_base::set_keyfile().
static void sbuild::basic_keyfile< K, P >::get_object_value | ( | C & | object, | |
void(C::*)(T const ¶m) | method, | |||
basic_keyfile< K, P > const & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key, | |||
basic_keyfile< K, P >::priority | priority | |||
) | [inline, static] |
Get a key value and set it by reference in an object using an object method.
This is the same as calling get_value directly, but handles exceptions being thrown by the object method, and deserialisation errors, which are turned into error exceptions pointing to the group, key and line number in the input file.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. | |
priority | the key priority. |
References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_value(), sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::keyfile_base::PASSTHROUGH_LGK.
bool sbuild::basic_keyfile< K, P >::get_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
T & | value | |||
) | const [inline] |
Get a key value.
group | the group the key is in. | |
key | the key to get. | |
value | the value to store the key's value in. This must be settable from an istream and be copyable. |
References sbuild::DEBUG_INFO, sbuild::DEBUG_NOTICE, sbuild::basic_keyfile< K, P >::find_item(), sbuild::basic_keyfile< K, P >::get_line(), sbuild::log_debug(), sbuild::log_exception_warning(), sbuild::parse_value(), sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::keyfile_base::PASSTHROUGH_LGK.
Referenced by sbuild::basic_keyfile< K, P >::get_list_value(), sbuild::basic_keyfile< K, P >::get_locale_string(), sbuild::basic_keyfile< K, P >::get_object_value(), sbuild::basic_keyfile< K, P >::get_value(), and sbuild::chroot_config::load_keyfile().
bool sbuild::basic_keyfile< K, P >::get_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
priority | priority, | |||
T & | value | |||
) | const [inline] |
Get a key value.
If the value does not exist, is deprecated or obsolete, warn appropriately.
group | the group the key is in. | |
key | the key to get. | |
priority | the priority of the option. | |
value | the value to store the key's value in. This must be settable from an istream and be copyable. |
References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_value().
bool sbuild::basic_keyfile< K, P >::has_group | ( | group_name_type const & | group | ) | const |
Check if a group exists.
group | the group to check for. |
References sbuild::basic_keyfile< K, P >::find_group().
Referenced by sbuild::basic_keyfile< K, P >::set_group().
bool sbuild::basic_keyfile< K, P >::has_key | ( | group_name_type const & | group, | |
key_type const & | key | |||
) | const |
Check if a key exists.
group | the group the key is in. | |
key | the key to check for. |
References sbuild::basic_keyfile< K, P >::find_item().
Referenced by sbuild::chroot_directory_base::set_keyfile().
sbuild::basic_keyfile< K, P > & sbuild::basic_keyfile< K, P >::operator+= | ( | basic_keyfile< K, P > const & | rhs | ) |
Add a basic_keyfile to the basic_keyfile.
rhs | the basic_keyfile to add. |
References sbuild::basic_keyfile< K, P >::groups, sbuild::basic_keyfile< K, P >::set_group(), and sbuild::basic_keyfile< K, P >::set_value().
void sbuild::basic_keyfile< K, P >::print_comment | ( | comment_type const & | comment, | |
std::ostream & | stream | |||
) | [static, private] |
Print a comment to a stream.
The comment will have hash ('#') marks printed at the start of each line.
comment | the comment to print. | |
stream | the stream to output to. |
void sbuild::basic_keyfile< K, P >::remove_group | ( | group_name_type const & | group | ) |
Remove a group.
group | the group to remove. |
References sbuild::basic_keyfile< K, P >::groups.
Referenced by sbuild::chroot::get_keyfile().
void sbuild::basic_keyfile< K, P >::remove_key | ( | group_name_type const & | group, | |
key_type const & | key | |||
) |
Remove a key.
group | the group the key is in. | |
key | the key to remove. |
References sbuild::basic_keyfile< K, P >::find_group().
void sbuild::basic_keyfile< K, P >::set_group | ( | group_name_type const & | group, | |
comment_type const & | comment, | |||
size_type | line | |||
) |
Set a group.
The group will be created (and the comment set) only if the group does not already exist.
group | the group to set. | |
comment | the comment to set. | |
line | the line number in the input file, or 0 otherwise. |
References sbuild::basic_keyfile< K, P >::groups, and sbuild::basic_keyfile< K, P >::has_group().
void sbuild::basic_keyfile< K, P >::set_group | ( | group_name_type const & | group, | |
comment_type const & | comment | |||
) |
Set a group.
The group will be created (and the comment set) only if the group does not already exist.
group | the group to set. | |
comment | the comment to set. |
Referenced by sbuild::basic_keyfile< K, P >::operator+=(), and sbuild::basic_keyfile< K, P >::set_value().
void sbuild::basic_keyfile< K, P >::set_list_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
I | begin, | |||
I | end, | |||
comment_type const & | comment | |||
) | [inline] |
Set a key value from a list.
group | the group the key is in. | |
key | the key to set. | |
begin | an iterator referring to the start of the list. The value type must allow output to an ostream. | |
end | an iterator referring to the end of the list. | |
comment | the comment for this key. |
References sbuild::basic_keyfile< K, P >::set_list_value().
void sbuild::basic_keyfile< K, P >::set_list_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
I | begin, | |||
I | end | |||
) | [inline] |
Set a key value from a list.
group | the group the key is in. | |
key | the key to set. | |
begin | an iterator referring to the start of the list. The value type must allow output to an ostream. | |
end | an iterator referring to the end of the list. |
Referenced by sbuild::basic_keyfile< K, P >::set_list_value(), and sbuild::basic_keyfile< K, P >::set_object_list_value().
void sbuild::basic_keyfile< K, P >::set_list_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
I | begin, | |||
I | end, | |||
comment_type const & | comment, | |||
size_type | line | |||
) | [inline] |
Set a key value from a list.
group | the group the key is in. | |
key | the key to set. | |
begin | an iterator referring to the start of the list. The value type must allow output to an ostream. | |
end | an iterator referring to the end of the list. | |
comment | the comment for this key. | |
line | the line number in the input file, or 0 otherwise. |
References sbuild::basic_keyfile< K, P >::separator, and sbuild::basic_keyfile< K, P >::set_value().
static void sbuild::basic_keyfile< K, P >::set_object_list_value | ( | C const & | object, | |
T const &(C::*)() const | method, | |||
basic_keyfile< K, P > & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key | |||
) | [inline, static] |
Set a key list value from an object method return value.
The method must return a container reference with begin() and end() methods which return forward iterators. This is the same as calling set_list_value directly, but handles exceptions being thrown by the object method, which are turned into error exceptions.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. |
References sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::basic_keyfile< K, P >::set_list_value().
static void sbuild::basic_keyfile< K, P >::set_object_list_value | ( | C const & | object, | |
T(C::*)() const | method, | |||
basic_keyfile< K, P > & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key | |||
) | [inline, static] |
Set a key list value from an object method return value.
The method must return a container with begin() and end() methods which return forward iterators. This is the same as calling set_list_value directly, but handles exceptions being thrown by the object method, which are turned into error exceptions.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. |
References sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::basic_keyfile< K, P >::set_list_value().
Referenced by sbuild::chroot::get_keyfile(), and sbuild::chroot_facet_source_clonable::get_keyfile().
static void sbuild::basic_keyfile< K, P >::set_object_value | ( | C const & | object, | |
T const &(C::*)() const | method, | |||
basic_keyfile< K, P > & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key | |||
) | [inline, static] |
Set a key value from an object method return value reference.
This is the same as calling set_value directly, but handles exceptions being thrown by the object method, which are turned into error exceptions.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. |
References sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::basic_keyfile< K, P >::set_value().
static void sbuild::basic_keyfile< K, P >::set_object_value | ( | C const & | object, | |
T(C::*)() const | method, | |||
basic_keyfile< K, P > & | basic_keyfile, | |||
group_name_type const & | group, | |||
key_type const & | key | |||
) | [inline, static] |
Set a key value from an object method return value.
This is the same as calling set_value directly, but handles exceptions being thrown by the object method, which are turned into error exceptions.
object | the object to use. | |
method | the object method to call. | |
basic_keyfile | the basic_keyfile to use. | |
group | the group the key is in. | |
key | the key to set. |
References sbuild::keyfile_base::PASSTHROUGH_GK, and sbuild::basic_keyfile< K, P >::set_value().
Referenced by sbuild::chroot::get_keyfile(), sbuild::chroot_lvm_snapshot::get_keyfile(), sbuild::chroot_loopback::get_keyfile(), sbuild::chroot_file::get_keyfile(), sbuild::chroot_facet_union::get_keyfile(), sbuild::chroot_facet_source_clonable::get_keyfile(), sbuild::chroot_facet_personality::get_keyfile(), sbuild::chroot_facet_mountable::get_keyfile(), sbuild::chroot_directory_base::get_keyfile(), sbuild::chroot_btrfs_snapshot::get_keyfile(), and sbuild::chroot_block_device_base::get_keyfile().
void sbuild::basic_keyfile< K, P >::set_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
T const & | value, | |||
comment_type const & | comment | |||
) | [inline] |
Set a key value.
group | the group the key is in. | |
key | the key to set. | |
value | the value to get the key's value from. This must allow output to an ostream. | |
comment | the comment for this key. |
References sbuild::basic_keyfile< K, P >::set_value().
void sbuild::basic_keyfile< K, P >::set_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
T const & | value, | |||
comment_type const & | comment, | |||
size_type | line | |||
) | [inline] |
Set a key value.
group | the group the key is in. | |
key | the key to set. | |
value | the value to get the key's value from. This must allow output to an ostream. | |
comment | the comment for this key. | |
line | the line number in the input file, or 0 otherwise. |
References sbuild::basic_keyfile< K, P >::find_group(), and sbuild::basic_keyfile< K, P >::set_group().
void sbuild::basic_keyfile< K, P >::set_value | ( | group_name_type const & | group, | |
key_type const & | key, | |||
T const & | value | |||
) | [inline] |
Set a key value.
group | the group the key is in. | |
key | the key to set. | |
value | the value to get the key's value from. This must allow output to an ostream. |
Referenced by sbuild::basic_keyfile< K, P >::operator+=(), sbuild::basic_keyfile< K, P >::set_list_value(), sbuild::basic_keyfile< K, P >::set_object_value(), and sbuild::basic_keyfile< K, P >::set_value().
basic_keyfile<_K, _P> operator+ | ( | basic_keyfile< _K, _P > const & | lhs, | |
basic_keyfile< _K, _P > const & | rhs | |||
) | [friend] |
Add a basic_keyfile to the basic_keyfile.
lhs | the basic_keyfile to add to. | |
rhs | the values to add. |
std::basic_ostream<charT,traits>& operator<< | ( | std::basic_ostream< charT, traits > & | stream, | |
basic_keyfile< K, P > const & | kf | |||
) | [friend] |
basic_keyfile output to an ostream.
stream | the stream to output to. | |
kf | the basic_keyfile to output. |
std::basic_istream<charT,traits>& operator>> | ( | std::basic_istream< charT, traits > & | stream, | |
basic_keyfile< K, P > & | kf | |||
) | [friend] |
basic_keyfile initialisation from an istream.
stream | the stream to input from. | |
kf | the basic_keyfile to set. |
group_map_type sbuild::basic_keyfile< K, P >::groups [private] |
value_type sbuild::basic_keyfile< K, P >::separator [private] |
The separator used as a list item delimiter.
Referenced by sbuild::basic_keyfile< K, P >::get_list_value(), and sbuild::basic_keyfile< K, P >::set_list_value().