8e8bc013498a3c489dd9d4fe148fbc8afb264673
[occt.git] / src / LDOM / LDOM_BasicAttribute.cxx
1 // File:      LDOM_BasicAttribute.cxx
2 // Created:   26.06.01 18:48:27
3 // Author:    Alexander GRIGORIEV
4 // Copyright: OpenCascade 2001
5 // History:
6
7 #include <LDOM_BasicAttribute.hxx>
8 #include <LDOM_MemManager.hxx>
9
10 #ifdef WNT
11 // Disable the warning: "operator new unmatched by delete"
12 #pragma warning (disable:4291)
13 #endif
14
15 //=======================================================================
16 //function : LDOM_BasicAttribute
17 //purpose  : 
18 //=======================================================================
19
20 LDOM_BasicAttribute::LDOM_BasicAttribute (const LDOM_Attr& anAttr)
21      : LDOM_BasicNode   (anAttr.Origin()),
22        myName           (anAttr.getName().GetString()),
23        myValue          (anAttr.getValue()) {}
24
25 //=======================================================================
26 //function : Create
27 //purpose  : construction in the Document's data pool
28 //=======================================================================
29
30 LDOM_BasicAttribute& LDOM_BasicAttribute::Create
31                                         (const LDOMBasicString&         theName,
32                                          const Handle(LDOM_MemManager)& theDoc,
33                                          Standard_Integer&              theHash)
34 {
35   void * aMem = theDoc -> Allocate (sizeof(LDOM_BasicAttribute));
36   LDOM_BasicAttribute * aNewAtt = new (aMem) LDOM_BasicAttribute;
37
38   const char * aString = theName.GetString();
39   aNewAtt -> myName =
40     theDoc -> HashedAllocate (aString, strlen(aString), theHash);
41
42   aNewAtt -> myNodeType = LDOM_Node::ATTRIBUTE_NODE;
43   return * aNewAtt;
44 }
45
46 //=======================================================================
47 //function : operator =
48 //purpose  : Assignment to NULL
49 //=======================================================================
50
51 LDOM_BasicAttribute& LDOM_BasicAttribute::operator= (const LDOM_NullPtr * aNull)
52 {
53   myName = NULL;
54   myValue = aNull;
55   LDOM_BasicNode::operator= (aNull);
56   return * this;
57 }