b311480e |
1 | // Created on: 2007-05-29 |
2 | // Created by: Vlad Romashko |
973c2be1 |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
42cf5bc1 |
16 | |
17 | #include <BinMDataStd_ExtStringListDriver.hxx> |
18 | #include <BinObjMgt_Persistent.hxx> |
19 | #include <CDM_MessageDriver.hxx> |
20 | #include <Standard_Type.hxx> |
7fd59977 |
21 | #include <TColStd_Array1OfExtendedString.hxx> |
42cf5bc1 |
22 | #include <TDataStd_ExtStringList.hxx> |
7fd59977 |
23 | #include <TDataStd_ListIteratorOfListOfExtendedString.hxx> |
42cf5bc1 |
24 | #include <TDF_Attribute.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_ExtStringListDriver,BinMDF_ADriver) |
27 | |
7fd59977 |
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()) |
34 | { |
35 | |
36 | } |
37 | |
38 | //======================================================================= |
39 | //function : NewEmpty |
40 | //purpose : |
41 | //======================================================================= |
42 | Handle(TDF_Attribute) BinMDataStd_ExtStringListDriver::NewEmpty() const |
43 | { |
44 | return new TDataStd_ExtStringList(); |
45 | } |
46 | |
47 | //======================================================================= |
48 | //function : Paste |
49 | //purpose : persistent -> transient (retrieve) |
50 | //======================================================================= |
d585e74e |
51 | Standard_Boolean BinMDataStd_ExtStringListDriver::Paste |
52 | (const BinObjMgt_Persistent& theSource, |
53 | const Handle(TDF_Attribute)& theTarget, |
54 | BinObjMgt_RRelocationTable& ) const |
7fd59977 |
55 | { |
56 | Standard_Integer aFirstInd, aLastInd; |
57 | if (! (theSource >> aFirstInd >> aLastInd)) |
58 | return Standard_False; |
d585e74e |
59 | if(aLastInd == 0) return Standard_True; |
7fd59977 |
60 | const Standard_Integer aLength = aLastInd - aFirstInd + 1; |
61 | if (aLength <= 0) |
62 | return Standard_False; |
d585e74e |
63 | const Handle(TDataStd_ExtStringList) anAtt = |
64 | Handle(TDataStd_ExtStringList)::DownCast(theTarget); |
7fd59977 |
65 | for (Standard_Integer i = aFirstInd; i <= aLastInd; i ++) |
66 | { |
67 | TCollection_ExtendedString aStr; |
68 | if ( !(theSource >> aStr) ) |
69 | { |
70 | return Standard_False; |
71 | } |
72 | anAtt->Append(aStr); |
73 | } |
74 | |
75 | return Standard_True; |
76 | } |
77 | |
78 | //======================================================================= |
79 | //function : Paste |
80 | //purpose : transient -> persistent (store) |
81 | //======================================================================= |
d585e74e |
82 | void BinMDataStd_ExtStringListDriver::Paste |
83 | (const Handle(TDF_Attribute)& theSource, |
84 | BinObjMgt_Persistent& theTarget, |
85 | BinObjMgt_SRelocationTable& ) const |
7fd59977 |
86 | { |
d585e74e |
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()); |
7fd59977 |
91 | theTarget << aFirstInd << aLastInd; |
92 | TDataStd_ListIteratorOfListOfExtendedString itr(anAtt->List()); |
93 | for (; itr.More(); itr.Next()) |
94 | { |
95 | theTarget << itr.Value(); |
96 | } |
97 | } |