access.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // access.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_ACCESS_HPP_EAN_10_04_2005
  8. #define BOOST_XPRESSIVE_DETAIL_CORE_ACCESS_HPP_EAN_10_04_2005
  9. // MS compatible compilers support #pragma once
  10. #if defined(_MSC_VER)
  11. # pragma once
  12. #endif
  13. #include <vector>
  14. #include <boost/shared_ptr.hpp>
  15. #include <boost/proto/traits.hpp>
  16. #include <boost/xpressive/detail/detail_fwd.hpp>
  17. #include <boost/xpressive/detail/dynamic/matchable.hpp>
  18. #include <boost/xpressive/match_results.hpp> // for type_info_less
  19. namespace boost { namespace xpressive { namespace detail
  20. {
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // core_access
  23. //
  24. template<typename BidiIter>
  25. struct core_access
  26. {
  27. typedef typename iterator_value<BidiIter>::type char_type;
  28. static std::size_t get_hidden_mark_count(basic_regex<BidiIter> const &rex)
  29. {
  30. return proto::value(rex)->hidden_mark_count_;
  31. }
  32. static bool match(basic_regex<BidiIter> const &rex, match_state<BidiIter> &state)
  33. {
  34. return rex.match_(state);
  35. }
  36. static shared_ptr<detail::regex_impl<BidiIter> > const &
  37. get_regex_impl(basic_regex<BidiIter> const &rex)
  38. {
  39. return proto::value(rex).get();
  40. }
  41. static void init_sub_match_vector
  42. (
  43. sub_match_vector<BidiIter> &subs_vect
  44. , sub_match_impl<BidiIter> *subs_ptr
  45. , std::size_t size
  46. )
  47. {
  48. subs_vect.init_(subs_ptr, size);
  49. }
  50. static void init_sub_match_vector
  51. (
  52. sub_match_vector<BidiIter> &subs_vect
  53. , sub_match_impl<BidiIter> *subs_ptr
  54. , std::size_t size
  55. , sub_match_vector<BidiIter> const &that
  56. )
  57. {
  58. subs_vect.init_(subs_ptr, size, that);
  59. }
  60. static void init_match_results
  61. (
  62. match_results<BidiIter> &what
  63. , regex_id_type regex_id
  64. , intrusive_ptr<traits<char_type> const> const &tr
  65. , sub_match_impl<BidiIter> *sub_matches
  66. , std::size_t size
  67. , std::vector<named_mark<char_type> > const &named_marks
  68. )
  69. {
  70. what.init_(regex_id, tr, sub_matches, size, named_marks);
  71. }
  72. static sub_match_vector<BidiIter> &get_sub_match_vector(match_results<BidiIter> &what)
  73. {
  74. return what.sub_matches_;
  75. }
  76. static sub_match_impl<BidiIter> *get_sub_matches(sub_match_vector<BidiIter> &subs)
  77. {
  78. return subs.sub_matches_;
  79. }
  80. static results_extras<BidiIter> &get_extras(match_results<BidiIter> &what)
  81. {
  82. return what.get_extras_();
  83. }
  84. static nested_results<BidiIter> &get_nested_results(match_results<BidiIter> &what)
  85. {
  86. return what.nested_results_;
  87. }
  88. static action_args_type &get_action_args(match_results<BidiIter> &what)
  89. {
  90. return what.args_;
  91. }
  92. static void set_prefix_suffix(match_results<BidiIter> &what, BidiIter begin, BidiIter end)
  93. {
  94. what.set_prefix_suffix_(begin, end);
  95. }
  96. static void reset(match_results<BidiIter> &what)
  97. {
  98. what.reset_();
  99. }
  100. static void set_base(match_results<BidiIter> &what, BidiIter base)
  101. {
  102. what.set_base_(base);
  103. }
  104. static BidiIter get_base(match_results<BidiIter> &what)
  105. {
  106. return *what.base_;
  107. }
  108. };
  109. }}} // namespace boost::xpressive::detail
  110. #endif