1
/*=============================================================================
3
Copyright (c) 2001-2003 Daniel Nuffer
4
Copyright (c) 2001-2003 Hartmut Kaiser
5
http://spirit.sourceforge.net/
7
Permission to copy, use, modify, sell and distribute this software is
8
granted provided this copyright notice appears in all copies. This
9
software is provided "as is" without express or implied warranty, and
10
with no claim as to its suitability for any purpose.
11
=============================================================================*/
13
#if !defined(TREE_TO_XML_HPP)
14
#define TREE_TO_XML_HPP
16
namespace boost { namespace spirit {
18
///////////////////////////////////////////////////////////////////////////////
20
// Dump a parse tree as a xml stream
22
// The functions 'tree_to_xml' can be used to output a parse tree as a xml
23
// stream into the given ostream. The parameters have the following
26
// mandatory parameters:
27
// ostrm The output stream used for streaming the parse tree.
28
// tree The parse tree to output.
30
// optional parameters:
31
// input_line The input line from which the parse tree was
32
// generated (if given, it is used to output a comment
33
// containing this line).
34
// id_to_name A map, which is used for converting the rule id's contained
35
// in the parse tree to readable strings. Here a auxiliary
36
// associative container can be used, which maps a rule_id to
37
// a std::string (i.e. a std::map<rule_id, std::string>).
39
// A function or functor, which takes an instance of a token
40
// and which should return a token id (i.e. something like
41
// 'int f(char const c)').
43
// A function or functor, which takes an instance of a token
44
// and which should return a readable representation of this
45
// token (i.e. something like 'std::string f(char const c)').
47
// The structure of the generated xml stream conforms to the DTD given in the
48
// file 'parsetree.dtd'. This file is located in the spirit/tree directory.
50
///////////////////////////////////////////////////////////////////////////////
53
typename TreeNodeT, typename AssocContainerT,
54
typename GetIdT, typename GetValueT
56
void tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
57
std::string const &input_line, AssocContainerT const& id_to_name,
58
GetIdT const &get_token_id, GetValueT const &get_token_value);
60
template <typename TreeNodeT, typename AssocContainerT>
61
void tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
62
std::string const &input_line, AssocContainerT const& id_to_name);
64
template <typename TreeNodeT>
65
void tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
66
std::string const &input_line = "");
68
}} // namespace boost::spirit
70
#include "boost/spirit/tree/impl/tree_to_xml.ipp"
72
#endif // !defined(TREE_TO_XML_HPP)