1 // Created on: 2001-09-11
2 // Created by: Julia DOROVSKIKH
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <XmlMXCAFDoc_ColorDriver.ixx>
17 #include <XmlObjMgt.hxx>
18 #include <XCAFDoc_Color.hxx>
20 //=======================================================================
21 //function : XmlMXCAFDoc_ColorDriver
22 //purpose : Constructor
23 //=======================================================================
24 XmlMXCAFDoc_ColorDriver::XmlMXCAFDoc_ColorDriver
25 (const Handle(CDM_MessageDriver)& theMsgDriver)
26 : XmlMDF_ADriver (theMsgDriver, "xcaf", "Color")
29 //=======================================================================
32 //=======================================================================
33 Handle(TDF_Attribute) XmlMXCAFDoc_ColorDriver::NewEmpty() const
35 return (new XCAFDoc_Color());
38 //=======================================================================
40 //purpose : persistent -> transient (retrieve)
41 //=======================================================================
42 Standard_Boolean XmlMXCAFDoc_ColorDriver::Paste
43 (const XmlObjMgt_Persistent& theSource,
44 const Handle(TDF_Attribute)& theTarget,
45 XmlObjMgt_RRelocationTable& ) const
47 Standard_Integer aValue;
48 XmlObjMgt_DOMString anIntStr = XmlObjMgt::GetStringValue(theSource);
50 if (anIntStr.GetInteger(aValue) == Standard_False) {
51 TCollection_ExtendedString aMessageString =
52 TCollection_ExtendedString("Cannot retrieve Color attribute from \"")
54 WriteMessage (aMessageString);
55 return Standard_False;
58 Handle(XCAFDoc_Color) anInt = Handle(XCAFDoc_Color)::DownCast(theTarget);
59 anInt->Set((Quantity_NameOfColor)aValue);
64 //=======================================================================
66 //purpose : transient -> persistent (store)
67 //=======================================================================
68 void XmlMXCAFDoc_ColorDriver::Paste (const Handle(TDF_Attribute)& theSource,
69 XmlObjMgt_Persistent& theTarget,
70 XmlObjMgt_SRelocationTable& ) const
72 Handle(XCAFDoc_Color) anInt = Handle(XCAFDoc_Color)::DownCast(theSource);
73 XmlObjMgt::SetStringValue (theTarget, (Standard_Integer)anInt->GetNOC());