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.
17 #include <BinMDataStd_ExtStringListDriver.hxx>
18 #include <BinObjMgt_Persistent.hxx>
19 #include <CDM_MessageDriver.hxx>
20 #include <Standard_Type.hxx>
21 #include <TColStd_Array1OfExtendedString.hxx>
22 #include <TDataStd_ExtStringList.hxx>
23 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
24 #include <TDF_Attribute.hxx>
26 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_ExtStringListDriver,BinMDF_ADriver)
28 //=======================================================================
29 //function : BinMDataStd_ExtStringListDriver
30 //purpose : Constructor
31 //=======================================================================
32 BinMDataStd_ExtStringListDriver::BinMDataStd_ExtStringListDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
33 : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataStd_ExtStringList)->Name())
38 //=======================================================================
41 //=======================================================================
42 Handle(TDF_Attribute) BinMDataStd_ExtStringListDriver::NewEmpty() const
44 return new TDataStd_ExtStringList();
47 //=======================================================================
49 //purpose : persistent -> transient (retrieve)
50 //=======================================================================
51 Standard_Boolean BinMDataStd_ExtStringListDriver::Paste
52 (const BinObjMgt_Persistent& theSource,
53 const Handle(TDF_Attribute)& theTarget,
54 BinObjMgt_RRelocationTable& ) const
56 Standard_Integer aFirstInd, aLastInd;
57 if (! (theSource >> aFirstInd >> aLastInd))
58 return Standard_False;
59 if(aLastInd == 0) return Standard_True;
60 const Standard_Integer aLength = aLastInd - aFirstInd + 1;
62 return Standard_False;
63 const Handle(TDataStd_ExtStringList) anAtt =
64 Handle(TDataStd_ExtStringList)::DownCast(theTarget);
65 for (Standard_Integer i = aFirstInd; i <= aLastInd; i ++)
67 TCollection_ExtendedString aStr;
68 if ( !(theSource >> aStr) )
70 return Standard_False;
78 //=======================================================================
80 //purpose : transient -> persistent (store)
81 //=======================================================================
82 void BinMDataStd_ExtStringListDriver::Paste
83 (const Handle(TDF_Attribute)& theSource,
84 BinObjMgt_Persistent& theTarget,
85 BinObjMgt_SRelocationTable& ) const
87 const Handle(TDataStd_ExtStringList) anAtt =
88 Handle(TDataStd_ExtStringList)::DownCast(theSource);
89 const Standard_Integer aFirstInd = (anAtt->Extent()> 0) ? 1 : 0;
90 const Standard_Integer aLastInd(anAtt->Extent());
91 theTarget << aFirstInd << aLastInd;
92 TDataStd_ListIteratorOfListOfExtendedString itr(anAtt->List());
93 for (; itr.More(); itr.Next())
95 theTarget << itr.Value();