csbuild::debian_changes Class Reference

Debian changes file parser. More...

#include <csbuild-debian-changes.h>

Collaboration diagram for csbuild::debian_changes:

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_KEY, INVALID_LINE, MISSING_KEY,
  MISSING_KEY_NL, NO_KEY, OBSOLETE_KEY, OBSOLETE_KEY_NL,
  PASSTHROUGH_K, PASSTHROUGH_LK
}
 Error codes. More...
typedef sbuild::parse_error
< error_code
error
 Exception type.

Public Member Functions

 debian_changes ()
 The constructor.
 debian_changes (std::string const &file)
 The constructor.
 debian_changes (std::istream &stream)
 The constructor.
virtual ~debian_changes ()
 The destructor.
sbuild::string_list get_keys () const
 Get a list of keys.
bool has_key (key_type const &key) const
 Check if a key exists.
size_type get_line (key_type const &key) const
 Get a key line number.
template<typename T>
bool get_value (key_type const &key, T &value) const
 Get a key value.
template<typename T>
bool get_value (key_type const &key, priority priority, T &value) const
 Get a key value.
bool get_value (key_type const &key, value_type &value) const
 Get a key value.
bool get_value (key_type const &key, priority priority, value_type &value) const
 Get a key value.
template<typename C>
bool get_list_value (key_type const &key, C &container, std::string const &separator) const
 Get a key value as a list.
template<typename C>
bool get_list_value (key_type const &key, priority priority, C &container) const
 Get a key value as a list.
template<typename T>
void set_value (key_type const &key, T const &value)
 Set a key value.
template<typename T>
void set_value (key_type const &key, T const &value, size_type line)
 Set a key value.
void set_value (key_type const &key, value_type const &value)
 Set a key value.
void set_value (key_type const &key, value_type const &value, size_type line)
 Set a key value.
template<typename I>
void set_list_value (key_type const &key, I begin, I end)
 Set a key value from a list.
template<typename I>
void set_list_value (key_type const &key, I begin, I end, std::string const &separator, size_type line)
 Set a key value from a list.
void remove_key (key_type const &key)
 Remove a key.
debian_changesoperator+= (debian_changes const &rhs)
 Add a debian_changes to the debian_changes.

Static Public Member Functions

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

Private Types

typedef std::string key_type
typedef std::vector< std::string > value_type
typedef unsigned int size_type
typedef std::tr1::tuple
< key_type, value_type,
size_type
item_type
 Key-value-line tuple.
typedef std::map< key_type,
item_type
item_map_type
 Map between key name and key-value-comment tuple.

Private Member Functions

const item_typefind_item (key_type const &key) const
 Find a key by its name.
item_typefind_item (key_type const &key)
 Find a key by its name.
void check_priority (key_type const &key, priority priority, bool valid) const
 Check if a key is missing or present when not permitted.

Private Attributes

item_map_type items
 The top-level items.

Friends

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


Detailed Description

Debian changes file parser.

This class is a generic parser for the file format used in Debian changes files for binary and source uploads (.changes and .dsc files).

Definition at line 45 of file csbuild-debian-changes.h.


Member Typedef Documentation

typedef std::string csbuild::debian_changes::key_type [private]

Definition at line 48 of file csbuild-debian-changes.h.

typedef std::vector<std::string> csbuild::debian_changes::value_type [private]

Definition at line 49 of file csbuild-debian-changes.h.

typedef unsigned int csbuild::debian_changes::size_type [private]

Definition at line 50 of file csbuild-debian-changes.h.

typedef std::tr1::tuple<key_type,value_type,size_type> csbuild::debian_changes::item_type [private]

Key-value-line tuple.

Definition at line 54 of file csbuild-debian-changes.h.

typedef std::map<key_type,item_type> csbuild::debian_changes::item_map_type [private]

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

Definition at line 57 of file csbuild-debian-changes.h.

