File indexing completed on 2025-12-17 09:38:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_STRING_FINDER_REGEX_DETAIL_HPP
0012 #define BOOST_STRING_FINDER_REGEX_DETAIL_HPP
0013
0014 #include <boost/algorithm/string/config.hpp>
0015 #include <boost/regex.hpp>
0016
0017 #include <boost/range/iterator_range_core.hpp>
0018 #include <boost/range/begin.hpp>
0019 #include <boost/range/end.hpp>
0020
0021 namespace boost {
0022 namespace algorithm {
0023 namespace detail {
0024
0025
0026
0027
0028 template<typename IteratorT>
0029 struct regex_search_result :
0030 public iterator_range<IteratorT>
0031 {
0032 typedef regex_search_result<IteratorT> type;
0033 typedef iterator_range<IteratorT> base_type;
0034 typedef BOOST_STRING_TYPENAME base_type::value_type value_type;
0035 typedef BOOST_STRING_TYPENAME base_type::difference_type difference_type;
0036 typedef BOOST_STRING_TYPENAME base_type::const_iterator const_iterator;
0037 typedef BOOST_STRING_TYPENAME base_type::iterator iterator;
0038 typedef boost::match_results<iterator> match_results_type;
0039
0040
0041
0042
0043 regex_search_result( const match_results_type& MatchResults ) :
0044 base_type( MatchResults[0].first, MatchResults[0].second ),
0045 m_MatchResults( MatchResults ) {}
0046
0047
0048 regex_search_result( IteratorT End ) :
0049 base_type( End, End ) {}
0050
0051 regex_search_result( const regex_search_result& Other ) :
0052 base_type( Other.begin(), Other.end() ),
0053 m_MatchResults( Other.m_MatchResults ) {}
0054
0055
0056 regex_search_result& operator=( const regex_search_result& Other )
0057 {
0058 base_type::operator=( Other );
0059 m_MatchResults=Other.m_MatchResults;
0060 return *this;
0061 }
0062
0063
0064 const match_results_type& match_results() const
0065 {
0066 return m_MatchResults;
0067 }
0068
0069 private:
0070
0071 match_results_type m_MatchResults;
0072 };
0073
0074
0075
0076
0077
0078 template<typename RegExT>
0079 struct find_regexF
0080 {
0081 typedef RegExT regex_type;
0082 typedef const RegExT& regex_reference_type;
0083
0084
0085 find_regexF( regex_reference_type Rx, match_flag_type MatchFlags = match_default ) :
0086 m_Rx(Rx), m_MatchFlags(MatchFlags) {}
0087
0088
0089 template< typename ForwardIteratorT >
0090 regex_search_result<ForwardIteratorT>
0091 operator()(
0092 ForwardIteratorT Begin,
0093 ForwardIteratorT End ) const
0094 {
0095 typedef ForwardIteratorT input_iterator_type;
0096 typedef regex_search_result<ForwardIteratorT> result_type;
0097
0098
0099 match_results<input_iterator_type> result;
0100
0101 if ( ::boost::regex_search( Begin, End, result, m_Rx, m_MatchFlags ) )
0102 {
0103
0104 return result_type( result );
0105 }
0106 else
0107 {
0108
0109 return result_type( End );
0110 }
0111 }
0112
0113 private:
0114 regex_reference_type m_Rx;
0115 match_flag_type m_MatchFlags;
0116 };
0117
0118 }
0119 }
0120 }
0121
0122 #endif