Base Framework
Public Member Functions | Protected Member Functions | List of all members
Text Class Reference

DOM text node. More...

#include <base/xml/Text.h>

Inherits CharacterData.

Inherited by CDATASection.

Public Member Functions

 Text (Node node)
 
 Text (CharacterData node)
 
Text splitText (unsigned int index)
 
- Public Member Functions inherited from CharacterData
 CharacterData (Node node)
 
String getData () const
 
void setData (const String &data)
 
unsigned int getLength () const noexcept
 
String substringData (unsigned int offset, unsigned int count)
 
void appendData (const String &value)
 
void insertData (unsigned int offset, const String &value)
 
void deleteData (unsigned int offset, unsigned int count)
 
void replaceData (unsigned int offset, unsigned int count, const String &value)
 
- Public Member Functions inherited from Node
 Node () noexcept
 
 Node (const Node &copy) noexcept
 
Nodeoperator= (const Node &assign) noexcept
 
Node appendChild (Node child)
 
Node insertBefore (Node newChild, Node refChild)
 
Node removeChild (Node child)
 
Node replaceChild (Node newChild, Node oldChild)
 
Node cloneNode (bool deep)
 
String getLocalName () const noexcept
 
String getNamespaceURI () const noexcept
 
String getName () const
 
NodeType getType () const
 
String getValue () const
 
ShadowDocument getOwnerDocument () noexcept
 
String getPrefix () const
 
void setPrefix (const String &prefix)
 
Node getParent () const noexcept
 
Node getPreviousSibling () const noexcept
 
Node getNextSibling () const noexcept
 
Node getFirstChild () const
 
Node getLastChild () const
 
bool hasAttributes () const noexcept
 
bool hasChildNodes () const
 
bool isSupported (const String &feature, const String &version) const noexcept
 
void normalize ()
 
void setValue (const String &value)
 
bool isValid () const noexcept
 
bool isInvalid () const noexcept
 
bool isUnlinked () const noexcept
 
bool isSame (const Node &node) const noexcept
 
bool operator== (const Node &node) const noexcept
 
bool hasSameOwner (const Node &node) const noexcept
 
bool isAncestor (const Node &node) const noexcept
 
 operator bool () const noexcept
 
 ~Node () noexcept
 

Protected Member Functions

 Text (void *context) noexcept
 
- Protected Member Functions inherited from CharacterData
 CharacterData (void *context) noexcept
 
- Protected Member Functions inherited from Node
 Node (void *_context) noexcept
 
void * getContext () noexcept
 
const void * getContext () const noexcept
 

Additional Inherited Members

- Public Types inherited from Node
enum  NodeType {
  ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE,
  ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE,
  DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE,
  ATTRIBUTE_DECL_NODE, ELEMENT_DECL_NODE, ENTITY_DECL_NODE
}
 

Detailed Description

DOM text node.

The Text class inherits from CharacterData and represents the textual content (termed character data in XML) of an Element or Attribute. If there is no markup inside an element's content, the text is contained in a single instance of the Text class that is the only child of the element. If there is markup, it is parsed into the information items (elements, comments, etc.) and Text nodes that form the list of children of the element.

When a document is first made available via the DOM, there is only one Text node for each block of text. Users may create adjacent Text nodes that represent the contents of a given element without any intervening markup, but should be aware that there is no way to represent the separations between these nodes in XML or HTML, so they will not (in general) persist between DOM editing sessions. The normalize() method on Node merges any such adjacent Text nodes into a single node for each block of text.

Version
1.0

Member Function Documentation

◆ splitText()

Text Text::splitText ( unsigned int  index)

Breaks this node into two nodes at the specified offset, keeping both in the tree as siblings. After being split, this node will contain all the content up to the offset point. A new node of the same type, which contains all the content at and after the offset point, is returned. If the original node had a parent node, the new node is inserted as the next sibling of the original node. When the offset is equal to the length of this node, the new node has no data.

Parameters
indexThe octet index (not character index).