typedef sbuild::parse_error<error_code> csbuild::debian_changes::error

Exception type.

Definition at line 90 of file csbuild-debian-changes.h.


Member Enumeration Documentation

enum csbuild::debian_changes::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 61 of file csbuild-debian-changes.h.

enum csbuild::debian_changes::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_KEY  The key is a duplicate.
INVALID_LINE  The line is invalid.
MISSING_KEY  The key is missing.
MISSING_KEY_NL  The key is missing (no line specified).
NO_KEY  No key was specified.
OBSOLETE_KEY  The key is obsolete.
OBSOLETE_KEY_NL  The key is obsolete (no line specified).
PASSTHROUGH_K  Pass through exception with key.
PASSTHROUGH_LK  Pass through exception with line and key.

Definition at line 71 of file csbuild-debian-changes.h.


Constructor & Destructor Documentation

debian_changes::debian_changes (  ) 

The constructor.

Definition at line 91 of file csbuild-debian-changes.cc.

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

The constructor.

Parameters:
file the file to load the configuration from.

Definition at line 96 of file csbuild-debian-changes.cc.

References BAD_FILE.

debian_changes::debian_changes ( std::istream &  stream  ) 

The constructor.

Parameters:
stream the stream to load the configuration from.

Definition at line 111 of file csbuild-debian-changes.cc.

debian_changes::~debian_changes (  )  [virtual]

The destructor.

Definition at line 117 of file csbuild-debian-changes.cc.


Member Function Documentation

sbuild::string_list debian_changes::get_keys (  )  const

Get a list of keys.

Returns:
a list of keys.

Definition at line 122 of file csbuild-debian-changes.cc.

References items.

bool debian_changes::has_key ( key_type const &  key  )  const

Check if a key exists.

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

Definition at line 135 of file csbuild-debian-changes.cc.

References find_item().

debian_changes::size_type debian_changes::get_line ( key_type const &  key  )  const

Get a key line number.

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

Definition at line 141 of file csbuild-debian-changes.cc.

References find_item().

Referenced by check_priority(), get_list_value(), get_object_list_value(), get_object_value(), and get_value().

Here is the caller graph for this function:

template<typename T>
bool csbuild::debian_changes::get_value ( key_type const &  key,
T &  value 
) const [inline]

Get a key value.

Parameters:
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 148 of file csbuild-debian-changes.h.

References sbuild::DEBUG_INFO, sbuild::DEBUG_NOTICE, find_item(), get_line(), sbuild::log_debug(), log_exception_warning(), sbuild::parse_value(), PASSTHROUGH_K, and PASSTHROUGH_LK.

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

Here is the caller graph for this function:

