0024095: Eliminate compiler warning C4512 in MSVC++ with warning level 4
[occt.git] / src / LDOM / LDOM_Node.hxx
CommitLineData
b311480e 1// Created on: 2001-06-26
2// Created by: Alexander GRIGORIEV
3// Copyright (c) 2001-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
20//AGV 120202: Replace myDocument for myPtrDocument for better
7fd59977 21// consistency of data
22
23#ifndef LDOM_Node_HeaderFile
24#define LDOM_Node_HeaderFile
25
26#include <Standard_Macro.hxx>
27#include <Standard_TypeDef.hxx>
28#include <Handle_LDOM_MemManager.hxx>
29#include <LDOMString.hxx>
30
31class LDOM_BasicNode;
32
33// LDOM_Node : base class for LDOM interface objects
34// references LDOM_BasicNode - the real data stored in Document
35// This type can be safely cast to any derived type, e.g. :
36// LDOM_Node aNode = MyGetElementNode();
37// LDOM_Element& anElemNode = (LDOM_Element&) aNode;
38// LDOMString anXcoord = anElemNode.getAtttribute("x");
39
40class LDOM_Node
41{
42 public:
43 enum NodeType {
44 UNKNOWN = 0,
45 ELEMENT_NODE = 1,
46 ATTRIBUTE_NODE = 2,
47 TEXT_NODE = 3,
48 CDATA_SECTION_NODE = 4,
49 COMMENT_NODE = 8
50 };
51
52 // ---------- PUBLIC METHODS ----------
53
54 LDOM_Node () : myOrigin (NULL),
55 myLastChild (NULL) {}
56 // Empty constructor
57
58 LDOM_Node (const LDOM_Node& anOther)
59 : myDocument (anOther.myDocument),
60 myOrigin (anOther.myOrigin),
61 myLastChild (anOther.myLastChild) {}
62 // Copy constructor
63
64 Standard_EXPORT const LDOM_MemManager& getOwnerDocument () const;
65
66 Standard_EXPORT LDOM_Node&
67 operator = (const LDOM_Node& anOther);
68
69 Standard_EXPORT LDOM_Node&
70 operator = (const LDOM_NullPtr * aNull);
71
72 Standard_Boolean operator == (const LDOM_NullPtr *) const
73 { return isNull(); }
74
75 Standard_Boolean operator != (const LDOM_NullPtr *) const
76 { return ! isNull(); }
77
78 Standard_EXPORT Standard_Boolean
79 operator == (const LDOM_Node& anOther) const;
80
81 Standard_EXPORT Standard_Boolean
82 operator != (const LDOM_Node& anOther) const;
83
84 Standard_EXPORT Standard_Boolean
85 isNull () const;
86
87 Standard_EXPORT NodeType
88 getNodeType () const;
89
90 Standard_EXPORT LDOMString
91 getNodeName () const;
92
93 Standard_EXPORT LDOMString
94 getNodeValue () const;
95
96 Standard_EXPORT LDOM_Node
97 getFirstChild () const;
98
99 Standard_EXPORT LDOM_Node
100 getLastChild () const;
101
102 Standard_EXPORT LDOM_Node
103 getNextSibling () const;
104
105 Standard_EXPORT void removeChild (const LDOM_Node& aChild);
106
107 Standard_EXPORT void appendChild (const LDOM_Node& aChild);
108
109 Standard_EXPORT Standard_Boolean
110 hasChildNodes () const;
111
112 Standard_EXPORT void SetValueClear () const;
113 // Avoids checking for '<', '&', '\'', '\"', etc. on storage (saves time)
114 // You MUST be pretty sure that the node value string is OK in this sense
115 // NEVER call this method if you are not stuck on the performance
116
117 protected:
118friend class LDOM_BasicAttribute;
119friend class LDOM_BasicElement;
120friend class LDOM_BasicText;
121friend class LDOM_NodeList;
122 // ---------- PROTECTED METHODS ----------
123
124 const LDOM_BasicNode& Origin () const;
125
126 LDOM_Node (const LDOM_BasicNode& anOrig, const Handle(LDOM_MemManager)& aDoc)
127 : myDocument (aDoc),
128 myOrigin ((LDOM_BasicNode *) &anOrig),
129 myLastChild (NULL) {}
130 // Copy constructor with assignment to Document
131
132 protected:
133 // ---------- PROTECTED FIELDS ----------
134
135 // smart pointer to document owner of the node
136 Handle(LDOM_MemManager) myDocument;
137
138 // pointer to (non-transient) node data in the document-managed memory
139 LDOM_BasicNode * myOrigin;
140
141 // Transient data (only applicable to LDOM_Element type):
142 // the last child; myLastChild->mySibling points to the first attribute
143 const LDOM_BasicNode * myLastChild;
144
145 friend char * db_pretty_print (const LDOM_Node *, int, char *);
146};
147
148#endif