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