summaryrefslogtreecommitdiff
path: root/src/LDOM/LDOM_NodeList.cxx
blob: ceb8774dbc0bac498fc6446045879b1266fa45e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// File:      LDOM_NodeList.cxx
// Created:   28.06.01 15:05:19
// Author:    Alexander GRIGORIEV
// Copyright: OpenCascade 2001
// History:

#include <LDOM_DeclareSequence.hxx>
#include <LDOM_NodeList.hxx>
#include <LDOM_BasicNode.hxx>

typedef const LDOM_BasicNode * LDOM_BasicNodePtr;

DECLARE_SEQUENCE   (LDOM_BasicNodeSequence, LDOM_BasicNodePtr)
IMPLEMENT_SEQUENCE (LDOM_BasicNodeSequence, LDOM_BasicNodePtr)

//=======================================================================
//function : LDOM_NodeList()
//purpose  : Constructor
//=======================================================================

LDOM_NodeList::LDOM_NodeList (  )
{
  mySeq = new LDOM_BasicNodeSequence;
}

//=======================================================================
//function : LDOM_NodeList
//purpose  : 
//=======================================================================

LDOM_NodeList::LDOM_NodeList (const Handle(LDOM_MemManager)& aDoc)
     : myDoc (aDoc)
{
  mySeq = new LDOM_BasicNodeSequence;
}

//=======================================================================
//function : Append
//purpose  : 
//=======================================================================

void LDOM_NodeList::Append (const LDOM_BasicNode& aNode) const
{
  mySeq -> Append (&aNode);
}

//=======================================================================
//function : LDOM_NodeList
//purpose  : Copy constructor
//=======================================================================

LDOM_NodeList::LDOM_NodeList (const LDOM_NodeList& theOther)
{
  mySeq = new LDOM_BasicNodeSequence;
  * mySeq = * theOther.mySeq;
  myDoc = theOther.myDoc;
}

//=======================================================================
//function : ~LDOM_NodeList
//purpose  : Destructor
//=======================================================================

LDOM_NodeList::~LDOM_NodeList ()
{
  delete mySeq;
}

//=======================================================================
//function : operator =
//purpose  : Assignment
//=======================================================================

LDOM_NodeList& LDOM_NodeList::operator = (const LDOM_NodeList& theOther)
{
  myDoc = theOther.myDoc;
  * mySeq = * theOther.mySeq;
  return * this;
}
  
//=======================================================================
//function : operator =
//purpose  : Nullify
//=======================================================================

LDOM_NodeList& LDOM_NodeList::operator = (const LDOM_NullPtr *)
{
  myDoc.Nullify();
  mySeq -> Clear ();
  return * this;
}
  
//=======================================================================
//function : operator ==
//purpose  : 
//=======================================================================

Standard_Boolean LDOM_NodeList::operator == (const LDOM_NullPtr *) const
{
  return myDoc.IsNull() || mySeq -> Length () == 0;
}

//=======================================================================
//function : operator !=
//purpose  : 
//=======================================================================

Standard_Boolean LDOM_NodeList::operator != (const LDOM_NullPtr *) const
{
  return ! (myDoc.IsNull() || mySeq -> Length () == 0);
}

//=======================================================================
//function : item
//purpose  : 
//=======================================================================

LDOM_Node LDOM_NodeList::item (const Standard_Integer anIndex) const
{
  if (myDoc.IsNull() || anIndex < 0 || anIndex >= mySeq -> Length ())
    return LDOM_Node();
  return LDOM_Node (* mySeq -> Value(anIndex+1), myDoc);
}

//=======================================================================
//function : getLength
//purpose  : 
//=======================================================================

Standard_Integer LDOM_NodeList::getLength () const
{
  return mySeq -> Length();
}