Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Node.h
1 /*
2  * $Id$
3  * xom::Comment class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2006-09, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef ELM_XOM_NODE_H
23 #define ELM_XOM_NODE_H
24 
25 #include <elm/xom/String.h>
26 
27 namespace elm { namespace xom {
28 
29 // Predeclaration
30 class Comment;
31 class Node;
32 class Document;
33 class ParentNode;
34 class NodeFactory;
35 class Nodes;
36 class XPathContext;
37 class Builder;
38 
39 // Node class
40 class Node {
41  friend class Builder;
42  friend class Elements;
43  friend class XIncluder;
44 
45 public:
46  typedef enum kind_t {
47  NONE = 0,
56  } kind_t;
57 
58 protected:
59  friend class ParentNode;
60  void *node;
61  Node(void *_node);
62  void setNode(void *_node);
63  Node *make(void *node);
64  inline Node *get(void *node);
65  Node *internCopy(void);
66  Node *internGetChild(int index);
67  int internGetChildCount(void);
68  String internGetValue(void);
69  String internToXML(void);
70  static void freeNode(void *node);
71 public:
72  virtual ~Node(void);
73  inline void *getNode(void) const;
74 
75  kind_t kind(void) const;
76  virtual Node *copy(void) = 0;
77  void detach(void);
78  bool equals(const Node * node) const;
79  virtual String getBaseURI(void);
80  virtual Node *getChild(int index) = 0;
81  virtual int getChildCount(void) = 0;
82  virtual Document *getDocument(void);
83  virtual ParentNode *getParent(void);
84  virtual String getValue(void) = 0;
85  virtual Nodes *query(const String& xpath);
86  virtual Nodes *query(const String& xpath, XPathContext *context);
87  virtual String toXML(void) = 0;
88 
89  // Non-XOM methods
90  int line(void) const;
91 };
92 
93 
94 // Node inlines
95 inline void *Node::getNode(void) const {
96  return node;
97 }
98 
99 } } // elm::xom
100 
101 #endif // ELM_XOM_NODE_H
Definition: Elements.h:19
Definition: XIncluder.h:15
Definition: Node.h:54
Node(void *_node)
Definition: xom_Node.cpp:131
Definition: Node.h:55
int internGetChildCount(void)
Definition: xom_Node.cpp:310
virtual String getBaseURI(void)
Definition: xom_Node.cpp:279
static void freeNode(void *node)
Definition: xom_Node.cpp:95
virtual Document * getDocument(void)
Definition: xom_Node.cpp:321
virtual ~Node(void)
Definition: xom_Node.cpp:113
virtual Node * getChild(int index)=0
Definition: Node.h:48
kind_t kind(void) const
Definition: xom_Node.cpp:172
Definition: Node.h:51
Definition: Node.h:52
virtual String getValue(void)=0
bool equals(const Node *node) const
Definition: xom_Node.cpp:239
void * getNode(void) const
Definition: Node.h:95
kind_t
Definition: Node.h:46
Definition: Node.h:50
virtual int getChildCount(void)=0
Definition: Document.h:20
Definition: String.h:38
void * node
Definition: Node.h:60
Definition: Node.h:47
void detach(void)
Definition: xom_Node.cpp:230
Node * internCopy(void)
Node * internGetChild(int index)
Definition: xom_Node.cpp:294
void setNode(void *_node)
Definition: xom_Node.cpp:121
virtual Nodes * query(const String &xpath)
Definition: xom_Node.cpp:414
virtual Node * copy(void)=0
Definition: Builder.h:20
virtual ParentNode * getParent(void)
Definition: xom_Node.cpp:207
Definition: Nodes.h:32
String internGetValue(void)
Definition: xom_Node.cpp:222
Node * make(void *node)
Definition: xom_Node.cpp:143
Definition: Node.h:40
virtual String toXML(void)=0
Definition: ParentNode.h:15
String internToXML(void)
Definition: xom_Node.cpp:390
int line(void) const
Definition: xom_Node.cpp:424
Definition: Node.h:49