44b969d5ce18fde1e45b70dea75db6cad7a0d850
[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
17 #include <Standard_GUID.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_AsciiString.hxx>
20 #include <TDataStd_AsciiString.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <TDF_Label.hxx>
23 #include <TDF_RelocationTable.hxx>
24
25 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_AsciiString,TDF_Attribute)
26
27 //=======================================================================
28 //function : TDataStd_AsciiString
29 //purpose  : 
30 //=======================================================================
31 TDataStd_AsciiString::TDataStd_AsciiString()
32 {
33   myString.Clear();
34 }
35
36 //=======================================================================
37 //function : GetID
38 //purpose  : 
39 //=======================================================================
40
41 const Standard_GUID& TDataStd_AsciiString::GetID()
42 {
43   static Standard_GUID theGUID ("3bbefc60-e618-11d4-ba38-0060b0ee18ea");
44   return theGUID;
45 }
46
47 //=======================================================================
48 //function : ID
49 //purpose  : 
50 //=======================================================================
51
52 const Standard_GUID& TDataStd_AsciiString::ID() const
53 {
54   return GetID();
55 }
56
57 //=======================================================================
58 //function : Set
59 //purpose  : 
60 //=======================================================================
61
62 Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
63                              const TDF_Label& theLabel,
64                              const TCollection_AsciiString& theAsciiString)
65 {
66   Handle(TDataStd_AsciiString) A;
67   if (!theLabel.FindAttribute(TDataStd_AsciiString::GetID(), A))
68   {
69     A = new TDataStd_AsciiString;
70     theLabel.AddAttribute(A);
71   }
72   A->Set(theAsciiString);
73   return A;
74 }
75
76 //=======================================================================
77 //function : Set
78 //purpose  : 
79 //=======================================================================
80
81 void TDataStd_AsciiString::Set (const TCollection_AsciiString& theAsciiString)
82 {
83   Backup();
84   myString = theAsciiString;
85 }
86
87 //=======================================================================
88 //function : Get
89 //purpose  : 
90 //=======================================================================
91
92 const TCollection_AsciiString& TDataStd_AsciiString::Get () const
93 {
94   return myString;
95 }
96
97 //=======================================================================
98 //function : NewEmpty
99 //purpose  : 
100 //=======================================================================
101
102 Handle(TDF_Attribute) TDataStd_AsciiString::NewEmpty () const
103 {
104   return new TDataStd_AsciiString();
105 }
106
107 //=======================================================================
108 //function : Restore
109 //purpose  : 
110 //=======================================================================
111
112 void TDataStd_AsciiString::Restore (const Handle(TDF_Attribute)& theWith)
113 {
114   Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast(theWith);
115   myString = R->Get();
116 }
117
118 //=======================================================================
119 //function : Paste
120 //purpose  : 
121 //=======================================================================
122
123 void TDataStd_AsciiString::Paste (const Handle(TDF_Attribute)& theInto,
124                               const Handle(TDF_RelocationTable)& /* RT */) const
125
126   Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast (theInto);
127   R->Set(myString);
128 }
129
130 //=======================================================================
131 //function : IsEmpty
132 //purpose  : 
133 //=======================================================================
134 Standard_Boolean TDataStd_AsciiString::IsEmpty () const
135 {
136   return myString.IsEmpty();
137 }
138 //=======================================================================
139 //function : Dump
140 //purpose  : 
141 //=======================================================================
142
143 Standard_OStream& TDataStd_AsciiString::Dump(Standard_OStream& theOS) const
144 {
145   Standard_OStream& anOS = TDF_Attribute::Dump( theOS );
146   anOS << myString;
147   return anOS;
148 }