#include <directives.h>
Inheritance diagram for conf::ConfValue< T >:
Public Types | |
typedef T | value_type |
The value type. | |
Public Member Functions | |
ConfValue (std::string const &name, bool reloadable, unsigned short min_params=1, unsigned short max_params=1) | |
Constructor setting directive name, reloadability and min./max. | |
ConfValue (std::string const &name, T const &defval, bool reloadable, unsigned short min_params=1, unsigned short max_params=1) | |
Constructor also setting the default value... | |
ConfValue (ConfValue const &cd) | |
Copy constructor. | |
virtual ConfValue< T > & | operator= (ConfValue< T > const &right) |
Assignment operator. | |
virtual bool | begin (Conf &conf) |
Begin parsing. | |
virtual bool | set (Conf &conf, unsigned short count, std::string const params[]) |
Sets the value. | |
virtual bool | end (Conf &conf) |
End parsing. | |
T const & | value () const |
Gets the value. | |
bool | has_value_changed () const |
Returns whether the value was changed by a configuration reload. | |
bool | has_default () const |
Returns whether a default value is available. | |
T const & | old_value () const |
Returns the old value. | |
virtual char const * | label (size_t index) const |
Implements ConfDir::label(). | |
virtual size_t | label_count () const |
Implements ConfDir::label_count(). | |
Protected Member Functions | |
virtual bool | assign (Conf &conf, unsigned short count, std::string const params[])=0 |
Sets the value. | |
virtual bool | check (Conf &conf, T const &value) |
Checks that a value is valid. | |
virtual bool | apply (Conf &conf) |
Does stuff based on the directive new value. | |
virtual bool | apply_change (Conf &conf) |
Lets the directive apply change. | |
Protected Attributes | |
T | m_value |
The value. | |
bool | m_value_set |
Has m_value been set? (Set to false again by end()). | |
bool | m_value_changed |
Is m_value different from m_oldvalue ? | |
T | m_defvalue |
The default value (don't use if m_has_default is false!). | |
bool | m_has_default |
Is m_default a valid default value? | |
T | m_oldvalue |
The old value (valid only on reload, set in begin()). | |
std::string | m_label |
The label of the value. |
Each of these directives have a value and an optional default value to which the value will be set if the set() function is not called before the end() function is (i.e. when the parser did not encounter the directive). If there is no default value, then setting the directive is REQUIRED and end() will yield false if it isn't the case.
On reload, the old value will saved so that you can do changes that would require you to know the old value easily.
|
Does arbitrary stuff based on the directive new value. This is guaranteed to be called by the end() function when the directive is successfully loaded or reloaded.
|
|
Like apply(), but will only be called after the directive has been reloaded, if and only if the new value is different than the old. This function is called before apply().
|
|
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).
Implemented in conf::ConfBool, conf::ConfDuration, conf::ConfEnum< T >, conf::ConfHostname, conf::ConfInt< T >, conf::ConfRatio, conf::ConfSet< T >, conf::ConfStr, conf::ConfArray< ValueT, ContainerT >, conf::ConfInt< uint16_t >, conf::ConfArray< ConfStrChar >, and conf::ConfArray< ConfModule, std::vector< ConfModule > >. |
|
Sets the old value.
Reimplemented from conf::ConfDir. |
|
Checks that the given value is valid.
|
|
Ensures a value has been set by the set() function. If so, calls apply_change() if the conf.reloading() is true and value changed; else sets it to the default value if available or sends an error message.
Reimplemented from conf::ConfDir. |
|
Returns the previous value the directive was set to. Beware that it is not meaningful unless begin() and end() were called and the configuration was reloaded.
|
|
Just calls assign to set the value... What a lazy function. ;) Reimplemented from conf::ConfDir. |
|
Gets the current value the directive is set to. Beware that it is not meaningful unless begin() and end() were called successfully.
|