StarEngine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
foreach.hpp
Go to the documentation of this file.
1 /*
2  * Boost.Foreach support for pugixml classes.
3  * This file is provided to the public domain.
4  * Written by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
5  */
6 
7 #ifndef HEADER_PUGIXML_FOREACH_HPP
8 #define HEADER_PUGIXML_FOREACH_HPP
9 
10 #include "pugixml.hpp"
11 
12 /*
13  * These types add support for BOOST_FOREACH macro to xml_node and xml_document classes (child iteration only).
14  * Example usage:
15  * BOOST_FOREACH(xml_node n, doc) {}
16  */
17 
18 namespace boost
19 {
20  template <typename> struct range_mutable_iterator;
21  template <typename> struct range_const_iterator;
22 
23  template<> struct range_mutable_iterator<pugi::xml_node>
24  {
25  typedef pugi::xml_node::iterator type;
26  };
27 
28  template<> struct range_const_iterator<pugi::xml_node>
29  {
30  typedef pugi::xml_node::iterator type;
31  };
32 
33  template<> struct range_mutable_iterator<pugi::xml_document>
34  {
35  typedef pugi::xml_document::iterator type;
36  };
37 
38  template<> struct range_const_iterator<pugi::xml_document>
39  {
40  typedef pugi::xml_document::iterator type;
41  };
42 }
43 
44 /*
45  * These types add support for BOOST_FOREACH macro to xml_node and xml_document classes (child/attribute iteration).
46  * Example usage:
47  * BOOST_FOREACH(xml_node n, children(doc)) {}
48  * BOOST_FOREACH(xml_node n, attributes(doc)) {}
49  */
50 
51 namespace pugi
52 {
53  inline xml_object_range<xml_node_iterator> children(const pugi::xml_node& node)
54  {
55  return node.children();
56  }
57 
58  inline xml_object_range<xml_attribute_iterator> attributes(const pugi::xml_node& node)
59  {
60  return node.attributes();
61  }
62 }
63 
64 #endif
xml_object_range< xml_attribute_iterator > attributes(const pugi::xml_node &node)
Definition: foreach.hpp:58
xml_object_range< xml_node_iterator > children(const pugi::xml_node &node)
Definition: foreach.hpp:53