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_ */
elm::MessageException
Definition: MessageException.h:30
elm::Vector::insert
void insert(int i, const T &v)
Definition: Vector.h:138
elm::xom::Nodes
Definition: Nodes.h:32
elm::Vector::count
int count(void) const
Definition: Vector.h:81
elm::xom::Nodes::operator=
Nodes & operator=(const Nodes &n)
Definition: Nodes.h:37
elm::MessageException::message
virtual String message(void)
Definition: util_MessageException.cpp:50
elm::xom::XMLException::XMLException
XMLException(const string &message)
Definition: Nodes.h:54
elm::xom::Nodes::remove
Node * remove(int index)
Definition: Nodes.h:44
elm::xom::Nodes::Nodes
Nodes(const Nodes &n)
Definition: Nodes.h:36
elm::xom::Nodes::Nodes
Nodes(void)
Definition: Nodes.h:34
elm::xom::XMLException
Definition: Nodes.h:52
elm
Definition: adapter.h:26
elm::Vector::add
void add(const T &v)
Definition: Vector.h:101
elm::Vector< Node * >
elm::Vector::contains
bool contains(const T &v) const
Definition: Vector.h:82
elm::xom::Nodes::get
Node * get(int index) const
Definition: Nodes.h:42
elm::Vector::addAll
void addAll(const C &c)
Definition: Vector.h:102
elm::xom::Nodes::insert
void insert(Node *node, int index)
Definition: Nodes.h:43
elm::Vector::remove
void remove(const T &value)
Definition: Vector.h:104
elm::xom::Nodes::contains
bool contains(Node *node) const
Definition: Nodes.h:41
elm::xom::Nodes::size
int size(void) const
Definition: Nodes.h:46
elm::xom::Nodes::append
void append(Node *node)
Definition: Nodes.h:40
elm::Vector::clear
void clear(void)
Definition: Vector.h:100
elm::xom::Nodes::Nodes
Nodes(Node *node)
Definition: Nodes.h:35
elm::xom::Node
Definition: Node.h:40