0022627: Change OCCT memory management defaults
[occt.git] / src / BinMDataStd / BinMDataStd_ExtStringListDriver.cxx
1 // File:        BinMDataStd_ExtStringListDriver.cxx
2 // Created:     May 29 11:40:00 2007
3 // Author:      Vlad Romashko
4 //              <vladislav.romashko@opencascade.com>
5 // Copyright:   Open CASCADE
6
7 #include <BinMDataStd_ExtStringListDriver.ixx>
8 #include <TDataStd_ExtStringList.hxx>
9 #include <TColStd_Array1OfExtendedString.hxx>
10 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
11
12 //=======================================================================
13 //function : BinMDataStd_ExtStringListDriver
14 //purpose  : Constructor
15 //=======================================================================
16 BinMDataStd_ExtStringListDriver::BinMDataStd_ExtStringListDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
17      : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TDataStd_ExtStringList)->Name())
18 {
19
20 }
21
22 //=======================================================================
23 //function : NewEmpty
24 //purpose  : 
25 //=======================================================================
26 Handle(TDF_Attribute) BinMDataStd_ExtStringListDriver::NewEmpty() const
27 {
28   return new TDataStd_ExtStringList();
29 }
30
31 //=======================================================================
32 //function : Paste
33 //purpose  : persistent -> transient (retrieve)
34 //=======================================================================
35 Standard_Boolean BinMDataStd_ExtStringListDriver::Paste(const BinObjMgt_Persistent&  theSource,
36                                                         const Handle(TDF_Attribute)& theTarget,
37                                                         BinObjMgt_RRelocationTable&  ) const
38 {
39   Standard_Integer aFirstInd, aLastInd;
40   if (! (theSource >> aFirstInd >> aLastInd))
41     return Standard_False;
42   const Standard_Integer aLength = aLastInd - aFirstInd + 1;
43   if (aLength <= 0)
44     return Standard_False;
45
46   Handle(TDataStd_ExtStringList) anAtt = Handle(TDataStd_ExtStringList)::DownCast(theTarget);
47   for (Standard_Integer i = aFirstInd; i <= aLastInd; i ++)
48   {
49     TCollection_ExtendedString aStr;
50     if ( !(theSource >> aStr) )
51     {
52       return Standard_False;
53     }
54     anAtt->Append(aStr);
55   }
56
57   return Standard_True;
58 }
59
60 //=======================================================================
61 //function : Paste
62 //purpose  : transient -> persistent (store)
63 //=======================================================================
64 void BinMDataStd_ExtStringListDriver::Paste(const Handle(TDF_Attribute)& theSource,
65                                             BinObjMgt_Persistent&        theTarget,
66                                             BinObjMgt_SRelocationTable&  ) const
67 {
68   Handle(TDataStd_ExtStringList) anAtt = Handle(TDataStd_ExtStringList)::DownCast(theSource);
69   const Standard_Integer aFirstInd = 1;
70   const Standard_Integer aLastInd  = anAtt->Extent();
71   theTarget << aFirstInd << aLastInd;
72   TDataStd_ListIteratorOfListOfExtendedString itr(anAtt->List());
73   for (; itr.More(); itr.Next())
74   {
75     theTarget << itr.Value();
76   }
77 }