OCC18056 Exception during copying Array attribute with array(0,0)
[occt.git] / src / TDataStd / TDataStd_AsciiString.cxx
1 // File:        TDataStd_AsciiString.cxx
2 // Created:     Tue Jul 31 12:39:17 2007
3 // Author:      Sergey ZARITCHNY
4 //              <sergey.zaritchny@opencascade.com>
5 //Copyright:    Open CasCade SA 2007
6
7 #include <TDataStd_AsciiString.ixx>
8 #include <Standard_GUID.hxx>
9 #include <TDF_Label.hxx>
10
11 //=======================================================================
12 //function : TDataStd_AsciiString
13 //purpose  : 
14 //=======================================================================
15
16 TDataStd_AsciiString::TDataStd_AsciiString()
17 {
18   myString.Clear();
19 }
20
21 //=======================================================================
22 //function : GetID
23 //purpose  : 
24 //=======================================================================
25
26 const Standard_GUID& TDataStd_AsciiString::GetID()
27 {
28   static Standard_GUID theGUID ("3bbefc60-e618-11d4-ba38-0060b0ee18ea");
29   return theGUID;
30 }
31
32 //=======================================================================
33 //function : ID
34 //purpose  : 
35 //=======================================================================
36
37 const Standard_GUID& TDataStd_AsciiString::ID() const
38 {
39   return GetID();
40 }
41
42 //=======================================================================
43 //function : Set
44 //purpose  : 
45 //=======================================================================
46
47 Handle(TDataStd_AsciiString) TDataStd_AsciiString::Set (
48                              const TDF_Label& theLabel,
49                              const TCollection_AsciiString& theAsciiString)
50 {
51   Handle(TDataStd_AsciiString) A;
52   if (!theLabel.FindAttribute(TDataStd_AsciiString::GetID(), A))
53   {
54     A = new TDataStd_AsciiString;
55     theLabel.AddAttribute(A);
56   }
57   A->Set(theAsciiString);
58   return A;
59 }
60
61 //=======================================================================
62 //function : Set
63 //purpose  : 
64 //=======================================================================
65
66 void TDataStd_AsciiString::Set (const TCollection_AsciiString& theAsciiString)
67 {
68   Backup();
69   myString = theAsciiString;
70 }
71
72 //=======================================================================
73 //function : Get
74 //purpose  : 
75 //=======================================================================
76
77 const TCollection_AsciiString& TDataStd_AsciiString::Get () const
78 {
79   return myString;
80 }
81
82 //=======================================================================
83 //function : NewEmpty
84 //purpose  : 
85 //=======================================================================
86
87 Handle(TDF_Attribute) TDataStd_AsciiString::NewEmpty () const
88 {
89   return new TDataStd_AsciiString();
90 }
91
92 //=======================================================================
93 //function : Restore
94 //purpose  : 
95 //=======================================================================
96
97 void TDataStd_AsciiString::Restore (const Handle(TDF_Attribute)& theWith)
98 {
99   Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast(theWith);
100   myString = R->Get();
101 }
102
103 //=======================================================================
104 //function : Paste
105 //purpose  : 
106 //=======================================================================
107
108 void TDataStd_AsciiString::Paste (const Handle(TDF_Attribute)& theInto,
109                               const Handle(TDF_RelocationTable)& /* RT */) const
110
111   Handle(TDataStd_AsciiString) R = Handle(TDataStd_AsciiString)::DownCast (theInto);
112   R->Set(myString);
113 }
114
115 //=======================================================================
116 //function : IsEmpty
117 //purpose  : 
118 //=======================================================================
119 Standard_Boolean TDataStd_AsciiString::IsEmpty () const
120 {
121   return myString.IsEmpty();
122 }
123 //=======================================================================
124 //function : Dump
125 //purpose  : 
126 //=======================================================================
127
128 Standard_OStream& TDataStd_AsciiString::Dump(Standard_OStream& theOS) const
129 {
130   Standard_OStream& anOS = TDF_Attribute::Dump( theOS );
131   anOS << myString;
132   return anOS;
133 }