transform_error_message.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef BOOST_METAPARSE_V1_TRANSFORM_ERROR_MESSAGE_HPP
  2. #define BOOST_METAPARSE_V1_TRANSFORM_ERROR_MESSAGE_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2015.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/metaparse/v1/is_error.hpp>
  8. #include <boost/metaparse/v1/reject.hpp>
  9. #include <boost/metaparse/v1/get_position.hpp>
  10. #include <boost/metaparse/v1/get_message.hpp>
  11. #include <boost/mpl/eval_if.hpp>
  12. namespace boost
  13. {
  14. namespace metaparse
  15. {
  16. namespace v1
  17. {
  18. template <class P, class F>
  19. struct transform_error_message
  20. {
  21. template <class R>
  22. struct rejection :
  23. reject<
  24. typename F::template apply<typename get_message<R>::type>::type,
  25. get_position<R>
  26. >
  27. {};
  28. template <class S, class Pos>
  29. struct apply :
  30. boost::mpl::eval_if<
  31. typename is_error<typename P::template apply<S, Pos> >::type,
  32. rejection<typename P::template apply<S, Pos> >,
  33. typename P::template apply<S, Pos>
  34. >
  35. {};
  36. typedef transform_error_message type;
  37. };
  38. }
  39. }
  40. }
  41. #endif