#include <directives.h>
Public Member Functions | |
ConfDir (std::string const &name, bool reloadable, unsigned short min=0, unsigned short max=0) | |
Main constructor. | |
ConfDir (ConfDir const &cd) | |
Copy constructor. | |
virtual | ~ConfDir () |
Destructor. | |
virtual ConfDir & | operator= (ConfDir const &cd) |
Assignment operator. | |
virtual bool | begin (Conf &conf) |
Notifies the directive that parsing has begun. | |
virtual bool | set (Conf &conf, unsigned short count, std::string const params[]) |
Sets the directive. | |
virtual bool | end (Conf &conf) |
Notifies the directive that parsing is finished. | |
std::string const & | name () const |
Returns the name of the directive. | |
bool | reloadable () const |
Returns whether directive is reloadable. | |
bool | ready () const |
Returns whether begin() has been called, but not yet end(). | |
virtual char const * | label (size_t index) const |
Returns a label describing a value of the directive. | |
virtual size_t | label_count () const |
Returns the number of labels available. | |
virtual Conf const * | sub () const |
Returns the sub-directives. | |
Protected Attributes | |
std::string | m_name |
Directive name. | |
bool | m_reloadable |
Is directive reloadable? | |
bool | m_ready |
Has begin() been called, but not yet end() ? | |
unsigned short | m_minparams |
Minimum number of parameters required. | |
unsigned short | m_maxparams |
Maximum number of parameters. |
Each directive must have an unique name in the list it is added to.
This class is essentially an interface to allow the parser to set directives in a standard way. It does nothing and must not be used directly. Other generic classes are defined for specific directive types, and you may also create your own by inheriting this class or any derived class and overriding the begin(), set() and end() functions. The label(), label_count() and sub() functions may also be overriden.
conf::ConfDir::ConfDir | ( | std::string const & | name, | |
bool | reloadable, | |||
unsigned short | min = 0 , |
|||
unsigned short | max = 0 | |||
) | [inline, explicit] |
This constructor is used to construct a ConfDir object from scratch.
[in] | name | The name of the directive, that must be unique within a directives list (case-insensitive). |
[in] | reloadable | Whether the directives' begin(), set() and end() functions should have an effect when reloading configuration. |
[in] | min | The minimum number of parameters required. The set() function will yield false if there aren't enough parameters. |
[in] | max | The maximum number of parameters. The set() function will yield false if there are too many parameters. |
virtual bool conf::ConfDir::begin | ( | Conf & | conf | ) | [inline, virtual] |
Notifies the directive that parsing has begun. This is usually called from the Conf::begin() function of the object to which the directive has been added. It must take care to initialize the directive so that's it's ready to be set.
The default implementation just sets m_ready to true. Overriders will need to ensure that this variable is set to true ONLY if the begin() function is successful, and to not do any initialization if m_ready is already true, because begin() may be called multiple times.
Reimplemented in conf::ConfValue< T >, conf::ConfBlock, conf::ConfBoolBlock, conf::ConfRules, conf::ConfValue< std::vector< modules::ConfModule > >, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< in_addr >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< std::vector< conf::ConfStrChar > >, conf::ConfValue< uint16_t >, conf::ConfValue< bool >, and conf::ConfValue< misc::URI >.
virtual bool conf::ConfDir::set | ( | Conf & | conf, | |
unsigned short | count, | |||
std::string const | params[] | |||
) | [virtual] |
Passes an array of parameters to be used as the value of the directive. The directive may do whatever it wants with it (the most common thing being to set a value). This is generally called automatically from the Conf::parse() or Conf::parse_file() functions. The begin() function of the directive is guaranteed to have been called at this point of time.
[in] | conf | The Conf object making the call. |
[in] | count | Number of parameters in params. |
[in] | params | Parameters passed to the directive (NULL if count is 0). |
Reimplemented in conf::ConfValue< T >, conf::ConfBlock, conf::ConfBoolBlock, conf::ConfRules::ConfRule, conf::ConfWarning, conf::ConfError, conf::ConfElse, conf::ConfIf, conf::ConfInclude, conf::ConfPath, conf::ConfVarSet, conf::ConfUnset, conf::ConfValue< std::vector< modules::ConfModule > >, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< in_addr >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< std::vector< conf::ConfStrChar > >, conf::ConfValue< uint16_t >, conf::ConfValue< bool >, and conf::ConfValue< misc::URI >.
virtual bool conf::ConfDir::end | ( | Conf & | conf | ) | [inline, virtual] |
Notifies the directive that parsing is finished. This is usually called from the end() function of the Conf object to which the directive has been added. It must do any action necessary to finish the configuration of the directive (if that's needed, of course).
The default implementation just sets m_ready to false. Overriders will need to ensure that this variable is set to false ONLY if the end() function is successful, and to not do any finalization if m_ready is not true, because begin() may be called multiple times.
Reimplemented in conf::ConfValue< T >, conf::ConfBlock, conf::ConfValue< std::vector< modules::ConfModule > >, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< in_addr >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< std::vector< conf::ConfStrChar > >, conf::ConfValue< uint16_t >, conf::ConfValue< bool >, and conf::ConfValue< misc::URI >.
virtual char const* conf::ConfDir::label | ( | size_t | index | ) | const [inline, virtual] |
Returns a label describing a value of the directive. A label is a string that has been generated based on one of the directive's value.
The default implementation always returns 0. Derived classes may choose to override this function to provide an appropriate label, but that's not required.
[in] | index | The index of the value that needs to be retrieved, which must be between 0 and label_count() - 1. |
Reimplemented in conf::ConfValue< T >, conf::ConfBool, conf::ConfDuration, conf::ConfEnum< T >, conf::ConfHostname, conf::ConfInt< T >, conf::ConfRatio, conf::ConfSet< T >, conf::ConfStr, conf::ConfUint< T >, conf::ConfURI, conf::ConfArray< ValueT, ContainerT >, conf::ConfBoolBlock, conf::ConfValue< std::vector< modules::ConfModule > >, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< in_addr >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< std::vector< conf::ConfStrChar > >, conf::ConfValue< uint16_t >, conf::ConfValue< bool >, conf::ConfValue< misc::URI >, conf::ConfInt< uint16_t >, conf::ConfArray< modules::ConfModule, std::vector< modules::ConfModule > >, and conf::ConfArray< ConfStrChar >.
virtual size_t conf::ConfDir::label_count | ( | ) | const [inline, virtual] |
Returns the number of labels available for this directive.
The default implementation always returns zero. Derived classes must override this function if they override the label() function to provide labels.
Reimplemented in conf::ConfValue< T >, conf::ConfArray< ValueT, ContainerT >, conf::ConfBoolBlock, conf::ConfValue< std::vector< modules::ConfModule > >, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< in_addr >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< std::vector< conf::ConfStrChar > >, conf::ConfValue< uint16_t >, conf::ConfValue< bool >, conf::ConfValue< misc::URI >, conf::ConfArray< modules::ConfModule, std::vector< modules::ConfModule > >, and conf::ConfArray< ConfStrChar >.
virtual Conf const* conf::ConfDir::sub | ( | ) | const [inline, virtual] |
Returns the sub-directives as a configuration parser filled with the sub-directives of this directive.
The default implementation always returns zero. Derived classes may override this function if they have sub-directives, but that's not required.
Reimplemented in conf::ConfBlock.