0025397: Iteration on a tree of nodes is too slow
[occt.git] / src / TDataStd / TDataStd_AsciiString.cxx
1 // Created on: 2007-07-31
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <TDataStd_AsciiString.ixx>
17 #include <Standard_GUID.hxx>
18 #include <TDF_Label.hxx>
19
20 //=======================================================================
21 //function : TDataStd_AsciiString
22 //purpose  : 
23 //=======================================================================
24
25 TDataStd_AsciiString::TDataStd_AsciiString()
26 {
27   myString.Clear();
28 }
29
30 //=======================================================================
31 //function : GetID
32 //purpose  : 
33 //=======================================================================
34
35 const Standard_GUID& TDataStd_AsciiString::GetID()
36 {
37   static Standard_GUID theGUID ("3bbefc60-e618-11d4-ba38-0060b0ee18ea");
38   return theGUID;
39 }
40
41 //=======================================================================
42 //function : ID
43 //purpose  : 
44 //=======================================================================
45
46 const Standard_GUID& TDataStd_AsciiString::ID() const
47 {
48   return GetID();
49 }
50
51 //=======================================================================
52 //function : Set
53 //purpose  : 
54 //=======================================================================
55
56 Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
57                              const TDF_Label& theLabel,
58                              const TCollection_AsciiString& theAsciiString)
59 {
60   Handle(TDataStd_AsciiString) A;
61   if (!theLabel.FindAttribute(TDataStd_AsciiString::GetID(), A))
62   {
63     A = new TDataStd_AsciiString;
64     theLabel.AddAttribute(A);
65   }
66   A->Set(theAsciiString);
67   return A;
68 }
69
70 //=======================================================================
71 //function : Set
72 //purpose  : 
73 //=======================================================================
74
75 void TDataStd_AsciiString::Set (const TCollection_AsciiString& theAsciiString)
76 {
77   Backup();
78   myString = theAsciiString;
79 }
80
81 //=======================================================================
82 //function : Get
83 //purpose  : 
84 //=======================================================================
85
86 const TCollection_AsciiString& TDataStd_AsciiString::Get () const
87 {
88   return myString;
89 }
90
91 //=======================================================================
92 //function : NewEmpty
93 //purpose  : 
94 //=======================================================================
95
96 Handle(TDF_Attribute) TDataStd_AsciiString::NewEmpty () const
97 {
98   return new TDataStd_AsciiString();
99 }
100
101 //=======================================================================
102 //function : Restore
103 //purpose  : 
104 //=======================================================================
105
106 void TDataStd_AsciiString::Restore (const Handle(TDF_Attribute)& theWith)
107 {
108   Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast(theWith);
109   myString = R->Get();
110 }
111
112 //=======================================================================
113 //function : Paste
114 //purpose  : 
115 //=======================================================================
116
117 void TDataStd_AsciiString::Paste (const Handle(TDF_Attribute)& theInto,
118                               const Handle(TDF_RelocationTable)& /* RT */) const
119
120   Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast (theInto);
121   R->Set(myString);
122 }
123
124 //=======================================================================
125 //function : IsEmpty
126 //purpose  : 
127 //=======================================================================
128 Standard_Boolean TDataStd_AsciiString::IsEmpty () const
129 {
130   return myString.IsEmpty();
131 }
132 //=======================================================================
133 //function : Dump
134 //purpose  : 
135 //=======================================================================
136
137 Standard_OStream& TDataStd_AsciiString::Dump(Standard_OStream& theOS) const
138 {
139   Standard_OStream& anOS = TDF_Attribute::Dump( theOS );
140   anOS << myString;
141   return anOS;
142 }