]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/docutils/tools/doxygen_xml2qbk/rapidxml_util.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / docutils / tools / doxygen_xml2qbk / rapidxml_util.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 //
3 // Copyright (c) 2010-2013 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 //
10 #ifndef RAPIDXML_UTIL_HPP
11 #define RAPIDXML_UTIL_HPP
12
13
14 #include <string>
15 #include <rapidxml.hpp>
16
17 class xml_doc : public rapidxml::xml_document<>
18 {
19 public :
20 xml_doc(const char* xml)
21 {
22 // Make a copy because rapidxml destructs string
23 m_copy = new char[strlen(xml) + 1];
24 strcpy(m_copy, xml);
25 this->parse<0>(m_copy);
26 };
27 virtual ~xml_doc()
28 {
29 delete[] m_copy;
30 }
31 private :
32 char* m_copy;
33
34 };
35
36 inline std::string get_attribute(rapidxml::xml_node<>* node, const char* name)
37 {
38 rapidxml::xml_attribute<> *attr = node->first_attribute(name);
39 std::string value;
40 if (attr)
41 {
42 value = attr->value();
43 }
44 return value;
45 }
46
47 inline void get_contents(rapidxml::xml_node<>* node, std::string& contents)
48 {
49 if (node != NULL)
50 {
51 if (node->type() == rapidxml::node_element)
52 {
53 //std::cout << "ELEMENT: " << node->name() << "=" << node->value() << std::endl;
54 }
55 else if (node->type() == rapidxml::node_data)
56 {
57 contents += node->value();
58 //std::cout << "DATA: " << node->name() << "=" << node->value() << std::endl;
59 }
60 else
61 {
62 //std::cout << "OTHER: " << node->name() << "=" << node->value() << std::endl;
63 }
64 get_contents(node->first_node(), contents);
65 get_contents(node->next_sibling(), contents);
66 }
67 }
68
69 #endif // RAPIDXML_UTIL_HPP