b311480e |
1 | // Created on: 2001-08-29 |
2 | // Created by: Julia DOROVSKIKH |
973c2be1 |
3 | // Copyright (c) 2001-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. |
b311480e |
15 | |
16 | //AGV 150202: Changed prototype XmlObjMgt::SetStringValue() |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <CDM_MessageDriver.hxx> |
19 | #include <Standard_Type.hxx> |
20 | #include <TDF_Attribute.hxx> |
7fd59977 |
21 | #include <TDF_TagSource.hxx> |
42cf5bc1 |
22 | #include <XmlMDF_TagSourceDriver.hxx> |
23 | #include <XmlObjMgt.hxx> |
24 | #include <XmlObjMgt_Persistent.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(XmlMDF_TagSourceDriver,XmlMDF_ADriver) |
27 | |
7fd59977 |
28 | //======================================================================= |
29 | //function : XmlMDF_TagSourceDriver |
30 | //purpose : Constructor |
31 | //======================================================================= |
7fd59977 |
32 | XmlMDF_TagSourceDriver::XmlMDF_TagSourceDriver |
33 | (const Handle(CDM_MessageDriver)& theMsgDriver) |
34 | : XmlMDF_ADriver (theMsgDriver, NULL) |
35 | {} |
36 | |
37 | //======================================================================= |
38 | //function : NewEmpty |
39 | //purpose : |
40 | //======================================================================= |
41 | Handle(TDF_Attribute) XmlMDF_TagSourceDriver::NewEmpty() const |
42 | { |
43 | return (new TDF_TagSource()); |
44 | } |
45 | |
46 | //======================================================================= |
47 | //function : Paste |
48 | //purpose : persistent -> transient (retrieve) |
49 | //======================================================================= |
50 | Standard_Boolean XmlMDF_TagSourceDriver::Paste |
51 | (const XmlObjMgt_Persistent& theSource, |
52 | const Handle(TDF_Attribute)& theTarget, |
53 | XmlObjMgt_RRelocationTable& ) const |
54 | { |
55 | Standard_Integer aTag; |
56 | XmlObjMgt_DOMString aTagStr = XmlObjMgt::GetStringValue(theSource.Element()); |
57 | |
58 | if (aTagStr.GetInteger(aTag) == Standard_False) { |
59 | TCollection_ExtendedString aMessageString = |
60 | TCollection_ExtendedString ("Cannot retrieve TagSource attribute from \"") |
61 | + aTagStr + "\""; |
62 | WriteMessage (aMessageString); |
63 | return Standard_False; |
64 | } |
65 | |
66 | if (aTag < 0) { |
67 | TCollection_ExtendedString aMessageString = |
68 | TCollection_ExtendedString ("Invalid value of TagSource retrieved: ") |
69 | + aTag; |
70 | WriteMessage (aMessageString); |
71 | return Standard_False; |
72 | } |
73 | |
74 | Handle(TDF_TagSource) aT = Handle(TDF_TagSource)::DownCast (theTarget); |
75 | aT->Set(aTag); |
76 | |
77 | return Standard_True; |
78 | } |
79 | |
80 | //======================================================================= |
81 | //function : Paste |
82 | //purpose : transient -> persistent (store) |
83 | //======================================================================= |
84 | void XmlMDF_TagSourceDriver::Paste (const Handle(TDF_Attribute)& theSource, |
85 | XmlObjMgt_Persistent& theTarget, |
86 | XmlObjMgt_SRelocationTable& ) const |
87 | { |
88 | Handle(TDF_TagSource) aTag = Handle(TDF_TagSource)::DownCast(theSource); |
89 | // No occurrence of '&', '<' and other irregular XML characters |
90 | XmlObjMgt::SetStringValue (theTarget.Element(), aTag->Get(), Standard_True); |
91 | } |
92 | |