0024750: Replace instantiations of TCollection generic classes by NCollection templat...
[occt.git] / src / XmlMDF / XmlMDF_TagSourceDriver.cxx
CommitLineData
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
18#include <XmlMDF_TagSourceDriver.ixx>
19#include <XmlObjMgt.hxx>
20#include <TDF_TagSource.hxx>
21
22//=======================================================================
23//function : XmlMDF_TagSourceDriver
24//purpose : Constructor
25//=======================================================================
26
27XmlMDF_TagSourceDriver::XmlMDF_TagSourceDriver
28 (const Handle(CDM_MessageDriver)& theMsgDriver)
29 : XmlMDF_ADriver (theMsgDriver, NULL)
30{}
31
32//=======================================================================
33//function : NewEmpty
34//purpose :
35//=======================================================================
36Handle(TDF_Attribute) XmlMDF_TagSourceDriver::NewEmpty() const
37{
38 return (new TDF_TagSource());
39}
40
41//=======================================================================
42//function : Paste
43//purpose : persistent -> transient (retrieve)
44//=======================================================================
45Standard_Boolean XmlMDF_TagSourceDriver::Paste
46 (const XmlObjMgt_Persistent& theSource,
47 const Handle(TDF_Attribute)& theTarget,
48 XmlObjMgt_RRelocationTable& ) const
49{
50 Standard_Integer aTag;
51 XmlObjMgt_DOMString aTagStr = XmlObjMgt::GetStringValue(theSource.Element());
52
53 if (aTagStr.GetInteger(aTag) == Standard_False) {
54 TCollection_ExtendedString aMessageString =
55 TCollection_ExtendedString ("Cannot retrieve TagSource attribute from \"")
56 + aTagStr + "\"";
57 WriteMessage (aMessageString);
58 return Standard_False;
59 }
60
61 if (aTag < 0) {
62 TCollection_ExtendedString aMessageString =
63 TCollection_ExtendedString ("Invalid value of TagSource retrieved: ")
64 + aTag;
65 WriteMessage (aMessageString);
66 return Standard_False;
67 }
68
69 Handle(TDF_TagSource) aT = Handle(TDF_TagSource)::DownCast (theTarget);
70 aT->Set(aTag);
71
72 return Standard_True;
73}
74
75//=======================================================================
76//function : Paste
77//purpose : transient -> persistent (store)
78//=======================================================================
79void XmlMDF_TagSourceDriver::Paste (const Handle(TDF_Attribute)& theSource,
80 XmlObjMgt_Persistent& theTarget,
81 XmlObjMgt_SRelocationTable& ) const
82{
83 Handle(TDF_TagSource) aTag = Handle(TDF_TagSource)::DownCast(theSource);
84 // No occurrence of '&', '<' and other irregular XML characters
85 XmlObjMgt::SetStringValue (theTarget.Element(), aTag->Get(), Standard_True);
86}
87