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 140202: Repl.(const char *) for (LDOMBasicString) => myTagName |
7fd59977 |
17 | |
18 | #ifndef LDOM_BasicElement_HeaderFile |
19 | #define LDOM_BasicElement_HeaderFile |
20 | |
21 | #include <LDOM_BasicNode.hxx> |
22 | #include <LDOMBasicString.hxx> |
23 | #include <LDOM_Node.hxx> |
24 | |
25 | class LDOM_XmlReader; |
26 | class LDOMParser; |
27 | class LDOM_NodeList; |
28 | class LDOM_Element; |
29 | class LDOM_BasicAttribute; |
30 | |
7fd59977 |
31 | // Class LDOM_BasicElement |
32 | // |
33 | |
34 | class LDOM_BasicElement : public LDOM_BasicNode |
35 | { |
36 | public: |
7fd59977 |
37 | |
38 | // ---------- PUBLIC METHODS ---------- |
39 | |
40 | LDOM_BasicElement () |
41 | : LDOM_BasicNode (LDOM_Node::UNKNOWN), |
42 | myTagName (NULL), |
43 | myAttributeMask (0), |
44 | myFirstChild (NULL) {} |
45 | // Empty constructor |
46 | |
47 | static LDOM_BasicElement& Create (const char * aName, |
48 | const Standard_Integer aLength, |
49 | const Handle(LDOM_MemManager)& aDoc); |
50 | |
51 | // Standard_EXPORT LDOM_BasicElement (const LDOM_BasicElement& theOther); |
52 | // Copy constructor |
53 | |
54 | Standard_EXPORT LDOM_BasicElement& |
55 | operator = (const LDOM_NullPtr * aNull); |
56 | // Nullify |
57 | |
58 | Standard_EXPORT ~LDOM_BasicElement (); |
59 | // Destructor |
60 | |
61 | const char * GetTagName () const { return myTagName; } |
62 | |
63 | const LDOM_BasicNode * |
64 | GetFirstChild () const { return myFirstChild; } |
65 | |
66 | Standard_EXPORT const LDOM_BasicNode * |
67 | GetLastChild () const; |
68 | |
69 | Standard_EXPORT const LDOM_BasicAttribute& |
70 | GetAttribute (const LDOMBasicString& aName, |
71 | const LDOM_BasicNode * aLastCh) const; |
72 | // Search for attribute name, using or setting myFirstAttribute |
73 | |
74 | protected: |
75 | // ---------- PROTECTED METHODS ---------- |
76 | |
77 | // LDOM_BasicElement (const LDOM_Element& anElement); |
78 | // Constructor |
79 | |
80 | Standard_EXPORT const LDOM_BasicNode * |
81 | AddAttribute (const LDOMBasicString& anAttrName, |
82 | const LDOMBasicString& anAttrValue, |
83 | const Handle(LDOM_MemManager)& aDoc, |
84 | const LDOM_BasicNode * aLastCh); |
85 | // add or replace an attribute to the element |
86 | |
87 | Standard_EXPORT const LDOM_BasicNode * |
88 | RemoveAttribute (const LDOMBasicString& aName, |
89 | const LDOM_BasicNode * aLastCh) const; |
90 | |
91 | Standard_EXPORT void |
92 | RemoveChild (const LDOM_BasicNode * aChild) const; |
93 | // remove a child element |
94 | |
95 | Standard_EXPORT void |
96 | AppendChild (const LDOM_BasicNode * aChild, |
97 | const LDOM_BasicNode *& aLastCh) const; |
98 | // append a child node to the end of the list |
99 | |
100 | private: |
101 | friend class LDOMParser; |
102 | friend class LDOM_XmlReader; |
103 | friend class LDOM_Document; |
104 | friend class LDOM_Element; |
105 | friend class LDOM_Node; |
106 | // ---------- PRIVATE METHODS ---------- |
107 | |
108 | const LDOM_BasicAttribute * |
109 | GetFirstAttribute (const LDOM_BasicNode *& aLastCh, |
110 | const LDOM_BasicNode **& thePrN) const; |
111 | |
112 | void RemoveNodes (); |
113 | |
114 | void ReplaceElement (const LDOM_BasicElement& anOther, |
115 | const Handle(LDOM_MemManager)& aDoc); |
116 | // remark: recursive |
117 | |
118 | void AddElementsByTagName (LDOM_NodeList& aList, |
119 | const LDOMBasicString& aTagName) const; |
120 | // remark: recursive |
121 | |
122 | void AddAttributes (LDOM_NodeList& aList, |
123 | const LDOM_BasicNode * aLastCh) const; |
124 | // add attributes to list |
125 | |
126 | private: |
127 | // ---------- PRIVATE FIELDS ---------- |
128 | |
129 | // LDOMBasicString myTagName; |
130 | const char * myTagName; |
131 | unsigned long myAttributeMask; |
132 | LDOM_BasicNode * myFirstChild; |
133 | }; |
134 | |
7fd59977 |
135 | #endif |