/Src/Dependencies/Boost/boost/spirit/home/classic/core/impl/match.ipp

http://hadesmem.googlecode.com/ · C++ Header · 113 lines · 82 code · 23 blank · 8 comment · 0 complexity · 0b86d236cfbfc96f81f4f5395349551d MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 1998-2003 Joel de Guzman
  3. http://spirit.sourceforge.net/
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #if !defined(BOOST_SPIRIT_MATCH_IPP)
  9. #define BOOST_SPIRIT_MATCH_IPP
  10. #include <algorithm>
  11. namespace boost { namespace spirit {
  12. BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
  13. template <typename T>
  14. inline match<T>::match()
  15. : len(-1), val() {}
  16. template <typename T>
  17. inline match<T>::match(std::size_t length_)
  18. : len(length_), val() {}
  19. template <typename T>
  20. inline match<T>::match(std::size_t length_, ctor_param_t val_)
  21. : len(length_), val(val_) {}
  22. template <typename T>
  23. inline bool
  24. match<T>::operator!() const
  25. {
  26. return len < 0;
  27. }
  28. template <typename T>
  29. inline std::ptrdiff_t
  30. match<T>::length() const
  31. {
  32. return len;
  33. }
  34. template <typename T>
  35. inline bool
  36. match<T>::has_valid_attribute() const
  37. {
  38. return val.is_initialized();
  39. }
  40. template <typename T>
  41. inline typename match<T>::return_t
  42. match<T>::value() const
  43. {
  44. BOOST_SPIRIT_ASSERT(val.is_initialized());
  45. return *val;
  46. }
  47. template <typename T>
  48. inline void
  49. match<T>::swap(match& other)
  50. {
  51. std::swap(len, other.len);
  52. std::swap(val, other.val);
  53. }
  54. inline match<nil_t>::match()
  55. : len(-1) {}
  56. inline match<nil_t>::match(std::size_t length_)
  57. : len(length_) {}
  58. inline match<nil_t>::match(std::size_t length_, nil_t)
  59. : len(length_) {}
  60. inline bool
  61. match<nil_t>::operator!() const
  62. {
  63. return len < 0;
  64. }
  65. inline bool
  66. match<nil_t>::has_valid_attribute() const
  67. {
  68. return false;
  69. }
  70. inline std::ptrdiff_t
  71. match<nil_t>::length() const
  72. {
  73. return len;
  74. }
  75. inline nil_t
  76. match<nil_t>::value() const
  77. {
  78. return nil_t();
  79. }
  80. inline void
  81. match<nil_t>::value(nil_t) {}
  82. inline void
  83. match<nil_t>::swap(match<nil_t>& other)
  84. {
  85. std::swap(len, other.len);
  86. }
  87. BOOST_SPIRIT_CLASSIC_NAMESPACE_END
  88. }} // namespace boost::spirit
  89. #endif