GPL v2.
[metaproxy-moved-to-github.git] / src / xmlutil.hpp
1 /* $Id: xmlutil.hpp,v 1.12 2007-05-09 21:23:09 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3
4 This file is part of Metaproxy.
5
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #ifndef XML_UTIL_HPP
23 #define XML_UTIL_HPP
24
25 #include <string>
26 #include <stdexcept>
27 #include <libxml/tree.h>
28
29 namespace metaproxy_1 {
30     namespace xml {
31         std::string get_text(const struct _xmlAttr *ptr);
32         std::string get_text(const xmlNode *ptr);
33         bool get_bool(const xmlNode *ptr, bool default_value);
34         int get_int(const xmlNode *ptr, int default_value);
35         bool check_attribute(const _xmlAttr *ptr, 
36                         const std::string &ns,
37                         const std::string &name);
38         bool is_attribute(const _xmlAttr *ptr, 
39                         const std::string &ns,
40                         const std::string &name);
41         bool is_element(const xmlNode *ptr, 
42                         const std::string &ns,
43                         const std::string &name);
44         bool is_element_mp(const xmlNode *ptr, const std::string &name);
45         bool check_element_mp(const xmlNode *ptr, 
46                                const std::string &name);
47         std::string get_route(const xmlNode *node);
48
49         const xmlNode* jump_to(const xmlNode* node, int node_type);
50
51         const xmlNode* jump_to_next(const xmlNode* node, int node_type);
52         
53         const xmlNode* jump_to_children(const xmlNode* node, int node_type);
54
55         void check_empty(const xmlNode *node);
56
57     }
58     class XMLError : public std::runtime_error {
59     public:
60         XMLError(const std::string msg) :
61             std::runtime_error("XMLError : " + msg) {} ;
62     };
63 }
64
65 #endif
66 /*
67  * Local variables:
68  * c-basic-offset: 4
69  * indent-tabs-mode: nil
70  * c-file-style: "stroustrup"
71  * End:
72  * vim: shiftwidth=4 tabstop=8 expandtab
73  */