sbuild  1.7.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
sbuild::keyfile Class Reference

Configuration file parser. More...

#include <keyfile.h>

+ Collaboration diagram for sbuild::keyfile:

Public Types

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.
 
typedef std::string group_name_type
 Group name.
 
typedef std::string key_type
 Key name.
 
typedef std::string value_type
 Value.
 
typedef std::string comment_type
 Comment.
 
typedef unsigned int size_type
 Line number.
 
typedef std::vector
< group_name_type
group_list
 Vector of groups.
 
typedef std::vector< value_typevalue_list
 Vector of values.
 

Public Member Functions

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

Static Public Member Functions

template<class C , typename T >
static void set_object_value (C const &object, T(C::*method)() const, keyfile &keyfile, const group_name_type &group, const key_type &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, keyfile &keyfile, const group_name_type &group, const key_type &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, keyfile &keyfile, const group_name_type &group, const key_type &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, keyfile &keyfile, const group_name_type &group, const key_type &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, keyfile &keyfile, const group_name_type &group, const key_type &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, keyfile &keyfile, const group_name_type &group, const key_type &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), const keyfile &keyfile, const group_name_type &group, const key_type &key, 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), const keyfile &keyfile, const group_name_type &group, const key_type &key, 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), const keyfile &keyfile, const group_name_type &group, const key_type &key, 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), const keyfile &keyfile, const group_name_type &group, const key_type &key, 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), const keyfile &keyfile, const group_name_type &group, const key_type &key, 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), const keyfile &keyfile, const group_name_type &group, const key_type &key, keyfile::priority priority)
 Get a key set value and set it by reference in an object using an object method. More...
 

Protected Types

typedef boost::any internal_value_type
 Internal value.
 
typedef std::tuple< key_type,
internal_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-internal_value-comment tuple.
 
typedef std::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_typekey_list
 Vector of keys.
 

Protected Member Functions

void set_value (const group_name_type &group, const key_type &key, const internal_value_type &value, const comment_type &comment, size_type line)
 Set a key value. More...
 
const group_typefind_group (const group_name_type &group) const
 Find a group by it's name. More...
 
group_typefind_group (const group_name_type &group)
 Find a group by it's name. More...
 
const item_typefind_item (const group_name_type &group, const key_type &key) const
 Find a key by it's group and name. More...
 
item_typefind_item (const group_name_type &group, const key_type &key)
 Find a key by it's group and name. More...
 
void check_priority (const group_name_type &group, const key_type &key, priority priority, bool valid) const
 Check if a key is missing or present when not permitted. More...
 

Protected Attributes

group_map_type groups
 The top-level groups.
 
value_type separator
 The separator used as a list item delimiter.
 

Friends

keyfile operator+ (const keyfile &lhs, const keyfile &rhs)
 Add a keyfile to the keyfile. More...
 

Detailed Description

Configuration file parser.

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

Member Enumeration Documentation

Error codes.

Enumerator
BAD_FILE 

The file to parse couldn't be opened.

DEPRECATED_KEY 

The key is deprecated.

DEPRECATED_KEY_NL 

The key is deprecated (no line specified).

DISALLOWED_KEY 

The key is not allowed.

DISALLOWED_KEY_NL 

The key is not allowed (no line specified).

DUPLICATE_GROUP 

The group is a duplicate.

DUPLICATE_KEY 

The key is a duplicate.

INVALID_GROUP 

The group is invalid.

INVALID_KEY 

The key is invalid.

INVALID_LINE 

The line is invalid.

MISSING_KEY 

The key is missing.

MISSING_KEY_NL 

The key is missing (no line specified).

NO_GROUP 

No group was specified.

NO_KEY 

No key was specified.

OBSOLETE_KEY 

The key is obsolete.

OBSOLETE_KEY_NL 

The key is obsolete (no line specified).

PASSTHROUGH_G 

Pass through exception with group.

PASSTHROUGH_GK 

Pass through exception with group and key.

PASSTHROUGH_LG 

Pass through exception with line and group.

PASSTHROUGH_LGK 

Pass through exception with line, group and key.

UNKNOWN_KEY 

The key is unknown.

Configuration parameter priority.

Enumerator
PRIORITY_OPTIONAL 

The parameter is optional.

PRIORITY_REQUIRED 

The parameter is required.

