0023024: Update headers of OCCT files
[occt.git] / src / XmlMDataStd / XmlMDataStd_IntegerDriver.cxx
CommitLineData
b311480e 1// Created on: 2001-08-24
2// Created by: Alexnder GRIGORIEV
3// Copyright (c) 2001-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21#include <XmlMDataStd_IntegerDriver.ixx>
22#include <XmlObjMgt.hxx>
23#include <TDataStd_Integer.hxx>
24
25//=======================================================================
26//function : XmlMDataStd_IntegerDriver
27//purpose : Constructor
28//=======================================================================
29
30XmlMDataStd_IntegerDriver::XmlMDataStd_IntegerDriver
31 (const Handle(CDM_MessageDriver)& theMsgDriver)
32 : XmlMDF_ADriver (theMsgDriver, NULL)
33{}
34
35//=======================================================================
36//function : NewEmpty
37//purpose :
38//=======================================================================
39Handle(TDF_Attribute) XmlMDataStd_IntegerDriver::NewEmpty() const
40{
41 return (new TDataStd_Integer());
42}
43
44//=======================================================================
45//function : Paste
46//purpose : persistent -> transient (retrieve)
47//=======================================================================
48Standard_Boolean XmlMDataStd_IntegerDriver::Paste
49 (const XmlObjMgt_Persistent& theSource,
50 const Handle(TDF_Attribute)& theTarget,
51 XmlObjMgt_RRelocationTable& ) const
52{
53 Standard_Integer aValue;
54 XmlObjMgt_DOMString anIntStr= XmlObjMgt::GetStringValue(theSource);
55
56 if (anIntStr.GetInteger(aValue) == Standard_False) {
57 TCollection_ExtendedString aMessageString =
58 TCollection_ExtendedString("Cannot retrieve Integer attribute from \"")
59 + anIntStr + "\"";
60 WriteMessage (aMessageString);
61 return Standard_False;
62 }
63
64 Handle(TDataStd_Integer) anInt= Handle(TDataStd_Integer)::DownCast(theTarget);
65 anInt->Set(aValue);
66
67 return Standard_True;
68}
69
70//=======================================================================
71//function : Paste
72//purpose : transient -> persistent (store)
73//=======================================================================
74void XmlMDataStd_IntegerDriver::Paste (const Handle(TDF_Attribute)& theSource,
75 XmlObjMgt_Persistent& theTarget,
76 XmlObjMgt_SRelocationTable& ) const
77{
78 Handle(TDataStd_Integer) anInt= Handle(TDataStd_Integer)::DownCast(theSource);
79 XmlObjMgt::SetStringValue (theTarget, anInt->Get());
80}