0024157: Parallelization of assembly part of BO
[occt.git] / src / XmlMDF / XmlMDF_TagSourceDriver.cxx
1 // Created on: 2001-08-29
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
20 //AGV 150202: Changed prototype XmlObjMgt::SetStringValue()
21
22 #include <XmlMDF_TagSourceDriver.ixx>
23 #include <XmlObjMgt.hxx>
24 #include <TDF_TagSource.hxx>
25
26 //=======================================================================
27 //function : XmlMDF_TagSourceDriver
28 //purpose  : Constructor
29 //=======================================================================
30
31 XmlMDF_TagSourceDriver::XmlMDF_TagSourceDriver
32                         (const Handle(CDM_MessageDriver)& theMsgDriver)
33       : XmlMDF_ADriver (theMsgDriver, NULL)
34 {}
35
36 //=======================================================================
37 //function : NewEmpty
38 //purpose  : 
39 //=======================================================================
40 Handle(TDF_Attribute) XmlMDF_TagSourceDriver::NewEmpty() const
41 {
42   return (new TDF_TagSource());
43 }
44
45 //=======================================================================
46 //function : Paste
47 //purpose  : persistent -> transient (retrieve)
48 //=======================================================================
49 Standard_Boolean XmlMDF_TagSourceDriver::Paste 
50                                 (const XmlObjMgt_Persistent&  theSource,
51                                  const Handle(TDF_Attribute)& theTarget,
52                                  XmlObjMgt_RRelocationTable&  ) const
53 {
54   Standard_Integer aTag;
55   XmlObjMgt_DOMString aTagStr = XmlObjMgt::GetStringValue(theSource.Element());
56
57   if (aTagStr.GetInteger(aTag) == Standard_False) {
58     TCollection_ExtendedString aMessageString =
59       TCollection_ExtendedString ("Cannot retrieve TagSource attribute from \"")
60         + aTagStr + "\"";
61     WriteMessage (aMessageString);
62     return Standard_False;
63   }
64
65   if (aTag < 0) {
66     TCollection_ExtendedString aMessageString =
67       TCollection_ExtendedString ("Invalid value of TagSource retrieved: ")
68         + aTag;
69     WriteMessage (aMessageString);
70     return Standard_False;
71   }
72
73   Handle(TDF_TagSource) aT = Handle(TDF_TagSource)::DownCast (theTarget);
74   aT->Set(aTag);
75
76   return Standard_True;
77 }
78
79 //=======================================================================
80 //function : Paste
81 //purpose  : transient -> persistent (store)
82 //=======================================================================
83 void XmlMDF_TagSourceDriver::Paste (const Handle(TDF_Attribute)& theSource,
84                                     XmlObjMgt_Persistent&        theTarget,
85                                     XmlObjMgt_SRelocationTable&  ) const
86 {
87   Handle(TDF_TagSource) aTag = Handle(TDF_TagSource)::DownCast(theSource);
88   // No occurrence of '&', '<' and other irregular XML characters
89   XmlObjMgt::SetStringValue (theTarget.Element(), aTag->Get(), Standard_True);
90 }
91