![]() |
TSDuck v3.46-4930
MPEG Transport Stream Toolkit
|
#include <tsxmlNode.h>


Public Member Functions | |
| virtual | ~Node () override |
| size_t | childrenCount () const |
| virtual void | clear () |
| virtual Node * | clone () const =0 |
| UString | debug () const |
| size_t | depth () const |
| Document * | document () |
| const Document * | document () const |
| virtual void | expandEnvironment (bool recurse) |
| Node * | firstChild () |
| const Node * | firstChild () const |
| Element * | firstChildElement () |
| const Element * | firstChildElement () const |
| bool | hasChildren () const |
| bool | ignoreNamespace () const |
| Node * | lastChild () |
| const Node * | lastChild () const |
| size_t | lineNumber () const |
| void | move (Node *new_sibling, bool before) |
| void | moveAfter (Node *new_sibling) |
| void | moveBefore (Node *new_sibling) |
| Node * | nextSibling () |
| const Node * | nextSibling () const |
| Element * | nextSiblingElement () |
| const Element * | nextSiblingElement () const |
| virtual UString | oneLiner () const |
| Node * | parent () |
| const Node * | parent () const |
| bool | preserveSpace () const |
| Node * | previousSibling () |
| const Node * | previousSibling () const |
| Element * | previousSiblingElement () |
| const Element * | previousSiblingElement () const |
| virtual void | print (TextFormatter &output, bool keep_node_open=false) const =0 |
| virtual void | printClose (TextFormatter &output, size_t levels=UNLIMITED) const |
| void | removeComments (bool recurse) |
| void | reparent (Node *new_parent, bool last=true) |
| Report & | report () const |
| bool | ringAlone () const |
| void | ringInsertAfter (RingNode *o) |
| void | ringInsertBefore (RingNode *o) |
| template<typename T> | |
| T * | ringNext () |
| template<typename T> | |
| const T * | ringNext () const |
| template<typename T> | |
| T * | ringPrevious () |
| template<typename T> | |
| const T * | ringPrevious () const |
| void | ringRemove () |
| size_t | ringSize () const |
| void | ringSwap (RingNode *o) |
| virtual void | setIignoreNamespace (bool ignore) |
| void | setValue (const UString &value) |
| virtual bool | stickyOutput () const |
| virtual const Tweaks & | tweaks () const |
| virtual UString | typeName () const =0 |
| const UString & | value () const |
Protected Member Functions | |
| Node (const Node &other) | |
| Node (Node *parent, const UString &value=UString(), bool last=true) | |
| Node (Report &report, size_t line=0) | |
| Node * | identifyNextNode (TextParser &parser) |
| virtual bool | parseChildren (TextParser &parser, size_t max_nested) |
| virtual bool | parseNode (TextParser &parser, const Node *parent, size_t max_nested)=0 |
| void | setPreserveSpace (bool on) |
Base class for all XML objects in a document.
Implementation note on inheritance: Node is a subclass of RingNode. The "ring" is used to link all siblings. This inheritance should be private since it is an internal characteristics of Node. However, if we make this inheritance private, the dynamic_cast operations in RingNode fail. This is a very annoying C++ feature.
|
overridevirtual |
Virtual destructor.
|
explicitprotected |
Constructor.
| [in,out] | report | Where to report errors. |
| [in] | line | Line number in input document. |
|
protected |
Copy constructor.
| [in] | other | Other instance to copy. |
|
explicitprotected |
Constructor.
| [in,out] | parent | The parent document into which the declaration is added. |
| [in] | value | Value of the node. |
| [in] | last | If true, the child is added at the end of the list of children. If false, it is added at the beginning. |
|
inline |
Get the line number in input document.
|
virtual |
Clear the content of the node. The node becomes empty but remains attached to its parent.
Reimplemented in ts::xml::Element.
|
pure virtual |
Clone the content of the node in a dynamically allocated object. This virtual method must be implemented by subclasses to allocate a object of the right class.
Implemented in ts::xml::Comment, ts::xml::Declaration, ts::xml::Document, ts::xml::Element, ts::xml::ModelDocument, ts::xml::PatchDocument, ts::xml::Text, and ts::xml::Unknown.
| void ts::xml::Node::reparent | ( | Node * | new_parent, |
| bool | last = true ) |
Attach the node to a new parent. The node is first detached from its previous parent.
| [in,out] | new_parent | New parent. If zero, the node becomes orphan. In that case, the node will no longer be freed by its parent and must be explicitly deleted. |
| [in] | last | If true, the child is added at the end of the list of children. If false, it is added at the beginning. |
|
inline |
Move the node before another node, potentially to a new parent.
| [in,out] | new_sibling | A new sibling. The node will be moved before this one. |
|
inline |
Move the node after another node, potentially to a new parent.
| [in,out] | new_sibling | A new sibling. The node will be moved after this one. |
| void ts::xml::Node::move | ( | Node * | new_sibling, |
| bool | before ) |
Move the node before or after another node, potentially to a new parent.
| [in,out] | new_sibling | A new sibling. The node will be moved before or after this one. |
| [in] | before | If true, move the node before new_sibling, after it otherwise. |
|
inline |
Get the parent's node.
|
inline |
Get the parent's node.
|
inline |
Get the document into which the node is located.
| Document * ts::xml::Node::document | ( | ) |
Get the document into which the node is located.
|
virtual |
Get a constant reference to the current XML parsing and formatting tweaks for this node.
Reimplemented in ts::xml::Document.
| size_t ts::xml::Node::depth | ( | ) | const |
Get the depth of an XML element.
| bool ts::xml::Node::preserveSpace | ( | ) | const |
Check if the node or one of its ancestors has attribute xml:space="preserve".
|
inline |
Check if namespace is ignored by default when comparing element and attribute names in this node's hierarchy.
|
virtual |
Specify if namespace is ignored by default when comparing element and attribute names in this node's hierarchy.
| [in] | ignore | It true, namespace is ignored by default. |
Reimplemented in ts::xml::Element.
|
inline |
Check if the node has children.
|
inline |
Get the number of children.
|
inline |
Get the first child of a node.
|
inline |
Get the first child of a node.
|
inline |
Get the last child.
|
inline |
Get the last child.
|
inline |
Get the next sibling node.
| Node * ts::xml::Node::nextSibling | ( | ) |
Get the next sibling node.
|
inline |
Get the previous sibling node.
| Node * ts::xml::Node::previousSibling | ( | ) |
Get the previous sibling node.
|
inline |
| Element * ts::xml::Node::firstChildElement | ( | ) |
|
inline |
Find the next sibling element.
| Element * ts::xml::Node::nextSiblingElement | ( | ) |
Find the next sibling element.
|
inline |
Find the previous sibling element.
| Element * ts::xml::Node::previousSiblingElement | ( | ) |
Find the previous sibling element.
|
inline |
Get the value of the node.
The semantic of the value depends on the node subclass:
|
inline |
| void ts::xml::Node::removeComments | ( | bool | recurse | ) |
Remove all comments in the XML node.
| [in] | recurse | If true, apply recursively to all children nodes. |
|
virtual |
Expand all environment variables in the XML node. Environment variables are referenced using '${varname}' in text, attributes, names.
| [in] | recurse | If true, apply recursively to all children nodes. |
Reimplemented in ts::xml::Element.
|
pure virtual |
Return a node type name, mainly for debug purpose.
Implemented in ts::xml::Comment, ts::xml::Declaration, ts::xml::Document, ts::xml::Element, ts::xml::Text, and ts::xml::Unknown.
|
pure virtual |
Format the node for an output XML document.
| [in,out] | output | The output object to format the XML document. |
| [in] | keep_node_open | If true, keep the node open so that children may be printed later. |
Implemented in ts::xml::Comment, ts::xml::Declaration, ts::xml::Document, ts::xml::Element, ts::xml::Text, and ts::xml::Unknown.
|
virtual |
Print the closing tags for the node. Typically used after print() when keep_node_open was true. The default implementation is to do nothing. Subclasses may replace this.
| [in,out] | output | The output object to format the XML document. |
| [in] | levels | Number of levels to close. By default, close the complete document. If zero, no output is produced. |
Reimplemented in ts::xml::Document, and ts::xml::Element.
|
virtual |
Format the value as a one-liner XML text.
|
virtual |
Check if the text shall be stuck to other elements in XML output.
Reimplemented in ts::xml::Text.
| UString ts::xml::Node::debug | ( | ) | const |
Build a debug string for the node.
|
inline |
Get a reference to the report object for the XML node.
|
protected |
Identify the next token in the document.
| [in,out] | parser | The document parser. |
|
protectedpure virtual |
Parse the node.
| [in,out] | parser | The document parser. On input, the current position of the parser after the tag which identified the node ("<?", "<!- -", etc.) On output, it must be after the last character of the node. |
| [in] | parent | Candidate parent node, for information only, do not modify. Can be null. |
| [in] | max_nested | Maximum number of nested levels to explore. |
Implemented in ts::xml::Comment, ts::xml::Declaration, ts::xml::Document, ts::xml::Element, ts::xml::Text, and ts::xml::Unknown.
|
protectedvirtual |
Parse children nodes and add them to the node. Stop either at end of document or before a "</" sequence or on error.
| [in,out] | parser | The document parser. |
| [in] | max_nested | Maximum number of nested levels to explore. |
|
inlineprotected |
Called by the subclass when its spaces shall be preserved. Typically called when xml:space="preserve" is encountered.
| [in] | on | True is spaces shall be preserved. |
|
inlineinherited |
Check if the node is alone in its own ring.
|
inherited |
Remove the node from the ring it belongs to and creates its own ring.
|
inherited |
Insert this object in a ring after the specified node.
| [in] | o | A node of a ring. This object is inserted after o in the ring. |
|
inherited |
Insert this object in a ring before the specified node.
| [in] | o | A node of a ring. This object is inserted before o in the ring. |
|
inherited |
Swap this object and another one in their rings. If the two objects belong to the same ring, their positions are swapped. If they belong to distinct rings, they also move to each other's ring.
| [in] | o | The node to swap with. |
|
inlineinherited |
Get the next node in the ring.
| T | A superclass of RingNode, the expected type of the next object in the ring. |
|
inlineinherited |
Get the next node in the ring.
| T | A superclass of RingNode, the expected type of the next object in the ring. |
|
inlineinherited |
Get the previous node in the ring.
| T | A superclass of RingNode, the expected type of the previous object in the ring. |
|
inlineinherited |
Get the previous node in the ring.
| T | A superclass of RingNode, the expected type of the previous object in the ring. |
|
inherited |
Count the number of element in the ring. Warning: This method has a linear response time, avoid using it when possible.