pattern_parser.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*=============================================================================
  2. Boost.Wave: A Standard compliant C++ preprocessor library
  3. Global application configuration
  4. http://www.boost.org/
  5. Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
  6. Software License, Version 1.0. (See accompanying file
  7. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. =============================================================================*/
  9. #if !defined(BOOST_SPIRIT_PATTERN_PARSER_HPP)
  10. #define BOOST_SPIRIT_PATTERN_PARSER_HPP
  11. #include <boost/spirit/include/classic_primitives.hpp>
  12. #include <boost/wave/wave_config.hpp>
  13. // this must occur after all of the includes and before any code appears
  14. #ifdef BOOST_HAS_ABI_HEADERS
  15. #include BOOST_ABI_PREFIX
  16. #endif
  17. ///////////////////////////////////////////////////////////////////////////////
  18. namespace boost {
  19. namespace wave {
  20. namespace util {
  21. ///////////////////////////////////////////////////////////////////////////
  22. //
  23. // pattern_and class
  24. //
  25. ///////////////////////////////////////////////////////////////////////////
  26. template <typename CharT = char>
  27. struct pattern_and
  28. : public boost::spirit::classic::char_parser<pattern_and<CharT> >
  29. {
  30. pattern_and(CharT pattern_, unsigned long pattern_mask_ = 0UL)
  31. : pattern(pattern_),
  32. pattern_mask((0UL != pattern_mask_) ?
  33. pattern_mask_ : (unsigned long)pattern_)
  34. {}
  35. template <typename T>
  36. bool test(T pattern_) const
  37. { return ((unsigned long)pattern_ & pattern_mask) == (unsigned long)pattern; }
  38. CharT pattern;
  39. unsigned long pattern_mask;
  40. };
  41. template <typename CharT>
  42. inline pattern_and<CharT>
  43. pattern_p(CharT pattern, unsigned long pattern_mask = 0UL)
  44. { return pattern_and<CharT>(pattern, pattern_mask); }
  45. ///////////////////////////////////////////////////////////////////////////////
  46. } // namespace util
  47. } // namespace wave
  48. } // namespace boost
  49. // the suffix header occurs after all of the code
  50. #ifdef BOOST_HAS_ABI_HEADERS
  51. #include BOOST_ABI_SUFFIX
  52. #endif
  53. #endif // defined(BOOST_SPIRIT_PATTERN_PARSER_HPP)