format_manip_auto.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #if !defined(BOOST_SPIRIT_KARMA_FORMAT_MANIP_AUTO_DEC_02_2009_1246PM)
  6. #define BOOST_SPIRIT_KARMA_FORMAT_MANIP_AUTO_DEC_02_2009_1246PM
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/spirit/home/karma/stream/detail/format_manip.hpp>
  11. #include <boost/spirit/home/karma/auto/create_generator.hpp>
  12. #include <boost/utility/enable_if.hpp>
  13. ///////////////////////////////////////////////////////////////////////////////
  14. namespace boost { namespace spirit { namespace karma { namespace detail
  15. {
  16. ///////////////////////////////////////////////////////////////////////////
  17. template <typename Expr>
  18. struct format<Expr
  19. , typename enable_if<traits::meta_create_exists<karma::domain, Expr> >::type>
  20. {
  21. typedef typename result_of::create_generator<Expr>::type expr_type;
  22. typedef format_manip<
  23. expr_type, mpl::true_, mpl::false_, unused_type, Expr
  24. > type;
  25. static type call(Expr const& expr)
  26. {
  27. return type(create_generator<Expr>(), unused, expr);
  28. }
  29. };
  30. ///////////////////////////////////////////////////////////////////////////
  31. template <typename Expr, typename Delimiter>
  32. struct format_delimited<Expr, Delimiter
  33. , typename enable_if<traits::meta_create_exists<karma::domain, Expr> >::type>
  34. {
  35. typedef typename result_of::create_generator<Expr>::type expr_type;
  36. typedef format_manip<
  37. expr_type, mpl::true_, mpl::false_, Delimiter, Expr
  38. > type;
  39. static type call(Expr const& expr
  40. , Delimiter const& delimiter
  41. , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit)
  42. {
  43. return type(create_generator<Expr>(), delimiter, pre_delimit, expr);
  44. }
  45. };
  46. }}}}
  47. #endif