Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:06

0001 /*=============================================================================
0002     Copyright (c) 2001-2007 Hartmut Kaiser
0003     Copyright (c) 2001-2003 Daniel Nuffer
0004     http://spirit.sourceforge.net/
0005 
0006   Distributed under the Boost Software License, Version 1.0. (See accompanying
0007   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 =============================================================================*/
0009 
0010 #ifndef BOOST_SPIRIT_CLASSIC_TREE_TREE_TO_XML_HPP
0011 #define BOOST_SPIRIT_CLASSIC_TREE_TREE_TO_XML_HPP
0012 
0013 #include <boost/spirit/home/classic/namespace.hpp>
0014 
0015 namespace boost { namespace spirit {
0016 
0017 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0018 
0019     namespace impl {
0020         template <typename CharT> struct default_string;
0021     }
0022     
0023 ///////////////////////////////////////////////////////////////////////////////
0024 //
0025 //  Dump a parse tree as a xml stream
0026 //
0027 //      The functions 'tree_to_xml' can be used to output a parse tree as a xml
0028 //      stream into the given ostream. The parameters have the following
0029 //      meaning:
0030 //
0031 //  mandatory parameters:
0032 //      ostrm       The output stream used for streaming the parse tree.
0033 //      tree        The parse tree to output.
0034 //
0035 //  optional parameters:
0036 //      input_line  The input line from which the parse tree was
0037 //                  generated (if given, it is used to output a comment
0038 //                  containing this line).
0039 //      id_to_name  A map, which is used for converting the rule id's contained
0040 //                  in the parse tree to readable strings. Here a auxiliary
0041 //                  associative container can be used, which maps a rule_id to
0042 //                  a std::string (i.e. a std::map<rule_id, std::string>).
0043 //      get_token_id
0044 //                  A function or functor, which takes an instance of a token
0045 //                  and which should return a token id (i.e. something like
0046 //                  'int f(char const c)').
0047 //      get_token_value
0048 //                  A function or functor, which takes an instance of a token
0049 //                  and which should return a readable representation of this
0050 //                  token (i.e. something like 'std::string f(char const c)').
0051 //
0052 //  The structure of the generated xml stream conforms to the DTD given in the
0053 //  file 'parsetree.dtd'. This file is located in the spirit/tree directory.
0054 //
0055 ///////////////////////////////////////////////////////////////////////////////
0056 
0057     template <
0058         typename CharT, typename TreeNodeT, typename AssocContainerT,
0059         typename GetIdT, typename GetValueT
0060     >
0061     inline void 
0062     basic_tree_to_xml (std::basic_ostream<CharT> &ostrm, TreeNodeT const &tree,
0063         std::basic_string<CharT> const &input_line, 
0064         AssocContainerT const& id_to_name, GetIdT const &get_token_id, 
0065         GetValueT const &get_token_value);
0066 
0067     template <typename CharT, typename TreeNodeT, typename AssocContainerT>
0068     inline void 
0069     basic_tree_to_xml (std::basic_ostream<CharT> &ostrm, TreeNodeT const &tree,
0070         std::basic_string<CharT> const &input_line, 
0071         AssocContainerT const& id_to_name);
0072 
0073     template <typename CharT, typename TreeNodeT>
0074     inline void 
0075     basic_tree_to_xml (std::basic_ostream<CharT> &ostrm, TreeNodeT const &tree,
0076         std::basic_string<CharT> const &input_line = 
0077             impl::default_string<CharT>::get());
0078 
0079     ///////////////////////////////////////////////////////////////////////////
0080     template <
0081         typename TreeNodeT, typename AssocContainerT,
0082         typename GetIdT, typename GetValueT
0083     >
0084     inline void 
0085     tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
0086         std::string const &input_line, AssocContainerT const& id_to_name, 
0087         GetIdT const &get_token_id, GetValueT const &get_token_value)
0088     {
0089         basic_tree_to_xml<char>(ostrm, tree, input_line, id_to_name, 
0090             get_token_id, get_token_value);
0091     }
0092 
0093     template <typename TreeNodeT, typename AssocContainerT>
0094     inline void 
0095     tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
0096         std::string const &input_line, AssocContainerT const& id_to_name)
0097     {
0098         basic_tree_to_xml<char>(ostrm, tree, input_line, id_to_name);
0099     }
0100     
0101     template <typename TreeNodeT>
0102     inline void 
0103     tree_to_xml (std::ostream &ostrm, TreeNodeT const &tree,
0104         std::string const &input_line = "")
0105     {
0106         basic_tree_to_xml<char>(ostrm, tree, input_line);
0107     }
0108 
0109 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0110 
0111 }} // namespace BOOST_SPIRIT_CLASSIC_NS
0112 
0113 #include <boost/spirit/home/classic/tree/impl/tree_to_xml.ipp>
0114 
0115 #endif
0116