sbuild  1.6.10
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
sbuild::basic_keyfile< K, P > Class Template Reference

Configuration file parser. More...

#include <sbuild-basic-keyfile.h>

+ Inheritance diagram for sbuild::basic_keyfile< K, P >:
+ Collaboration diagram for sbuild::basic_keyfile< K, P >:

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_typegroup_list
 Vector of groups.
 
typedef std::vector< value_typevalue_list
 Vector of values.
 
- Public Types inherited from sbuild::keyfile_base
enum  priority {
  PRIORITY_OPTIONAL, PRIORITY_REQUIRED, PRIORITY_DISALLOWED, PRIORITY_DEPRECATED,
  PRIORITY_OBSOLETE
}
 Configuration parameter priority. More...
 
enum  error_code {
  BAD_FILE, DEPRECATED_KEY, DEPRECATED_KEY_NL, DISALLOWED_KEY,
  DISALLOWED_KEY_NL, DUPLICATE_GROUP, DUPLICATE_KEY, INVALID_GROUP,
  INVALID_KEY, INVALID_LINE, MISSING_KEY, MISSING_KEY_NL,
  NO_GROUP, NO_KEY, OBSOLETE_KEY, OBSOLETE_KEY_NL,
  PASSTHROUGH_G, PASSTHROUGH_GK, PASSTHROUGH_LG, PASSTHROUGH_LGK,
  UNKNOWN_KEY
}
 Error codes. More...
 
typedef parse_error< error_codeerror
 Exception type.
 

Public Member Functions

 basic_keyfile ()
 The constructor.
 
 basic_keyfile (std::string const &file)
 The constructor. More...
 
 basic_keyfile (std::istream &stream)
 The constructor. More...
 
virtual ~basic_keyfile ()
 The destructor.
 
group_list get_groups () const
 Get a list of groups. More...
 
key_list get_keys (group_name_type const &group) const
 Get a list of keys in a group. More...
 
void check_keys (group_name_type const &group, key_list const &keys) const
 Check for unused keys in a group. More...
 
bool has_group (group_name_type const &group) const
 Check if a group exists. More...
 
bool has_key (group_name_type const &group, key_type const &key) const
 Check if a key exists. More...
 
void set_group (group_name_type const &group, comment_type const &comment)
 Set a group. More...
 
void set_group (group_name_type const &group, comment_type const &comment, size_type line)
 Set a group. More...
 
comment_type get_comment (group_name_type const &group) const
 Get a group comment. More...
 
comment_type get_comment (group_name_type const &group, key_type const &key) const
 Get a key comment. More...
 
size_type get_line (group_name_type const &group) const
 Get a group line number. More...
 
size_type get_line (group_name_type const &group, key_type const &key) const
 Get a key line number. More...
 
template<typename T >
bool get_value (group_name_type const &group, key_type const &key, T &value) const
 Get a key value. More...
 
template<typename T >
bool get_value (group_name_type const &group, key_type const &key, priority priority, T &value) const
 Get a key value. More...
 
bool get_locale_string (group_name_type const &group, key_type const &key, value_type &value) const
 Get a localised key string value. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename C >
bool get_set_value (group_name_type const &group, key_type const &key, C &container) const
 Get a key value as a set. More...
 
template<typename C >
bool get_set_value (group_name_type const &group, key_type const &key, priority priority, C &container) const
 Get a key value as a set. More...
 
template<typename T >
void set_value (group_name_type const &group, key_type const &key, T const &value)
 Set a key value. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename I >
void set_set_value (group_name_type const &group, key_type const &key, I begin, I end)
 Set a key value from a set. More...
 
template<typename I >
void set_set_value (group_name_type const &group, key_type const &key, I begin, I end, comment_type const &comment)
 Set a key value from a set. More...
 
template<typename I >
void set_set_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 set. More...
 
void remove_group (group_name_type const &group)
 Remove a group. More...
 
void remove_key (group_name_type const &group, key_type const &key)
 Remove a key. More...
 
basic_keyfileoperator+= (basic_keyfile const &rhs)
 Add a basic_keyfile to the basic_keyfile. More...
 
- Public Member Functions inherited from sbuild::keyfile_base
 keyfile_base ()
 The constructor.
 
