Project

Profile

Help

Support #2625 » XdmNode.h

Duygu Colak, 2016-02-23 10:01

 
1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright (c) 2015 Saxonica Limited.
3
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7

    
8
#ifndef SAXON_XDMNODE_h
9
#define SAXON_XDMNODE_h
10

    
11
#include "XdmItem.h"
12
#include <string.h>
13
//#include "XdmValue.h"
14

    
15
typedef enum eXdmNodeKind { DOCUMENT=9, ELEMENT=1, ATTRIBUTE=2, TEXT=3, COMMENT=8, PROCESSING_INSTRUCTION=7, NAMESPACE=13, UNKNOWN=0 } XDM_NODE_KIND;
16

    
17

    
18

    
19
class XdmValue;
20

    
21
class XdmNode : public XdmItem
22
{
23

    
24
public:
25

    
26

    
27
   /* XdmNode(const XdmValue& valuei){
28
        //value = (sxnc_value *)malloc(sizeof(sxnc_value));
29
        value = valuei.values[0]->getUnderlyingCValue();
30
        xdmSize =1;
31
        refCount = 1;
32
        nodeKind = UNKNOWN;
33
        }*/
34

    
35
    XdmNode(jobject);
36

    
37
    XdmNode(XdmNode *parent, jobject, XDM_NODE_KIND);
38

    
39
     virtual ~XdmNode(){
40
        delete baseURI;
41
        delete nodeName;
42

    
43
        //There might be potential issues with children and attribute node not being deleted when the parent node has been deleted
44
        //we need to track this kind of problem.
45
    }
46

    
47
    virtual bool isAtomic();
48
    
49
    
50
    XDM_NODE_KIND getNodeKind();
51

    
52
    /**
53
     * Get the name of the node, as a string in the form of a EQName
54
     *
55
     * @return the name of the node. In the case of unnamed nodes (for example, text and comment nodes)
56
     *         return null.
57
     */
58
    const char * getNodeName();
59
    
60
    const char* getBaseUri();
61
    
62
    
63
    XdmValue * getTypedValue();
64
    
65
    XdmNode* getParent();
66

    
67
    
68
    const char* getAttributeValue(const char *str);
69
    
70
    int getAttributeCount();
71

    
72
    XdmNode** getAttributeNodes();
73

    
74
    
75
    XdmNode** getChildren();
76

    
77
    int getChildCount();
78

    
79
     /**
80
        * Get the type of the object
81
        */
82
    XDM_TYPE getType(){
83
        return XDM_NODE;
84
    }
85
    
86
   // const char* getOuterXml();
87

    
88

    
89
    
90
private:
91
        const char * baseURI;
92
        const char * nodeName;
93
        XdmNode ** children; //caches child nodes when getChildren method is first called;
94
        int childCount;
95
        XdmNode * parent;
96
        XdmNode ** attrValues;//caches attribute nodes when getAttributeNodes method is first called;
97
        int attrCount;
98
        XDM_NODE_KIND nodeKind;
99
    
100
};
101

    
102
#endif
(6-6/10)