Windows: use Boost 1.59, msvc 14.0
[metaproxy-moved-to-github.git] / include / metaproxy / xmlutil.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 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
33         void parse_attr(const xmlNode *node, const char **names,
34                         std::string *values);
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         std::string get_route(const xmlNode *node, std::string &auth);
49
50         const xmlNode* jump_to(const xmlNode* node, int node_type);
51
52         const xmlNode* jump_to_next(const xmlNode* node, int node_type);
53
54         const xmlNode* jump_to_children(const xmlNode* node, int node_type);
55
56         void check_empty(const xmlNode *node);
57
58         std::string url_recipe_handle(xmlDoc *doc, std::string recipe);
59     }
60     class XMLError : public std::runtime_error {
61     public:
62         XMLError(const std::string msg) :
63             std::runtime_error("XMLError : " + msg) {} ;
64     };
65 }
66
67 #endif
68 /*
69  * Local variables:
70  * c-basic-offset: 4
71  * c-file-style: "Stroustrup"
72  * indent-tabs-mode: nil
73  * End:
74  * vim: shiftwidth=4 tabstop=8 expandtab
75  */
76