|
| CParamNode (bool isOk=true) |
| Constructs a new, empty node. More...
|
|
const CParamNode & | GetChild (const char *name) const |
| Returns the (unique) child node with the given name, or a node with IsOk() == false if there is none. More...
|
|
const CParamNode & | GetOnlyChild () const |
| Returns the only child node, or a node with IsOk() == false if there is none. More...
|
|
bool | IsOk () const |
| Returns true if this is a valid CParamNode, false if it represents a non-existent node. More...
|
|
const std::wstring | ToWString () const |
| Returns the content of this node as a wstring. More...
|
|
const std::string & | ToString () const |
| Returns the content of this node as an UTF8 string. More...
|
|
const CStrIntern | ToUTF8Intern () const |
| Returns the content of this node as an internalized 8-bit string. More...
|
|
int | ToInt () const |
| Parses the content of this node as an integer. More...
|
|
fixed | ToFixed () const |
| Parses the content of this node as a fixed-point number. More...
|
|
float | ToFloat () const |
| Parses the content of this node as a floating-point number. More...
|
|
bool | ToBool () const |
| Parses the content of this node as a boolean ("true" == true, anything else == false) More...
|
|
std::string | ToXMLString () const |
| Returns the content of this node and its children as an XML string. More...
|
|
void | ToXMLString (std::ostream &strm) const |
| Write the content of this node and its children as an XML string, to the stream. More...
|
|
void | ToJSVal (const ScriptRequest &rq, bool cacheValue, JS::MutableHandleValue ret) const |
| Returns a JS::Value representation of this node and its children. More...
|
|
const ChildrenMap & | GetChildren () const |
| Returns the names/nodes of the children of this node, ordered by name. More...
|
|
An entity initialisation parameter node.
Each node has a text value, plus a number of named child nodes (in a tree structure). Child nodes are unordered, and there cannot be more than one with the same name. Nodes are immutable.
Nodes can be initialised from XML files. Child elements are mapped onto child nodes. Attributes are mapped onto child nodes with names prefixed by "@" (e.g. the XML <a b="c"><d/></a>
is loaded as a node with two child nodes, one called "@b" and one called "d").
They can also be initialised from multiple XML files, which is used by ICmpTemplateManager for entity template inheritance. Loading one XML file like:
<Example1>
<A attr="value">text</A>
</Example1>
<Example2>
<B/>
</Example2>
<Example3>
<C/>
</Example3>
<Example4 datatype="tokens">
one two three
</Example4>
<Example5>
<F>
<I>test</I>
</F>
<H>
<J>example</J>
</H>
</Example5>
then a second like:
<Example1>
<A>example</A> <!-- replace the content of the old A element -->
<D>new</D> <!-- add a new child to the old Example1 element -->
</Example1>
<Example2 disable=""/> <!-- delete the old Example2 element -->
<Example3 replace=""> <!-- replace all the old children of the Example3 element -->
<D>new</D>
</Example3>
<Example4 datatype="tokens"> <!-- treat as space-separated lists of tokens to merge -->
four <!-- add a token to the parent's set -->
-two <!-- remove a token from the parent's set -->
</Example4>
<Example5 filtered=""> <!-- drop all children of this node that are not in this file -->
<F merge=""> <!-- only add this element if it is also present in the parent -->
<K>example</K> <!-- if F is present merge its children normally -->
</F>
<G merge=""/> <!-- keep the G element of the parent if it exists -->
<H>
<J>text</J>
</H>
</Example5>
is equivalent to loading a single file like:
<Example1>
<A attr="value">example</A>
<D>new</D>
</Example1>
<Example3>
<D>new</D>
</Example3>
<Example4>
one three four
</Example4>
<Example5>
<F>
<I>test</I>
<K>example</K>
</F>
<H>
<J>text</J>
</H>
</Example5>
Parameter nodes can be translated to JavaScript objects. The previous example will become the object:
{ "Entity": {
"Example1": {
"A": { "@attr": "value", "_string": "example" },
"D": "new"
},
"Example3": {
"D": "new"
},
"Example4": { "@datatype": "tokens", "_string": "one three four" },
"Example5": {
"F": {
"I": "test",
"K": "example"
},
"H": {
"J": "text"
}
}
}
}
(Note the special _string
for the hopefully-rare cases where a node contains both child nodes and text.)