024d6f77 |
1 | // Created on: 2017-02-14 |
2 | // Created by: Sergey NIKONOV |
3 | // Copyright (c) 2008-2017 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
83ae3591 |
16 | #include <Message_Messenger.hxx> |
024d6f77 |
17 | #include <Standard_Type.hxx> |
18 | #include <TDF_Attribute.hxx> |
19 | #include <XCAFDoc_Note.hxx> |
20 | #include <XmlMXCAFDoc_NoteDriver.hxx> |
21 | #include <XmlObjMgt_Persistent.hxx> |
22 | |
23 | IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_NoteDriver, XmlMDF_ADriver) |
24 | IMPLEMENT_DOMSTRING(UserName, "user_name") |
25 | IMPLEMENT_DOMSTRING(TimeStamp, "time_stamp") |
26 | |
27 | //======================================================================= |
28 | //function : |
29 | //purpose : |
30 | //======================================================================= |
83ae3591 |
31 | XmlMXCAFDoc_NoteDriver::XmlMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver, |
024d6f77 |
32 | Standard_CString theName) |
33 | : XmlMDF_ADriver(theMsgDriver, theName) |
34 | { |
35 | } |
36 | |
37 | //======================================================================= |
38 | //function : |
39 | //purpose : |
40 | //======================================================================= |
41 | Standard_Boolean XmlMXCAFDoc_NoteDriver::Paste(const XmlObjMgt_Persistent& theSource, |
42 | const Handle(TDF_Attribute)& theTarget, |
43 | XmlObjMgt_RRelocationTable& /*theRelocTable*/) const |
44 | { |
45 | const XmlObjMgt_Element& anElement = theSource; |
46 | |
47 | XmlObjMgt_DOMString aUserName = anElement.getAttribute(::UserName()); |
48 | XmlObjMgt_DOMString aTimeStamp = anElement.getAttribute(::TimeStamp()); |
49 | if (aUserName == NULL || aTimeStamp == NULL) |
50 | return Standard_False; |
51 | |
52 | Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theTarget); |
53 | if (aNote.IsNull()) |
54 | return Standard_False; |
55 | |
56 | aNote->Set(aUserName.GetString(), aTimeStamp.GetString()); |
57 | |
58 | return Standard_True; |
59 | } |
60 | |
61 | //======================================================================= |
62 | //function : |
63 | //purpose : |
64 | //======================================================================= |
65 | void XmlMXCAFDoc_NoteDriver::Paste(const Handle(TDF_Attribute)& theSource, |
66 | XmlObjMgt_Persistent& theTarget, |
67 | XmlObjMgt_SRelocationTable& /*theRelocTable*/) const |
68 | { |
69 | Handle(XCAFDoc_Note) aNote = Handle(XCAFDoc_Note)::DownCast(theSource); |
70 | if (aNote.IsNull()) |
71 | return; |
72 | |
73 | XmlObjMgt_DOMString aUserName(TCollection_AsciiString(aNote->UserName()).ToCString()); |
74 | XmlObjMgt_DOMString aTimeStamp(TCollection_AsciiString(aNote->TimeStamp()).ToCString()); |
75 | |
76 | theTarget.Element().setAttribute(::UserName(), aUserName); |
77 | theTarget.Element().setAttribute(::TimeStamp(), aTimeStamp); |
78 | } |