Test for 0022778: Bug in BRepMesh
[occt.git] / src / XmlMXCAFDoc / XmlMXCAFDoc_ColorDriver.cxx
CommitLineData
b311480e 1// Created on: 2001-09-11
2// Created by: Julia DOROVSKIKH
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 <XmlMXCAFDoc_ColorDriver.ixx>
22#include <XmlObjMgt.hxx>
23#include <XCAFDoc_Color.hxx>
24
25//=======================================================================
26//function : XmlMXCAFDoc_ColorDriver
27//purpose : Constructor
28//=======================================================================
29XmlMXCAFDoc_ColorDriver::XmlMXCAFDoc_ColorDriver
30 (const Handle(CDM_MessageDriver)& theMsgDriver)
31 : XmlMDF_ADriver (theMsgDriver, "xcaf", "Color")
32{}
33
34//=======================================================================
35//function : NewEmpty
36//purpose :
37//=======================================================================
38Handle(TDF_Attribute) XmlMXCAFDoc_ColorDriver::NewEmpty() const
39{
40 return (new XCAFDoc_Color());
41}
42
43//=======================================================================
44//function : Paste
45//purpose : persistent -> transient (retrieve)
46//=======================================================================
47Standard_Boolean XmlMXCAFDoc_ColorDriver::Paste
48 (const XmlObjMgt_Persistent& theSource,
49 const Handle(TDF_Attribute)& theTarget,
50 XmlObjMgt_RRelocationTable& ) const
51{
52 Standard_Integer aValue;
53 XmlObjMgt_DOMString anIntStr = XmlObjMgt::GetStringValue(theSource);
54
55 if (anIntStr.GetInteger(aValue) == Standard_False) {
56 TCollection_ExtendedString aMessageString =
57 TCollection_ExtendedString("Cannot retrieve Color attribute from \"")
58 + anIntStr + "\"";
59 WriteMessage (aMessageString);
60 return Standard_False;
61 }
62
63 Handle(XCAFDoc_Color) anInt = Handle(XCAFDoc_Color)::DownCast(theTarget);
64 anInt->Set((Quantity_NameOfColor)aValue);
65
66 return Standard_True;
67}
68
69//=======================================================================
70//function : Paste
71//purpose : transient -> persistent (store)
72//=======================================================================
73void XmlMXCAFDoc_ColorDriver::Paste (const Handle(TDF_Attribute)& theSource,
74 XmlObjMgt_Persistent& theTarget,
75 XmlObjMgt_SRelocationTable& ) const
76{
77 Handle(XCAFDoc_Color) anInt = Handle(XCAFDoc_Color)::DownCast(theSource);
78 XmlObjMgt::SetStringValue (theTarget, (Standard_Integer)anInt->GetNOC());
79}