0027277: geom/extruded_00/A0: OCAF document is not opened correctly
[occt.git] / src / StdLPersistent / StdLPersistent_HString.cxx
CommitLineData
ff205346 1// Copyright (c) 2015 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
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.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#include <StdLPersistent_HString.hxx>
15#include <StdObjMgt_ReadData.hxx>
16#include <TDF_Label.hxx>
17#include <TDF_Tool.hxx>
18
19
20//=======================================================================
21//function : Read
22//purpose : Read persistent data from a file
23//=======================================================================
24template <class StringClass, typename CharType>
25void StdLPersistent_HString::instance<StringClass, CharType>::Read
26 (StdObjMgt_ReadData& theReadData)
27{
45d8465e 28 StdObjMgt_ReadData::Object anObjectData (theReadData);
ff205346 29
30 Standard_Integer aSize;
45d8465e 31 anObjectData >> aSize;
ff205346 32 myValue = new StringClass (aSize, 0);
33
34 for (Standard_Integer i = 1; i <= aSize; i++)
35 {
36 CharType aChar;
45d8465e 37 anObjectData >> aChar;
ff205346 38 myValue->SetValue (i, aChar);
39 }
ff205346 40}
41
42//=======================================================================
43//function : Label
44//purpose : Get/create a label defined by referenced string
45//=======================================================================
46template <class StringClass, typename CharType>
47TDF_Label StdLPersistent_HString::instance<StringClass, CharType>::Label
48 (const Handle(TDF_Data)& theDF) const
49{
50 TDF_Label aLabel;
51
52 if (!myValue.IsNull())
53 TDF_Tool::Label (theDF, myValue->String(), aLabel, Standard_True);
54
55 return aLabel;
56}
57
58//=======================================================================
59//function : AsciiString
60//purpose : Get referenced ASCII string
61//=======================================================================
62Handle(TCollection_HAsciiString)
63 StdLPersistent_HString::Ascii::AsciiString() const
64 { return myValue; }
65
66//=======================================================================
67//function : ExtString
68//purpose : Get referenced extended string
69//=======================================================================
70Handle(TCollection_HExtendedString)
71 StdLPersistent_HString::Extended::ExtString() const
72 { return myValue; }
73
74
75template class StdLPersistent_HString::instance
76 <TCollection_HAsciiString, Standard_Character>;
77
78template class StdLPersistent_HString::instance
79 <TCollection_HExtendedString, Standard_ExtCharacter>;