fail_function.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  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. #ifndef BOOST_SPIRIT_QI_DETAIL_FAIL_FUNCTION_HPP
  7. #define BOOST_SPIRIT_QI_DETAIL_FAIL_FUNCTION_HPP
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <boost/spirit/home/support/unused.hpp>
  12. namespace boost { namespace spirit { namespace qi { namespace detail
  13. {
  14. #ifdef _MSC_VER
  15. # pragma warning(push)
  16. # pragma warning(disable: 4512) // assignment operator could not be generated.
  17. #endif
  18. template <typename Iterator, typename Context, typename Skipper>
  19. struct fail_function
  20. {
  21. typedef Iterator iterator_type;
  22. typedef Context context_type;
  23. fail_function(
  24. Iterator& first_, Iterator const& last_
  25. , Context& context_, Skipper const& skipper_)
  26. : first(first_)
  27. , last(last_)
  28. , context(context_)
  29. , skipper(skipper_)
  30. {
  31. }
  32. template <typename Component, typename Attribute>
  33. bool operator()(Component const& component, Attribute& attr) const
  34. {
  35. // return true if the parser fails
  36. return !component.parse(first, last, context, skipper, attr);
  37. }
  38. template <typename Component>
  39. bool operator()(Component const& component) const
  40. {
  41. // return true if the parser fails
  42. return !component.parse(first, last, context, skipper, unused);
  43. }
  44. Iterator& first;
  45. Iterator const& last;
  46. Context& context;
  47. Skipper const& skipper;
  48. };
  49. #ifdef _MSC_VER
  50. # pragma warning(pop)
  51. #endif
  52. }}}}
  53. #endif