sbuild::keyfile Class Reference

Configuration file parser. More...

#include <sbuild-keyfile.h>

Collaboration diagram for sbuild::keyfile:

Collaboration graph
[legend]
List of all members.

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_LINE, MISSING_KEY, MISSING_KEY_NL, NO_GROUP,
  NO_KEY, OBSOLETE_KEY, OBSOLETE_KEY_NL, PASSTHROUGH_G,
  PASSTHROUGH_GK, PASSTHROUGH_LG, PASSTHROUGH_LGK
}
 Error codes. More...
typedef parse_error< error_codeerror
 Exception type.

Public Member Functions

 keyfile ()
 The constructor.
 keyfile (std::string const &file)
 The constructor.
 keyfile (std::istream &stream)
 The constructor.
virtual ~keyfile ()
 The destructor.
string_list get_groups () const
 Get a list of groups.
string_list get_keys (std::string const &group) const
 Get a list of keys in a group.
bool has_group (std::string const &group) const
 Check if a group exists.
bool has_key (std::string const &group, std::string const &key) const
 Check if a key exists.
void set_group (std::string const &group, std::string const &comment)
 Set a group.
void set_group (std::string const &group, std::string const &comment, unsigned int line)
 Set a group.
std::string get_comment (std::string const &group) const
 Get a group comment.
std::string get_comment (std::string const &group, std::string const &key) const
 Get a key comment.
unsigned int get_line (std::string const &group) const
 Get a group line number.
unsigned int get_line (std::string const &group, std::string const &key) const
 Get a key line number.
template<typename T>
bool get_value (std::string const &group, std::string const &key, T &value) const
 Get a key value.
template<typename T>
bool get_value (std::string const &group, std::string const &key, priority priority, T &value) const
 Get a key value.
bool get_locale_string (std::string const &group, std::string const &key, std::string &value) const
 Get a localised key string value.
bool get_locale_string (std::string const &group, std::string const &key, priority priority, std::string &value) const
 Get a localised key string value.
bool get_locale_string (std::string const &group, std::string const &key, std::string const &locale, std::string &value) const
 Get a localised key string value for a specific locale.
bool get_locale_string (std::string const &group, std::string const &key, std::string const &locale, priority priority, std::string &value) const
 Get a localised key string value for a specific locale.
template<typename C>
bool get_list_value (std::string const &group, std::string const &key, C &container) const
 Get a key value as a list.
template<typename C>
bool get_list_value (std::string const &group, std::string const &key, priority priority, C &container) const
 Get a key value as a list.
template<typename T>
void set_value (std::string const &group, std::string const &key, T const &value)
 Set a key value.
template<typename T>
void set_value (std::string const &group, std::string const &key, T const &value, std::string const &comment)
 Set a key value.
template<typename T>
void set_value (std::string const &group, std::string const &key, T const &value, std::string const &comment, unsigned int line)
 Set a key value.
template<typename I>
void set_list_value (std::string const &group, std::string const &key, I begin, I end)
 Set a key value from a list.
template<typename I>
void set_list_value (std::string const &group, std::string const &key, I begin, I end, std::string const &comment)
 Set a key value from a list.
template<typename I>
void set_list_value (std::string const &group, std::string const &key, I begin, I end, std::string const &comment, unsigned int line)
 Set a key value from a list.
void remove_group (std::string const &group)
 Remove a group.
void remove_key (std::string const &group, std::string const &key)
 Remove a key.
keyfileoperator+= (keyfile const &rhs)
 Add a keyfile to the keyfile.

Static Public Member Functions

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

Private Types

typedef std::tr1::tuple< std::string,
std::string, std::string,
unsigned int > 
item_type
 Key-value-comment-line tuple.
typedef std::map< std::string,
item_type
item_map_type
 Map between key name and key-value-comment tuple.
typedef std::tr1::tuple< std::string,
item_map_type, std::string,
unsigned int > 
group_type
 Group-items-comment-line tuple.
typedef std::map< std::string,
group_type
group_map_type
 Map between group name and group-items-comment tuple.

Private Member Functions

const group_typefind_group (std::string const &group) const
 Find a group by it's name.
group_typefind_group (std::string const &group)
 Find a group by it's name.
const item_typefind_item (std::string const &group, std::string const &key) const
 Find a key by it's group and name.
item_typefind_item (std::string const &group, std::string const &key)
 Find a key by it's group and name.
void check_priority (std::string const &group, std::string 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 (std::string const &comment, std::ostream &stream)
 Print a comment to a stream.

Private Attributes

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

Friends

keyfile operator+ (keyfile const &lhs, keyfile const &rhs)
 Add a keyfile to the keyfile.
template<class charT, class traits>
std::basic_istream< charT,
traits > & 
operator>> (std::basic_istream< charT, traits > &stream, keyfile &kf)
 keyfile initialisation from an istream.
template<class charT, class traits>
std::basic_ostream< charT,
traits > & 
operator<< (std::basic_ostream< charT, traits > &stream, keyfile const &kf)
 keyfile output to an ostream.

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). It is an independent reimplementation of the Glib GKeyFile class, which it replaces.

