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 | |
18 | #include <XmlObjMgt_Persistent.ixx> |
19 | #include <XmlObjMgt_Document.hxx> |
20 | #include <XmlObjMgt.hxx> |
21 | #include <TCollection_AsciiString.hxx> |
22 | |
23 | //======================================================================= |
24 | //function : XmlObjMgt_Persistent |
25 | //purpose : empty constructor |
26 | //======================================================================= |
27 | |
28 | XmlObjMgt_Persistent::XmlObjMgt_Persistent () |
29 | : myID (0) |
30 | {} |
31 | |
32 | //======================================================================= |
33 | //function : XmlObjMgt_Persistent |
34 | //purpose : |
35 | //======================================================================= |
36 | XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement) |
37 | : myElement (theElement), myID (0) |
38 | { |
39 | if (theElement != NULL) |
40 | theElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID); |
41 | } |
42 | |
43 | //======================================================================= |
44 | //function : XmlObjMgt_Persistent |
45 | //purpose : |
46 | //======================================================================= |
47 | XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement, |
48 | const XmlObjMgt_DOMString& theRef) |
49 | : myID (0) |
50 | { |
51 | if (theElement != NULL) { |
52 | Standard_Integer aRefID; |
53 | if (theElement.getAttribute (theRef).GetInteger (aRefID)) { |
54 | myElement = XmlObjMgt::FindChildElement (theElement, aRefID); |
55 | if (myElement != NULL) |
56 | myElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID); |
57 | } |
58 | } |
59 | } |
60 | |
61 | //======================================================================= |
62 | //function : CreateElement |
63 | //purpose : <theType id="theID"/> |
64 | //======================================================================= |
65 | void XmlObjMgt_Persistent::CreateElement (XmlObjMgt_Element& theParent, |
66 | const XmlObjMgt_DOMString& theType, |
67 | const Standard_Integer theID) |
68 | { |
69 | //AGV XmlObjMgt_Document& anOwnerDoc = |
70 | //AGV (XmlObjMgt_Document&)theParent.getOwnerDocument(); |
71 | XmlObjMgt_Document anOwnerDoc = |
72 | XmlObjMgt_Document (theParent.getOwnerDocument()); |
73 | myElement = anOwnerDoc.createElement (theType); |
74 | theParent.appendChild (myElement); |
75 | SetId (theID); |
76 | } |
77 | |
78 | //======================================================================= |
79 | //function : SetId |
80 | //purpose : |
81 | //======================================================================= |
82 | void XmlObjMgt_Persistent::SetId(const Standard_Integer theId) |
83 | { |
84 | myID = theId; |
85 | myElement.setAttribute (XmlObjMgt::IdString(), theId); |
86 | } |