Simbody  3.6
SimTK::Xml::Comment Class Reference

A comment contains only uninterpreted text. More...

+ Inheritance diagram for SimTK::Xml::Comment:

Public Member Functions

 Comment ()
 Create an empty Comment node handle, suitable only for holding references to other Comment nodes. More...
 
 Comment (const String &text)
 Create a new Comment node with the given text; the node is not yet owned by any XML document. More...
 
Comment clone () const
 The clone() method makes a deep copy of this Comment node and returns a new orphan Comment node with the same contents; ordinary assignment and copy construction are shallow. More...
 
- Public Member Functions inherited from SimTK::Xml::Node
bool operator== (const Node &other) const
 Comparing Nodes for equality means asking if the two Node handles are referring to exactly the same object; two different nodes that happen to have the same properties will not test equal by this criteria. More...
 
bool operator!= (const Node &other) const
 Inequality test using same criteria as operator==(). More...
 
 Node ()
 Create an empty Node handle that can be used to hold a reference to any kind of Node. More...
 
 Node (const Node &src)
 Copy constructor is shallow; that is, this handle will refer to the same node as the source. More...
 
Nodeoperator= (const Node &src)
 Copy assignment is shallow; the handle is first cleared and then will refer to the same node as the source. More...
 
Node clone () const
 The clone() method makes a deep copy of this Node and its children and returns a new orphan Node with the same contents; ordinary assignment and copy construction is shallow. More...
 
 ~Node ()
 The Node handle destructor does not recover heap space so if you create orphan nodes and then don't put them in a document there will be a memory leak unless you explicitly destruct them first with clearOrphan(). More...
 
void clear ()
 This method restores the Node handle to its default-constructed state but does not recover any heap space; use clearOrphan() if you know this node was never put into a document. More...
 
void clearOrphan ()
 This method explicitly frees the heap space for an orphan node that was created but never inserted into a document. More...
 
NodeType getNodeType () const
 Get the Xml::NodeType of this node. More...
 
String getNodeTypeAsString () const
 Get the Node type as a string; an empty handle returns "NoNode". More...
 
bool isValid () const
 Return true if this Node handle is referencing some node, false if the Node handle is empty. More...
 
bool isTopLevelNode () const
 Return true if this Node is owned by the top-level Xml document, false if the Node is owned by an Element or is an orphan, or if the Node handle is empty. More...
 
bool isOrphan () const
 Return true if this Node is an orphan, meaning that it is not empty, but is not owned by any element or top-level document. More...
 
bool hasParentElement () const
 Return true if this node has a parent, i.e. More...
 
Element getParentElement ()
 Return a handle referencing this node's parent if it has one, otherwise throws an error; check first with hasParentElement() if you aren't sure. More...
 
const StringgetNodeText () const
 Return a text value associated with this Node (not including its child nodes if any); the behavior depends on the NodeType. More...
 
void writeToString (String &out, bool compact=false) const
 Serialize this node (and everything it contains) to the given String. More...
 

Static Public Member Functions

Conversion to Comment from Node

If you have a handle to a Node, such as would be returned by a node_iterator, you can check whether that Node is a Comment node and if so cast it to one.

static bool isA (const Node &)
 Test whether a given Node is an Comment node. More...
 
static const CommentgetAs (const Node &node)
 Recast a Node to a const Comment, throwing an error if the Node is not actually an Comment node. More...
 
static CommentgetAs (Node &node)
 Recast a writable Node to a writable Comment, throwing an error if the Node is not actually an Comment node. More...
 

Additional Inherited Members

Detailed Description

A comment contains only uninterpreted text.

Constructor & Destructor Documentation

◆ Comment() [1/2]

SimTK::Xml::Comment::Comment ( )
inline

Create an empty Comment node handle, suitable only for holding references to other Comment nodes.

◆ Comment() [2/2]

SimTK::Xml::Comment::Comment ( const String text)
explicit

Create a new Comment node with the given text; the node is not yet owned by any XML document.

Don't include the comment delimiters "<!--" and "-->" in the text; those will be added automatically if the document is serialized to a file or string.

Member Function Documentation

◆ clone()

Comment SimTK::Xml::Comment::clone ( ) const

The clone() method makes a deep copy of this Comment node and returns a new orphan Comment node with the same contents; ordinary assignment and copy construction are shallow.

◆ isA()

static bool SimTK::Xml::Comment::isA ( const Node )
static

Test whether a given Node is an Comment node.

◆ getAs() [1/2]

static const Comment& SimTK::Xml::Comment::getAs ( const Node node)
static

Recast a Node to a const Comment, throwing an error if the Node is not actually an Comment node.

See also
isA()

◆ getAs() [2/2]

static Comment& SimTK::Xml::Comment::getAs ( Node node)
static

Recast a writable Node to a writable Comment, throwing an error if the Node is not actually an Comment node.

See also
isA()

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