[857] | 1 | /*=============================================================================
|
---|
| 2 | Copyright (c) 2001-2003 Daniel Nuffer
|
---|
| 3 | Copyright (c) 2001-2003 Hartmut Kaiser
|
---|
| 4 | http://spirit.sourceforge.net/
|
---|
| 5 |
|
---|
| 6 | Use, modification and distribution is subject to the Boost Software
|
---|
| 7 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
| 8 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 9 | =============================================================================*/
|
---|
| 10 |
|
---|
| 11 | #if !defined(TREE_TO_XML_HPP)
|
---|
| 12 | #define TREE_TO_XML_HPP
|
---|
| 13 |
|
---|
| 14 | namespace boost { namespace spirit {
|
---|
| 15 |
|
---|
| 16 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 17 | //
|
---|
| 18 | // Dump a parse tree as a xml stream
|
---|
| 19 | //
|
---|
| 20 | // The functions 'tree_to_xml' can be used to output a parse tree as a xml
|
---|
| 21 | // stream into the given ostream. The parameters have the following
|
---|
| 22 | // meaning:
|
---|
| 23 | //
|
---|
| 24 | // mandatory parameters:
|
---|
| 25 | // ostrm The output stream used for streaming the parse tree.
|
---|
| 26 | // tree The parse tree to output.
|
---|
| 27 | //
|
---|
| 28 | // optional parameters:
|
---|
| 29 | // input_line The input line from which the parse tree was
|
---|
| 30 | // generated (if given, it is used to output a comment
|
---|
| 31 | // containing this line).
|
---|
| 32 | // id_to_name A map, which is used for converting the rule id's contained
|
---|
| 33 | // in the parse tree to readable strings. Here a auxiliary
|
---|
| 34 | // associative container can be used, which maps a rule_id to
|
---|
| 35 | // a std::string (i.e. a std::map<rule_id, std::string>).
|
---|
| 36 | // get_token_id
|
---|
| 37 | // A function or functor, which takes an instance of a token
|
---|
| 38 | // and which should return a token id (i.e. something like
|
---|
| 39 | // 'int f(char const c)').
|
---|
| 40 | // get_token_value
|
---|
| 41 | // A function or functor, which takes an instance of a token
|
---|
| 42 | // and which should return a readable representation of this
|
---|
| 43 | // token (i.e. something like 'std::string f(char const c)').
|
---|
| 44 | //
|
---|
| 45 | // The structure of the generated xml stream conforms to the DTD given in the
|
---|
| 46 | // file 'parsetree.dtd'. This file is located in the spirit/tree directory.
|
---|
| 47 | //
|
---|
| 48 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 49 |
|
---|
| 50 | template <
|
---|
| 51 | typename TreeNodeT, typename AssocContainerT,
|
---|
| 52 | typename GetIdT, typename GetValueT
|
---|
| 53 | >
|
---|
| 54 | void tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
|
---|
| 55 | std::string const &input_line, AssocContainerT const& id_to_name,
|
---|
| 56 | GetIdT const &get_token_id, GetValueT const &get_token_value);
|
---|
| 57 |
|
---|
| 58 | template <typename TreeNodeT, typename AssocContainerT>
|
---|
| 59 | void tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
|
---|
| 60 | std::string const &input_line, AssocContainerT const& id_to_name);
|
---|
| 61 |
|
---|
| 62 | template <typename TreeNodeT>
|
---|
| 63 | void tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
|
---|
| 64 | std::string const &input_line = "");
|
---|
| 65 |
|
---|
| 66 | }} // namespace boost::spirit
|
---|
| 67 |
|
---|
| 68 | #include <boost/spirit/tree/impl/tree_to_xml.ipp>
|
---|
| 69 |
|
---|
| 70 | #endif // !defined(TREE_TO_XML_HPP)
|
---|
| 71 |
|
---|