CatapultServer  v0.5.0.1 (Elephant)
catapult::utils::ConfigurationBag Class Reference

A simple bag of properties. More...

Public Types

template<typename TValue >
using OrderedKeyValueMap = std::vector< std::pair< std::string, TValue > >
 A strongly typed ordered key to value map. More...
 
template<typename TValue >
using UnorderedKeyValueMap = std::unordered_map< std::string, TValue >
 A strongly typed unordered key to value map. More...
 
using ValuesContainer = std::unordered_map< std::string, OrderedKeyValueMap< std::string > >
 Underlying container that a configuration bag is created around. More...
 

Public Member Functions

 ConfigurationBag (ValuesContainer &&values)
 Creates a new configuration bag around values. More...
 
size_t size () const
 Returns the number of properties in this bag. More...
 
size_t size (const char *section) const
 Returns the number of section properties in this bag. More...
 
bool contains (const ConfigurationKey &key) const
 Returns true if the property identified by key is contained in this bag. More...
 
std::unordered_set< std::string > sections () const
 Gets the names of all sections in this bag. More...
 
template<typename T >
bool tryGet (const ConfigurationKey &key, T &value) const
 
template<typename T >
get (const ConfigurationKey &key) const
 Gets the property identified by key from this bag. More...
 
template<typename T >
UnorderedKeyValueMap< T > getAll (const char *section) const
 Gets all section properties from this bag. More...
 
template<typename T >
OrderedKeyValueMap< T > getAllOrdered (const char *section) const
 Gets all section properties from this bag preserving source order. More...
 

Static Public Member Functions

static ConfigurationBag FromStream (std::istream &input)
 Loads a configuration bag from the specified stream (input). More...
 
static ConfigurationBag FromPath (const std::string &path)
 Loads a configuration bag from the specified path. More...
 

Private Member Functions

const std::string * lookup (const ConfigurationKey &key) const
 

Private Attributes

ValuesContainer m_values
 

Detailed Description

A simple bag of properties.

Member Typedef Documentation

◆ OrderedKeyValueMap

template<typename TValue >
using catapult::utils::ConfigurationBag::OrderedKeyValueMap = std::vector<std::pair<std::string, TValue> >

A strongly typed ordered key to value map.

◆ UnorderedKeyValueMap

template<typename TValue >
using catapult::utils::ConfigurationBag::UnorderedKeyValueMap = std::unordered_map<std::string, TValue>

A strongly typed unordered key to value map.

◆ ValuesContainer

using catapult::utils::ConfigurationBag::ValuesContainer = std::unordered_map<std::string, OrderedKeyValueMap<std::string> >

Underlying container that a configuration bag is created around.

Constructor & Destructor Documentation

◆ ConfigurationBag()

catapult::utils::ConfigurationBag::ConfigurationBag ( ValuesContainer &&  values)
inline

Creates a new configuration bag around values.

Here is the caller graph for this function:

Member Function Documentation

◆ contains()

bool catapult::utils::ConfigurationBag::contains ( const ConfigurationKey key) const
inline

Returns true if the property identified by key is contained in this bag.

Here is the call graph for this function:

◆ FromPath()

ConfigurationBag catapult::utils::ConfigurationBag::FromPath ( const std::string &  path)
static

Loads a configuration bag from the specified path.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FromStream()

ConfigurationBag catapult::utils::ConfigurationBag::FromStream ( std::istream &  input)
static

Loads a configuration bag from the specified stream (input).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

template<typename T >
T catapult::utils::ConfigurationBag::get ( const ConfigurationKey key) const
inline

Gets the property identified by key from this bag.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAll()

template<typename T >
UnorderedKeyValueMap<T> catapult::utils::ConfigurationBag::getAll ( const char *  section) const
inline

Gets all section properties from this bag.

Here is the caller graph for this function:

◆ getAllOrdered()

template<typename T >
OrderedKeyValueMap<T> catapult::utils::ConfigurationBag::getAllOrdered ( const char *  section) const
inline

Gets all section properties from this bag preserving source order.

Here is the caller graph for this function:

◆ lookup()

const std::string* catapult::utils::ConfigurationBag::lookup ( const ConfigurationKey key) const
inlineprivate
Here is the caller graph for this function:

◆ sections()

std::unordered_set<std::string> catapult::utils::ConfigurationBag::sections ( ) const
inline

Gets the names of all sections in this bag.

Here is the caller graph for this function:

◆ size() [1/2]

size_t catapult::utils::ConfigurationBag::size ( ) const
inline

Returns the number of properties in this bag.

Here is the caller graph for this function:

◆ size() [2/2]

size_t catapult::utils::ConfigurationBag::size ( const char *  section) const
inline

Returns the number of section properties in this bag.

◆ tryGet()

template<typename T >
bool catapult::utils::ConfigurationBag::tryGet ( const ConfigurationKey key,
T &  value 
) const
inline

Tries to get the property identified by key from this bag and puts it into value.

Note
this function will throw if the value is present but malformed.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_values

ValuesContainer catapult::utils::ConfigurationBag::m_values
private

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