Rudiments
|
Inherits object.
Public Member Functions | |
templateengine () | |
virtual | ~templateengine () |
void | setVariableStart (const char *delimiter) |
void | setVariableEnd (const char *delimiter) |
void | setQuotedVariableStart (const char *delimiter) |
void | setQuotedVariableEnd (const char *delimiter) |
void | setDoubleQuotedVariableStart (const char *delimiter) |
void | setDoubleQuotedVariableEnd (const char *delimiter) |
void | setEscapeCharacter (char esc) |
void | setBlockStartStart (const char *delimiter) |
void | setBlockStartEnd (const char *delimiter) |
void | setBlockEndStart (const char *delimiter) |
void | setBlockEndEnd (const char *delimiter) |
void | setIncludeStart (const char *delimiter) |
void | setIncludeEnd (const char *delimiter) |
const char * | getVariableStart () |
const char * | getVariableEnd () |
const char * | getQuotedVariableStart () |
const char * | getQuotedVariableEnd () |
const char * | getDoubleQuotedVariableStart () |
const char * | getDoubleQuotedVariableEnd () |
char | getEscapeCharacter () |
const char * | getBlockStartStart () |
const char * | getBlockStartEnd () |
const char * | getBlockEndStart () |
const char * | getBlockEndEnd () |
const char * | getIncludeStart () |
const char * | getIncludeEnd () |
bool | parse (output *out, const char *filename, fileparser *fileparsers, dictionary< const char *, const char * > *vars) |
bool | parse (output *out, const char *filename, blockparser *blockparsers, dictionary< const char *, const char * > *vars) |
bool | parse (output *out, const char *block, uint64_t blocklength, blockparser *blockparsers, dictionary< const char *, const char * > *vars) |
const char * | getError () |
Public Member Functions inherited from object | |
virtual | ~object () |
The templateengine class provides a framework for registering user-defined methods to parse and perform replacements in marked-up files or strings.
templateengine::templateengine | ( | ) |
Creates an instance of the templateengine class.
|
virtual |
Deletes this instance of the templateengine class.
const char* templateengine::getBlockEndEnd | ( | ) |
Returns the delimiter that the parse() methods look for at the end of a block-end.
The default is " -->".
For example, by defaults, blocks are delimited like:
... block ...
const char* templateengine::getBlockEndStart | ( | ) |
Returns the delimiter that the parse() methods look for at the beginning of a block-end.
The default is "<!-- end ".
For example, by defaults, blocks are delimited like:
... block ...
const char* templateengine::getBlockStartEnd | ( | ) |
Returns the delimiter that the parse() methods look for at the end of a block-start.
The default is " -->".
For example, by defaults, blocks are delimited like:
... block ...
const char* templateengine::getBlockStartStart | ( | ) |
Returns the delimiter that the parse() methods look for at beginning of a block-start.
The default is "<!-- start ".
For example, by defaults, blocks are delimited like:
... block ...
const char* templateengine::getDoubleQuotedVariableEnd | ( | ) |
Returns the delimiter that the parse() methods look for at the end of a variable whos value's double-quotes shall be escaped.
The default is ")".
For example, by defaults, variables are delimited like:
const char* templateengine::getDoubleQuotedVariableStart | ( | ) |
Returns the delimiter that the parse() methods look for at the beginning of a variable whos value's double-quotes shall be escaped.
The default is "$dq(".
For example, by defaults, variables are delimited like:
const char* templateengine::getError | ( | ) |
Returns the error that occurred if a parse() method returned false.
char templateengine::getEscapeCharacter | ( | ) |
Returns the escape character. Defaults to backslash.
const char* templateengine::getIncludeEnd | ( | ) |
Returns the delimiter that the parse() methods look for at the end of an include.
The default is " -->".
For example, by defaults, blocks are delimited like:
const char* templateengine::getIncludeStart | ( | ) |
Returns the delimiter that the parse() methods look for at the beginning of an include.
The default is "<!-- include ".
For example, by defaults, blocks are delimited like:
const char* templateengine::getQuotedVariableEnd | ( | ) |
Returns the delimiter that the parse() methods look for at the end of a variable whos value's single-quotes shall be escaped.
The default is ")".
For example, by defaults, variables are delimited like:
const char* templateengine::getQuotedVariableStart | ( | ) |
Returns the delimiter that the parse() methods look for at the beginning of a variable whos value's single-quotes shall be escaped.
The default is "$q(".
For example, by defaults, variables are delimited like:
const char* templateengine::getVariableEnd | ( | ) |
Returns the delimiter that the parse() methods look for at the end of a variable.
The default is ")".
For example, by defaults, variables are delimited like:
const char* templateengine::getVariableStart | ( | ) |
Returns the delimiter that the parse() methods look for at the beginning of a variable.
The default is "$(".
For example, by defaults, variables are delimited like:
bool templateengine::parse | ( | output * | out, |
const char * | block, | ||
uint64_t | blocklength, | ||
blockparser * | blockparsers, | ||
dictionary< const char *, const char * > * | vars | ||
) |
Parses "length" characters of "block" and writes the out to "out". For each variable encountered, values from "vars" are substituted. For each nested block encountered, the block is looked up in "blockparsers" and the appropriate block parser method is called. The block parser method is passed "req", "resp", the name, data and character length of the block, "out" and "data" from the blockparser entry.
If a block is encountered but no block parser method is registered for it, it is parsed using "vars".
Returns false if a block parser method returns false and true otherwise.
bool templateengine::parse | ( | output * | out, |
const char * | filename, | ||
blockparser * | blockparsers, | ||
dictionary< const char *, const char * > * | vars | ||
) |
Parses the file at "filename" and writes the out to "out". For each variable encountered, values from "vars" are substituted. For each block encountered, the block is looked up in "blockparsers" and the appropriate block parser method is called. The block parser method is passed "req", "resp", "out", the name, data and character length of the block and "data" from the blockparser entry.
If a block is encountered but no block parser method is registered for it, it is parsed using "vars".
Returns false if a block parser method returns false and true otherwise.
bool templateengine::parse | ( | output * | out, |
const char * | filename, | ||
fileparser * | fileparsers, | ||
dictionary< const char *, const char * > * | vars | ||
) |
Looks up "filename" in "fileparsers", and calls the appropriate file parser method.
For each variable encountered in "filename", values from "vars" are substitued.
Returns true on success and false if the file parser method returns false or if no fileparser was found.
void templateengine::setBlockEndEnd | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the end of a block-end to "delimiter".
Defaults to " -->".
For example, by defaults, blocks are delimited like:
... block ...
void templateengine::setBlockEndStart | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the beginning of a block-end to "delimiter".
Defaults to "<!-- end ".
For example, by defaults, blocks are delimited like:
... block ...
void templateengine::setBlockStartEnd | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the end of a block-start to "delimiter".
Defaults to " -->".
For example, by defaults, blocks are delimited like:
... block ...
void templateengine::setBlockStartStart | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at beginning of a block-start to "delimiter".
Defaults to "<!-- start ".
For example, by defaults, blocks are delimited like:
... block ...
void templateengine::setDoubleQuotedVariableEnd | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the end of a variable whos value's double-quotes shall be escaped to "delimiter".
Defaults to ")".
For example, by defaults, variables are delimited like:
void templateengine::setDoubleQuotedVariableStart | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the beginning of a variable whos value's double-quotes shall be escaped to "delimiter".
Defaults to "$dq(".
For example, by defaults, variables are delimited like:
void templateengine::setEscapeCharacter | ( | char | esc | ) |
Sets the escape character. Defaults to backslash.
void templateengine::setIncludeEnd | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the end of an include to "delimiter".
Defaults to " -->".
For example, by defaults, blocks are delimited like:
void templateengine::setIncludeStart | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the beginning of an include to "delimiter".
Defaults to "<!-- include ".
For example, by defaults, blocks are delimited like:
void templateengine::setQuotedVariableEnd | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the end of a variable whos value's single-quotes shall be escaped to "delimiter".
Defaults to ")".
For example, by defaults, variables are delimited like:
void templateengine::setQuotedVariableStart | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the beginning of a variable whos value's single-quotes shall be escaped to "delimiter".
Defaults to "$q(".
For example, by defaults, variables are delimited like:
void templateengine::setVariableEnd | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the end of a variable to "delimiter".
Defaults to ")".
For example, by defaults, variables are delimited like:
void templateengine::setVariableStart | ( | const char * | delimiter | ) |
Sets the delimiter that the parse() methods look for at the beginning of a variable to "delimiter".
Defaults to "$(".
For example, by defaults, variables are delimited like: