#include <directives.h>
Inheritance diagram for conf::ConfBoolBlock:
Public Member Functions | |
ConfBoolBlock (std::string const &name, bool reloadable=true) | |
Constructor setting directive name and reloadability. | |
ConfBoolBlock (ConfBoolBlock const &cd) | |
Copy constructor. | |
virtual ConfBoolBlock & | operator= (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 |
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 ;).