#include <parser.h>
Public Types | |
typedef std::map< std::string, ConfDir *, misc::insensitive_less > | DirList |
Directive list type. | |
Public Member Functions | |
Conf (ConfLogger &logger) | |
Constructor. | |
Conf (Conf const &conf) | |
Copy constructor. | |
~Conf () | |
Destructor. | |
Conf & | operator= (Conf const &right) |
Assignment operator. | |
bool | add (ConfDir &dir) |
Adds a directive to the list of valid directives. | |
bool | remove (ConfDir &dir) |
Removes a directive from the list of valid directives. | |
ConfDir * | find (std::string const &name) |
Finds a directive in the list of valid directives. | |
bool | begin (ConfGlobal &global, bool reload) |
Initializes the parser. | |
bool | parse_file (std::string const &filename) |
Parses a configuration file. | |
bool | parse_string (std::string const &str, std::string const &context) |
Parses a string. | |
bool | parse (std::istream &is, std::string const &context) |
Parses a stream. | |
bool | end () |
Finalizes the parser. | |
void | warning (std::string const &msg) const |
Logs a warning message. | |
void | warningf (char const *format,...) const FORMAT(printf |
Like warning() but with a printf-like syntax. | |
void void | error (std::string const &err) const |
Logs an error message. | |
void | errorf (char const *format,...) const FORMAT(printf |
Like error() but with a printf-like syntax. | |
void DirList const & | directives () const |
Returns the directives list. | |
ConfGlobal & | global () const |
Returns the ConfGlobal object associated with the parser. | |
ConfLogger & | logger () const |
Returns the ConfLogger object associated with the parser. | |
std::string const & | context () const |
Returns the current context. | |
char const * | c_context () const |
Same as context() but returns a char const *. | |
unsigned int | line () const |
Returns the current line number. | |
bool | ready () const |
Returns whether begin(), but not end(), has been called yet. | |
bool | reloading () const |
Returns whether the configuration is being reloaded. |
|
Constructs the parser.
|
|
Adds a directive to the list of valid directives. This directive will then be set when encountered by the configuration parser. This function assumes that no directive with the same name is already in the list.
|
|
Initializes the parser and calls the begin() member functions for all directives in the list. This function MUST be called before using the parse() and parse_file() member functions (you may call those as many times as you want without having to call begin() again). Don't forget to call end() when ALL parsing is finished.
|
|
Returns the current context, i.e. a string that helps identify the current parsing location (for example, a directive name or a file).
|
|
Finalizes the parser (does any cleanup task) and calls the end() member functions of all directives in the list and all directives of the ConfGlobal object associated to this object. This function MUST be called after all parsing has been done through the parse() and parse_file() functions.
|
|
Logs an error message using logger().error(), with current context and line number.
|
|
Finds a directive in the list of valid directives.
|
|
Returns the ConfGlobal object associated with the parser. This object is used by the parser when it needs to look for defines, global directives and config files search path.
|
|
Returns the current line number, relative to the current context.
|
|
Returns the ConfLogger object associated with the parser. This object is used by the debug() and error() member functions to log messages. |
|
Parses the given stream.
|
|
Parses the given configuration file. The parser context will be set to the name of the file.
|
|
Parses the given string.
|
|
Removes a directive from the list of valid directives.
|
|
Logs a warning message using logger().warning(), with current context and line number.
|