1 // Copyright (c) 2005 Carl Barron. Distributed under the Boost 2 // Software License, Version 1.0. (See accompanying file 3 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 5 #include "tag.hpp" 6 #include <iostream> 7 #include <algorithm> 8 9 namespace 10 { 11 struct print_pair 12 { 13 template <class P> operator ()__anon97f1bca70111::print_pair14 void operator () (const P &x) 15 { 16 std::cout << '\t' << x.first << ':' << x.second <<'\n'; 17 } 18 }; 19 20 } 21 operator ()(const std::string & x)22void walk_data::operator () (const std::string &x) 23 { 24 std::cout << "String:" << x <<'\n'; 25 } 26 operator ()(const tag & t)27void walk_data::operator () (const tag &t) 28 { 29 std::cout << "Tag:" << t.id << '\n'; 30 std::cout << "Attributes\n"; 31 32 std::for_each 33 ( 34 t.attributes.begin(), 35 t.attributes.end(), 36 print_pair() 37 ); 38 std::cout << "Children:\n"; 39 std::for_each 40 ( 41 t.children.begin(), 42 t.children.end(), 43 boost::apply_visitor(*this) 44 ); 45 std::cout << "End of tag:" << t.id << '\n'; 46 } 47