Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:39

0001 //  Copyright (c) 2001-2011 Hartmut Kaiser
0002 // 
0003 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
0004 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #if !defined(BOOST_SPIRIT_KARMA_FORMAT_MANIP_MAY_01_2007_1211PM)
0007 #define BOOST_SPIRIT_KARMA_FORMAT_MANIP_MAY_01_2007_1211PM
0008 
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012 
0013 #include <boost/spirit/home/karma/generate.hpp>
0014 #include <boost/spirit/home/karma/generator.hpp>
0015 #include <boost/spirit/home/karma/detail/output_iterator.hpp>
0016 #include <boost/spirit/home/karma/stream/detail/format_manip.hpp>
0017 #include <boost/spirit/home/support/unused.hpp>
0018 #include <boost/mpl/bool.hpp>
0019 #include <iosfwd>
0020 
0021 ///////////////////////////////////////////////////////////////////////////////
0022 namespace boost { namespace spirit { namespace karma 
0023 {
0024     ///////////////////////////////////////////////////////////////////////////
0025     template <typename Expr>
0026     inline typename detail::format<Expr>::type 
0027     format(Expr const& expr)
0028     {
0029         return detail::format<Expr>::call(expr);
0030     }
0031 
0032     template <typename Expr, typename Attribute>
0033     inline detail::format_manip<Expr, mpl::false_, mpl::false_, unused_type, Attribute> 
0034     format(
0035         Expr const& expr
0036       , Attribute const& attr)
0037     {
0038         using karma::detail::format_manip;
0039 
0040         // Report invalid expression error as early as possible.
0041         // If you got an error_invalid_expression error message here,
0042         // then the expression (expr) is not a valid spirit karma expression.
0043         BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
0044         return format_manip<Expr, mpl::false_, mpl::false_, unused_type, Attribute>(
0045             expr, unused, attr);
0046     }
0047 
0048     ///////////////////////////////////////////////////////////////////////////
0049     template <typename Expr, typename Delimiter>
0050     inline typename detail::format_delimited<Expr, Delimiter>::type 
0051     format_delimited(
0052         Expr const& expr
0053       , Delimiter const& d
0054       , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit = 
0055             delimit_flag::dont_predelimit)
0056     {
0057         return detail::format_delimited<Expr, Delimiter>::call(expr, d, pre_delimit);
0058     }
0059 
0060     template <typename Expr, typename Delimiter, typename Attribute>
0061     inline detail::format_manip<Expr, mpl::false_, mpl::false_, Delimiter, Attribute> 
0062     format_delimited(
0063         Expr const& xpr
0064       , Delimiter const& d
0065       , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit
0066       , Attribute const& attr)
0067     {
0068         using karma::detail::format_manip;
0069 
0070         // Report invalid expression error as early as possible.
0071         // If you got an error_invalid_expression error message here,
0072         // then the expression (expr) is not a valid spirit karma expression.
0073         BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
0074         BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
0075         return format_manip<Expr, mpl::false_, mpl::false_, Delimiter, Attribute>(
0076             xpr, d, pre_delimit, attr);
0077     }
0078 
0079     template <typename Expr, typename Delimiter, typename Attribute>
0080     inline detail::format_manip<Expr, mpl::false_, mpl::false_, Delimiter, Attribute> 
0081     format_delimited(
0082         Expr const& xpr
0083       , Delimiter const& d
0084       , Attribute const& attr)
0085     {
0086         using karma::detail::format_manip;
0087 
0088         // Report invalid expression error as early as possible.
0089         // If you got an error_invalid_expression error message here,
0090         // then the expression (expr) is not a valid spirit karma expression.
0091         BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
0092         BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Delimiter);
0093         return format_manip<Expr, mpl::false_, mpl::false_, Delimiter, Attribute>(
0094             xpr, d, delimit_flag::dont_predelimit, attr);
0095     }
0096 
0097     ///////////////////////////////////////////////////////////////////////////
0098     template<typename Char, typename Traits, typename Derived> 
0099     inline std::basic_ostream<Char, Traits> & 
0100     operator<< (std::basic_ostream<Char, Traits> &os, generator<Derived> const& g)
0101     {
0102         typedef traits::properties_of<
0103             typename result_of::compile<karma::domain, Derived>::type
0104         > properties;
0105         typedef karma::ostream_iterator<Char, Char, Traits> outiter_type;
0106 
0107         outiter_type target_sink(os);
0108         karma::detail::output_iterator<outiter_type, properties> sink(target_sink);
0109 
0110         if (!g.derived().generate(sink, unused, unused, unused))
0111         {
0112             os.setstate(std::basic_ostream<Char, Traits>::failbit);
0113         }
0114         return os;
0115     }
0116 }}}
0117 
0118 #endif 
0119