template<typename T>
bool csbuild::debian_changes::get_value ( 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:
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 196 of file csbuild-debian-changes.h.

References check_priority(), and get_value().

bool debian_changes::get_value ( key_type const &  key,
value_type value 
) const

Get a key value.

Parameters:
key the key to get.
value the value to store the key's value in.
Returns:
true if the key was found, otherwise false (in which case value will be unchanged).

Definition at line 151 of file csbuild-debian-changes.cc.

References sbuild::DEBUG_INFO, sbuild::DEBUG_NOTICE, find_item(), and sbuild::log_debug().

bool debian_changes::get_value ( key_type const &  key,
priority  priority,
value_type value 
) const

Get a key value.

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

Parameters:
key the key to get.
priority the priority of the option.
value the value to store the key's value in.
Returns:
true if the key was found, otherwise false (in which case value will be unchanged).

Definition at line 169 of file csbuild-debian-changes.cc.

References check_priority(), and get_value().

template<typename C>
bool csbuild::debian_changes::get_list_value ( key_type const &  key,
C &  container,
std::string const &  separator 
) const [inline]

Get a key value as a list.

Parameters:
key the key to get. Note that if the key contains multiple lines, each line will be split using the separator.
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.
separator the characters to separate the values.
Returns:
true if the key was found, otherwise false (in which case value will be undefined).

Definition at line 247 of file csbuild-debian-changes.h.

References get_line(), get_value(), items, log_exception_warning(), sbuild::parse_value(), PASSTHROUGH_K, PASSTHROUGH_LK, 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 csbuild::debian_changes::get_list_value ( 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:
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 310 of file csbuild-debian-changes.h.

References check_priority(), and get_list_value().

template<typename T>
void csbuild::debian_changes::set_value ( key_type const &  key,
T const &  value 
) [inline]

Set a key value.

Parameters:
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 328 of file csbuild-debian-changes.h.

Referenced by operator+=(), set_list_value(), set_object_value(), and set_value().

Here is the caller graph for this function:

template<typename T>
void csbuild::debian_changes::set_value ( key_type const &  key,
T const &  value,
size_type  line 
) [inline]

Set a key value.

Parameters:
key the key to set.
value the value to get the key's value from. This must allow output to an ostream.
line the line number in the input file, or 0 otherwise.

Definition at line 344 of file csbuild-debian-changes.h.

References items.

void csbuild::debian_changes::set_value ( key_type const &  key,
value_type const &  value 
) [inline]

Set a key value.

Parameters:
key the key to set.
value the value to get the key's value from.

Definition at line 369 of file csbuild-debian-changes.h.

References set_value().

void debian_changes::set_value ( key_type const &  key,
value_type const &  value,
size_type  line 
)

Set a key value.

Parameters:
key the key to set.
value the value to get the key's value from.
line the line number in the input file, or 0 otherwise.

Definition at line 179 of file csbuild-debian-changes.cc.

References items.

template<typename I>
void csbuild::debian_changes::set_list_value ( key_type const &  key,
begin,
end 
) [inline]

Set a key value from a list.

Parameters:
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 397 of file csbuild-debian-changes.h.

Referenced by set_object_list_value().

Here is the caller graph for this function:

template<typename I>
void csbuild::debian_changes::set_list_value ( key_type const &  key,
begin,
end,
std::string const &  separator,
size_type  line 
) [inline]

Set a key value from a list.

Parameters:
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.
separator the characters to separate the values.
line the line number in the input file, or 0 otherwise.

Definition at line 416 of file csbuild-debian-changes.h.

References set_value().

void debian_changes::remove_key ( key_type const &  key  ) 

Remove a key.

Parameters:
key the key to remove.

Definition at line 192 of file csbuild-debian-changes.cc.

References items.

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

Add a debian_changes to the debian_changes.

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

Definition at line 200 of file csbuild-debian-changes.cc.

References items, and set_value().

const debian_changes::item_type * debian_changes::find_item ( key_type const &  key  )  const [private]

Find a key by its name.

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

Definition at line 226 of file csbuild-debian-changes.cc.

References items.

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

Here is the caller graph for this function:

debian_changes::item_type * debian_changes::find_item ( key_type const &  key  )  [private]

Find a key by its name.

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

Definition at line 236 of file csbuild-debian-changes.cc.

References items.

void debian_changes::check_priority ( key_type const &  key,
priority  priority,
bool  valid 
) const [private]

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

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

Definition at line 246 of file csbuild-debian-changes.cc.

References DEPRECATED_KEY, DEPRECATED_KEY_NL, DISALLOWED_KEY, DISALLOWED_KEY_NL, get_line(), 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(), and get_value().

Here is the caller graph for this function:

template<class C, typename T>
static void csbuild::debian_changes::set_object_value ( C const &  object,
T(C::*)() const   method,
debian_changes debian_changes,
debian_changes::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.
debian_changes the debian_changes to use.
key the key to set.

Definition at line 598 of file csbuild-debian-changes.h.

References PASSTHROUGH_K, and set_value().

template<class C, typename T>
static void csbuild::debian_changes::set_object_value ( C const &  object,
T const &(C::*)() const   method,
debian_changes debian_changes,
debian_changes::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.
debian_changes the debian_changes to use.
key the key to set.

Definition at line 626 of file csbuild-debian-changes.h.

References PASSTHROUGH_K, and set_value().

template<class C, typename T>
static void csbuild::debian_changes::set_object_list_value ( C const &  object,
T(C::*)() const   method,
debian_changes debian_changes,
debian_changes::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.
debian_changes the debian_changes to use.
key the key to set.

Definition at line 655 of file csbuild-debian-changes.h.

References PASSTHROUGH_K, and set_list_value().

template<class C, typename T>
static void csbuild::debian_changes::set_object_list_value ( C const &  object,
T const &(C::*)() const   method,
debian_changes debian_changes,
debian_changes::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.
debian_changes the debian_changes to use.
key the key to set.

Definition at line 687 of file csbuild-debian-changes.h.

References PASSTHROUGH_K, and set_list_value().

template<class C, typename T>
static void csbuild::debian_changes::get_object_value ( C &  object,
void(C::*)(T param)  method,
debian_changes const &  debian_changes,
debian_changes::key_type const &  key,
debian_changes::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 key and line number in the input file.

Parameters:
object the object to use.
method the object method to call.
debian_changes the debian_changes to use.
key the key to set.
priority the key priority.

Definition at line 719 of file csbuild-debian-changes.h.

References get_line(), get_value(), PASSTHROUGH_K, and PASSTHROUGH_LK.

template<class C, typename T>
static void csbuild::debian_changes::get_object_value ( C &  object,
void(C::*)(T const &param)  method,
debian_changes const &  debian_changes,
debian_changes::key_type const &  key,
debian_changes::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 key and line number in the input file.

Parameters:
object the object to use.
method the object method to call.
debian_changes the debian_changes to use.
key the key to set.
priority the key priority.

Definition at line 756 of file csbuild-debian-changes.h.

References get_line(), get_value(), PASSTHROUGH_K, and PASSTHROUGH_LK.

template<class C, typename T>
static void csbuild::debian_changes::get_object_list_value ( C &  object,
void(C::*)(T param)  method,
debian_changes const &  debian_changes,
debian_changes::key_type const &  key,
debian_changes::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 key and line number in the input file.

Parameters:
object the object to use.
method the object method to call.
debian_changes the debian_changes to use.
key the key to set.
priority the key priority.

Definition at line 793 of file csbuild-debian-changes.h.

References get_line(), get_list_value(), PASSTHROUGH_K, and PASSTHROUGH_LK.

template<class C, typename T>
static void csbuild::debian_changes::get_object_list_value ( C &  object,
void(C::*)(T const &param)  method,
debian_changes const &  debian_changes,
debian_changes::key_type const &  key,
debian_changes::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 key and line number in the input file.

Parameters:
object the object to use.
method the object method to call.
debian_changes the debian_changes to use.
key the key to set.
priority the key priority.

Definition at line 833 of file csbuild-debian-changes.h.

References get_line(), get_list_value(), PASSTHROUGH_K, and PASSTHROUGH_LK.


Friends And Related Function Documentation

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

Add a debian_changes to the debian_changes.

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

Definition at line 217 of file csbuild-debian-changes.cc.

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

debian_changes initialisation from an istream.

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

Definition at line 478 of file csbuild-debian-changes.h.

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

debian_changes output to an ostream.

Parameters:
stream the stream to output to.
dc the debian_changes to output.
Returns:
the stream.

Definition at line 531 of file csbuild-debian-changes.h.


Member Data Documentation

item_map_type csbuild::debian_changes::items [private]

The top-level items.

Definition at line 582 of file csbuild-debian-changes.h.

Referenced by find_item(), get_keys(), get_list_value(), operator+=(), remove_key(), and set_value().


The documentation for this class was generated from the following files:
Generated on Mon Jan 21 00:38:55 2008 for schroot by  doxygen 1.5.4