Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
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
elm::xom::Node::node
void * node
Definition: Node.h:60
elm::xom::Node::kind
kind_t kind(void) const
Definition: xom_Node.cpp:172
elm::xom::Node::query
virtual Nodes * query(const String &xpath)
Definition: xom_Node.cpp:414
elm::xom::Node::TEXT
@ TEXT
Definition: Node.h:50
elm::xom::Node::equals
bool equals(const Node *node) const
Definition: xom_Node.cpp:239
elm::xom::Nodes
Definition: Nodes.h:32
elm::xom::Node::getChild
virtual Node * getChild(int index)=0
elm::xom::Node::~Node
virtual ~Node(void)
Definition: xom_Node.cpp:113
elm::xom::Node::ELEMENT
@ ELEMENT
Definition: Node.h:48
elm::xom::Node::DOCUMENT
@ DOCUMENT
Definition: Node.h:49
elm::xom::Node::ATTRIBUTE
@ ATTRIBUTE
Definition: Node.h:52
elm::xom::String
Definition: String.h:35
elm::xom::Node::freeNode
static void freeNode(void *node)
Definition: xom_Node.cpp:95
elm::xom::Node::getDocument
virtual Document * getDocument(void)
Definition: xom_Node.cpp:321
elm::xom::Node::COMMENT
@ COMMENT
Definition: Node.h:51
elm::xom::Node::kind_t
kind_t
Definition: Node.h:46
elm::xom::Node::internGetChildCount
int internGetChildCount(void)
Definition: xom_Node.cpp:310
elm::xom::Node::getChildCount
virtual int getChildCount(void)=0
elm::xom::Node::internToXML
String internToXML(void)
Definition: xom_Node.cpp:390
elm
Definition: adapter.h:26
elm::xom::Elements
Definition: Elements.h:19
elm::xom::Node::Node
Node(void *_node)
Definition: xom_Node.cpp:131
elm::xom::Node::make
Node * make(void *node)
Definition: xom_Node.cpp:143
elm::xom::Node::internGetValue
String internGetValue(void)
Definition: xom_Node.cpp:222
elm::xom::Node::internCopy
Node * internCopy(void)
elm::xom::Node::NAMESPACE
@ NAMESPACE
Definition: Node.h:55
elm::xom::ParentNode
Definition: ParentNode.h:15
elm::xom::Node::detach
void detach(void)
Definition: xom_Node.cpp:230
elm::xom::Builder
Definition: Builder.h:20
elm::xom::Node::getValue
virtual String getValue(void)=0
elm::xom::Document
Definition: Document.h:20
elm::xom::Node::DOCTYPE
@ DOCTYPE
Definition: Node.h:54
elm::xom::Node::getParent
virtual ParentNode * getParent(void)
Definition: xom_Node.cpp:207
elm::xom::Node::get
Node * get(void *node)
Definition: xom_macros.h:17
elm::xom::Node::copy
virtual Node * copy(void)=0
elm::xom::Node::internGetChild
Node * internGetChild(int index)
Definition: xom_Node.cpp:294
elm::xom::Node::PROCESSING_INSTRUCTION
@ PROCESSING_INSTRUCTION
Definition: Node.h:53
elm::xom::XIncluder
Definition: XIncluder.h:15
elm::xom::Node::toXML
virtual String toXML(void)=0
elm::xom::Node::NONE
@ NONE
Definition: Node.h:47
elm::xom::Node::getNode
void * getNode(void) const
Definition: Node.h:95
elm::xom::Node::line
int line(void) const
Definition: xom_Node.cpp:424
elm::xom::Node::setNode
void setNode(void *_node)
Definition: xom_Node.cpp:121
elm::xom::Node::getBaseURI
virtual String getBaseURI(void)
Definition: xom_Node.cpp:279
elm::xom::Node
Definition: Node.h:40