conf::ConfGlobal Class Reference

Global settings for configuration parser. More...

#include <global.h>

List of all members.

Public Types

typedef std::list< std::string > PathList
 Type of the path list.
typedef std::map< std::string,
std::string, misc::insensitive_less
VarList
 Type of defines list.

Public Member Functions

 ConfGlobal (Conf &conf)
 Constructor setting the global directives.
 ~ConfGlobal ()
 Destructor.
Confdirectives () const
 Returns the global directives.
ConfElseelse_directive () const
 Returns the ConfElse object.
PathList const & incl_paths () const
 Returns the current include paths.
bool incl_paths_add (std::string const &path, PathList::const_iterator *pi=0)
 Adds an include path.
bool incl_paths_remove (std::string const &path)
 Removes an include path.
bool var_get (std::string const &name, std::string *value=NULL) const
 Retrieves the value of a variable.
bool var_set (std::string const &name, std::string const &value)
 Sets a variable.
bool var_set (std::string const &assignment)
 Sets a variable from an assignment string.
bool var_unset (std::string const &name)
 Unsets a variable.

Friends

class Conf


Detailed Description

This class is used by the Conf class to retrieve special global directives, retrieve and set variables and look for include paths.

The include paths are used by Conf::parse_file() as potential paths to look into when opening a configuration file with a non-absolute (i.e. no leading /) name.

Variables are used by the configuration parser to do substitution in quoted strings (i.e. in "$(somename)", will be replaced by the value of the variable named somename).

Finally, global directives are used by the parser as an additional list of directives to look into when resolving a directive name. The local directives are checked before the global ones.


Constructor & Destructor Documentation

conf::ConfGlobal::ConfGlobal Conf conf  )  [inline, explicit]
 

This constructor will set the global directives list. Global directives are stored in a simple Conf object, so you can add and remove directives to it easily. The object is NOT copied, so it must exist until the ConfGlobal object is destructed.

You do not need to call Conf::begin() or Conf::end() on the Conf object, this is done automatically by the Conf::begin() and Conf::end() functions of the object that owns this ConfGlobal object.

When the ConfDir::set() function is called from the parser for a global directive, the directive's owning Conf object will be temporarily set to the calling Conf object, before being reset to its previous value. This in order to have a meaningful context... =) (Actually it makes it even more practical to write global directives -- they're just like standard ones.)

This constructor will add some default global directives to the list automatically.

Parameters:
conf The Conf object containing the global directives.


Member Function Documentation

Conf& conf::ConfGlobal::directives  )  const [inline]
 

Returns the global directives list. They are stored in a simple object of the Conf class, so you may add and remove directives to it easily.

Returns:
The global directives list.
See also:
ConfGlobal(Conf &)

ConfElse& conf::ConfGlobal::else_directive  )  const [inline]
 

Returns the ConfElse object that has been added to the global directives list as the "else" global directive. This is necessary for ConfIf (and derived) classes to call the ConfElse::can_process() function accordingly.

Returns:
The ConfElse object.

PathList const& conf::ConfGlobal::incl_paths  )  const [inline]
 

Returns a container of the current include paths. The include paths are used by Conf::parse_file() as potential paths to look into when opening a configuration file with a non-absolute (i.e. no leading /) name.

Returns:
The current include paths.

bool conf::ConfGlobal::incl_paths_add std::string const &  path,
PathList::const_iterator *  pi = 0
 

Adds an include path. Existence of the path is checked before being added to the list. If the specified path is not absolute, then it must be relative to either the process current working directory or to a path already in the list, and it is automatically converted to an absolute path.

Parameters:
[in] path The new include path.
[in] pi Optional pointer to the iterator that will receive a copy of the iterator to the newly-added path in the list (only when the function returns true).
Returns:
true if the path exists and was added, false otherwise.
See also:
incl_paths()

bool conf::ConfGlobal::incl_paths_remove std::string const &  path  ) 
 

Removes an include path.

Parameters:
[in] path The include path to be removed.
Returns:
true if the path was found and deleted, false otherwise.
See also:
incl_paths()

bool conf::ConfGlobal::var_get std::string const &  name,
std::string *  value = NULL
const
 

Retrieves the value of a given variable (if it exists).

Parameters:
[in] name The variable name.
[out] value A pointer to the string that will have been set to the variable value when function returns. If this parameter is NULL then the function just checks whether the variable exists or not.
Returns:
true if the variable exists, false otherwise.

bool conf::ConfGlobal::var_set std::string const &  assignment  ) 
 

Sets a variable to a given value, using the given assignment. If a variable with this name already exists its value is overriden.

Parameters:
[in] assignment A string in the form xxxx=yyyy where xxxx is the variable name and yyyy is the value.
Returns:
true if the variable has been set, false otherwise (because either the assignment or the name is invalid).

bool conf::ConfGlobal::var_set std::string const &  name,
std::string const &  value
 

Sets a variable to a given value. If a variable with this name already exists its value is overriden.

Parameters:
[in] name The variable name.
[in] value The new value of the variable.
Returns:
true if the variable has been set, false otherwise (because the name is invalid).

bool conf::ConfGlobal::var_unset std::string const &  name  ) 
 

Unsets the given variable, if it exists.

Parameters:
[in] name The variable name.
Returns:
true if the variable existed and has been unset, false otherwise.


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