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


Public Member Functions | |
| RunningDocument (Report &report=(ts::NullReport::Instance())) | |
| virtual | ~RunningDocument () override |
| size_t | childrenCount () const |
| virtual void | clear () |
| virtual Node * | clone () const override |
| void | close () |
| 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 |
| void | flush () |
| bool | hasChildren () const |
| bool | ignoreNamespace () const |
| Element * | initialize (const UString &rootName, const UString &declaration=UString()) |
| Node * | lastChild () |
| const Node * | lastChild () const |
| size_t | lineNumber () const |
| bool | load (const UString &file_name, bool search=true, size_t max_nested=DEFAULT_MAX_NESTED) |
| bool | load (std::istream &strm, size_t max_nested=DEFAULT_MAX_NESTED) |
| 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 |
| Element * | open (const UString &rootName, const UString &declaration=UString(), const fs::path &fileName=fs::path(), std::ostream &strm=std::cout) |
| Node * | parent () |
| const Node * | parent () const |
| bool | parse (const UString &text, size_t max_nested=DEFAULT_MAX_NESTED) |
| bool | parse (const UStringList &lines, size_t max_nested=DEFAULT_MAX_NESTED) |
| 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 override |
| virtual void | printClose (TextFormatter &output, size_t levels=std::numeric_limits< size_t >::max()) const override |
| 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) |
| Element * | rootElement () |
| const Element * | rootElement () const |
| bool | save (const fs::path &file_name, size_t indent=2) |
| virtual void | setIignoreNamespace (bool ignore) |
| void | setTweaks (const Tweaks &tw) |
| void | setValue (const UString &value) |
| virtual bool | stickyOutput () const |
| virtual UString | toString () const override |
| virtual const Tweaks & | tweaks () const override |
| virtual UString | typeName () const override |
| const UString & | value () const |
Static Public Member Functions | |
| static UString | DisplayFileName (const UString &name, bool stdInputIfEmpty=false) |
| static bool | IsInlineXML (const UString &name) |
Protected Member Functions | |
| 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) override |
| void | setPreserveSpace (bool on) |
Representation of a "running" XML document which is displayed on the fly.
The idea is to display or save an XML document which is built element by element without waiting for the end of the document. Moreover, considering that the document can be arbitrary long, can take an arbitrary long time to be built and is not used for anything else than display or save, elements are destroyed after being displayed or saved to avoid wasting memory.
|
explicit |
Constructor.
| [in,out] | report | Where to report errors. |
|
overridevirtual |
Destructor.
| Element * ts::xml::RunningDocument::open | ( | const UString & | rootName, |
| const UString & | declaration = UString(), | ||
| const fs::path & | fileName = fs::path(), | ||
| std::ostream & | strm = std::cout ) |
Initialize the running document. The initial declaration and root are created. The output XML file is initialized but nothing is printed yet.
| [in] | rootName | Name of the root element to create. |
| [in] | declaration | Optional XML declaration. When omitted or empty, the standard declaration is used, specifying UTF-8 as format. |
| [in] | fileName | Output file name to create. When empty or "-", strm is used for output. |
| [in,out] | strm | The default output text stream when fileName is empty or "-". The referenced stream object must remain valid as long as this object. |
| void ts::xml::RunningDocument::flush | ( | ) |
Flush the running document. All elements under the document root are displayed or saved and then deleted. The XML document header is issued with the first element. The XML structure is left open for more elements, in the next call to flush().
| void ts::xml::RunningDocument::close | ( | ) |
Close the running document. If the XML structure is still open, it is closed. The output file, if any, is closed.
|
inherited |
Parse an XML document.
| [in] | lines | List of text lines forming the XML document. |
| [in] | max_nested | Maximum number of nested levels to parse. The default value is recommended to avoid stack overflow. |
|
inherited |
Parse an XML document.
| [in] | text | The XML document. |
| [in] | max_nested | Maximum number of nested levels to parse. The default value is recommended to avoid stack overflow. |
|
inherited |
Load and parse an XML file.
| [in] | file_name | Name of the XML file to load. If file_name is empty or "-", read the standard input. If file_name starts with "<?xml", this is considered as "inline XML content". The document is loaded from this string instead of reading a file. |
| [in] | search | If true, search the XML file in the TSDuck configuration directories if file_name is not found and does not contain any directory part. |
| [in] | max_nested | Maximum number of nested levels to parse. The default value is recommended to avoid stack overflow. |
|
inherited |
Load and parse an XML file.
| [in,out] | strm | A standard text stream in input mode. |
| [in] | max_nested | Maximum number of nested levels to parse. The default value is recommended to avoid stack overflow. |
|
inherited |
Save an XML file.
| [in] | file_name | Name of the XML file to save. If file_name is empty or "-", writes to the standard output. |
| [in] | indent | Indentation width of each level. |
|
staticinherited |
Check if a "file name" is in fact inline XML content instead of a file name.
| [in] | name | A file name string. |
|
staticinherited |
Get a suitable display name for an XML file name or inline content.
| [in] | name | A file name string. |
| [in] | stdInputIfEmpty | If true and if file_name is empty, reads the standard input. |
|
inlineinherited |
Get the root element of the document.
|
inlineinherited |
Get the root element of the document.
|
inherited |
Initialize the document. The initial declaration and root are created.
| [in] | rootName | Name of the root element to create. |
| [in] | declaration | Optional XML declaration. When omitted, the standard declaration is used, specifying UTF-8 as format. |
|
overridevirtualinherited |
Get a constant reference to the global XML parsing and formatting tweaks for the document.
Reimplemented from ts::xml::Node.
|
inlineinherited |
Set the global XML parsing and formatting tweaks for the document.
| [in] | tw | The new global XML tweaks. |
|
overridevirtualinherited |
Convert to a string object.
Implements ts::StringifyInterface.
|
overridevirtualinherited |
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.
Implements ts::xml::Node.
Reimplemented in ts::xml::ModelDocument, and ts::xml::PatchDocument.
|
overridevirtualinherited |
|
overridevirtualinherited |
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. |
Implements ts::xml::Node.
|
overridevirtualinherited |
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 from ts::xml::Node.
|
overrideprotectedvirtualinherited |
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. |
Implements ts::xml::Node.
|
inlineinherited |
Get the line number in input document.
|
virtualinherited |
Clear the content of the node. The node becomes empty but remains attached to its parent.
Reimplemented in ts::xml::Element.
|
inherited |
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. |
|
inlineinherited |
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. |
|
inlineinherited |
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. |
|
inherited |
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. |
|
inlineinherited |
Get the parent's node.
|
inlineinherited |
Get the parent's node.
|
inlineinherited |
Get the document into which the node is located.
|
inherited |
Get the document into which the node is located.
|
inherited |
Get the depth of an XML element.
|
inherited |
Check if the node or one of its ancestors has attribute xml:space="preserve".
|
inlineinherited |
Check if namespace is ignored by default when comparing element and attribute names in this node's hierarchy.
|
virtualinherited |
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.
|
inlineinherited |
Check if the node has children.
|
inlineinherited |
Get the number of children.
|
inlineinherited |
Get the first child of a node.
|
inlineinherited |
Get the first child of a node.
|
inlineinherited |
Get the last child.
|
inlineinherited |
Get the last child.
|
inlineinherited |
Get the next sibling node.
|
inherited |
Get the next sibling node.
|
inlineinherited |
Get the previous sibling node.
|
inherited |
Get the previous sibling node.
|
inlineinherited |
|
inherited |
|
inlineinherited |
Find the next sibling element.
|
inherited |
Find the next sibling element.
|
inlineinherited |
Find the previous sibling element.
|
inherited |
Find the previous sibling element.
|
inlineinherited |
Get the value of the node.
The semantic of the value depends on the node subclass:
|
inlineinherited |
|
inherited |
Remove all comments in the XML node.
| [in] | recurse | If true, apply recursively to all children nodes. |
|
virtualinherited |
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.
|
virtualinherited |
Format the value as a one-liner XML text.
|
virtualinherited |
Check if the text shall be stuck to other elements in XML output.
Reimplemented in ts::xml::Text.
|
inherited |
Build a debug string for the node.
|
inlineinherited |
Get a reference to the report object for the XML node.
|
protectedinherited |
Identify the next token in the document.
| [in,out] | parser | The document parser. |
|
protectedvirtualinherited |
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. |
|
inlineprotectedinherited |
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.