1 // Copyright (c) 2015 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <StdLPersistent_HString.hxx>
15 #include <StdObjMgt_ReadData.hxx>
16 #include <StdObjMgt_WriteData.hxx>
17 #include <TDF_Label.hxx>
18 #include <TDF_Tool.hxx>
21 //=======================================================================
23 //purpose : Read persistent data from a file
24 //=======================================================================
25 template <class StringClass, typename CharType>
26 void StdLPersistent_HString::instance<StringClass, CharType>::Read
27 (StdObjMgt_ReadData& theReadData)
29 StdObjMgt_ReadData::ObjectSentry aSentry (theReadData);
31 Standard_Integer aSize;
33 myValue = new StringClass (aSize, 0);
35 for (Standard_Integer i = 1; i <= aSize; i++)
39 myValue->SetValue (i, aChar);
43 //=======================================================================
45 //purpose : Write persistent data to a file
46 //=======================================================================
47 template <class StringClass, typename CharType>
48 void StdLPersistent_HString::instance<StringClass, CharType>::Write
49 (StdObjMgt_WriteData& theWriteData) const
51 StdObjMgt_WriteData::ObjectSentry aSentry (theWriteData);
53 Standard_Integer aSize = myValue->Length();
54 theWriteData << aSize;
56 for (Standard_Integer i = 1; i <= aSize; i++)
59 theWriteData << aChar;
63 //=======================================================================
65 //purpose : Get/create a label defined by referenced string
66 //=======================================================================
67 template <class StringClass, typename CharType>
68 TDF_Label StdLPersistent_HString::instance<StringClass, CharType>::Label
69 (const Handle(TDF_Data)& theDF) const
73 if (!myValue.IsNull())
74 TDF_Tool::Label (theDF, myValue->String(), aLabel, Standard_True);
79 //=======================================================================
80 //function : AsciiString
81 //purpose : Get referenced ASCII string
82 //=======================================================================
83 Handle(TCollection_HAsciiString)
84 StdLPersistent_HString::Ascii::AsciiString() const
87 //=======================================================================
88 //function : ExtString
89 //purpose : Get referenced extended string
90 //=======================================================================
91 Handle(TCollection_HExtendedString)
92 StdLPersistent_HString::Extended::ExtString() const
96 template class StdLPersistent_HString::instance
97 <TCollection_HAsciiString, Standard_Character>;
99 template class StdLPersistent_HString::instance
100 <TCollection_HExtendedString, Standard_ExtCharacter>;