1 // Created on: 2001-06-26
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //AGV 120202: Replace myDocument for myPtrDocument for better
17 // consistency of data
19 #ifndef LDOM_Node_HeaderFile
20 #define LDOM_Node_HeaderFile
22 #include <LDOMString.hxx>
23 #include <LDOM_MemManager.hxx>
27 // LDOM_Node : base class for LDOM interface objects
28 // references LDOM_BasicNode - the real data stored in Document
29 // This type can be safely cast to any derived type, e.g. :
30 // LDOM_Node aNode = MyGetElementNode();
31 // LDOM_Element& anElemNode = (LDOM_Element&) aNode;
32 // LDOMString anXcoord = anElemNode.getAtttribute("x");
42 CDATA_SECTION_NODE = 4,
46 // ---------- PUBLIC METHODS ----------
48 LDOM_Node () : myOrigin (NULL),
52 LDOM_Node (const LDOM_Node& anOther)
53 : myDocument (anOther.myDocument),
54 myOrigin (anOther.myOrigin),
55 myLastChild (anOther.myLastChild) {}
58 Standard_EXPORT const LDOM_MemManager& getOwnerDocument () const;
60 Standard_EXPORT LDOM_Node&
61 operator = (const LDOM_Node& anOther);
63 Standard_EXPORT LDOM_Node&
64 operator = (const LDOM_NullPtr * aNull);
66 Standard_Boolean operator == (const LDOM_NullPtr *) const
69 Standard_Boolean operator != (const LDOM_NullPtr *) const
70 { return ! isNull(); }
72 Standard_EXPORT Standard_Boolean
73 operator == (const LDOM_Node& anOther) const;
75 Standard_EXPORT Standard_Boolean
76 operator != (const LDOM_Node& anOther) const;
78 Standard_EXPORT Standard_Boolean
81 Standard_EXPORT NodeType
84 Standard_EXPORT LDOMString
87 Standard_EXPORT LDOMString
88 getNodeValue () const;
90 Standard_EXPORT LDOM_Node
91 getFirstChild () const;
93 Standard_EXPORT LDOM_Node
94 getLastChild () const;
96 Standard_EXPORT LDOM_Node
97 getNextSibling () const;
99 Standard_EXPORT void removeChild (const LDOM_Node& aChild);
101 Standard_EXPORT void appendChild (const LDOM_Node& aChild);
103 Standard_EXPORT Standard_Boolean
104 hasChildNodes () const;
106 Standard_EXPORT void SetValueClear () const;
107 // Avoids checking for '<', '&', '\'', '\"', etc. on storage (saves time)
108 // You MUST be pretty sure that the node value string is OK in this sense
109 // NEVER call this method if you are not stuck on the performance
112 friend class LDOM_BasicAttribute;
113 friend class LDOM_BasicElement;
114 friend class LDOM_BasicText;
115 friend class LDOM_NodeList;
116 // ---------- PROTECTED METHODS ----------
118 const LDOM_BasicNode& Origin () const;
120 LDOM_Node (const LDOM_BasicNode& anOrig, const Handle(LDOM_MemManager)& aDoc)
122 myOrigin ((LDOM_BasicNode *) &anOrig),
123 myLastChild (NULL) {}
124 // Copy constructor with assignment to Document
127 // ---------- PROTECTED FIELDS ----------
129 // smart pointer to document owner of the node
130 Handle(LDOM_MemManager) myDocument;
132 // pointer to (non-transient) node data in the document-managed memory
133 LDOM_BasicNode * myOrigin;
135 // Transient data (only applicable to LDOM_Element type):
136 // the last child; myLastChild->mySibling points to the first attribute
137 const LDOM_BasicNode * myLastChild;
139 friend char * db_pretty_print (const LDOM_Node *, int, char *);