b311480e |
1 | // Created on: 2001-06-26 |
2 | // Created by: Alexander GRIGORIEV |
973c2be1 |
3 | // Copyright (c) 2001-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //AGV 120202: Replace myDocument for myPtrDocument for better |
7fd59977 |
17 | // consistency of data |
18 | |
19 | #ifndef LDOM_Node_HeaderFile |
20 | #define LDOM_Node_HeaderFile |
21 | |
22 | #include <Standard_Macro.hxx> |
23 | #include <Standard_TypeDef.hxx> |
7fd59977 |
24 | #include <LDOMString.hxx> |
25 | |
26 | class LDOM_BasicNode; |
c04c30b3 |
27 | class LDOM_MemManager; |
7fd59977 |
28 | |
29 | // LDOM_Node : base class for LDOM interface objects |
30 | // references LDOM_BasicNode - the real data stored in Document |
31 | // This type can be safely cast to any derived type, e.g. : |
32 | // LDOM_Node aNode = MyGetElementNode(); |
33 | // LDOM_Element& anElemNode = (LDOM_Element&) aNode; |
34 | // LDOMString anXcoord = anElemNode.getAtttribute("x"); |
35 | |
36 | class LDOM_Node |
37 | { |
38 | public: |
39 | enum NodeType { |
40 | UNKNOWN = 0, |
41 | ELEMENT_NODE = 1, |
42 | ATTRIBUTE_NODE = 2, |
43 | TEXT_NODE = 3, |
44 | CDATA_SECTION_NODE = 4, |
45 | COMMENT_NODE = 8 |
46 | }; |
47 | |
48 | // ---------- PUBLIC METHODS ---------- |
49 | |
50 | LDOM_Node () : myOrigin (NULL), |
51 | myLastChild (NULL) {} |
52 | // Empty constructor |
53 | |
54 | LDOM_Node (const LDOM_Node& anOther) |
55 | : myDocument (anOther.myDocument), |
56 | myOrigin (anOther.myOrigin), |
57 | myLastChild (anOther.myLastChild) {} |
58 | // Copy constructor |
59 | |
60 | Standard_EXPORT const LDOM_MemManager& getOwnerDocument () const; |
61 | |
62 | Standard_EXPORT LDOM_Node& |
63 | operator = (const LDOM_Node& anOther); |
64 | |
65 | Standard_EXPORT LDOM_Node& |
66 | operator = (const LDOM_NullPtr * aNull); |
67 | |
68 | Standard_Boolean operator == (const LDOM_NullPtr *) const |
69 | { return isNull(); } |
70 | |
71 | Standard_Boolean operator != (const LDOM_NullPtr *) const |
72 | { return ! isNull(); } |
73 | |
74 | Standard_EXPORT Standard_Boolean |
75 | operator == (const LDOM_Node& anOther) const; |
76 | |
77 | Standard_EXPORT Standard_Boolean |
78 | operator != (const LDOM_Node& anOther) const; |
79 | |
80 | Standard_EXPORT Standard_Boolean |
81 | isNull () const; |
82 | |
83 | Standard_EXPORT NodeType |
84 | getNodeType () const; |
85 | |
86 | Standard_EXPORT LDOMString |
87 | getNodeName () const; |
88 | |
89 | Standard_EXPORT LDOMString |
90 | getNodeValue () const; |
91 | |
92 | Standard_EXPORT LDOM_Node |
93 | getFirstChild () const; |
94 | |
95 | Standard_EXPORT LDOM_Node |
96 | getLastChild () const; |
97 | |
98 | Standard_EXPORT LDOM_Node |
99 | getNextSibling () const; |
100 | |
101 | Standard_EXPORT void removeChild (const LDOM_Node& aChild); |
102 | |
103 | Standard_EXPORT void appendChild (const LDOM_Node& aChild); |
104 | |
105 | Standard_EXPORT Standard_Boolean |
106 | hasChildNodes () const; |
107 | |
108 | Standard_EXPORT void SetValueClear () const; |
109 | // Avoids checking for '<', '&', '\'', '\"', etc. on storage (saves time) |
110 | // You MUST be pretty sure that the node value string is OK in this sense |
111 | // NEVER call this method if you are not stuck on the performance |
112 | |
113 | protected: |
114 | friend class LDOM_BasicAttribute; |
115 | friend class LDOM_BasicElement; |
116 | friend class LDOM_BasicText; |
117 | friend class LDOM_NodeList; |
118 | // ---------- PROTECTED METHODS ---------- |
119 | |
120 | const LDOM_BasicNode& Origin () const; |
121 | |
122 | LDOM_Node (const LDOM_BasicNode& anOrig, const Handle(LDOM_MemManager)& aDoc) |
123 | : myDocument (aDoc), |
124 | myOrigin ((LDOM_BasicNode *) &anOrig), |
125 | myLastChild (NULL) {} |
126 | // Copy constructor with assignment to Document |
127 | |
128 | protected: |
129 | // ---------- PROTECTED FIELDS ---------- |
130 | |
131 | // smart pointer to document owner of the node |
132 | Handle(LDOM_MemManager) myDocument; |
133 | |
134 | // pointer to (non-transient) node data in the document-managed memory |
135 | LDOM_BasicNode * myOrigin; |
136 | |
137 | // Transient data (only applicable to LDOM_Element type): |
138 | // the last child; myLastChild->mySibling points to the first attribute |
139 | const LDOM_BasicNode * myLastChild; |
140 | |
141 | friend char * db_pretty_print (const LDOM_Node *, int, char *); |
142 | }; |
143 | |
144 | #endif |