1 // Created on: 2001-08-24
2 // Created by: Alexnder GRIGORIEV
3 // Copyright (c) 2001-2012 OPEN CASCADE SAS
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.
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.
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.
20 //AGV 150202: Changed prototype XmlObjMgt::SetStringValue()
22 #define OCC6010 // vro 09.06.2004
25 #include <XmlMDataStd_RealDriver.ixx>
26 #include <TDataStd_Real.hxx>
27 #include <XmlObjMgt.hxx>
29 //=======================================================================
30 //function : XmlMDataStd_RealDriver
31 //purpose : Constructor
32 //=======================================================================
34 XmlMDataStd_RealDriver::XmlMDataStd_RealDriver
35 (const Handle(CDM_MessageDriver)& theMsgDriver)
36 : XmlMDF_ADriver (theMsgDriver, NULL)
39 //=======================================================================
42 //=======================================================================
43 Handle(TDF_Attribute) XmlMDataStd_RealDriver::NewEmpty() const
45 return (new TDataStd_Real());
48 //=======================================================================
50 //purpose : persistent -> transient (retrieve)
51 //=======================================================================
52 Standard_Boolean XmlMDataStd_RealDriver::Paste
53 (const XmlObjMgt_Persistent& theSource,
54 const Handle(TDF_Attribute)& theTarget,
55 XmlObjMgt_RRelocationTable& ) const
58 XmlObjMgt_DOMString aRealStr= XmlObjMgt::GetStringValue (theSource);
60 if (XmlObjMgt::GetReal(aRealStr, aValue) == Standard_False) {
61 TCollection_ExtendedString aMessageString =
62 TCollection_ExtendedString("Cannot retrieve Real attribute from \"")
64 WriteMessage (aMessageString);
65 return Standard_False;
68 Handle(TDataStd_Real) anInt = Handle(TDataStd_Real)::DownCast(theTarget);
74 //=======================================================================
76 //purpose : transient -> persistent (store)
77 //=======================================================================
78 void XmlMDataStd_RealDriver::Paste (const Handle(TDF_Attribute)& theSource,
79 XmlObjMgt_Persistent& theTarget,
80 XmlObjMgt_SRelocationTable& ) const
82 Handle(TDataStd_Real) anInt = Handle(TDataStd_Real)::DownCast(theSource);
84 TCollection_AsciiString aValueStr (anInt->Get());
87 sprintf(aValueChar, "%.15g", anInt->Get());
88 TCollection_AsciiString aValueStr(aValueChar);
90 // No occurrence of '&', '<' and other irregular XML characters
91 XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);