0032969: Coding - get rid of unused headers [IMeshData to PLib]
[occt.git] / src / LDOM / LDOM_Node.hxx
1 // Created on: 2001-06-26
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //AGV 120202: Replace myDocument for myPtrDocument for better
17 //                          consistency of data
18
19 #ifndef LDOM_Node_HeaderFile
20 #define LDOM_Node_HeaderFile
21
22 #include <LDOMString.hxx>
23 #include <LDOM_MemManager.hxx>
24
25 class LDOM_BasicNode;
26
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");
33
34 class LDOM_Node
35 {
36  public:
37   enum NodeType {
38     UNKNOWN             = 0,
39     ELEMENT_NODE        = 1,
40     ATTRIBUTE_NODE      = 2,
41     TEXT_NODE           = 3,
42     CDATA_SECTION_NODE  = 4,
43     COMMENT_NODE        = 8
44     };
45
46   // ---------- PUBLIC METHODS ----------
47
48   LDOM_Node () : myOrigin        (NULL),
49                  myLastChild     (NULL) {}
50   //    Empty constructor
51
52   LDOM_Node (const LDOM_Node& anOther)
53     : myDocument        (anOther.myDocument),
54       myOrigin          (anOther.myOrigin),
55       myLastChild       (anOther.myLastChild) {}
56   //    Copy constructor
57
58   Standard_EXPORT const LDOM_MemManager& getOwnerDocument () const;
59
60   Standard_EXPORT LDOM_Node&
61                         operator =      (const LDOM_Node& anOther);
62
63   Standard_EXPORT LDOM_Node&
64                         operator =      (const LDOM_NullPtr * aNull); 
65
66   Standard_Boolean      operator ==     (const LDOM_NullPtr *) const
67                                         { return isNull(); }
68
69   Standard_Boolean      operator !=     (const LDOM_NullPtr *) const
70                                         { return ! isNull(); }
71
72   Standard_EXPORT Standard_Boolean
73                         operator ==     (const LDOM_Node& anOther) const;
74
75   Standard_EXPORT Standard_Boolean
76                         operator !=     (const LDOM_Node& anOther) const;
77
78   Standard_EXPORT Standard_Boolean
79                         isNull          () const;
80
81   Standard_EXPORT NodeType
82                         getNodeType     () const;
83
84   Standard_EXPORT LDOMString
85                         getNodeName     () const;
86
87   Standard_EXPORT LDOMString
88                         getNodeValue     () const;
89
90   Standard_EXPORT LDOM_Node
91                         getFirstChild   () const;
92
93   Standard_EXPORT LDOM_Node
94                         getLastChild   () const;
95
96   Standard_EXPORT LDOM_Node
97                         getNextSibling  () const;
98
99   Standard_EXPORT void  removeChild     (const LDOM_Node& aChild);
100
101   Standard_EXPORT void  appendChild     (const LDOM_Node& aChild);
102
103   Standard_EXPORT Standard_Boolean
104                         hasChildNodes   () const;
105
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 
110
111  protected:
112 friend class LDOM_BasicAttribute;
113 friend class LDOM_BasicElement;
114 friend class LDOM_BasicText;
115 friend class LDOM_NodeList;
116   // ---------- PROTECTED METHODS ----------
117
118   const LDOM_BasicNode& Origin          () const;
119
120   LDOM_Node (const LDOM_BasicNode& anOrig, const Handle(LDOM_MemManager)& aDoc)
121     : myDocument        (aDoc),
122       myOrigin          ((LDOM_BasicNode *) &anOrig),
123       myLastChild       (NULL) {}
124   //    Copy constructor with assignment to Document
125
126  protected:
127   // ---------- PROTECTED FIELDS ----------
128
129         // smart pointer to document owner of the node
130   Handle(LDOM_MemManager)       myDocument;
131
132         // pointer to (non-transient) node data in the document-managed memory
133   LDOM_BasicNode                * myOrigin;
134
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;
138
139   friend char * db_pretty_print (const LDOM_Node *, int, char *);
140 };
141
142 #endif