Simbody  3.7
SimTK::Xml::Text Class Reference

This is the "leaf" content of an element. More...

+ Inheritance diagram for SimTK::Xml::Text:

Public Member Functions

 Text ()
 Create an empty Text node handle, suitable only for holding references to other Text nodes. More...
 
 Text (const String &text)
 Create a new Text node with the given text; the node is not yet owned by any XML document. More...
 
Text clone () const
 The clone() method makes a deep copy of this Text node and returns a new orphan Text node with the same contents; ordinary assignment and copy construction are shallow. More...
 
const StringgetText () const
 Obtain a const reference to the String holding the value of this Text. More...
 
StringupdText ()
 Obtain a writable reference to the String holding the value of this Text node; this can be used to alter the value. 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 Text 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 Text node and if so cast it to one.

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

Additional Inherited Members

Detailed Description

This is the "leaf" content of an element.

Constructor & Destructor Documentation

◆ Text() [1/2]

SimTK::Xml::Text::Text ( )
inline

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

◆ Text() [2/2]

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

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

Member Function Documentation

◆ clone()

Text SimTK::Xml::Text::clone ( ) const

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

◆ getText()

const String& SimTK::Xml::Text::getText ( ) const

Obtain a const reference to the String holding the value of this Text.

◆ updText()

String& SimTK::Xml::Text::updText ( )

Obtain a writable reference to the String holding the value of this Text node; this can be used to alter the value.

◆ isA()

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

Test whether a given Node is an Text node.

◆ getAs() [1/2]

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

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

See also
isA()

◆ getAs() [2/2]

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

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

See also
isA()

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