Definition at line 47 of file sbuild-keyfile.h.


Member Typedef Documentation

typedef std::tr1::tuple<std::string,std::string,std::string,unsigned int> sbuild::keyfile::item_type [private]

Key-value-comment-line tuple.

Definition at line 52 of file sbuild-keyfile.h.

typedef std::map<std::string,item_type> sbuild::keyfile::item_map_type [private]

Map between key name and key-value-comment tuple.

Definition at line 55 of file sbuild-keyfile.h.

typedef std::tr1::tuple<std::string,item_map_type,std::string,unsigned int> sbuild::keyfile::group_type [private]

Group-items-comment-line tuple.

Definition at line 58 of file sbuild-keyfile.h.

typedef std::map<std::string,group_type> sbuild::keyfile::group_map_type [private]

Map between group name and group-items-comment tuple.

Definition at line 61 of file sbuild-keyfile.h.

typedef parse_error<error_code> sbuild::keyfile::error

Exception type.

Definition at line 99 of file sbuild-keyfile.h.


Member Enumeration Documentation

enum sbuild::keyfile::priority

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.

Definition at line 65 of file sbuild-keyfile.h.

enum sbuild::keyfile::error_code

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

Definition at line 75 of file sbuild-keyfile.h.


Constructor & Destructor Documentation

keyfile::keyfile (  ) 

The constructor.

Definition at line 117 of file sbuild-keyfile.cc.

Referenced by get_object_list_value(), get_object_value(), set_object_list_value(), and set_object_value().

Here is the caller graph for this function:

keyfile::keyfile ( std::string const &  file  ) 

The constructor.

Parameters:
file the file to load the configuration from.

Definition at line 123 of file sbuild-keyfile.cc.

References BAD_FILE.

keyfile::keyfile ( std::istream &  stream  ) 

The constructor.

Parameters:
stream the stream to load the configuration from.

Definition at line 139 of file sbuild-keyfile.cc.

keyfile::~keyfile (  )  [virtual]

The destructor.

Definition at line 146 of file sbuild-keyfile.cc.


Member Function Documentation

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

Definition at line 151 of file sbuild-keyfile.cc.

References groups.

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

Here is the caller graph for this function:

