generate_auto.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_DETAIL_GENERATE_AUTO_DEC_01_2009_0743PM)
  6. #define BOOST_SPIRIT_KARMA_DETAIL_GENERATE_AUTO_DEC_01_2009_0743PM
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/spirit/home/karma/generate.hpp>
  11. #include <boost/spirit/home/karma/auto/create_generator.hpp>
  12. #include <boost/utility/enable_if.hpp>
  13. #include <boost/mpl/not.hpp>
  14. #include <boost/mpl/and.hpp>
  15. namespace boost { namespace spirit { namespace karma { namespace detail
  16. {
  17. ///////////////////////////////////////////////////////////////////////////
  18. template <typename Expr>
  19. struct generate_impl<Expr
  20. , typename enable_if<
  21. mpl::and_<
  22. traits::meta_create_exists<karma::domain, Expr>
  23. , mpl::not_<traits::matches<karma::domain, Expr> > >
  24. >::type>
  25. {
  26. template <typename OutputIterator>
  27. static bool call(
  28. OutputIterator& sink
  29. , Expr const& expr)
  30. {
  31. return karma::generate(sink, create_generator<Expr>(), expr);
  32. }
  33. };
  34. ///////////////////////////////////////////////////////////////////////////
  35. template <typename Expr>
  36. struct generate_delimited_impl<Expr
  37. , typename enable_if<
  38. mpl::and_<
  39. traits::meta_create_exists<karma::domain, Expr>
  40. , mpl::not_<traits::matches<karma::domain, Expr> > >
  41. >::type>
  42. {
  43. template <typename OutputIterator, typename Delimiter>
  44. static bool call(
  45. OutputIterator& sink
  46. , Expr const& expr
  47. , Delimiter const& delimiter
  48. , BOOST_SCOPED_ENUM(delimit_flag) pre_delimit)
  49. {
  50. return karma::generate_delimited(
  51. sink, create_generator<Expr>(), delimiter, pre_delimit, expr);
  52. }
  53. };
  54. }}}}
  55. #endif