// Created on: 2001-09-11 // Created by: Julia DOROVSKIKH // Copyright (c) 2001-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include #include #include #include IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_ColorDriver,XmlMDF_ADriver) //======================================================================= //function : XmlMXCAFDoc_ColorDriver //purpose : Constructor //======================================================================= XmlMXCAFDoc_ColorDriver::XmlMXCAFDoc_ColorDriver (const Handle(Message_Messenger)& theMsgDriver) : XmlMDF_ADriver (theMsgDriver, "xcaf", "Color") {} //======================================================================= //function : NewEmpty //purpose : //======================================================================= Handle(TDF_Attribute) XmlMXCAFDoc_ColorDriver::NewEmpty() const { return (new XCAFDoc_Color()); } //======================================================================= //function : Paste //purpose : persistent -> transient (retrieve) //======================================================================= Standard_Boolean XmlMXCAFDoc_ColorDriver::Paste (const XmlObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, XmlObjMgt_RRelocationTable& ) const { Standard_Integer aValue; XmlObjMgt_DOMString anIntStr = XmlObjMgt::GetStringValue(theSource); if (anIntStr.GetInteger(aValue) == Standard_False) { TCollection_ExtendedString aMessageString = TCollection_ExtendedString("Cannot retrieve Color attribute from \"") + anIntStr + "\""; myMessageDriver->Send (aMessageString, Message_Fail); return Standard_False; } Handle(XCAFDoc_Color) anInt = Handle(XCAFDoc_Color)::DownCast(theTarget); anInt->Set((Quantity_NameOfColor)aValue); return Standard_True; } //======================================================================= //function : Paste //purpose : transient -> persistent (store) //======================================================================= void XmlMXCAFDoc_ColorDriver::Paste (const Handle(TDF_Attribute)& theSource, XmlObjMgt_Persistent& theTarget, XmlObjMgt_SRelocationTable& ) const { Handle(XCAFDoc_Color) anInt = Handle(XCAFDoc_Color)::DownCast(theSource); XmlObjMgt::SetStringValue (theTarget, (Standard_Integer)anInt->GetNOC()); }