PCL
pcl::XMLNode Class Referenceabstract

Abstract base class of all XML document node classes. More...

#include <XML.h>

+ Inheritance diagram for pcl::XMLNode:

Public Types

using node_type = XMLNodeType::mask_type
 

Public Member Functions

 XMLNode (const XMLNode &x)
 
 XMLNode (node_type type)
 
 ~XMLNode () override
 
bool IsChildNode () const
 
bool IsComment () const
 
bool IsElement () const
 
bool IsText () const
 
const XMLNodeLocationLocation () const
 
virtual bool NLAfter (const XMLNode &previous) const
 
node_type NodeType () const
 
virtual void Serialize (IsoString &text, bool autoFormat, char indentChar, unsigned indentSize, unsigned level) const =0
 
virtual void SerializeAsHTML (IsoString &text, bool autoFormat, char indentChar, unsigned indentSize, unsigned level) const
 
- Public Member Functions inherited from pcl::XMLComponent
 XMLComponent ()=default
 
 XMLComponent (const XMLComponent &)=default
 
virtual ~XMLComponent ()
 
bool IsTopLevel () const
 
XMLElementParentElement () const
 

Detailed Description

XML document nodes can be elements, text, CDATA sections, processing instructions, comments, and unknown special elements. This class extends the XMLComponent root base class to implement XML document node classification and serialization.

Definition at line 506 of file XML.h.

Member Typedef Documentation

◆ node_type

using pcl::XMLNode::node_type = XMLNodeType::mask_type

Represents the type of an XML document node. Supported/valid node types are defined in the XMLNodeType namespace.

Definition at line 514 of file XML.h.

Constructor & Destructor Documentation

◆ XMLNode() [1/2]

pcl::XMLNode::XMLNode ( node_type  type)
inline

Default constructor. Constructs a default XMLNode object of the specified type, with no parent element and undefined source code location.

Definition at line 521 of file XML.h.

◆ XMLNode() [2/2]

pcl::XMLNode::XMLNode ( const XMLNode x)
inline

Copy constructor.

The newly constructed node will be an orphan object, that is, it will have no parent element even if the source object x is a child node. This reflects the fact that document nodes are unique objects.

Definition at line 533 of file XML.h.

◆ ~XMLNode()

pcl::XMLNode::~XMLNode ( )
inlineoverride

Destroys an XMLNode object.

Definition at line 542 of file XML.h.

Member Function Documentation

◆ IsChildNode()

bool pcl::XMLNode::IsChildNode ( ) const
inline

Returns true iff this is a child node of an existing XML element.

Definition at line 549 of file XML.h.

◆ IsComment()

bool pcl::XMLNode::IsComment ( ) const
inline

Returns true iff this node represents an XML comment. If this member function returns true, this node can be statically casted to XMLComment.

Definition at line 584 of file XML.h.

◆ IsElement()

bool pcl::XMLNode::IsElement ( ) const
inline

Returns true iff this node is an XML element. If this member function returns true, this node can be statically casted to XMLElement.

Definition at line 566 of file XML.h.

Referenced by pcl::XMLDocument::RemoveElementsByFilter(), and pcl::XMLDocument::RemoveElementsByName().

◆ IsText()

bool pcl::XMLNode::IsText ( ) const
inline

Returns true iff this node represents an XML text block. If this member function returns true, this node can be statically casted to XMLText.

Definition at line 575 of file XML.h.

◆ Location()

const XMLNodeLocation& pcl::XMLNode::Location ( ) const
inline

Returns a reference to the (immutable) source code location of this node.

Definition at line 592 of file XML.h.

◆ NLAfter()

virtual bool pcl::XMLNode::NLAfter ( const XMLNode previous) const
virtual

Returns true iff a new line character (#x0A) can be inserted before serializing this node after the specified previous node.

Reimplemented in pcl::XMLText.

◆ NodeType()

node_type pcl::XMLNode::NodeType ( ) const
inline

Returns the type of this XML document node.

Definition at line 557 of file XML.h.

Referenced by pcl::XMLElement::AddChildNode().

◆ Serialize()

virtual void pcl::XMLNode::Serialize ( IsoString text,
bool  autoFormat,
char  indentChar,
unsigned  indentSize,
unsigned  level 
) const
pure virtual

Serializes this document node as an XML fragment encoded in UTF-8.

Parameters
textReference to an 8-bit string to which the UTF-8 encoded serialization of this node must be appended.
autoFormatTrue if line break characters (#x0A) and indentation strings must be used to improve readability of the generated XML code. False if no superfluous white space should be generated.
indentCharA character used for indentation of generated text lines, when autoFormat is true. This parameter should be either a white space (' ' or #x20) or a tabulator ('\t' or #x09) character.
indentSizeNumber of indentChar characters used for each indentation level, when autoFormat is true.
levelRecursion level. A value greater than zero denotes that this function is being called from a parent XML element. The recursion level determines the number of indentChar characters prepended to each text line for indentation, when autoFormat is true.

Implemented in pcl::XMLUnknownElement, pcl::XMLComment, pcl::XMLProcessingInstructions, pcl::XMLCDATA, pcl::XMLText, and pcl::XMLElement.

◆ SerializeAsHTML()

virtual void pcl::XMLNode::SerializeAsHTML ( IsoString text,
bool  autoFormat,
char  indentChar,
unsigned  indentSize,
unsigned  level 
) const
inlinevirtual

Serializes this document node as an XML fragment encoded in UTF-8, following a set of rules and restrictions pertaining to HTML.

In particular, HTML restricts self-closing tags to a reduced subset of void elements. See section 13.1.2 of the HTML Living Standard for details:

https://html.spec.whatwg.org/multipage/syntax.html#void-elements

See Serialize() for complete information on function parameters.

Reimplemented in pcl::XMLElement.

Definition at line 636 of file XML.h.


The documentation for this class was generated from the following file: