match_manip_auto.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Hartmut Kaiser
  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. ==============================================================================*/
  6. #if !defined(BOOST_SPIRIT_MATCH_MANIP_AUTO_DEC_02_2009_0813PM)
  7. #define BOOST_SPIRIT_MATCH_MANIP_AUTO_DEC_02_2009_0813PM
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <boost/spirit/home/qi/stream/detail/match_manip.hpp>
  12. #include <boost/spirit/home/qi/auto/create_parser.hpp>
  13. #include <boost/utility/enable_if.hpp>
  14. ///////////////////////////////////////////////////////////////////////////////
  15. namespace boost { namespace spirit { namespace qi { namespace detail
  16. {
  17. ///////////////////////////////////////////////////////////////////////////
  18. template <typename Expr>
  19. struct match<Expr
  20. , typename enable_if<traits::meta_create_exists<qi::domain, Expr> >::type>
  21. {
  22. typedef typename result_of::create_parser<Expr>::type expr_type;
  23. typedef match_manip<
  24. expr_type, mpl::true_, mpl::false_, unused_type, Expr
  25. > type;
  26. static type call(Expr const& expr)
  27. {
  28. return type(create_parser<Expr>(), unused, const_cast<Expr&>(expr));
  29. }
  30. };
  31. ///////////////////////////////////////////////////////////////////////////
  32. template <typename Expr, typename Skipper>
  33. struct phrase_match<Expr, Skipper
  34. , typename enable_if<traits::meta_create_exists<qi::domain, Expr> >::type>
  35. {
  36. typedef typename result_of::create_parser<Expr>::type expr_type;
  37. typedef match_manip<
  38. expr_type, mpl::true_, mpl::false_, Skipper, Expr
  39. > type;
  40. static type call(
  41. Expr const& expr
  42. , Skipper const& skipper
  43. , BOOST_SCOPED_ENUM(skip_flag) post_skip)
  44. {
  45. // Report invalid expression error as early as possible.
  46. // If you got an error_invalid_expression error message here,
  47. // then the delimiter is not a valid spirit karma expression.
  48. BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
  49. return type(create_parser<Expr>(), skipper, post_skip
  50. , const_cast<Expr&>(expr));
  51. }
  52. };
  53. }}}}
  54. #endif