0028714: XmlMFunction_ScopeDriver fail to read and write function label including...
[occt.git] / src / XmlObjMgt / XmlObjMgt_Persistent.cxx
CommitLineData
b311480e 1// Created on: 2001-07-17
2// Created by: Julia DOROVSKIKH
973c2be1 3// Copyright (c) 2001-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
16//AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()
7fd59977 17
7fd59977 18#include <TCollection_AsciiString.hxx>
42cf5bc1 19#include <XmlObjMgt.hxx>
20#include <XmlObjMgt_Document.hxx>
21#include <XmlObjMgt_Persistent.hxx>
7fd59977 22
23//=======================================================================
24//function : XmlObjMgt_Persistent
25//purpose : empty constructor
26//=======================================================================
7fd59977 27XmlObjMgt_Persistent::XmlObjMgt_Persistent ()
28 : myID (0)
29{}
30
31//=======================================================================
32//function : XmlObjMgt_Persistent
33//purpose :
34//=======================================================================
35XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement)
36 : myElement (theElement), myID (0)
37{
38 if (theElement != NULL)
39 theElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
40}
41
42//=======================================================================
43//function : XmlObjMgt_Persistent
44//purpose :
45//=======================================================================
46XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement,
47 const XmlObjMgt_DOMString& theRef)
48 : myID (0)
49{
50 if (theElement != NULL) {
51 Standard_Integer aRefID;
52 if (theElement.getAttribute (theRef).GetInteger (aRefID)) {
53 myElement = XmlObjMgt::FindChildElement (theElement, aRefID);
54 if (myElement != NULL)
55 myElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
56 }
57 }
58}
59
60//=======================================================================
61//function : CreateElement
62//purpose : <theType id="theID"/>
63//=======================================================================
64void XmlObjMgt_Persistent::CreateElement (XmlObjMgt_Element& theParent,
65 const XmlObjMgt_DOMString& theType,
66 const Standard_Integer theID)
67{
68//AGV XmlObjMgt_Document& anOwnerDoc =
69//AGV (XmlObjMgt_Document&)theParent.getOwnerDocument();
70 XmlObjMgt_Document anOwnerDoc =
71 XmlObjMgt_Document (theParent.getOwnerDocument());
72 myElement = anOwnerDoc.createElement (theType);
73 theParent.appendChild (myElement);
74 SetId (theID);
75}
76
77//=======================================================================
78//function : SetId
79//purpose :
80//=======================================================================
81void XmlObjMgt_Persistent::SetId(const Standard_Integer theId)
82{
83 myID = theId;
84 myElement.setAttribute (XmlObjMgt::IdString(), theId);
85}