b311480e |
1 | // Created on: 2001-06-28 |
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 | |
7fd59977 |
20 | |
21 | #include <LDOM_DeclareSequence.hxx> |
22 | #include <LDOM_NodeList.hxx> |
23 | #include <LDOM_BasicNode.hxx> |
24 | |
25 | typedef const LDOM_BasicNode * LDOM_BasicNodePtr; |
26 | |
27 | DECLARE_SEQUENCE (LDOM_BasicNodeSequence, LDOM_BasicNodePtr) |
28 | IMPLEMENT_SEQUENCE (LDOM_BasicNodeSequence, LDOM_BasicNodePtr) |
29 | |
30 | //======================================================================= |
31 | //function : LDOM_NodeList() |
32 | //purpose : Constructor |
33 | //======================================================================= |
34 | |
35 | LDOM_NodeList::LDOM_NodeList ( ) |
36 | { |
37 | mySeq = new LDOM_BasicNodeSequence; |
38 | } |
39 | |
40 | //======================================================================= |
41 | //function : LDOM_NodeList |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | LDOM_NodeList::LDOM_NodeList (const Handle(LDOM_MemManager)& aDoc) |
46 | : myDoc (aDoc) |
47 | { |
48 | mySeq = new LDOM_BasicNodeSequence; |
49 | } |
50 | |
51 | //======================================================================= |
52 | //function : Append |
53 | //purpose : |
54 | //======================================================================= |
55 | |
56 | void LDOM_NodeList::Append (const LDOM_BasicNode& aNode) const |
57 | { |
58 | mySeq -> Append (&aNode); |
59 | } |
60 | |
61 | //======================================================================= |
62 | //function : LDOM_NodeList |
63 | //purpose : Copy constructor |
64 | //======================================================================= |
65 | |
66 | LDOM_NodeList::LDOM_NodeList (const LDOM_NodeList& theOther) |
67 | { |
68 | mySeq = new LDOM_BasicNodeSequence; |
69 | * mySeq = * theOther.mySeq; |
70 | myDoc = theOther.myDoc; |
71 | } |
72 | |
73 | //======================================================================= |
74 | //function : ~LDOM_NodeList |
75 | //purpose : Destructor |
76 | //======================================================================= |
77 | |
78 | LDOM_NodeList::~LDOM_NodeList () |
79 | { |
80 | delete mySeq; |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : operator = |
85 | //purpose : Assignment |
86 | //======================================================================= |
87 | |
88 | LDOM_NodeList& LDOM_NodeList::operator = (const LDOM_NodeList& theOther) |
89 | { |
90 | myDoc = theOther.myDoc; |
91 | * mySeq = * theOther.mySeq; |
92 | return * this; |
93 | } |
94 | |
95 | //======================================================================= |
96 | //function : operator = |
97 | //purpose : Nullify |
98 | //======================================================================= |
99 | |
100 | LDOM_NodeList& LDOM_NodeList::operator = (const LDOM_NullPtr *) |
101 | { |
102 | myDoc.Nullify(); |
103 | mySeq -> Clear (); |
104 | return * this; |
105 | } |
106 | |
107 | //======================================================================= |
108 | //function : operator == |
109 | //purpose : |
110 | //======================================================================= |
111 | |
112 | Standard_Boolean LDOM_NodeList::operator == (const LDOM_NullPtr *) const |
113 | { |
114 | return myDoc.IsNull() || mySeq -> Length () == 0; |
115 | } |
116 | |
117 | //======================================================================= |
118 | //function : operator != |
119 | //purpose : |
120 | //======================================================================= |
121 | |
122 | Standard_Boolean LDOM_NodeList::operator != (const LDOM_NullPtr *) const |
123 | { |
124 | return ! (myDoc.IsNull() || mySeq -> Length () == 0); |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : item |
129 | //purpose : |
130 | //======================================================================= |
131 | |
132 | LDOM_Node LDOM_NodeList::item (const Standard_Integer anIndex) const |
133 | { |
134 | if (myDoc.IsNull() || anIndex < 0 || anIndex >= mySeq -> Length ()) |
135 | return LDOM_Node(); |
136 | return LDOM_Node (* mySeq -> Value(anIndex+1), myDoc); |
137 | } |
138 | |
139 | //======================================================================= |
140 | //function : getLength |
141 | //purpose : |
142 | //======================================================================= |
143 | |
144 | Standard_Integer LDOM_NodeList::getLength () const |
145 | { |
146 | return mySeq -> Length(); |
147 | } |
148 | |