1 // Created on: 2007-08-01
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <BinMDataStd_AsciiStringDriver.hxx>
18 #include <BinMDF_ADriver.hxx>
19 #include <BinObjMgt_Persistent.hxx>
20 #include <BinObjMgt_RRelocationTable.hxx>
21 #include <BinObjMgt_SRelocationTable.hxx>
22 #include <CDM_MessageDriver.hxx>
23 #include <Standard_Type.hxx>
24 #include <TDataStd_AsciiString.hxx>
25 #include <TDF_Attribute.hxx>
26 #include <BinMDataStd.hxx>
28 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_AsciiStringDriver,BinMDF_ADriver)
30 //=======================================================================
31 //function : BinMDataStd_AsciiStringDriver
33 //=======================================================================
34 BinMDataStd_AsciiStringDriver::BinMDataStd_AsciiStringDriver
35 (const Handle(CDM_MessageDriver)& theMessageDriver)
36 : BinMDF_ADriver (theMessageDriver, STANDARD_TYPE(TDataStd_AsciiString)->Name())
40 //=======================================================================
43 //=======================================================================
45 Handle(TDF_Attribute) BinMDataStd_AsciiStringDriver::NewEmpty() const
47 return new TDataStd_AsciiString;
50 //=======================================================================
52 //purpose : persistent -> transient (retrieve)
53 //=======================================================================
55 Standard_Boolean BinMDataStd_AsciiStringDriver::Paste
56 (const BinObjMgt_Persistent& Source,
57 const Handle(TDF_Attribute)& Target,
58 BinObjMgt_RRelocationTable& /*RelocTable*/) const
60 Handle(TDataStd_AsciiString) aStrAtt = Handle(TDataStd_AsciiString)::DownCast(Target);
61 TCollection_AsciiString aString;
62 Standard_Boolean ok = Source >> aString;
64 aStrAtt->Set( aString );
65 if(BinMDataStd::DocumentVersion() > 8) { // process user defined guid
66 const Standard_Integer& aPos = Source.Position();
70 Source.SetPosition(aPos);
71 aStrAtt->SetID(TDataStd_AsciiString::GetID());
74 aStrAtt->SetID(aGuid);
77 aStrAtt->SetID(TDataStd_AsciiString::GetID());
81 //=======================================================================
83 //purpose : transient -> persistent (store)
84 //=======================================================================
86 void BinMDataStd_AsciiStringDriver::Paste
87 (const Handle(TDF_Attribute)& Source,
88 BinObjMgt_Persistent& Target,
89 BinObjMgt_SRelocationTable& /*RelocTable*/) const
91 Handle(TDataStd_AsciiString) anAtt = Handle(TDataStd_AsciiString)::DownCast(Source);
92 Target << anAtt->Get();
93 // process user defined guid
94 if(anAtt->ID() != TDataStd_AsciiString::GetID())
95 Target << anAtt->ID();