]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/include/boost/spirit/home/classic/tree/tree_to_xml.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / spirit / include / boost / spirit / home / classic / tree / tree_to_xml.hpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2007 Hartmut Kaiser
3 Copyright (c) 2001-2003 Daniel Nuffer
4 http://spirit.sourceforge.net/
5
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8=============================================================================*/
9
10#if !defined(TREE_TO_XML_HPP)
11#define TREE_TO_XML_HPP
12
13#include <boost/spirit/home/classic/namespace.hpp>
14
15namespace boost { namespace spirit {
16
17BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
18
19 namespace impl {
20 template <typename CharT> struct default_string;
21 }
22
23///////////////////////////////////////////////////////////////////////////////
24//
25// Dump a parse tree as a xml stream
26//
27// The functions 'tree_to_xml' can be used to output a parse tree as a xml
28// stream into the given ostream. The parameters have the following
29// meaning:
30//
31// mandatory parameters:
32// ostrm The output stream used for streaming the parse tree.
33// tree The parse tree to output.
34//
35// optional parameters:
36// input_line The input line from which the parse tree was
37// generated (if given, it is used to output a comment
38// containing this line).
39// id_to_name A map, which is used for converting the rule id's contained
40// in the parse tree to readable strings. Here a auxiliary
41// associative container can be used, which maps a rule_id to
42// a std::string (i.e. a std::map<rule_id, std::string>).
43// get_token_id
44// A function or functor, which takes an instance of a token
45// and which should return a token id (i.e. something like
46// 'int f(char const c)').
47// get_token_value
48// A function or functor, which takes an instance of a token
49// and which should return a readable representation of this
50// token (i.e. something like 'std::string f(char const c)').
51//
52// The structure of the generated xml stream conforms to the DTD given in the
53// file 'parsetree.dtd'. This file is located in the spirit/tree directory.
54//
55///////////////////////////////////////////////////////////////////////////////
56
57 template <
58 typename CharT, typename TreeNodeT, typename AssocContainerT,
59 typename GetIdT, typename GetValueT
60 >
61 inline void
62 basic_tree_to_xml (std::basic_ostream<CharT> &ostrm, TreeNodeT const &tree,
63 std::basic_string<CharT> const &input_line,
64 AssocContainerT const& id_to_name, GetIdT const &get_token_id,
65 GetValueT const &get_token_value);
66
67 template <typename CharT, typename TreeNodeT, typename AssocContainerT>
68 inline void
69 basic_tree_to_xml (std::basic_ostream<CharT> &ostrm, TreeNodeT const &tree,
70 std::basic_string<CharT> const &input_line,
71 AssocContainerT const& id_to_name);
72
73 template <typename CharT, typename TreeNodeT>
74 inline void
75 basic_tree_to_xml (std::basic_ostream<CharT> &ostrm, TreeNodeT const &tree,
76 std::basic_string<CharT> const &input_line =
77 impl::default_string<CharT>::get());
78
79 ///////////////////////////////////////////////////////////////////////////
80 template <
81 typename TreeNodeT, typename AssocContainerT,
82 typename GetIdT, typename GetValueT
83 >
84 inline void
85 tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
86 std::string const &input_line, AssocContainerT const& id_to_name,
87 GetIdT const &get_token_id, GetValueT const &get_token_value)
88 {
89 basic_tree_to_xml<char>(ostrm, tree, input_line, id_to_name,
90 get_token_id, get_token_value);
91 }
92
93 template <typename TreeNodeT, typename AssocContainerT>
94 inline void
95 tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
96 std::string const &input_line, AssocContainerT const& id_to_name)
97 {
98 basic_tree_to_xml<char>(ostrm, tree, input_line, id_to_name);
99 }
100
101 template <typename TreeNodeT>
102 inline void
103 tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
104 std::string const &input_line = "")
105 {
106 basic_tree_to_xml<char>(ostrm, tree, input_line);
107 }
108
109BOOST_SPIRIT_CLASSIC_NAMESPACE_END
110
111}} // namespace BOOST_SPIRIT_CLASSIC_NS
112
113#include <boost/spirit/home/classic/tree/impl/tree_to_xml.ipp>
114
115#endif // !defined(TREE_TO_XML_HPP)
116