#include <directives.h>
Public Types | |
typedef std::map < std::string, T, misc::insensitive_less > | BitList |
Public Member Functions | |
ConfSet (std::string const &name, bool reloadable) | |
Constructor setting the directive name. | |
ConfSet (std::string const &name, T const &defval, bool reloadable) | |
Constructor setting the directive name and default value. | |
ConfSet (ConfSet const &cd) | |
Copy constructor. | |
virtual ConfSet< T > & | operator= (ConfSet< T > const &right) |
Assignment operator. | |
operator T const & () const | |
Conversion operator. | |
virtual char const * | label (size_t index) const |
Implements ConfDir::label(). | |
Protected Member Functions | |
virtual bool | add (Conf &conf)=0 |
Adds valid bits to the list. | |
virtual bool | assign (Conf &conf, unsigned short count, std::string const params[]) |
Sets the value. | |
Protected Attributes | |
BitList | m_bits |
The list of bits. |
For example, for a bit named "SOMETHING", if a parameter "+SOMETHING" is set to a directive of this type, then the SOMETHING bit will be set to the value, and if a parameter "-SOMETHING" is set to a directive of this type, then the SOMETHING bit will be cleared. Of course, directives of this type may be set multiple times to set or clear bits.
This class must not be used directly. Instead, it must be inherited, and the add() function should be overriden to add all possible bits to m_bits.
The template parameter is the type in which bits will be stored. A conversion operator to this type is provided for easy access to the value.
virtual bool conf::ConfSet< T >::add | ( | Conf & | conf | ) | [protected, pure virtual] |
This function adds valid bits to the m_bits list. It must be defined in an inherited class. Example of adding a bit to the list. m_bits["SOMETHING"] = 0x00080000;
bool conf::ConfSet< T >::assign | ( | Conf & | conf, | |
unsigned short | count, | |||
std::string const | params[] | |||
) | [inline, protected, virtual] |
Transforms the string array passed by the parser into the directive's value. This function must ensure that the value is valid through a call to check() before setting it (you don't need to set m_value_set to true, this will be handled by set() when the function returns successfully).
[in] | conf | The Conf object that called set(). |
[in] | count | Number of parameters in params. |
[in] | params | Parameters passed to the directive (NULL if count is 0). |
Implements conf::ConfValue< T >.