0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / XmlMDocStd / XmlMDocStd_XLinkDriver.cxx
CommitLineData
b311480e 1// Created on: 2001-09-04
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.
7fd59977 15
16#include <XmlMDocStd_XLinkDriver.ixx>
17
18#include <XmlObjMgt.hxx>
19
20#include <TDocStd_XLink.hxx>
21#include <TDF_Tool.hxx>
22#include <TDF_Label.hxx>
23
24IMPLEMENT_DOMSTRING (DocEntryString, "documentEntry")
25
26//=======================================================================
27//function : XmlMDocStd_XLinkDriver
28//purpose : Constructor
29//=======================================================================
30XmlMDocStd_XLinkDriver::XmlMDocStd_XLinkDriver
31 (const Handle(CDM_MessageDriver)& theMsgDriver)
32 : XmlMDF_ADriver (theMsgDriver, NULL)
33{}
34
35//=======================================================================
36//function : NewEmpty
37//purpose :
38//=======================================================================
39Handle(TDF_Attribute) XmlMDocStd_XLinkDriver::NewEmpty() const
40{
41 return (new TDocStd_XLink());
42}
43
44//=======================================================================
45//function : Paste
46//purpose : persistent -> transient (retrieve)
47//=======================================================================
48Standard_Boolean XmlMDocStd_XLinkDriver::Paste
49 (const XmlObjMgt_Persistent& theSource,
50 const Handle(TDF_Attribute)& theTarget,
51 XmlObjMgt_RRelocationTable& ) const
52{
53 XmlObjMgt_DOMString anXPath = XmlObjMgt::GetStringValue (theSource);
54
55 if (anXPath == NULL)
56 {
57 WriteMessage ("XLink: Cannot retrieve reference string from element");
58 return Standard_False;
59 }
60
61 TCollection_AsciiString anEntry;
62 if (XmlObjMgt::GetTagEntryString (anXPath, anEntry) == Standard_False)
63 {
64 TCollection_ExtendedString aMessage =
65 TCollection_ExtendedString ("Cannot retrieve XLink reference from \"")
66 + anXPath + '\"';
67 WriteMessage (aMessage);
68 return Standard_False;
69 }
70
71 Handle(TDocStd_XLink) aRef = Handle(TDocStd_XLink)::DownCast(theTarget);
72
73 // set referenced label
74 aRef->LabelEntry(anEntry);
75
76 // document entry
77 aRef->DocumentEntry(theSource.Element().getAttribute(::DocEntryString()));
78
79 return Standard_True;
80}
81
82//=======================================================================
83//function : Paste
84//purpose : transient -> persistent (store)
85// <label tag='1'> <This is label entry 0:4:1>
86// ...
87// <label tag='8'> <This is label entry 0:4:1:8>
88//
89// <TDocStd_XLink id="621"> /document/label/label[@tag="4"]/label[@tag="1"]
90// </TDocStd_XLink> <This is reference to label 0:4:1>
91//=======================================================================
92void XmlMDocStd_XLinkDriver::Paste (const Handle(TDF_Attribute)& theSource,
93 XmlObjMgt_Persistent& theTarget,
94 XmlObjMgt_SRelocationTable& ) const
95{
96 Handle(TDocStd_XLink) aRef = Handle(TDocStd_XLink)::DownCast(theSource);
97 if (!aRef.IsNull())
98 {
99 // reference
100 TCollection_AsciiString anEntry = aRef->LabelEntry();
101 XmlObjMgt_DOMString aDOMString;
102 XmlObjMgt::SetTagEntryString (aDOMString, anEntry);
103 XmlObjMgt::SetStringValue (theTarget, aDOMString);
104
105 // document entry
106 theTarget.Element().setAttribute(::DocEntryString(),
107 aRef->DocumentEntry().ToCString());
108 }
109}