Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends

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 >:

List of all members.

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_typevalue_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_keyfileoperator+= (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 &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.
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 &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.

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

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 >
sbuild::basic_keyfile< K, P >::basic_keyfile ( std::string const &  file  ) 

The constructor.

Parameters:
file the file to load the configuration from.

References sbuild::keyfile_base::BAD_FILE.

template<typename K , typename P >
sbuild::basic_keyfile< K, P >::basic_keyfile ( std::istream &  stream  ) 

The constructor.

Parameters:
stream the stream to load the configuration from.

Member Function Documentation

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

template<typename K , typename P >
void sbuild::basic_keyfile< K, P >::check_priority ( group_name_type const &  group,
key_type const &  key,
priority  priority,
bool  valid 
) const [private]
template<typename K , typename P >
const sbuild::basic_keyfile< K, P >::group_type * sbuild::basic_keyfile< K, P >::find_group ( group_name_type const &  group  )  const [private]
template<typename K , typename P >
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.

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

References sbuild::basic_keyfile< K, P >::groups.

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

Parameters:
group the group the key is in.
key the key to find
Returns:
the key, or 0 if not found.

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

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

Parameters:
group the group the key is in.
key the key to find
Returns:
the key, or 0 if not found.

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().

Here is the caller graph for this function:

template<typename K , typename P >
sbuild::basic_keyfile< K, P >::comment_type sbuild::basic_keyfile< K, P >::get_comment ( group_name_type const &  group  )  const

Get a group comment.

Parameters:
group the group to find.
Returns:
the comment.

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

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

Parameters:
group the group to find.
key the key to find.
Returns:
the comment.

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

template<typename K , typename P >
sbuild::basic_keyfile< K, P >::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.

References sbuild::basic_keyfile< K, P >::groups.

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

Here is the caller graph for this function:

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

Parameters:
group the 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.

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

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

Here is the caller graph for this function:

template<typename K , typename P >
sbuild::basic_keyfile< K, P >::size_type sbuild::basic_keyfile< K, P >::get_line ( group_name_type const &  group  )  const
template<typename K , typename P >
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.

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

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

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:
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.
Returns:
true if the key was found, otherwise false (in which case value will be undefined).

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().

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:
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.
Returns:
true if the key was found, otherwise false (in which case value will be undefined).

References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_list_value().

template<typename K , typename P >
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:
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.
Returns:
true if the key was found, otherwise false (in which case value will be unchanged).

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

template<typename K , typename P >
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:
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.
Returns:
true if the key was found, otherwise false (in which case value will be unchanged).

References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_locale_string().

template<typename K , typename P >
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:
group the group the key is in.
key the key to get.
value the 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).

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

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

Here is the caller graph for this function:

template<typename K , typename P >
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:
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.
Returns:
true if the key was found, otherwise false (in which case value will be unchanged).

References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_locale_string().

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 
) [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.

Parameters:
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().

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 
) [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.

Parameters:
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.

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 
) [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.

Parameters:
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().

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 
) [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.

Parameters:
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.

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:
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.
Returns:
true if the key was found, otherwise false (in which case value will be unchanged).

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().

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:
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.
Returns:
true if the key was found, otherwise false (in which case value will be unchanged).

References sbuild::basic_keyfile< K, P >::check_priority(), and sbuild::basic_keyfile< K, P >::get_value().

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

Check if a group exists.

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

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

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

Here is the caller graph for this function:

template<typename K , typename P >
bool sbuild::basic_keyfile< K, P >::has_key ( group_name_type const &  group,
key_type const &  key 
) const

Check if a key exists.

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

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

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

Here is the caller graph for this function:

template<typename K , typename P >
sbuild::basic_keyfile< K, P > & sbuild::basic_keyfile< K, P >::operator+= ( basic_keyfile< K, P > const &  rhs  ) 
template<typename K , typename P >
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.

Parameters:
comment the comment to print.
stream the 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 >
void sbuild::basic_keyfile< K, P >::remove_group ( group_name_type const &  group  ) 

Remove a group.

Parameters:
group the group to remove.

References sbuild::basic_keyfile< K, P >::groups.

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

Here is the caller graph for this function:

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

Remove a key.

Parameters:
group the group the key is in.
key the key to remove.

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

template<typename K , typename P >
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:
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().

template<typename K , typename P >
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:
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().

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:
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().

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:
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().

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,
size_type  line 
) [inline]

Set a key value from a list.

Parameters:
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().

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 
) [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.

Parameters:
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().

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 
) [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.

Parameters:
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().

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 
) [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.

Parameters:
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().

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 
) [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.

Parameters:
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().

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:
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().

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:
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().

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:
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().

Here is the caller graph for this function:


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:
lhs the basic_keyfile to add to.
rhs the 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:
stream the stream to output to.
kf the 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:
stream the stream to input from.
kf the basic_keyfile to set.
Returns:
the stream.

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