Aspose::Words::Node Class Referenceabstract

Base class for all nodes of a Word document. More...

#include "Aspose.Words.Cpp/Model/Nodes/Node.h"

Inherits System::Object.

Inherited by Aspose::Words::BookmarkEnd, Aspose::Words::BookmarkStart, Aspose::Words::CommentRangeEnd, Aspose::Words::CommentRangeStart, Aspose::Words::CompositeNode, Aspose::Words::EditableRangeEnd, Aspose::Words::EditableRangeStart, Aspose::Words::Inline, and Aspose::Words::SubDocument.

Public Member Functions

virtual Aspose::Words::NodeType get_NodeType () const =0
 Gets the type of this node. More...
 
System::SharedPtr< Aspose::Words::CompositeNodeget_ParentNode ()
 Gets the immediate parent of this node. More...
 
System::SharedPtr< Aspose::Words::DocumentBaseget_Document ()
 Gets the document to which this node belongs. More...
 
System::SharedPtr< Aspose::Words::Nodeget_PreviousSibling ()
 Gets the node immediately preceding this node. More...
 
System::SharedPtr< Aspose::Words::Nodeget_NextSibling ()
 Gets the node immediately following this node. More...
 
virtual bool get_IsComposite ()
 Returns true if this node can contain other nodes. More...
 
System::SharedPtr< Aspose::Words::Rangeget_Range ()
 Returns a Range object that represents the portion of a document that is contained in this node. More...
 
System::SharedPtr< Aspose::Words::NodeClone (bool isCloneChildren)
 
virtual bool Accept (System::SharedPtr< Aspose::Words::DocumentVisitor > visitor)=0
 Accepts a visitor. More...
 
virtual System::String GetText ()
 Gets the text of this node and of all its children. More...
 
template<typename T >
GetAncestorOf ()
 
System::SharedPtr< Aspose::Words::CompositeNodeGetAncestor (Aspose::Words::NodeType ancestorType)
 Gets the first ancestor of the specified Aspose::Words::NodeType. More...
 
void Remove ()
 Removes itself from the parent. More...
 
System::SharedPtr< Aspose::Words::NodeNextPreOrder (System::SharedPtr< Aspose::Words::Node > rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
System::SharedPtr< Aspose::Words::NodePreviousPreOrder (System::SharedPtr< Aspose::Words::Node > rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
System::String ToString (Aspose::Words::SaveFormat saveFormat)
 Exports the content of the node into a string in the specified format. More...
 
System::String ToString (System::SharedPtr< Aspose::Words::Saving::SaveOptions > saveOptions)
 Exports the content of the node into a string using the specified save options. More...
 
- Public Member Functions inherited from System::Object
 Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ~Object ()
 Destroys object. Frees all internal data structures. More...
 
 Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared refernce counter. More...
 
void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual int GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual String ToString () ASPOSE_CONST
 Analog of C# Object.ToString() method. Enables converting custom objects to string. More...
 
virtual ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual void SetTemplateWeakPtr (unsigned int argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 

Static Public Member Functions

static System::String NodeTypeToString (Aspose::Words::NodeType nodeType)
 A utility method that converts a node type enum value into a user friendly string. More...
 
- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Impleemnts C# typeof(System.Object) construct. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 
template<>
bool Equals (double const &objA, double const &objB)
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 

Detailed Description

Base class for all nodes of a Word document.

A document is represented as a tree of nodes, similar to DOM or XmlDocument.

For more info see the Composite design pattern.

The Aspose::Words::Node class:

  • Defines the child node interface.
  • Defines the interface for visiting nodes.
  • Provides default cloning capability.
  • Implements parent node and owner document mechanisms.
  • Implements access to sibling nodes.

Member Function Documentation

◆ Accept()

◆ Clone()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::Clone ( bool  isCloneChildren)

◆ get_Document()

System::SharedPtr<Aspose::Words::DocumentBase> Aspose::Words::Node::get_Document ( )

Gets the document to which this node belongs.

The node always belongs to a document even if it has just been created and not yet added to the tree, or if it has been removed from the tree.

◆ get_IsComposite()

virtual bool Aspose::Words::Node::get_IsComposite ( )
virtual

Returns true if this node can contain other nodes.

This method returns false as Node cannot have child nodes.

Reimplemented in Aspose::Words::CompositeNode.

◆ get_NextSibling()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::get_NextSibling ( )

Gets the node immediately following this node.

If there is no next node, a null is returned.

◆ get_NodeType()

◆ get_ParentNode()

System::SharedPtr<Aspose::Words::CompositeNode> Aspose::Words::Node::get_ParentNode ( )

Gets the immediate parent of this node.

If a node has just been created and not yet added to the tree, or if it has been removed from the tree, the parent is null.

◆ get_PreviousSibling()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::get_PreviousSibling ( )

Gets the node immediately preceding this node.

If there is no preceding node, a null is returned.

◆ get_Range()

System::SharedPtr<Aspose::Words::Range> Aspose::Words::Node::get_Range ( )

Returns a Range object that represents the portion of a document that is contained in this node.

◆ GetAncestor()

System::SharedPtr<Aspose::Words::CompositeNode> Aspose::Words::Node::GetAncestor ( Aspose::Words::NodeType  ancestorType)

Gets the first ancestor of the specified Aspose::Words::NodeType.

Parameters
ancestorTypeThe node type of the ancestor to retrieve.
Returns
The ancestor of the specified type or null if no ancestor of this type was found.

◆ GetAncestorOf()

template<typename T >
T Aspose::Words::Node::GetAncestorOf ( )
inline

◆ GetText()

virtual System::String Aspose::Words::Node::GetText ( )
virtual

Gets the text of this node and of all its children.

The returned string includes all control and special characters as described in Aspose::Words::ControlChar.

Reimplemented in Aspose::Words::Paragraph, Aspose::Words::CompositeNode, Aspose::Words::Tables::Row, Aspose::Words::Run, Aspose::Words::BookmarkStart, and Aspose::Words::SpecialChar.

◆ NextPreOrder()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::NextPreOrder ( System::SharedPtr< Aspose::Words::Node rootNode)

Gets next node according to the pre-order tree traversal algorithm.

Parameters
rootNodeThe top node (limit) of traversal.
Returns
Next node in pre-order order. Null if reached the rootNode.

◆ NodeTypeToString()

static System::String Aspose::Words::Node::NodeTypeToString ( Aspose::Words::NodeType  nodeType)
static

A utility method that converts a node type enum value into a user friendly string.

◆ PreviousPreOrder()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::PreviousPreOrder ( System::SharedPtr< Aspose::Words::Node rootNode)

Gets the previous node according to the pre-order tree traversal algorithm.

Parameters
rootNodeThe top node (limit) of traversal.
Returns
Previous node in pre-order order. Null if reached the rootNode.

◆ Remove()

void Aspose::Words::Node::Remove ( )

Removes itself from the parent.

◆ ToString() [1/2]

System::String Aspose::Words::Node::ToString ( Aspose::Words::SaveFormat  saveFormat)

Exports the content of the node into a string in the specified format.

Returns
The content of the node in the specified format.

◆ ToString() [2/2]

System::String Aspose::Words::Node::ToString ( System::SharedPtr< Aspose::Words::Saving::SaveOptions saveOptions)

Exports the content of the node into a string using the specified save options.

Parameters
saveOptionsSpecifies the options that control how the node is saved.
Returns
The content of the node in the specified format.