attr_begin_matcher.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // attr_begin_matcher.hpp
  3. //
  4. // Copyright 2008 Eric Niebler. Distributed under the Boost
  5. // Software License, Version 1.0. (See accompanying file
  6. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_ATTR_BEGIN_MATCHER_HPP_EAN_06_09_2007
  8. #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_ATTR_BEGIN_MATCHER_HPP_EAN_06_09_2007
  9. // MS compatible compilers support #pragma once
  10. #if defined(_MSC_VER)
  11. # pragma once
  12. #endif
  13. #include <boost/xpressive/detail/detail_fwd.hpp>
  14. #include <boost/xpressive/detail/core/quant_style.hpp>
  15. #include <boost/xpressive/detail/core/state.hpp>
  16. namespace boost { namespace xpressive { namespace detail
  17. {
  18. ///////////////////////////////////////////////////////////////////////////////
  19. // attr_begin_matcher
  20. //
  21. template<typename Nbr>
  22. struct attr_begin_matcher
  23. : quant_style<quant_none, 0, false>
  24. {
  25. template<typename BidiIter, typename Next>
  26. static bool match(match_state<BidiIter> &state, Next const &next)
  27. {
  28. void const *attr_slots[Nbr::value] = {};
  29. attr_context old_attr_context = state.attr_context_;
  30. state.attr_context_.attr_slots_ = attr_slots;
  31. state.attr_context_.prev_attr_context_ = &old_attr_context;
  32. if(next.match(state))
  33. {
  34. return true;
  35. }
  36. state.attr_context_ = old_attr_context;
  37. return false;
  38. }
  39. };
  40. }}}
  41. #endif