summaryrefslogtreecommitdiff
path: root/src/XmlObjMgt/XmlObjMgt_Persistent.cxx
blob: bf7388e371be48d3f432c8972c7aec2b1b5d4763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// File:        XmlObjMgt_Persistent.cxx
// Created:     Tue Jul 17 12:30:46 2001
// Author:      Julia DOROVSKIKH <jfa@hotdox.nnov.matra-dtv.fr>
// Copyright:   Matra Datavision 2001
// History:   AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()

#include <XmlObjMgt_Persistent.ixx>
#include <XmlObjMgt_Document.hxx>
#include <XmlObjMgt.hxx>
#include <TCollection_AsciiString.hxx>

//=======================================================================
//function : XmlObjMgt_Persistent
//purpose  : empty constructor
//=======================================================================

XmlObjMgt_Persistent::XmlObjMgt_Persistent ()
     : myID (0)
{}

//=======================================================================
//function : XmlObjMgt_Persistent
//purpose  : 
//=======================================================================
XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement)
     : myElement (theElement), myID (0)
{
  if (theElement != NULL)
    theElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
}

//=======================================================================
//function : XmlObjMgt_Persistent
//purpose  : 
//=======================================================================
XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement,
                                            const XmlObjMgt_DOMString& theRef)
     : myID (0)
{
  if (theElement != NULL) {
    Standard_Integer aRefID;
    if (theElement.getAttribute (theRef).GetInteger (aRefID)) {
      myElement = XmlObjMgt::FindChildElement (theElement, aRefID);
      if (myElement != NULL)
        myElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
    }
  }
}

//=======================================================================
//function : CreateElement
//purpose  : <theType id="theID"/>
//=======================================================================
void XmlObjMgt_Persistent::CreateElement (XmlObjMgt_Element&         theParent,
                                          const XmlObjMgt_DOMString& theType,
                                          const Standard_Integer     theID)
{
//AGV  XmlObjMgt_Document& anOwnerDoc =
//AGV    (XmlObjMgt_Document&)theParent.getOwnerDocument();
  XmlObjMgt_Document anOwnerDoc =
    XmlObjMgt_Document (theParent.getOwnerDocument());
  myElement = anOwnerDoc.createElement (theType);
  theParent.appendChild (myElement);
  SetId (theID);
}

//=======================================================================
//function : SetId
//purpose  : 
//=======================================================================
void XmlObjMgt_Persistent::SetId(const Standard_Integer theId)
{
  myID = theId;
  myElement.setAttribute (XmlObjMgt::IdString(), theId);
}