1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <Standard_GUID.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_ExtendedString.hxx>
20 #include <TDataStd_ExtStringList.hxx>
21 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
22 #include <TDF_Attribute.hxx>
23 #include <TDF_Label.hxx>
24 #include <TDF_RelocationTable.hxx>
26 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_ExtStringList,TDF_Attribute)
28 //=======================================================================
31 //=======================================================================
32 const Standard_GUID& TDataStd_ExtStringList::GetID()
34 static Standard_GUID TDataStd_ExtStringListID ("D13FBE0A-E084-4912-A99D-7713C59C0AC4");
35 return TDataStd_ExtStringListID;
38 //=======================================================================
39 //function : TDataStd_ExtStringList
40 //purpose : Empty Constructor
41 //=======================================================================
42 TDataStd_ExtStringList::TDataStd_ExtStringList()
47 //=======================================================================
50 //=======================================================================
51 Handle(TDataStd_ExtStringList) TDataStd_ExtStringList::Set(const TDF_Label& label)
53 Handle(TDataStd_ExtStringList) A;
54 if (!label.FindAttribute (TDataStd_ExtStringList::GetID(), A))
56 A = new TDataStd_ExtStringList;
57 label.AddAttribute(A);
62 //=======================================================================
65 //=======================================================================
66 Standard_Boolean TDataStd_ExtStringList::IsEmpty() const
68 return myList.IsEmpty();
71 //=======================================================================
74 //=======================================================================
75 Standard_Integer TDataStd_ExtStringList::Extent() const
77 return myList.Extent();
80 //=======================================================================
83 //=======================================================================
84 void TDataStd_ExtStringList::Prepend(const TCollection_ExtendedString& value)
87 myList.Prepend(value);
90 //=======================================================================
93 //=======================================================================
94 void TDataStd_ExtStringList::Append(const TCollection_ExtendedString& value)
100 //=======================================================================
101 //function : InsertBefore
103 //=======================================================================
104 Standard_Boolean TDataStd_ExtStringList::InsertBefore(const TCollection_ExtendedString& value,
105 const TCollection_ExtendedString& before_value)
107 TDataStd_ListIteratorOfListOfExtendedString itr(myList);
108 for (; itr.More(); itr.Next())
110 if (itr.Value() == before_value)
113 myList.InsertBefore(value, itr);
114 return Standard_True;
117 return Standard_False;
120 //=======================================================================
121 //function : InsertAfter
123 //=======================================================================
124 Standard_Boolean TDataStd_ExtStringList::InsertAfter(const TCollection_ExtendedString& value,
125 const TCollection_ExtendedString& after_value)
127 TDataStd_ListIteratorOfListOfExtendedString itr(myList);
128 for (; itr.More(); itr.Next())
130 if (itr.Value() == after_value)
133 myList.InsertAfter(value, itr);
134 return Standard_True;
137 return Standard_False;
140 //=======================================================================
143 //=======================================================================
144 Standard_Boolean TDataStd_ExtStringList::Remove(const TCollection_ExtendedString& value)
146 TDataStd_ListIteratorOfListOfExtendedString itr(myList);
147 for (; itr.More(); itr.Next())
149 if (itr.Value() == value)
153 return Standard_True;
156 return Standard_False;
159 //=======================================================================
162 //=======================================================================
163 void TDataStd_ExtStringList::Clear()
169 //=======================================================================
172 //=======================================================================
173 const TCollection_ExtendedString& TDataStd_ExtStringList::First() const
175 return myList.First();
178 //=======================================================================
181 //=======================================================================
182 const TCollection_ExtendedString& TDataStd_ExtStringList::Last() const
184 return myList.Last();
187 //=======================================================================
190 //=======================================================================
191 const TDataStd_ListOfExtendedString& TDataStd_ExtStringList::List() const
196 //=======================================================================
199 //=======================================================================
200 const Standard_GUID& TDataStd_ExtStringList::ID () const
205 //=======================================================================
206 //function : NewEmpty
208 //=======================================================================
209 Handle(TDF_Attribute) TDataStd_ExtStringList::NewEmpty () const
211 return new TDataStd_ExtStringList();
214 //=======================================================================
217 //=======================================================================
218 void TDataStd_ExtStringList::Restore(const Handle(TDF_Attribute)& With)
221 Handle(TDataStd_ExtStringList) aList = Handle(TDataStd_ExtStringList)::DownCast(With);
222 TDataStd_ListIteratorOfListOfExtendedString itr(aList->List());
223 for (; itr.More(); itr.Next())
225 myList.Append(itr.Value());
229 //=======================================================================
232 //=======================================================================
233 void TDataStd_ExtStringList::Paste (const Handle(TDF_Attribute)& Into,
234 const Handle(TDF_RelocationTable)& ) const
236 Handle(TDataStd_ExtStringList) aList = Handle(TDataStd_ExtStringList)::DownCast(Into);
238 TDataStd_ListIteratorOfListOfExtendedString itr(myList);
239 for (; itr.More(); itr.Next())
241 aList->Append(itr.Value());
245 //=======================================================================
248 //=======================================================================
249 Standard_OStream& TDataStd_ExtStringList::Dump (Standard_OStream& anOS) const
251 anOS << "ExtStringList";