conf::ConfDir Class Reference

Configuration directive base class. More...

#include <directives.h>

Inheritance diagram for conf::ConfDir:

conf::ConfBlock conf::ConfElse conf::ConfIf conf::ConfInclude conf::ConfPath conf::ConfRules::ConfRule conf::ConfUnset conf::ConfValue< T > conf::ConfValue< bool > conf::ConfValue< ContainerT > conf::ConfValue< misc::Ratio > conf::ConfValue< std::string > conf::ConfValue< std::vector< ConfModule > > conf::ConfValue< std::vector< ConfStrChar > > conf::ConfValue< struct in_addr > conf::ConfValue< time_t > conf::ConfValue< uint16_t > conf::ConfVarSet conf::ConfWarning List of all members.

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 ConfDiroperator= (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.

Detailed Description

ConfDir is the configuration directive base class; all directive types ultimately inherit from it.

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.


Constructor & Destructor Documentation

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.

Parameters:
[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.


Member Function Documentation

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.

Parameters:
[in] conf The Conf object making the call.
Returns:
true if the function is successful, false otherwise (conf.error() should have be called with an appropriate error message in that case).
See also:
Conf::begin(), Conf::error()

Reimplemented in conf::ConfValue< T >, conf::ConfBlock, conf::ConfBoolBlock, conf::ConfRules, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< struct in_addr >, conf::ConfValue< std::vector< ConfModule > >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< uint16_t >, conf::ConfValue< std::vector< ConfStrChar > >, and conf::ConfValue< bool >.

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.

Parameters:
[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).
Returns:
true if the function is successful, false otherwise (conf.error() should have be called with an appropriate error message in that case).
See also:
Conf::parse(), Conf::parse_file(), begin(), Conf::error()

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< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< struct in_addr >, conf::ConfValue< std::vector< ConfModule > >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< uint16_t >, conf::ConfValue< std::vector< ConfStrChar > >, and conf::ConfValue< bool >.

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.

Parameters:
[in] conf The Conf object making the call.
Returns:
true if the function is successful, false otherwise (conf.error() should have be called with an appropriate error message in that case).
See also:
Conf::end(), Conf::error()

Reimplemented in conf::ConfValue< T >, conf::ConfBlock, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< struct in_addr >, conf::ConfValue< std::vector< ConfModule > >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< uint16_t >, conf::ConfValue< std::vector< ConfStrChar > >, and conf::ConfValue< bool >.

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.

Parameters:
[in] index The index of the value that needs to be retrieved, which must be between 0 and label_count() - 1.
Returns:
A pointer to a label, or 0 if there is no label for this value.
See also:
label_count()

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::ConfArray< ValueT, ContainerT >, conf::ConfBoolBlock, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< struct in_addr >, conf::ConfValue< std::vector< ConfModule > >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< uint16_t >, conf::ConfValue< std::vector< ConfStrChar > >, conf::ConfValue< bool >, conf::ConfInt< uint16_t >, conf::ConfArray< ConfStrChar >, and conf::ConfArray< ConfModule, std::vector< ConfModule > >.

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.

Returns:
The number of labels available.

Reimplemented in conf::ConfValue< T >, conf::ConfArray< ValueT, ContainerT >, conf::ConfBoolBlock, conf::ConfValue< misc::Ratio >, conf::ConfValue< std::string >, conf::ConfValue< struct in_addr >, conf::ConfValue< std::vector< ConfModule > >, conf::ConfValue< time_t >, conf::ConfValue< ContainerT >, conf::ConfValue< uint16_t >, conf::ConfValue< std::vector< ConfStrChar > >, conf::ConfValue< bool >, conf::ConfArray< ConfStrChar >, and conf::ConfArray< ConfModule, std::vector< ConfModule > >.

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.

Returns:
A pointer to the configuration parser with a list of configuration directives added.

Reimplemented in conf::ConfBlock.


The documentation for this class was generated from the following file:
Generated on Wed Aug 15 00:37:22 2007 for Epona API by  doxygen 1.5.2