0024645: Pointer to the last is wrong for a tree node
[occt.git] / src / TDataStd / TDataStd_BooleanList.cxx
CommitLineData
b311480e 1// Created on: 2007-05-29
2// Created by: Vlad Romashko
973c2be1 3// Copyright (c) 2007-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 <TDataStd_BooleanList.ixx>
17#include <TDataStd_ListIteratorOfListOfByte.hxx>
18
19//=======================================================================
20//function : GetID
21//purpose :
22//=======================================================================
23const Standard_GUID& TDataStd_BooleanList::GetID()
24{
25 static Standard_GUID TDataStd_BooleanListID ("23A9D60E-A033-44d8-96EE-015587A41BBC");
26 return TDataStd_BooleanListID;
27}
28
29//=======================================================================
30//function : TDataStd_BooleanList
31//purpose : Empty Constructor
32//=======================================================================
33TDataStd_BooleanList::TDataStd_BooleanList()
34{
35
36}
37
38//=======================================================================
39//function : Set
40//purpose :
41//=======================================================================
42Handle(TDataStd_BooleanList) TDataStd_BooleanList::Set(const TDF_Label& label)
43{
44 Handle(TDataStd_BooleanList) A;
45 if (!label.FindAttribute (TDataStd_BooleanList::GetID(), A))
46 {
47 A = new TDataStd_BooleanList;
48 label.AddAttribute(A);
49 }
50 return A;
51}
52
53//=======================================================================
54//function : IsEmpty
55//purpose :
56//=======================================================================
57Standard_Boolean TDataStd_BooleanList::IsEmpty() const
58{
59 return myList.IsEmpty();
60}
61
62//=======================================================================
63//function : Extent
64//purpose :
65//=======================================================================
66Standard_Integer TDataStd_BooleanList::Extent() const
67{
68 return myList.Extent();
69}
70
71//=======================================================================
72//function : Prepend
73//purpose :
74//=======================================================================
75void TDataStd_BooleanList::Prepend(const Standard_Boolean value)
76{
77 Backup();
78 myList.Prepend( value ? 1 : 0 );
79}
80
81//=======================================================================
82//function : Append
83//purpose :
84//=======================================================================
85void TDataStd_BooleanList::Append(const Standard_Boolean value)
86{
87 Backup();
88 myList.Append( value ? 1 : 0 );
89}
90
91//=======================================================================
92//function : Clear
93//purpose :
94//=======================================================================
95void TDataStd_BooleanList::Clear()
96{
97 Backup();
98 myList.Clear();
99}
100
101//=======================================================================
102//function : First
103//purpose :
104//=======================================================================
105Standard_Boolean TDataStd_BooleanList::First() const
106{
107 return myList.First() == 1;
108}
109
110//=======================================================================
111//function : Last
112//purpose :
113//=======================================================================
114Standard_Boolean TDataStd_BooleanList::Last() const
115{
116 return myList.Last() == 1;
117}
118
119//=======================================================================
120//function : List
121//purpose :
122//=======================================================================
123const TDataStd_ListOfByte& TDataStd_BooleanList::List() const
124{
125 return myList;
126}
127
128//=======================================================================
129//function : ID
130//purpose :
131//=======================================================================
132const Standard_GUID& TDataStd_BooleanList::ID () const
133{
134 return GetID();
135}
136
137//=======================================================================
138//function : NewEmpty
139//purpose :
140//=======================================================================
141Handle(TDF_Attribute) TDataStd_BooleanList::NewEmpty () const
142{
143 return new TDataStd_BooleanList();
144}
145
146//=======================================================================
147//function : Restore
148//purpose :
149//=======================================================================
150void TDataStd_BooleanList::Restore(const Handle(TDF_Attribute)& With)
151{
152 myList.Clear();
153 Handle(TDataStd_BooleanList) aList = Handle(TDataStd_BooleanList)::DownCast(With);
154 TDataStd_ListIteratorOfListOfByte itr(aList->List());
155 for (; itr.More(); itr.Next())
156 {
157 myList.Append(itr.Value());
158 }
159}
160
161//=======================================================================
162//function : Paste
163//purpose :
164//=======================================================================
165void TDataStd_BooleanList::Paste (const Handle(TDF_Attribute)& Into,
166 const Handle(TDF_RelocationTable)& ) const
167{
168 Handle(TDataStd_BooleanList) aList = Handle(TDataStd_BooleanList)::DownCast(Into);
169 aList->Clear();
170 TDataStd_ListIteratorOfListOfByte itr(myList);
171 for (; itr.More(); itr.Next())
172 {
173 aList->Append(itr.Value());
174 }
175}
176
177//=======================================================================
178//function : Dump
179//purpose :
180//=======================================================================
181Standard_OStream& TDataStd_BooleanList::Dump (Standard_OStream& anOS) const
182{
183 anOS << "BooleanList";
184 return anOS;
185}