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