#include <gracetmpl.h>
Public Member Functions | |
| Environment (Environment *parent=0) | |
| Default constructor. | |
| void | clear () |
| Clears all variables - not the contexts. | |
| void | setParent (Environment *parent) |
| Set the parent Environment. | |
| void | setName (const std::string &name) |
| Set the context name. | |
| void | set (const std::string &name, const std::string &value) |
| Set an environment variable. | |
| void | add (const std::string &name, Environment *value) |
| set a named context - ensures consistency | |
| Environment * | use () |
| do we really need this? | |
| int | unuse () |
| do we really need this? | |
| std::string | expand (const std::string &, int nests=20) |
| Expands a string containing variables. | |
| std::string | substitute (const std::string &context, const std::string &variable, const std::string &fallback) |
| Substitutes a variable honouring its context. | |
A (named) Environment holds a number of variablename/value pairs. The environment's name can be seen as a context. As such, it can be contained in other Environment objects as a contextname/Environment pair.
|
||||||||||||
|
Expands a string containing variables. Searches for syntactically correct variables in the provided string and substitutes them using substitute(context,variable,fallback). Valid variable syntax is either:
Nested variables are allowed: |
|
||||||||||||||||
|
Substitutes a variable honouring its context. This method also uses parent->substitute(context,variable,fallback) or context_[context]->substitute(context2,variable,fallback) for expansion, if this should be necessary. |
1.3.2