1 // Created on: 2004-08-24
2 // Created by: Pavel TELKOV
3 // Copyright (c) 2004-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.hxx>
18 #include <BinMDataStd_ExtStringArrayDriver.hxx>
19 #include <BinObjMgt_Persistent.hxx>
20 #include <Message_Messenger.hxx>
21 #include <Standard_Type.hxx>
22 #include <TColStd_Array1OfExtendedString.hxx>
23 #include <TColStd_HArray1OfExtendedString.hxx>
24 #include <TDataStd_ExtStringArray.hxx>
25 #include <TDF_Attribute.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_ExtStringArrayDriver,BinMDF_ADriver)
29 //=======================================================================
30 //function : BinMDataStd_ExtStringArrayDriver
31 //purpose : Constructor
32 //=======================================================================
33 BinMDataStd_ExtStringArrayDriver::BinMDataStd_ExtStringArrayDriver
34 (const Handle(Message_Messenger)& theMsgDriver)
35 : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataStd_ExtStringArray)->Name())
39 //=======================================================================
42 //=======================================================================
44 Handle(TDF_Attribute) BinMDataStd_ExtStringArrayDriver::NewEmpty() const
46 return new TDataStd_ExtStringArray();
49 //=======================================================================
51 //purpose : persistent -> transient (retrieve)
52 //=======================================================================
54 Standard_Boolean BinMDataStd_ExtStringArrayDriver::Paste
55 (const BinObjMgt_Persistent& theSource,
56 const Handle(TDF_Attribute)& theTarget,
57 BinObjMgt_RRelocationTable& theRelocTable) const
59 Standard_Integer aFirstInd, aLastInd;
60 if (! (theSource >> aFirstInd >> aLastInd))
61 return Standard_False;
62 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
64 return Standard_False;
66 Handle(TDataStd_ExtStringArray) anAtt =
67 Handle(TDataStd_ExtStringArray)::DownCast(theTarget);
68 anAtt->Init(aFirstInd, aLastInd);
69 TColStd_Array1OfExtendedString& aTargetArray = anAtt->Array()->ChangeArray1();
70 Standard_Boolean ok = Standard_True;
71 for (Standard_Integer i = aFirstInd; i <= aLastInd; i ++)
73 TCollection_ExtendedString aStr;
74 if ( !(theSource >> aStr) )
79 aTargetArray.SetValue( i, aStr );
83 Standard_Boolean aDelta(Standard_False);
84 if(theRelocTable.GetHeaderData()->StorageVersion().IntegerValue() > 2) {
85 Standard_Byte aDeltaValue;
86 if (! (theSource >> aDeltaValue)) {
87 return Standard_False;
90 aDelta = (aDeltaValue != 0);
92 anAtt->SetDelta(aDelta);
95 BinMDataStd::SetAttributeID(theSource, anAtt, theRelocTable.GetHeaderData()->StorageVersion().IntegerValue());
99 //=======================================================================
101 //purpose : transient -> persistent (store)
102 //=======================================================================
104 void BinMDataStd_ExtStringArrayDriver::Paste
105 (const Handle(TDF_Attribute)& theSource,
106 BinObjMgt_Persistent& theTarget,
107 BinObjMgt_SRelocationTable& ) const
109 const Handle(TDataStd_ExtStringArray) anAtt =
110 Handle(TDataStd_ExtStringArray)::DownCast(theSource);
111 const TColStd_Array1OfExtendedString& aSourceArray = anAtt->Array()->Array1();
112 const Standard_Integer aFirstInd = aSourceArray.Lower();
113 const Standard_Integer aLastInd = aSourceArray.Upper();
114 theTarget << aFirstInd << aLastInd;
115 for (Standard_Integer i = aFirstInd; i <= aLastInd; i ++)
116 theTarget << anAtt->Value( i );
118 theTarget << (Standard_Byte)(anAtt->GetDelta() ? 1 : 0);
120 // process user defined guid
121 if(anAtt->ID() != TDataStd_ExtStringArray::GetID())
122 theTarget << anAtt->ID();