Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Nodes.h
1 /*
2  * $Id$
3  * xom::Nodes class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2009, 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_NODES_H_
23 #define ELM_XOM_NODES_H_
24 
25 #include <elm/util/MessageException.h>
26 #include <elm/data/Vector.h>
27 #include <elm/xom/Node.h>
28 
29 namespace elm { namespace xom {
30 
31 // Nodes class
32 class Nodes {
33 public:
34  inline Nodes(void) { }
35  inline Nodes(Node *node) { nodes.add(node); }
36  inline Nodes(const Nodes& n): nodes(n.nodes) { }
37  inline Nodes& operator=(const Nodes& n)
38  { nodes.clear(); nodes.addAll(n.nodes); return *this; }
39 
40  inline void append(Node *node) { nodes.add(node); }
41  inline bool contains(Node *node) const { return nodes.contains(node); }
42  inline Node *get(int index) const { return nodes[index]; }
43  inline void insert(Node *node, int index) { nodes.insert(index, node); }
44  inline Node *remove(int index)
45  { Node *node = nodes[index]; nodes.remove(node); return node; }
46  inline int size(void) const { return nodes.count(); }
47 private:
48  Vector<Node *> nodes;
49 };
50 
51 // XMLException class
53 public:
54  inline XMLException(const string& message): MessageException(message) { }
55 };
56 
57 } } // elm::xom
58 
59 #endif /* ELM_XOM_NODES_H_ */
Definition: MessageException.h:30
virtual String message(void)
Definition: util_MessageException.cpp:50
void addAll(const C &c)
Definition: Vector.h:116
void insert(int i, const T &v)
Definition: Vector.h:152
int count(void) const
Definition: Vector.h:88
bool contains(const T &v) const
Definition: Vector.h:89
void remove(const T &value)
Definition: Vector.h:118
void add(const T &v)
Definition: Vector.h:115
void clear(void)
Definition: Vector.h:114
Definition: Node.h:40
Definition: Nodes.h:32
Nodes(void)
Definition: Nodes.h:34
void append(Node *node)
Definition: Nodes.h:40
Nodes(Node *node)
Definition: Nodes.h:35
Node * remove(int index)
Definition: Nodes.h:44
Nodes & operator=(const Nodes &n)
Definition: Nodes.h:37
bool contains(Node *node) const
Definition: Nodes.h:41
Node * get(int index) const
Definition: Nodes.h:42
void insert(Node *node, int index)
Definition: Nodes.h:43
int size(void) const
Definition: Nodes.h:46
Nodes(const Nodes &n)
Definition: Nodes.h:36
Definition: Nodes.h:52
XMLException(const string &message)
Definition: Nodes.h:54
Definition: adapter.h:26