Util--  1.1
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
utilmm::config_set Class Reference

#include <utilmm/configfile/configset.hh>

Inheritance diagram for utilmm::config_set:
Inheritance graph
[legend]
Collaboration diagram for utilmm::config_set:
Collaboration graph
[legend]

Public Types

typedef std::list< const config_set * > subsets
 

Public Member Functions

 config_set (config_set *parent=0)
 
 ~config_set ()
 
bool empty () const
 
bool exists (const std::string &attribute) const
 
const config_setparent () const
 
config_setparent ()
 
std::list< const config_set * > children (const std::string &name) const
 
config_set const & child (std::string const &name) const
 
template<typename T >
get (std::string const &name, T const &defval=T(), typename boost::enable_if< details::is_list< T > >::type *enabler=0) const
 
template<typename T >
get (std::string const &name, T const &defval=T(), typename boost::disable_if< details::is_list< T > >::type *enabler=0) const
 
void set (std::string const &name, std::string const &value)
 
void set (std::string const &name, std::list< std::string > const &value)
 
void insert (std::string const &name, std::string const &value)
 
void insert (std::string const &name, std::list< std::string > const &value)
 
void insert (std::string const &name, config_set const *value)
 
void erase (std::string const &name)
 
template<>
bool convert (std::string const &value)
 
template<>
config_set::stringlist get (std::string const &name, config_set::stringlist const &defval, boost::enable_if< details::is_list< config_set::stringlist > >::type *enabler) const
 

Protected Types

typedef std::multimap< std::string, std::string > ValueMap
 
typedef std::multimap< std::string, const config_set * > ChildMap
 

Protected Member Functions

void clear ()
 

Protected Attributes

config_setm_parent
 
ValueMap m_values
 
ChildMap m_children
 

Friends

class ConfigFile
 

Detailed Description

A scope in configuration files

Member Typedef Documentation

◆ ChildMap

typedef std::multimap<std::string, const config_set*> utilmm::config_set::ChildMap
protected

◆ subsets

typedef std::list<const config_set*> utilmm::config_set::subsets

◆ ValueMap

typedef std::multimap<std::string, std::string> utilmm::config_set::ValueMap
protected

Constructor & Destructor Documentation

◆ config_set()

utilmm::config_set::config_set ( config_set parent = 0)
explicit

◆ ~config_set()

utilmm::config_set::~config_set ( )

Member Function Documentation

◆ child()

config_set const& utilmm::config_set::child ( std::string const &  name) const

Get the first child named name or an empty set

◆ children()

std::list<const config_set*> utilmm::config_set::children ( const std::string &  name) const

Get the list of children named name

◆ clear()

void utilmm::config_set::clear ( )
protected

Clears this set

◆ convert()

template<>
bool utilmm::config_set::convert ( std::string const &  value)

◆ empty()

bool utilmm::config_set::empty ( ) const

Checks if this set is empty (no child, no attributes)

◆ erase()

void utilmm::config_set::erase ( std::string const &  name)

Remove the given option

◆ exists()

bool utilmm::config_set::exists ( const std::string &  attribute) const

Tests for the existence of an attribute

◆ get() [1/3]

template<typename T >
T utilmm::config_set::get ( std::string const &  name,
T const &  defval = T(),
typename boost::enable_if< details::is_list< T > >::type *  enabler = 0 
) const

In a config_set object, all values are stored as lists of strings. This method converts the stored value into the required type using the associated config_set::convert template specialization (if it exists).

If no value is stored under the given key, returns defval

◆ get() [2/3]

template<typename T >
T utilmm::config_set::get ( std::string const &  name,
T const &  defval = T(),
typename boost::disable_if< details::is_list< T > >::type *  enabler = 0 
) const

In a config_set object, all values are stored as lists of strings. This method is a convenience method when only one value is stored for a given key. It converts the stored value into the required type using the associated config_set::convert template specialization (if it exists).

If no value is associated with the key, returns defval

◆ get() [3/3]

template<>
config_set::stringlist utilmm::config_set::get ( std::string const &  name,
config_set::stringlist const &  defval,
boost::enable_if< details::is_list< config_set::stringlist > >::type *  enabler 
) const

◆ insert() [1/3]

void utilmm::config_set::insert ( std::string const &  name,
std::string const &  value 
)

Appends the given value to the values already associated with name

◆ insert() [2/3]

void utilmm::config_set::insert ( std::string const &  name,
std::list< std::string > const &  value 
)

Appends the given values to the valus already associated with name

◆ insert() [3/3]

void utilmm::config_set::insert ( std::string const &  name,
config_set const *  value 
)

Add a child to this config_set

◆ parent() [1/2]

const config_set* utilmm::config_set::parent ( ) const

The parent config_set object

Returns
the config_set object for our parent scope, or 0 if this scope is top-level

◆ parent() [2/2]

config_set* utilmm::config_set::parent ( )

◆ set() [1/2]

void utilmm::config_set::set ( std::string const &  name,
std::string const &  value 
)

Replaces any value associated with name with the value provided. See insert to append new values to already existing ones

◆ set() [2/2]

void utilmm::config_set::set ( std::string const &  name,
std::list< std::string > const &  value 
)

Sets multiple values for this key. If some value was already associated with name, the new value replaces it. See insert to append new values to already existing ones.

Friends And Related Function Documentation

◆ ConfigFile

friend class ConfigFile
friend

Member Data Documentation

◆ m_children

ChildMap utilmm::config_set::m_children
protected

◆ m_parent

config_set* utilmm::config_set::m_parent
protected

◆ m_values

ValueMap utilmm::config_set::m_values
protected

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

Generated on Mon Sep 24 2018 17:06:40 for Util-- by doxygen 1.8.13
SourceForge.net Project Page