virtual ~keyfile_base ()
 The destructor.
 

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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<class C , typename T >
static void set_object_set_value (C const &object, T(C::*method)() const, basic_keyfile &basic_keyfile, group_name_type const &group, key_type const &key)
 Set a key set value from an object method return value. More...
 
template<class C , typename T >
static void set_object_set_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 set value from an object method return value. More...
 
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. More...
 
template<class C , typename T >
static void get_object_value (C &object, void(C::*method)(T const &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 by reference in an object using an object method. More...
 
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. More...
 
template<class C , typename T >
static void get_object_list_value (C &object, void(C::*method)(T const &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 by reference in an object using an object method. More...
 
template<class C , typename T >
static void get_object_set_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 set value and set it in an object using an object method. More...
 
template<class C , typename T >
static void get_object_set_value (C &object, void(C::*method)(T const &param), basic_keyfile const &basic_keyfile, group_name_type const &group, key_type const &key, basic_keyfile::priority priority)
 Get a key set value and set it by reference in an object using an object method. More...
 

Private Types

typedef P parse_type
 Parse type.
 
typedef std::tuple< key_type, value_type, comment_type, size_typeitem_type
 Key-value-comment-line tuple.
 
typedef std::map< key_type, item_typeitem_map_type
 Map between key name and key-value-comment tuple.
 
typedef std::tuple< group_name_type, item_map_type, comment_type, size_typegroup_type
 Group-items-comment-line tuple.
 
typedef std::map< group_name_type, group_typegroup_map_type
 Map between group name and group-items-comment tuple.
 
typedef std::vector< key_typekey_list
 Vector of keys.
 

Private Member Functions

const group_typefind_group (group_name_type const &group) const
 Find a group by it's name. More...
 
group_typefind_group (group_name_type const &group)
 Find a group by it's name. More...
 
const item_typefind_item (group_name_type const &group, key_type const &key) const
 Find a key by it's group and name. More...
 
item_typefind_item (group_name_type const &group, key_type const &key)
 Find a key by it's group and name. More...
 
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. More...
 

Static Private Member Functions

static void print_comment (comment_type const &comment, std::ostream &stream)
 Print a comment to a stream. More...
 

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. More...
 
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. More...
 
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. More...
 

Detailed Description

template<typename K, typename P = basic_keyfile_parser<K>>
class sbuild::basic_keyfile< K, P >

Configuration file parser.

This class loads an INI-style configuration file from a file or stream. The format is documented in schroot.conf(5).

Constructor & Destructor Documentation

template<typename K, typename P = basic_keyfile_parser<K>>
sbuild::basic_keyfile< K, P >::basic_keyfile ( std::string const &  file)

The constructor.

Parameters
filethe file to load the configuration from.
template<typename K, typename P = basic_keyfile_parser<K>>
sbuild::basic_keyfile< K, P >::basic_keyfile ( std::istream &  stream)

The constructor.

Parameters
streamthe stream to load the configuration from.

Member Function Documentation

template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group to use.
keysthe keys which have been used.
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group the key is in.
keythe key to get.
prioritythe key priority.
validtrue if key exists, false if not existing.
template<typename K, typename P = basic_keyfile_parser<K>>
const group_type* sbuild::basic_keyfile< K, P >::find_group ( group_name_type const &  group) const
private

Find a group by it's name.

Parameters
groupthe group to find.
Returns
the group, or 0 if not found.
template<typename K, typename P = basic_keyfile_parser<K>>
group_type* sbuild::basic_keyfile< K, P >::find_group ( group_name_type const &  group)
private

Find a group by it's name.

Parameters
groupthe group to find.
Returns
the group, or 0 if not found.
template<typename K, typename P = basic_keyfile_parser<K>>
const 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.

Parameters
groupthe group the key is in.
keythe key to find
Returns
the key, or 0 if not found.
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group the key is in.
keythe key to find
Returns
the key, or 0 if not found.
template<typename K, typename P = basic_keyfile_parser<K>>
comment_type sbuild::basic_keyfile< K, P >::get_comment ( group_name_type const &  group) const

Get a group comment.

Parameters
groupthe group to find.
Returns
the comment.
template<typename K, typename P = basic_keyfile_parser<K>>
comment_type sbuild::basic_keyfile< K, P >::get_comment ( group_name_type const &  group,
key_type const &  key 
) const

Get a key comment.

Parameters
groupthe group to find.
keythe key to find.
Returns
the comment.
template<typename K, typename P = basic_keyfile_parser<K>>
group_list sbuild::basic_keyfile< K, P >::get_groups ( ) const

Get a list of groups.

Returns
a list of groups in the basic_keyfile. If no groups exist, the list will be empty.

Referenced by sbuild::chroot_config::load_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
key_list sbuild::basic_keyfile< K, P >::get_keys ( group_name_type const &  group) const

Get a list of keys in a group.

Parameters
groupthe group to use.
Returns
a list of keys in a group. If no keys exist in the group, or the group does not exist, the list will be empty.

Referenced by sbuild::chroot::set_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
size_type sbuild::basic_keyfile< K, P >::get_line ( group_name_type const &  group) const

Get a group line number.

Parameters
groupthe group to find.
Returns
the line number, or 0 if not available.

Referenced by sbuild::chroot_config::add(), sbuild::basic_keyfile< K, P >::get_object_list_value(), sbuild::basic_keyfile< K, P >::get_object_set_value(), sbuild::basic_keyfile< K, P >::get_object_value(), and sbuild::chroot::set_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
size_type sbuild::basic_keyfile< K, P >::get_line ( group_name_type const &  group,
key_type const &  key 
) const

Get a key line number.

Parameters
groupthe group to find.
keythe key to find.
Returns
the line number, or 0 if not available.
template<typename K, typename P = basic_keyfile_parser<K>>
template<typename C >
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.

Parameters
groupthe group the key is in.
keythe key to get.
containerthe 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.
Returns
true if the key was found, otherwise false (in which case value will be undefined).

References sbuild::log_exception_warning(), sbuild::parse_value(), and sbuild::split_string().

Referenced by sbuild::basic_keyfile< K, P >::get_object_list_value().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename C >
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.

Parameters
groupthe group the key is in.
keythe key to get.
prioritythe priority of the option.
containerthe 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.
Returns
true if the key was found, otherwise false (in which case value will be undefined).
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group the key is in.
keythe key to get.
valuethe string to store the key's localised value in.
Returns
true if the key was found, otherwise false (in which case value will be unchanged).
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group the key is in.
keythe key to get.
prioritythe priority of the option.
valuethe string to store the key's localised value in.
Returns
true if the key was found, otherwise false (in which case value will be unchanged).
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group the key is in.
keythe key to get.
localethe locale to use.
valuethe string to store the key's localised value in.
Returns
true if the key was found, otherwise false (in which case value will be unchanged).
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group the key is in.
keythe key to get.
localethe locale to use.
prioritythe priority of the option.
valuethe string to store the key's localised value in.
Returns
true if the key was found, otherwise false (in which case value will be unchanged).
template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
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 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_list_value(), sbuild::basic_keyfile_parser< K >::group, sbuild::basic_keyfile_parser< K >::key, and sbuild::basic_keyfile_parser< K >::value.

Referenced by sbuild::chroot_facet_session::set_keyfile(), sbuild::chroot_facet_source_clonable::set_keyfile(), and sbuild::chroot::set_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
static void sbuild::basic_keyfile< K, P >::get_object_list_value ( C &  object,
void(C::*)(T const &param)  method,
basic_keyfile< K, P > const &  basic_keyfile,
group_name_type const &  group,
key_type const &  key,
basic_keyfile< K, P >::priority  priority 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_list_value(), sbuild::basic_keyfile_parser< K >::group, sbuild::basic_keyfile_parser< K >::key, and sbuild::basic_keyfile_parser< K >::value.

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
static void sbuild::basic_keyfile< K, P >::get_object_set_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 
)
inlinestatic

Get a key set value and set it in an object using an object method.

This is the same as calling get_set_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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_set_value(), sbuild::basic_keyfile_parser< K >::group, sbuild::basic_keyfile_parser< K >::key, and sbuild::basic_keyfile_parser< K >::value.

Referenced by sbuild::chroot_facet_userdata::set_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
static void sbuild::basic_keyfile< K, P >::get_object_set_value ( C &  object,
void(C::*)(T const &param)  method,
basic_keyfile< K, P > const &  basic_keyfile,
group_name_type const &  group,
key_type const &  key,
basic_keyfile< K, P >::priority  priority 
)
inlinestatic

Get a key set value and set it by reference in an object using an object method.

This is the same as calling get_set_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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_set_value(), sbuild::basic_keyfile_parser< K >::group, sbuild::basic_keyfile_parser< K >::key, and sbuild::basic_keyfile_parser< K >::value.

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
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 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_value(), and sbuild::basic_keyfile_parser< K >::value.

Referenced by sbuild::chroot_directory_base::set_keyfile(), sbuild::chroot_block_device_base::set_keyfile(), sbuild::chroot_facet_personality::set_keyfile(), sbuild::chroot_loopback::set_keyfile(), sbuild::chroot_lvm_snapshot::set_keyfile(), sbuild::chroot_custom::set_keyfile(), sbuild::chroot_facet_mountable::set_keyfile(), sbuild::chroot_facet_session::set_keyfile(), sbuild::chroot_btrfs_snapshot::set_keyfile(), sbuild::chroot_file::set_keyfile(), sbuild::chroot_facet_union::set_keyfile(), sbuild::chroot_facet_source_clonable::set_keyfile(), and sbuild::chroot::set_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
static void sbuild::basic_keyfile< K, P >::get_object_value ( C &  object,
void(C::*)(T const &param)  method,
basic_keyfile< K, P > const &  basic_keyfile,
group_name_type const &  group,
key_type const &  key,
basic_keyfile< K, P >::priority  priority 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References sbuild::basic_keyfile< K, P >::get_line(), sbuild::basic_keyfile< K, P >::get_value(), and sbuild::basic_keyfile_parser< K >::value.

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename C >
bool sbuild::basic_keyfile< K, P >::get_set_value ( group_name_type const &  group,
key_type const &  key,
C &  container 
) const
inline

Get a key value as a set.

Parameters
groupthe group the key is in.
keythe key to get.
containerthe container to store the key's value in. The value type must be settable from an istream and be copyable. The set must be a container with a standard insert method.
Returns
true if the key was found, otherwise false (in which case value will be undefined).

References sbuild::log_exception_warning(), sbuild::parse_value(), and sbuild::split_string().

Referenced by sbuild::basic_keyfile< K, P >::get_object_set_value().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename C >
bool sbuild::basic_keyfile< K, P >::get_set_value ( group_name_type const &  group,
key_type const &  key,
priority  priority,
C &  container 
) const
inline

Get a key value as a set.

If the value does not exist, is deprecated or obsolete, warn appropriately.

Parameters
groupthe group the key is in.
keythe key to get.
prioritythe priority of the option.
containerthe container to store the key's value in. The value type must be settable from an istream and be copyable. The set must be a container with a standard insert method.
Returns
true if the key was found, otherwise false (in which case value will be undefined).
template<typename K, typename P = basic_keyfile_parser<K>>
template<typename T >
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.

Parameters
groupthe group the key is in.
keythe key to get.
valuethe value to store the key's value in. This must be settable from an istream and be copyable.
Returns
true if the key was found, otherwise false (in which case value will be unchanged).

References sbuild::DEBUG_INFO, sbuild::DEBUG_NOTICE, sbuild::log_debug(), sbuild::log_exception_warning(), and sbuild::parse_value().

Referenced by sbuild::basic_keyfile< K, P >::get_object_value(), sbuild::chroot_config::load_keyfile(), and sbuild::chroot::set_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename T >
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.

Parameters
groupthe group the key is in.
keythe key to get.
prioritythe priority of the option.
valuethe value to store the key's value in. This must be settable from an istream and be copyable.
Returns
true if the key was found, otherwise false (in which case value will be unchanged).

References sbuild::basic_keyfile_parser< K >::key, and sbuild::basic_keyfile_parser< K >::value.

template<typename K, typename P = basic_keyfile_parser<K>>
bool sbuild::basic_keyfile< K, P >::has_group ( group_name_type const &  group) const

Check if a group exists.

Parameters
groupthe group to check for.
Returns
true if the group exists, otherwise false.
template<typename K, typename P = basic_keyfile_parser<K>>
bool sbuild::basic_keyfile< K, P >::has_key ( group_name_type const &  group,
key_type const &  key 
) const

Check if a key exists.

Parameters
groupthe group the key is in.
keythe key to check for.
Returns
true if the key exists, otherwise false.

Referenced by sbuild::chroot_directory_base::set_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
basic_keyfile& sbuild::basic_keyfile< K, P >::operator+= ( basic_keyfile< K, P > const &  rhs)

Add a basic_keyfile to the basic_keyfile.

Parameters
rhsthe basic_keyfile to add.
Returns
the modified basic_keyfile.
template<typename K, typename P = basic_keyfile_parser<K>>
static void sbuild::basic_keyfile< K, P >::print_comment ( comment_type const &  comment,
std::ostream &  stream 
)
staticprivate

Print a comment to a stream.

The comment will have hash ('#') marks printed at the start of each line.

Parameters
commentthe comment to print.
streamthe stream to output to.
Todo:
Use split string or some general iterator/algorithm instead of custom string manipulation. This could be reused by log_exception_* functions and split_string.
template<typename K, typename P = basic_keyfile_parser<K>>
void sbuild::basic_keyfile< K, P >::remove_group ( group_name_type const &  group)

Remove a group.

Parameters
groupthe group to remove.

Referenced by sbuild::chroot::get_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
void sbuild::basic_keyfile< K, P >::remove_key ( group_name_type const &  group,
key_type const &  key 
)

Remove a key.

Parameters
groupthe group the key is in.
keythe key to remove.
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group to set.
commentthe comment to set.
template<typename K, typename P = basic_keyfile_parser<K>>
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.

Parameters
groupthe group to set.
commentthe comment to set.
linethe line number in the input file, or 0 otherwise.
template<typename K, typename P = basic_keyfile_parser<K>>
template<typename I >
void sbuild::basic_keyfile< K, P >::set_list_value ( group_name_type const &  group,
key_type const &  key,
begin,
end 
)
inline

Set a key value from a list.

Parameters
groupthe group the key is in.
keythe key to set.
beginan iterator referring to the start of the list. The value type must allow output to an ostream.
endan iterator referring to the end of the list.

Referenced by sbuild::basic_keyfile< K, P >::set_object_list_value().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename I >
void sbuild::basic_keyfile< K, P >::set_list_value ( group_name_type const &  group,
key_type const &  key,
begin,
end,
comment_type const &  comment 
)
inline

Set a key value from a list.

Parameters
groupthe group the key is in.
keythe key to set.
beginan iterator referring to the start of the list. The value type must allow output to an ostream.
endan iterator referring to the end of the list.
commentthe comment for this key.
template<typename K, typename P = basic_keyfile_parser<K>>
template<typename I >
void sbuild::basic_keyfile< K, P >::set_list_value ( group_name_type const &  group,
key_type const &  key,
begin,
end,
comment_type const &  comment,
size_type  line 
)
inline

Set a key value from a list.

Parameters
groupthe group the key is in.
keythe key to set.
beginan iterator referring to the start of the list. The value type must allow output to an ostream.
endan iterator referring to the end of the list.
commentthe comment for this key.
linethe line number in the input file, or 0 otherwise.

References sbuild::basic_keyfile_parser< K >::end().

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
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 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.

References sbuild::basic_keyfile_parser< K >::begin(), sbuild::basic_keyfile_parser< K >::end(), and sbuild::basic_keyfile< K, P >::set_list_value().

Referenced by sbuild::chroot_facet_source_clonable::get_keyfile(), and sbuild::chroot::get_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
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 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.

References sbuild::basic_keyfile_parser< K >::begin(), sbuild::basic_keyfile_parser< K >::end(), and sbuild::basic_keyfile< K, P >::set_list_value().

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
static void sbuild::basic_keyfile< K, P >::set_object_set_value ( C const &  object,
T(C::*)() const  method,
basic_keyfile< K, P > &  basic_keyfile,
group_name_type const &  group,
key_type const &  key 
)
inlinestatic

Set a key set 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_set_value directly, but handles exceptions being thrown by the object method, which are turned into error exceptions.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.

References sbuild::basic_keyfile_parser< K >::begin(), sbuild::basic_keyfile_parser< K >::end(), and sbuild::basic_keyfile< K, P >::set_set_value().

Referenced by sbuild::chroot_facet_userdata::get_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
static void sbuild::basic_keyfile< K, P >::set_object_set_value ( C const &  object,
T const &(C::*)() const  method,
basic_keyfile< K, P > &  basic_keyfile,
group_name_type const &  group,
key_type const &  key 
)
inlinestatic

Set a key set 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_set_value directly, but handles exceptions being thrown by the object method, which are turned into error exceptions.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.

References sbuild::basic_keyfile_parser< K >::begin(), sbuild::basic_keyfile_parser< K >::end(), and sbuild::basic_keyfile< K, P >::set_set_value().

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
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 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.

References sbuild::basic_keyfile< K, P >::set_value().

Referenced by sbuild::chroot_directory_base::get_keyfile(), sbuild::chroot_block_device_base::get_keyfile(), sbuild::chroot_facet_personality::get_keyfile(), sbuild::chroot_loopback::get_keyfile(), sbuild::chroot_lvm_snapshot::get_keyfile(), sbuild::chroot_custom::get_keyfile(), sbuild::chroot_facet_mountable::get_keyfile(), sbuild::chroot_facet_session::get_keyfile(), sbuild::chroot_btrfs_snapshot::get_keyfile(), sbuild::chroot_file::get_keyfile(), sbuild::chroot_facet_union::get_keyfile(), sbuild::chroot_facet_source_clonable::get_keyfile(), and sbuild::chroot::get_keyfile().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<class C , typename T >
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 
)
inlinestatic

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.

Parameters
objectthe object to use.
methodthe object method to call.
basic_keyfilethe basic_keyfile to use.
groupthe group the key is in.
keythe key to set.

References sbuild::basic_keyfile< K, P >::set_value().

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename I >
void sbuild::basic_keyfile< K, P >::set_set_value ( group_name_type const &  group,
key_type const &  key,
begin,
end 
)
inline

Set a key value from a set.

Parameters
groupthe group the key is in.
keythe key to set.
beginan iterator referring to the start of the set. The value type must allow output to an ostream.
endan iterator referring to the end of the set.

Referenced by sbuild::basic_keyfile< K, P >::set_object_set_value().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename I >
void sbuild::basic_keyfile< K, P >::set_set_value ( group_name_type const &  group,
key_type const &  key,
begin,
end,
comment_type const &  comment 
)
inline

Set a key value from a set.

Parameters
groupthe group the key is in.
keythe key to set.
beginan iterator referring to the start of the set. The value type must allow output to an ostream.
endan iterator referring to the end of the set.
commentthe comment for this key.

References sbuild::basic_keyfile_parser< K >::comment.

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename I >
void sbuild::basic_keyfile< K, P >::set_set_value ( group_name_type const &  group,
key_type const &  key,
begin,
end,
comment_type const &  comment,
size_type  line 
)
inline

Set a key value from a set.

Parameters
groupthe group the key is in.
keythe key to set.
beginan iterator referring to the start of the set. The value type must allow output to an ostream.
endan iterator referring to the end of the set.
commentthe comment for this key.
linethe line number in the input file, or 0 otherwise.

References sbuild::basic_keyfile_parser< K >::comment.

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename T >
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.

Parameters
groupthe group the key is in.
keythe key to set.
valuethe value to get the key's value from. This must allow output to an ostream.

Referenced by sbuild::chroot_facet_userdata::get_keyfile(), and sbuild::basic_keyfile< K, P >::set_object_value().

+ Here is the caller graph for this function:

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename T >
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.

Parameters
groupthe group the key is in.
keythe key to set.
valuethe value to get the key's value from. This must allow output to an ostream.
commentthe comment for this key.
template<typename K, typename P = basic_keyfile_parser<K>>
template<typename T >
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.

Parameters
groupthe group the key is in.
keythe key to set.
valuethe value to get the key's value from. This must allow output to an ostream.
commentthe comment for this key.
linethe line number in the input file, or 0 otherwise.

References sbuild::basic_keyfile_parser< K >::comment, and sbuild::basic_keyfile_parser< K >::value.

Friends And Related Function Documentation

template<typename K, typename P = basic_keyfile_parser<K>>
template<typename _K , typename _P >
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.

Parameters
lhsthe basic_keyfile to add to.
rhsthe values to add.
Returns
the new basic_keyfile.
template<typename K, typename P = basic_keyfile_parser<K>>
template<class charT , class traits >
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.

Parameters
streamthe stream to output to.
kfthe basic_keyfile to output.
Returns
the stream.
template<typename K, typename P = basic_keyfile_parser<K>>
template<class charT , class traits >
std::basic_istream<charT,traits>& operator>> ( std::basic_istream< charT, traits > &  stream,
basic_keyfile< K, P > &  kf 
)
friend

basic_keyfile initialisation from an istream.

Parameters
streamthe stream to input from.
kfthe basic_keyfile to set.
Returns
the stream.

The documentation for this class was generated from the following file: