b311480e |
1 | // Created on: 2001-08-24 |
2 | // Created by: Alexnder GRIGORIEV |
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. |
7fd59977 |
15 | |
42cf5bc1 |
16 | |
83ae3591 |
17 | #include <Message_Messenger.hxx> |
42cf5bc1 |
18 | #include <Standard_Type.hxx> |
7fd59977 |
19 | #include <TDataStd_UAttribute.hxx> |
42cf5bc1 |
20 | #include <TDF_Attribute.hxx> |
21 | #include <XmlMDataStd_UAttributeDriver.hxx> |
22 | #include <XmlObjMgt_Persistent.hxx> |
7fd59977 |
23 | |
92efcf78 |
24 | IMPLEMENT_STANDARD_RTTIEXT(XmlMDataStd_UAttributeDriver,XmlMDF_ADriver) |
7fd59977 |
25 | IMPLEMENT_DOMSTRING (GuidString, "guid") |
26 | |
27 | //======================================================================= |
28 | //function : XmlMDataStd_UAttributeDriver |
29 | //purpose : Constructor |
30 | //======================================================================= |
31 | |
32 | XmlMDataStd_UAttributeDriver::XmlMDataStd_UAttributeDriver |
83ae3591 |
33 | (const Handle(Message_Messenger)& theMsgDriver) |
7fd59977 |
34 | : XmlMDF_ADriver (theMsgDriver, NULL) |
35 | {} |
36 | |
37 | //======================================================================= |
38 | //function : NewEmpty |
39 | //purpose : |
40 | //======================================================================= |
41 | Handle(TDF_Attribute) XmlMDataStd_UAttributeDriver::NewEmpty() const |
42 | { |
43 | return (new TDataStd_UAttribute()); |
44 | } |
45 | |
46 | //======================================================================= |
47 | //function : Paste |
48 | //purpose : |
49 | //======================================================================= |
50 | Standard_Boolean XmlMDataStd_UAttributeDriver::Paste |
51 | (const XmlObjMgt_Persistent& theSource, |
52 | const Handle(TDF_Attribute)& theTarget, |
53 | XmlObjMgt_RRelocationTable& ) const |
54 | { |
55 | XmlObjMgt_DOMString aGuidDomStr = |
56 | theSource.Element().getAttribute (::GuidString()); |
57 | Standard_CString aGuidStr = (Standard_CString)aGuidDomStr.GetString(); |
58 | if (aGuidStr[0] == '\0') { |
83ae3591 |
59 | myMessageDriver->Send ("error retrieving GUID for type TDataStd_UAttribute", Message_Fail); |
7fd59977 |
60 | return Standard_False; |
61 | } |
62 | |
63 | Handle(TDataStd_UAttribute)::DownCast (theTarget) -> SetID (aGuidStr); |
64 | return Standard_True; |
65 | } |
66 | |
67 | |
68 | //======================================================================= |
69 | //function : Paste |
70 | //purpose : |
71 | //======================================================================= |
72 | void XmlMDataStd_UAttributeDriver::Paste(const Handle(TDF_Attribute)& theSource, |
73 | XmlObjMgt_Persistent& theTarget, |
74 | XmlObjMgt_SRelocationTable& ) const |
75 | { |
76 | Handle(TDataStd_UAttribute) aName = |
77 | Handle(TDataStd_UAttribute)::DownCast(theSource); |
78 | |
79 | //convert GUID into attribute value |
80 | Standard_Character aGuidStr [40]; |
81 | Standard_PCharacter pGuidStr; |
82 | pGuidStr=aGuidStr; |
83 | aName->ID().ToCString (pGuidStr); |
84 | |
85 | theTarget.Element().setAttribute (::GuidString(), aGuidStr); |
86 | } |