PRIORITY_DISALLOWED 

The parameter is not allowed in this context.

PRIORITY_DEPRECATED 

The parameter is deprecated, but functional.

PRIORITY_OBSOLETE 

The parameter is obsolete, and not functional.

Member Function Documentation

void sbuild::keyfile::check_keys ( const group_name_type group,
const key_list 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.

References sbuild::_(), sbuild::log_exception_warning(), and sbuild::error_base::set_reason().

void sbuild::keyfile::check_priority ( const group_name_type group,
const key_type key,
priority  priority,
bool  valid 
) const
protected

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.

References sbuild::_(), sbuild::log_exception_warning(), and sbuild::error_base::set_reason().

Referenced by get_list_value(), get_set_value(), and get_value().

+ Here is the caller graph for this function:

const sbuild::keyfile::group_type * sbuild::keyfile::find_group ( const group_name_type group) const
protected

Find a group by it's name.

Parameters
groupthe group to find.
Returns
the group, or 0 if not found.

Referenced by set_value().

+ Here is the caller graph for this function:

sbuild::keyfile::group_type * sbuild::keyfile::find_group ( const group_name_type group)
protected

Find a group by it's name.

Parameters
groupthe group to find.
Returns
the group, or 0 if not found.
const sbuild::keyfile::item_type * sbuild::keyfile::find_item ( const group_name_type group,
const key_type key 
) const
protected

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.

Referenced by get_value().

+ Here is the caller graph for this function:

sbuild::keyfile::item_type * sbuild::keyfile::find_item ( const group_name_type group,
const key_type key 
)
protected

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.
sbuild::keyfile::comment_type sbuild::keyfile::get_comment ( const group_name_type group) const

Get a group comment.

Parameters
groupthe group to find.
Returns
the comment.

Referenced by sbuild::keyfile_writer::write_stream().

+ Here is the caller graph for this function:

sbuild::keyfile::comment_type sbuild::keyfile::get_comment ( const group_name_type group,
const key_type key 
) const

Get a key comment.

Parameters
groupthe group to find.
keythe key to find.
Returns
the comment.
sbuild::keyfile::group_list sbuild::keyfile::get_groups ( ) const

Get a list of groups.

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

Referenced by sbuild::chroot::config::load_keyfile(), and sbuild::keyfile_writer::write_stream().

+ Here is the caller graph for this function:

sbuild::keyfile::key_list sbuild::keyfile::get_keys ( const group_name_type 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::facet::userdata::set_keyfile(), and sbuild::keyfile_writer::write_stream().

+ Here is the caller graph for this function:

sbuild::keyfile::size_type sbuild::keyfile::get_line ( const group_name_type 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(), get_list_value(), get_object_list_value(), get_object_set_value(), get_object_value(), get_set_value(), get_value(), and sbuild::chroot::facet::userdata::set_keyfile().

+ Here is the caller graph for this function:

sbuild::keyfile::size_type sbuild::keyfile::get_line ( const group_name_type group,
const key_type 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 C >
bool sbuild::keyfile::get_list_value ( const group_name_type group,
const key_type 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 get_line(), get_value(), sbuild::log_exception_warning(), sbuild::parse_value(), PASSTHROUGH_GK, PASSTHROUGH_LGK, separator, and sbuild::split_string().

Referenced by get_list_value(), and get_object_list_value().

+ Here is the caller graph for this function:

template<typename C >
bool sbuild::keyfile::get_list_value ( const group_name_type group,
const key_type 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).

References check_priority(), and get_list_value().

bool sbuild::keyfile::get_locale_string ( const group_name_type group,
const key_type 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).
bool sbuild::keyfile::get_locale_string ( const group_name_type group,
const key_type 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).
bool sbuild::keyfile::get_locale_string ( const group_name_type group,
const key_type key,
const std::string &  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).
bool sbuild::keyfile::get_locale_string ( const group_name_type group,
const key_type key,
const std::string &  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<class C , typename T >
static void sbuild::keyfile::get_object_list_value ( C &  object,
void(C::*)(T param)  method,
const keyfile keyfile,
const group_name_type group,
const key_type key,
keyfile::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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References get_line(), get_list_value(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

Referenced by sbuild::chroot::facet::source_clonable::set_keyfile(), and sbuild::chroot::chroot::set_keyfile().

+ Here is the caller graph for this function:

template<class C , typename T >
static void sbuild::keyfile::get_object_list_value ( C &  object,
void(C::*)(T const &param)  method,
const keyfile keyfile,
const group_name_type group,
const key_type key,
keyfile::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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References get_line(), get_list_value(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

template<class C , typename T >
static void sbuild::keyfile::get_object_set_value ( C &  object,
void(C::*)(T param)  method,
const keyfile keyfile,
const group_name_type group,
const key_type key,
keyfile::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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References get_line(), get_set_value(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

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

+ Here is the caller graph for this function:

template<class C , typename T >
static void sbuild::keyfile::get_object_set_value ( C &  object,
void(C::*)(T const &param)  method,
const keyfile keyfile,
const group_name_type group,
const key_type key,
keyfile::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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References get_line(), get_set_value(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

template<class C , typename T >
static void sbuild::keyfile::get_object_value ( C &  object,
void(C::*)(T param)  method,
const keyfile keyfile,
const group_name_type group,
const key_type key,
keyfile::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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References get_line(), get_value(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

Referenced by sbuild::chroot::facet::personality::set_keyfile(), sbuild::chroot::facet::directory_base::set_keyfile(), sbuild::chroot::facet::block_device_base::set_keyfile(), sbuild::chroot::facet::loopback::set_keyfile(), sbuild::chroot::facet::session::set_keyfile(), sbuild::chroot::facet::mountable::set_keyfile(), sbuild::chroot::facet::lvm_snapshot::set_keyfile(), sbuild::chroot::facet::custom::set_keyfile(), sbuild::chroot::facet::unshare::set_keyfile(), sbuild::chroot::facet::file::set_keyfile(), sbuild::chroot::facet::btrfs_snapshot::set_keyfile(), sbuild::chroot::facet::source_clonable::set_keyfile(), sbuild::chroot::facet::fsunion::set_keyfile(), and sbuild::chroot::chroot::set_keyfile().

+ Here is the caller graph for this function:

template<class C , typename T >
static void sbuild::keyfile::get_object_value ( C &  object,
void(C::*)(T const &param)  method,
const keyfile keyfile,
const group_name_type group,
const key_type key,
keyfile::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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.
prioritythe key priority.

References get_line(), get_value(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

template<typename C >
bool sbuild::keyfile::get_set_value ( const group_name_type group,
const key_type 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 get_line(), get_value(), sbuild::log_exception_warning(), sbuild::parse_value(), PASSTHROUGH_GK, PASSTHROUGH_LGK, separator, and sbuild::split_string().

Referenced by get_object_set_value(), and get_set_value().

+ Here is the caller graph for this function:

template<typename C >
bool sbuild::keyfile::get_set_value ( const group_name_type group,
const key_type 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).

References check_priority(), and get_set_value().

template<typename T >
bool sbuild::keyfile::get_value ( const group_name_type group,
const key_type 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, find_item(), get_line(), sbuild::log_debug(), sbuild::log_exception_warning(), sbuild::parse_value(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

Referenced by get_list_value(), get_object_value(), get_set_value(), get_value(), sbuild::chroot::config::load_keyfile(), sbuild::chroot::facet::userdata::set_keyfile(), and sbuild::keyfile_writer::write_stream().

+ Here is the caller graph for this function:

template<typename T >
bool sbuild::keyfile::get_value ( const group_name_type group,
const key_type 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 check_priority(), and get_value().

bool sbuild::keyfile::has_group ( const group_name_type group) const

Check if a group exists.

Parameters
groupthe group to check for.
Returns
true if the group exists, otherwise false.

Referenced by sbuild::keyfile_reader::read_stream().

+ Here is the caller graph for this function:

bool sbuild::keyfile::has_key ( const group_name_type group,
const key_type 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::keyfile_reader::read_stream(), and sbuild::chroot::facet::directory_base::set_keyfile().

+ Here is the caller graph for this function:

sbuild::keyfile & sbuild::keyfile::operator+= ( const keyfile rhs)

Add a keyfile to the keyfile.

Parameters
rhsthe keyfile to add.
Returns
the modified keyfile.

References groups.

void sbuild::keyfile::remove_group ( const group_name_type group)

Remove a group.

Parameters
groupthe group to remove.

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

+ Here is the caller graph for this function:

void sbuild::keyfile::remove_key ( const group_name_type group,
const key_type key 
)

Remove a key.

Parameters
groupthe group the key is in.
keythe key to remove.
void sbuild::keyfile::set_group ( const group_name_type group,
const comment_type 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.

Referenced by sbuild::keyfile_reader::read_stream(), and set_value().

+ Here is the caller graph for this function:

void sbuild::keyfile::set_group ( const group_name_type group,
const comment_type 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 I >
void sbuild::keyfile::set_list_value ( const group_name_type group,
const key_type 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 set_list_value(), set_object_list_value(), and set_set_value().

+ Here is the caller graph for this function:

template<typename I >
void sbuild::keyfile::set_list_value ( const group_name_type group,
const key_type key,
begin,
end,
const comment_type 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.

References set_list_value().

template<typename I >
void sbuild::keyfile::set_list_value ( const group_name_type group,
const key_type key,
begin,
end,
const comment_type 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 separator, and set_value().

template<class C , typename T >
static void sbuild::keyfile::set_object_list_value ( C const &  object,
T(C::*)() const  method,
keyfile keyfile,
const group_name_type group,
const key_type 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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.

References PASSTHROUGH_GK, and set_list_value().

Referenced by sbuild::chroot::facet::source_clonable::get_keyfile(), and sbuild::chroot::chroot::get_keyfile().

+ Here is the caller graph for this function:

template<class C , typename T >
static void sbuild::keyfile::set_object_list_value ( C const &  object,
T const &(C::*)() const  method,
keyfile keyfile,
const group_name_type group,
const key_type 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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.

References PASSTHROUGH_GK, and set_list_value().

template<class C , typename T >
static void sbuild::keyfile::set_object_set_value ( C const &  object,
T(C::*)() const  method,
keyfile keyfile,
const group_name_type group,
const key_type 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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.

References PASSTHROUGH_GK, and set_set_value().

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

+ Here is the caller graph for this function:

template<class C , typename T >
static void sbuild::keyfile::set_object_set_value ( C const &  object,
T const &(C::*)() const  method,
keyfile keyfile,
const group_name_type group,
const key_type 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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.

References PASSTHROUGH_GK, and set_set_value().

template<class C , typename T >
static void sbuild::keyfile::set_object_value ( C const &  object,
T(C::*)() const  method,
keyfile keyfile,
const group_name_type group,
const key_type key 
)
inlinestatic
template<class C , typename T >
static void sbuild::keyfile::set_object_value ( C const &  object,
T const &(C::*)() const  method,
keyfile keyfile,
const group_name_type group,
const key_type 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.
keyfilethe keyfile to use.
groupthe group the key is in.
keythe key to set.

References PASSTHROUGH_GK, and set_value().

template<typename I >
void sbuild::keyfile::set_set_value ( const group_name_type group,
const key_type 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.

References set_list_value().

Referenced by set_object_set_value().

+ Here is the caller graph for this function:

template<typename I >
void sbuild::keyfile::set_set_value ( const group_name_type group,
const key_type key,
begin,
end,
const comment_type 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 set_list_value().

template<typename I >
void sbuild::keyfile::set_set_value ( const group_name_type group,
const key_type key,
begin,
end,
const comment_type 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 set_list_value().

template<typename T >
void sbuild::keyfile::set_value ( const group_name_type group,
const key_type 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(), sbuild::keyfile_reader::read_stream(), set_list_value(), set_object_value(), and set_value().

+ Here is the caller graph for this function:

template<typename T >
void sbuild::keyfile::set_value ( const group_name_type group,
const key_type key,
T const &  value,
const comment_type 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.

References set_value().

void sbuild::keyfile::set_value ( const group_name_type group,
const key_type key,
const internal_value_type value,
const comment_type comment,
size_type  line 
)
inlineprotected

Set a key value.

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

References find_group(), and set_group().

template<typename T >
void sbuild::keyfile::set_value ( const group_name_type group,
const key_type key,
T const &  value,
const comment_type 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 find_group(), and set_group().

Friends And Related Function Documentation

keyfile operator+ ( const keyfile lhs,
const keyfile rhs 
)
friend

Add a keyfile to the keyfile.

Parameters
lhsthe keyfile to add to.
rhsthe values to add.
Returns
the new keyfile.

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