Registry¶
-
class
Registry_Exception
: public std::logic_error¶ - #include <registry.h>
The base exception class thrown by the registry.
It is derived from the STL logic_error exception.
Subclassed by Registry_Key_not_found_Exception
Public Functions
-
Registry_Exception
(const std::string &err_msg)¶ Construct exception with error message.
- Parameters
err_msg
: The error message.
-
-
class
Registry_Key_not_found_Exception
: public Registry_Exception¶ - #include <registry.h>
The exception when the desired key is not found.
Subclassed by Registry_Block_Data_not_found_Exception, Registry_Block_not_found_Exception, Registry_cfgfile_not_found_Exception
Public Functions
-
Registry_Key_not_found_Exception
(const std::string &err_msg)¶ The Exception when a requested key is not found.
- Parameters
err_msg
: The error message of which key is not found.
-
-
class
Registry_Block_Data_not_found_Exception
: public Registry_Key_not_found_Exception¶ - #include <registry.h>
The exception when the requested data in a block is not present.
Public Functions
-
Registry_Block_Data_not_found_Exception
(const std::string &key_value)¶ Construct an exception when the data was not found.
- Parameters
key_value
: which key was not found.
-
~Registry_Block_Data_not_found_Exception
()¶
Public Members
-
const std::string
block_key
¶ to denote the block where no data was found
-
-
class
Registry_Block_not_found_Exception
: public Registry_Key_not_found_Exception¶ - #include <registry.h>
The exception when the requested block is not present.
Public Functions
-
Registry_Block_not_found_Exception
(const std::string &key_value)¶ Construct an exception where a block was not found.
- Parameters
key_value
: the block which has not been found.
-
~Registry_Block_not_found_Exception
()¶
Public Members
-
const std::string
block
¶ which block has not been found.
-
-
class
Registry_cfgfile_not_found_Exception
: public Registry_Key_not_found_Exception¶ - #include <registry.h>
The exception when the requested config file could not be found.
Public Functions
-
Registry_cfgfile_not_found_Exception
(const std::string &key_value)¶ Construct the respective exception when a file was not found.
- Parameters
key_value
: Which config file could not be found.
-
~Registry_cfgfile_not_found_Exception
()¶
Public Members
-
const std::string
cfgfile
¶ which config file was not found.
-
-
class
Block
¶ - #include <registry.h>
This class contains the contents of a [BLOCK] structure in a config file.
In Config Files those [BLOCK] thingies.
Public Functions
-
Block
()¶ Create an empty block.
-
Block
(std::string blockname, const std::vector<std::string> &block)¶ Create a block from a vector of strings.
- Parameters
blockname
: The name of the block.block
: a vector of strings.
-
unsigned int
size
(void) const¶ Get the number of keys that we store.
- Return
the number of keys that we store.
-
const std::vector<std::string>
GetKeys
() const¶ Get the list of keys that we store.
- Return
The list of keys that we store.
-
std::string &
operator[]
(const std::string &key)¶ Get access to the contents of a block.
This distinguishes itself from find() by doing no checks.
- Return
the value of the key.
- Parameters
key
: the key for which to look.
-
std::string &
find
(const std::string &key)¶ Get access to the contents of a block.
non-const version. In contrast to operator[] this perform checking.
- Return
the value of the key.
- Parameters
key
: the key for which to look.
- Exceptions
Registry_Block_Data_not_found_Exception
: If the key was not found
-
const std::string &
find
(const std::string &key) const¶ Get access to the contents of a block.
constified version. In contrast to operator[] this perform checking.
- Return
the value of the key.
- Parameters
key
: the key for which to look.
- Exceptions
Registry_Block_Data_not_found_Exception
: If the key was not found
-
~Block
()¶ Clean up a block.
Private Functions
-
void
push_back_Key
(std::string arg)¶ Add a key-value pair.
- Parameters
arg
: Add this key-value pair.
Private Members
-
std::map<std::string, std::string>
Block_Data
¶ A map between the keys and their values.
-
std::string
BlockName
¶ The name of the block.
-
std::vector<std::string>
Keys
¶ all keys that have been found.
-
std::map<std::string, std::string>::size_type
NrOfKeys
¶ the number of key-value pairs that we have.
-
-
class
cfile
¶ - #include <registry.h>
This class contains the contents of a single config file.
Public Functions
-
cfile
()¶ Default constructor.
-
Block &
operator[]
(std::string a)¶ Get access to the contents of a file.
This distinguishes itself from find() by doing no checks.
- Return
A block that can be queried further.
- Parameters
a
: the block for which to look.
-
Block &
find
(const std::string &key)¶ Get access to the contents of a file.
non-const version. In contrast to operator[] this perform checking.
- Return
the blocks of the file.
- Parameters
key
: the file for which to look.
-
const Block &
find
(const std::string &key) const¶ Get access to the contents of a file.
const version. In contrast to operator[] this perform checking.
- Return
the blocks of the file.
- Parameters
key
: the file for which to look.
-
cfile
(std::string &file)¶ Constructor that initializes this with the contents of a config-file.
- Parameters
file
: The file that we should parse.
-
-
class
RegistryDB
¶ - #include <registry.h>
This holds together all the contents of the configuration directory and provides access via the Get() template.
Public Functions
-
int
init
(const std::string &cfgDir, const std::string pat = "")¶ Initialize registry.
This initializes the registry via a separate function call.
- Parameters
cfgDir
: the directory that contains all the files the registry should containpat
: a suffix to select only certain files, e.g. : .ini
-
RegistryDB
(const std::string &arg, const std::string pat = "")¶ construct the registry.
This is the constructor for the registry.
- Parameters
arg
: the directory that contains all the files the registry should containpat
: a suffix to select only certain files, e.g. : .ini
-
RegistryDB
()¶ Empty default constructor.
-
~RegistryDB
()¶ Tidy up everything.
-
Block
GetBlock
(std::string file, std::string bloc)¶ Get a particular block in a file of the Registry.
- Return
the requested block.
- Parameters
file
: the file in which to look.bloc
: the bloc we require.
-
template<typename
T
>
TGet
(const std::string &file, const std::string &block, const std::string &key) const¶ Function to get a value from the registry.
The template parameter determines to which type to convert the key.
- Return
the requested key
- Template Parameters
T
: to which type do we convert.
- Parameters
file
: the file in which to lookblock
: under which block is the valuekey
: for which key to look
-
int
-
template<typename
A
>
structGetTrait
¶ - #include <registry.h>
The helper template for performing string -> type conversions.
The basic template for doing the conversion between strings and the requested type. We use the C++ stringstreams thus we benefit from all overloads that are already provided by C++.
- Template Parameters
A
: to which type do we want to convert.
-
template<>
structGetTrait
<bool>¶ - #include <registry.h>
The helper template for performing string -> bool conversion.
Specialization for boolean(true, false) like strings
Public Static Functions
-
bool
Convert
(std::string arg)¶ Helper function to convert from a string to a boolean value.
Every occurence of uppercase/lowercase mixing of TRUE is interpreted as true, everything else is false.
- Return
boolean true, if the string was [Tt][Rr][Uu][Ee]
-
bool
-
template<typename
A
>
structSetTrait
¶ - #include <registry.h>
A helper template to set values in the registry.
- Template Parameters
A
: the type of the value.
-
template<typename
T
>
structGetTrait
<std::vector<T>>¶ - #include <registry.h>
A helper trait for reading vectors of values with a predefined separator.
The predefined separator is currently hard-coded to “;” or “,”.
- Template Parameters
T
: the type of the elements in the vector.
-
template<>
structGetTrait
<std::vector<std::string>>¶ - #include <registry.h>
A helper trait for reading vectors of strings with a predefined separator.
The predefined separator is currently hard-coded to “;” or “,”.
- Template Parameters
T
: the type of the elements in the vector.
Public Static Functions
-
std::vector<std::string>
Convert
(std::string arg)¶ Implementation function for the conversion.
- Return
the strings stored in a C++ std::vector .
- Parameters
arg
: the string that we intend to break up.