conf::ConfBoolBlock Class Reference

Class implementing a boolean block directive type. More...

#include <directives.h>

Inheritance diagram for conf::ConfBoolBlock:

conf::ConfBlock conf::ConfDir List of all members.

Public Member Functions

 ConfBoolBlock (std::string const &name, bool reloadable=true)
 Constructor setting directive name and reloadability.
 ConfBoolBlock (ConfBoolBlock const &cd)
 Copy constructor.
virtual ConfBoolBlockoperator= (ConfBoolBlock const &right)
 Assignment operator.
 operator bool () const
 Conversion operator.
virtual bool begin (Conf &)
 Just sets m_set to false.
virtual bool set (Conf &conf, unsigned short count, std::string const params[])
 Calls ConfBlock::begin(), then ConfBlock::set() and sets m_set.
virtual char const * label (size_t index) const
 Implements ConfDir::label().
virtual size_t label_count () const
 Implements ConfDir::label_count().

Protected Attributes

bool m_set

Detailed Description

This class implements a boolean block directive type, derived from ConfBlock. In this class, m_conf will only be initialized from the set() function; this means that, if the directive is not encountered by the parser, the directives of the block will be totally ignored. They won't be set to their default value, or anything like that, because their begin() and end() functions will NEVER BE CALLED !

This is useful when implementing a directive that should be able to turn off a feature altogether when it is not set explicitely. If you were using a ConfBlock class, if there was a directive with no default value in the block, then the end() function would return false, even if the directive was not set explicitely, which is what this class will prevent.

Of course, if the directive is set, and you don't set a value for a required directive in the block, end() will still cause an error. To sum up, this class implements a block directive that is optional, but that must have values for all of its directives whenever it is set explicitely! I hope it is clear. :P

There is a conversion operator to bool that is useful to know whether the directive was set or not (hence the name of the class ;).


The documentation for this class was generated from the following file:
Generated on Sun May 20 21:32:18 2007 for Epona API by  doxygen 1.4.6