1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
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.
16 #include <BinMDataStd_BooleanListDriver.ixx>
17 #include <TDataStd_BooleanList.hxx>
18 #include <TDataStd_ListIteratorOfListOfByte.hxx>
19 #include <TColStd_Array1OfByte.hxx>
21 //=======================================================================
22 //function : BinMDataStd_BooleanListDriver
23 //purpose : Constructor
24 //=======================================================================
25 BinMDataStd_BooleanListDriver::BinMDataStd_BooleanListDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
26 : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataStd_BooleanList)->Name())
31 //=======================================================================
34 //=======================================================================
35 Handle(TDF_Attribute) BinMDataStd_BooleanListDriver::NewEmpty() const
37 return new TDataStd_BooleanList();
40 //=======================================================================
42 //purpose : persistent -> transient (retrieve)
43 //=======================================================================
44 Standard_Boolean BinMDataStd_BooleanListDriver::Paste(const BinObjMgt_Persistent& theSource,
45 const Handle(TDF_Attribute)& theTarget,
46 BinObjMgt_RRelocationTable& ) const
48 Standard_Integer aIndex, aFirstInd, aLastInd;
49 if (! (theSource >> aFirstInd >> aLastInd))
50 return Standard_False;
51 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
53 return Standard_False;
55 TColStd_Array1OfByte aTargetArray(aFirstInd, aLastInd);
56 theSource.GetByteArray (&aTargetArray(aFirstInd), aLength);
58 Handle(TDataStd_BooleanList) anAtt = Handle(TDataStd_BooleanList)::DownCast(theTarget);
59 for (aIndex = aFirstInd; aIndex <= aLastInd; aIndex++)
61 anAtt->Append(aTargetArray.Value(aIndex) ? Standard_True : Standard_False);
66 //=======================================================================
68 //purpose : transient -> persistent (store)
69 //=======================================================================
70 void BinMDataStd_BooleanListDriver::Paste(const Handle(TDF_Attribute)& theSource,
71 BinObjMgt_Persistent& theTarget,
72 BinObjMgt_SRelocationTable& ) const
74 Handle(TDataStd_BooleanList) anAtt = Handle(TDataStd_BooleanList)::DownCast(theSource);
75 const Standard_Integer aFirstInd = 1;
76 const Standard_Integer aLastInd = anAtt->Extent();
77 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
80 theTarget << aFirstInd << aLastInd;
81 TColStd_Array1OfByte aSourceArray(aFirstInd, aLastInd);
84 TDataStd_ListIteratorOfListOfByte itr(anAtt->List());
85 for (Standard_Integer i = 1; itr.More(); itr.Next(), i++)
87 aSourceArray.SetValue(i, itr.Value());
89 Standard_Byte *aPtr = (Standard_Byte *) &aSourceArray(aFirstInd);
90 theTarget.PutByteArray(aPtr, aLength);