0029352: Adding support of GBK and Big5 code pages
[occt.git] / src / XmlTObjDrivers / XmlTObjDrivers_ObjectDriver.cxx
CommitLineData
b311480e 1// Created on: 2004-11-24
2// Created by: Edward AGAPOV
973c2be1 3// Copyright (c) 2004-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
7fd59977 16// The original implementation Copyright: (C) RINA S.p.A
17
18
19#include <CDM_MessageDriver.hxx>
20#include "XmlTObjDrivers_ObjectDriver.hxx"
21#include <TObj_TObject.hxx>
22#include <TObj_Persistence.hxx>
23#include <XmlObjMgt_Persistent.hxx>
24#include <XmlObjMgt_RRelocationTable.hxx>
25#include <XmlObjMgt.hxx>
26
ec357c5c 27
28
7fd59977 29
92efcf78 30IMPLEMENT_STANDARD_RTTIEXT(XmlTObjDrivers_ObjectDriver,XmlMDF_ADriver)
31
7fd59977 32//=======================================================================
33//function : XmlTObjDrivers_ObjectDriver
34//purpose : constructor
35//=======================================================================
36
37XmlTObjDrivers_ObjectDriver::XmlTObjDrivers_ObjectDriver
38 (const Handle(CDM_MessageDriver)& theMessageDriver)
39: XmlMDF_ADriver( theMessageDriver, NULL)
40{
41}
42
43//=======================================================================
44//function : NewEmpty
45//purpose : Creates a new attribute
46//=======================================================================
47
48Handle(TDF_Attribute) XmlTObjDrivers_ObjectDriver::NewEmpty() const
49{
50 return new TObj_TObject;
51}
52
53//=======================================================================
54//function : Paste
55//purpose : Translate the contents of <aSource> and put it
56// into <aTarget>, using the relocation table
57// <aRelocTable> to keep the sharings.
58//=======================================================================
59
60Standard_Boolean XmlTObjDrivers_ObjectDriver::Paste
61 (const XmlObjMgt_Persistent& Source,
62 const Handle(TDF_Attribute)& Target,
63 XmlObjMgt_RRelocationTable& /*RelocTable*/) const
64{
65 TCollection_ExtendedString aString;
66 if (XmlObjMgt::GetExtendedString (Source, aString))
67 {
68 TCollection_AsciiString anAscii (aString);
69 Handle(TObj_Object) anObject =
70 TObj_Persistence::CreateNewObject(anAscii.ToCString(),Target->Label());
71 Handle(TObj_TObject)::DownCast (Target) ->Set( anObject );
72 return Standard_True;
73 }
74 WriteMessage("error retrieving ExtendedString for type TObj_TModel");
75 return Standard_False;
76}
77
78//=======================================================================
79//function : Paste
80//purpose : Translate the contents of <aSource> and put it
81// into <aTarget>, using the relocation table
82// <aRelocTable> to keep the sharings.
83// anObject is stored as a Name of class derived from TObj_Object
84//=======================================================================
85
86void XmlTObjDrivers_ObjectDriver::Paste
87 (const Handle(TDF_Attribute)& Source,
88 XmlObjMgt_Persistent& Target,
89 XmlObjMgt_SRelocationTable& /*RelocTable*/) const
90{
91 Handle(TObj_TObject) aTObj =
92 Handle(TObj_TObject)::DownCast( Source );
93 Handle(TObj_Object) anIObject = aTObj->Get();
94
95 XmlObjMgt::SetExtendedString (Target, anIObject->DynamicType()->Name());
96}
97