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_ReferenceListDriver.ixx>
17 #include <TDataStd_ReferenceList.hxx>
18 #include <TDF_ListIteratorOfLabelList.hxx>
19 #include <TDF_Label.hxx>
20 #include <TDF_Tool.hxx>
22 //=======================================================================
23 //function : BinMDataStd_ReferenceListDriver
24 //purpose : Constructor
25 //=======================================================================
26 BinMDataStd_ReferenceListDriver::BinMDataStd_ReferenceListDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
27 : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataStd_ReferenceList)->Name())
32 //=======================================================================
35 //=======================================================================
36 Handle(TDF_Attribute) BinMDataStd_ReferenceListDriver::NewEmpty() const
38 return new TDataStd_ReferenceList();
41 //=======================================================================
43 //purpose : persistent -> transient (retrieve)
44 //=======================================================================
45 Standard_Boolean BinMDataStd_ReferenceListDriver::Paste(const BinObjMgt_Persistent& theSource,
46 const Handle(TDF_Attribute)& theTarget,
47 BinObjMgt_RRelocationTable& ) const
49 Standard_Integer aFirstInd, aLastInd;
50 if (! (theSource >> aFirstInd >> aLastInd))
51 return Standard_False;
52 if(aLastInd == 0) return Standard_True;
54 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
56 return Standard_False;
58 const Handle(TDataStd_ReferenceList) anAtt = Handle(TDataStd_ReferenceList)::DownCast(theTarget);
59 for (Standard_Integer i = aFirstInd; i <= aLastInd; i++)
61 TCollection_AsciiString entry;
62 if ( !(theSource >> entry) )
63 return Standard_False;
65 TDF_Tool::Label(anAtt->Label().Data(), entry, L, Standard_True);
73 //=======================================================================
75 //purpose : transient -> persistent (store)
76 //=======================================================================
77 void BinMDataStd_ReferenceListDriver::Paste(const Handle(TDF_Attribute)& theSource,
78 BinObjMgt_Persistent& theTarget,
79 BinObjMgt_SRelocationTable& ) const
81 const Handle(TDataStd_ReferenceList) anAtt = Handle(TDataStd_ReferenceList)::DownCast(theSource);
84 const Standard_Integer aFirstInd = (anAtt->Extent()> 0) ? 1 : 0;
85 const Standard_Integer aLastInd(anAtt->Extent());
86 theTarget << aFirstInd << aLastInd;
87 if(aLastInd == 0) return;
88 TDF_ListIteratorOfLabelList itr(anAtt->List());
89 for (Standard_Integer i = aFirstInd; itr.More(); itr.Next(), i++)
91 TDF_Label L = itr.Value();
94 TCollection_AsciiString entry;
95 TDF_Tool::Entry(L, entry);