string_list keyfile::get_keys ( std::string 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.

Definition at line 164 of file sbuild-keyfile.cc.

References find_group().

Here is the call graph for this function:

bool keyfile::has_group ( std::string const &  group  )  const

Check if a group exists.

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

Definition at line 182 of file sbuild-keyfile.cc.

References find_group().

Referenced by dchroot::chroot_config::parse_data(), dchroot_dsa::chroot_config::parse_data(), and set_group().

Here is the call graph for this function:

Here is the caller graph for this function:

bool keyfile::has_key ( std::string const &  group,
std::string 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.

Definition at line 188 of file sbuild-keyfile.cc.

References find_item().

Here is the call graph for this function:

void keyfile::set_group ( std::string const &  group,
std::string 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.

Definition at line 195 of file sbuild-keyfile.cc.

Referenced by operator+=(), dchroot::chroot_config::parse_data(), dchroot_dsa::chroot_config::parse_data(), and set_value().

Here is the caller graph for this function:

void keyfile::set_group ( std::string const &  group,
std::string const &  comment,
unsigned int  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.

Definition at line 202 of file sbuild-keyfile.cc.

References groups, and has_group().

Here is the call graph for this function:

std::string keyfile::get_comment ( std::string const &  group  )  const

Get a group comment.

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

Definition at line 216 of file sbuild-keyfile.cc.

References find_group().

Here is the call graph for this function:

std::string keyfile::get_comment ( std::string const &  group,
std::string const &  key 
) const

Get a key comment.

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

Definition at line 226 of file sbuild-keyfile.cc.

References find_item().

Here is the call graph for this function:

unsigned int keyfile::get_line ( std::string const &  group  )  const

Get a group line number.

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

Definition at line 237 of file sbuild-keyfile.cc.

References find_group().

Referenced by sbuild::chroot_config::add(), check_priority(), get_list_value(), and get_value().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int keyfile::get_line ( std::string const &  group,
std::string 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.

Definition at line 247 of file sbuild-keyfile.cc.

References find_item().

Here is the call graph for this function:

template<typename T>
bool sbuild::keyfile::get_value ( std::string const &  group,
std::string 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).

Definition at line 236 of file sbuild-keyfile.h.

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_locale_string(), get_value(), and sbuild::chroot_config::load_keyfile().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T>
bool sbuild::keyfile::get_value ( std::string const &  group,
std::string 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).

Definition at line 285 of file sbuild-keyfile.h.

References check_priority(), and get_value().

Here is the call graph for this function:

bool keyfile::get_locale_string ( std::string const &  group,
std::string const &  key,
std::string &  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).

Definition at line 258 of file sbuild-keyfile.cc.

References get_value().

Referenced by get_locale_string().

Here is the call graph for this function:

Here is the caller graph for this function:

bool keyfile::get_locale_string ( std::string const &  group,
std::string const &  key,
priority  priority,
std::string &  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).

Definition at line 287 of file sbuild-keyfile.cc.

References check_priority(), and get_locale_string().

Here is the call graph for this function:

bool keyfile::get_locale_string ( std::string const &  group,
std::string const &  key,
std::string const &  locale,
std::string &  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).

Definition at line 298 of file sbuild-keyfile.cc.

References get_value().

Here is the call graph for this function:

bool keyfile::get_locale_string ( std::string const &  group,
std::string const &  key,
std::string const &  locale,
priority  priority,
std::string &  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).

Definition at line 308 of file sbuild-keyfile.cc.

References check_priority(), and get_locale_string().

Here is the call graph for this function:

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

Definition at line 376 of file sbuild-keyfile.h.

References get_line(), get_value(), sbuild::log_exception_warning(), sbuild::parse_value(), PASSTHROUGH_GK, PASSTHROUGH_LGK, and sbuild::split_string().

Referenced by get_list_value().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 435 of file sbuild-keyfile.h.

References check_priority(), and get_list_value().

Here is the call graph for this function:

template<typename T>
void sbuild::keyfile::set_value ( std::string const &  group,
std::string 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.

Definition at line 455 of file sbuild-keyfile.h.

Referenced by sbuild::chroot_config::load_keyfile(), operator+=(), dchroot::chroot_config::parse_data(), dchroot_dsa::chroot_config::parse_data(), set_list_value(), and set_value().

Here is the caller graph for this function:

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

Definition at line 473 of file sbuild-keyfile.h.

References set_value().

Here is the call graph for this function:

template<typename T>
void sbuild::keyfile::set_value ( std::string const &  group,
std::string const &  key,
T const &  value,
std::string const &  comment,
unsigned int  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.

Definition at line 493 of file sbuild-keyfile.h.

References find_group(), and set_group().

Here is the call graph for this function:

template<typename I>
void sbuild::keyfile::set_list_value ( std::string const &  group,
std::string 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.

Definition at line 528 of file sbuild-keyfile.h.

Referenced by dchroot::chroot_config::parse_data(), dchroot_dsa::chroot_config::parse_data(), and set_list_value().

Here is the caller graph for this function:

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

Definition at line 548 of file sbuild-keyfile.h.

References set_list_value().

Here is the call graph for this function:

template<typename I>
void sbuild::keyfile::set_list_value ( std::string const &  group,
std::string const &  key,
begin,
end,
std::string const &  comment,
unsigned int  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.

Definition at line 570 of file sbuild-keyfile.h.

References separator, and set_value().

Here is the call graph for this function:

void keyfile::remove_group ( std::string const &  group  ) 

Remove a group.

Parameters:
group the group to remove.

Definition at line 320 of file sbuild-keyfile.cc.

References groups.

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

Here is the caller graph for this function:

void keyfile::remove_key ( std::string const &  group,
std::string const &  key 
)

Remove a key.

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

Definition at line 328 of file sbuild-keyfile.cc.

References find_group().

Here is the call graph for this function:

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

Add a keyfile to the keyfile.

Parameters:
rhs the keyfile to add.
Returns:
the modified keyfile.

Definition at line 342 of file sbuild-keyfile.cc.

References groups, set_group(), and set_value().

Here is the call graph for this function:

const keyfile::group_type * keyfile::find_group ( std::string const &  group  )  const [private]

Find a group by it's name.

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

Definition at line 380 of file sbuild-keyfile.cc.

References groups.

Referenced by find_item(), get_comment(), get_keys(), get_line(), has_group(), remove_key(), and set_value().

Here is the caller graph for this function:

keyfile::group_type * keyfile::find_group ( std::string const &  group  )  [private]

Find a group by it's name.

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

Definition at line 390 of file sbuild-keyfile.cc.

References groups.

const keyfile::item_type * keyfile::find_item ( std::string const &  group,
std::string 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.

Definition at line 400 of file sbuild-keyfile.cc.

References find_group().

Referenced by get_comment(), get_line(), get_value(), and has_key().

Here is the call graph for this function:

Here is the caller graph for this function:

keyfile::item_type * keyfile::find_item ( std::string const &  group,
std::string 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.

Definition at line 416 of file sbuild-keyfile.cc.

References find_group().

Here is the call graph for this function:

void keyfile::check_priority ( std::string const &  group,
std::string const &  key,
priority  priority,
bool  valid 
) const [private]

Check if a key is missing or present when not permitted.

Parameters:
group the group the key is in.
key the key to get.
priority the key priority.
valid true if key exists, false if not existing.

Definition at line 457 of file sbuild-keyfile.cc.

References _, DEPRECATED_KEY, DEPRECATED_KEY_NL, DISALLOWED_KEY, DISALLOWED_KEY_NL, get_line(), sbuild::log_exception_warning(), MISSING_KEY, MISSING_KEY_NL, OBSOLETE_KEY, OBSOLETE_KEY_NL, PRIORITY_DEPRECATED, PRIORITY_DISALLOWED, PRIORITY_OBSOLETE, PRIORITY_REQUIRED, and sbuild::error_base::set_reason().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void keyfile::print_comment ( std::string 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.

Definition at line 432 of file sbuild-keyfile.cc.

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

Definition at line 859 of file sbuild-keyfile.h.

References keyfile(), and PASSTHROUGH_GK.

Referenced by sbuild::chroot::get_keyfile(), sbuild::chroot_lvm_snapshot::get_keyfile(), sbuild::chroot_file::get_keyfile(), sbuild::chroot_directory::get_keyfile(), and sbuild::chroot_block_device::get_keyfile().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 889 of file sbuild-keyfile.h.

References keyfile(), and PASSTHROUGH_GK.

Here is the call graph for this function:

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

Definition at line 920 of file sbuild-keyfile.h.

References keyfile(), and PASSTHROUGH_GK.

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

Here is the call graph for this function:

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,
std::string const &  group,
std::string 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.
keyfile the keyfile to use.
group the group the key is in.
key the key to set.

Definition at line 954 of file sbuild-keyfile.h.

References keyfile(), and PASSTHROUGH_GK.

Here is the call graph for this function:

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

Definition at line 988 of file sbuild-keyfile.h.

References keyfile(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

Referenced by sbuild::chroot::set_keyfile(), sbuild::chroot_lvm_snapshot::set_keyfile(), sbuild::chroot_file::set_keyfile(), sbuild::chroot_directory::set_keyfile(), and sbuild::chroot_block_device::set_keyfile().

Here is the call graph for this function:

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,
keyfile const &  keyfile,
std::string const &  group,
std::string const &  key,
keyfile::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.
keyfile the keyfile to use.
group the group the key is in.
key the key to set.
priority the key priority.

Definition at line 1027 of file sbuild-keyfile.h.

References keyfile(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

Here is the call graph for this function:

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

Definition at line 1066 of file sbuild-keyfile.h.

References keyfile(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

Referenced by sbuild::chroot::set_keyfile(), and sbuild::chroot_source::set_keyfile().

Here is the call graph for this function:

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,
keyfile const &  keyfile,
std::string const &  group,
std::string const &  key,
keyfile::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.
keyfile the keyfile to use.
group the group the key is in.
key the key to set.
priority the key priority.

Definition at line 1108 of file sbuild-keyfile.h.

References keyfile(), PASSTHROUGH_GK, and PASSTHROUGH_LGK.

Here is the call graph for this function:


Friends And Related Function Documentation

keyfile operator+ ( keyfile const &  lhs,
keyfile const &  rhs 
) [friend]

Add a keyfile to the keyfile.

Parameters:
lhs the keyfile to add to.
rhs the values to add.
Returns:
the new keyfile.

Definition at line 371 of file sbuild-keyfile.cc.

template<class charT, class traits>
std::basic_istream<charT,traits>& operator>> ( std::basic_istream< charT, traits > &  stream,
keyfile kf 
) [friend]

keyfile initialisation from an istream.

Parameters:
stream the stream to input from.
kf the keyfile to set.
Returns:
the stream.

Definition at line 643 of file sbuild-keyfile.h.

template<class charT, class traits>
std::basic_ostream<charT,traits>& operator<< ( std::basic_ostream< charT, traits > &  stream,
keyfile const &  kf 
) [friend]

keyfile output to an ostream.

Parameters:
stream the stream to output to.
kf the keyfile to output.
Returns:
the stream.

Definition at line 728 of file sbuild-keyfile.h.


Member Data Documentation

group_map_type sbuild::keyfile::groups [private]

The top-level groups.

Definition at line 840 of file sbuild-keyfile.h.

Referenced by find_group(), get_groups(), operator+=(), remove_group(), and set_group().

char sbuild::keyfile::separator [private]

The separator used as a list item delimiter.

Definition at line 842 of file sbuild-keyfile.h.

Referenced by set_list_value().


The documentation for this class was generated from the following files:
Generated on Sat Jan 27 16:14:25 2007 for schroot by  doxygen 1.5.1