fail_function.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #if !defined(SPIRIT_FAIL_FUNCTION_APRIL_22_2006_0159PM)
  7. #define SPIRIT_FAIL_FUNCTION_APRIL_22_2006_0159PM
  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. template <typename Iterator, typename Context, typename Skipper>
  15. struct fail_function
  16. {
  17. typedef Iterator iterator_type;
  18. typedef Context context_type;
  19. fail_function(
  20. Iterator& first_, Iterator const& last_
  21. , Context& context_, Skipper const& skipper_)
  22. : first(first_)
  23. , last(last_)
  24. , context(context_)
  25. , skipper(skipper_)
  26. {
  27. }
  28. template <typename Component, typename Attribute>
  29. bool operator()(Component const& component, Attribute& attr) const
  30. {
  31. // return true if the parser fails
  32. return !component.parse(first, last, context, skipper, attr);
  33. }
  34. template <typename Component>
  35. bool operator()(Component const& component) const
  36. {
  37. // return true if the parser fails
  38. return !component.parse(first, last, context, skipper, unused);
  39. }
  40. Iterator& first;
  41. Iterator const& last;
  42. Context& context;
  43. Skipper const& skipper;
  44. // silence MSVC warning C4512: assignment operator could not be generated
  45. BOOST_DELETED_FUNCTION(fail_function& operator= (fail_function const&))
  46. };
  47. }}}}
  48. #endif