diff --git a/asio/include/asio/detail/regex_fwd.hpp b/asio/include/asio/detail/regex_fwd.hpp index 11bfed96d3..fe1092231e 100644 --- a/asio/include/asio/detail/regex_fwd.hpp +++ b/asio/include/asio/detail/regex_fwd.hpp @@ -17,18 +17,6 @@ #if defined(ASIO_HAS_BOOST_REGEX) -#include -#include -#if BOOST_VERSION >= 107600 -# if defined(BOOST_REGEX_CXX03) -# include -# else // defined(BOOST_REGEX_CXX03) -# include -# endif // defined(BOOST_REGEX_CXX03) -#else // BOOST_VERSION >= 107600 -# include -#endif // BOOST_VERSION >= 107600 - namespace boost { template @@ -37,6 +25,9 @@ struct sub_match; template class match_results; +template +class basic_regex; + } // namespace boost #endif // defined(ASIO_HAS_BOOST_REGEX) diff --git a/asio/include/asio/impl/read_until.hpp b/asio/include/asio/impl/read_until.hpp index c1d7dbcce8..f3f1fbb554 100644 --- a/asio/include/asio/impl/read_until.hpp +++ b/asio/include/asio/impl/read_until.hpp @@ -231,10 +231,22 @@ std::size_t read_until(SyncReadStream& s, #if !defined(ASIO_NO_EXTENSIONS) #if defined(ASIO_HAS_BOOST_REGEX) -template -inline std::size_t read_until(SyncReadStream& s, - DynamicBuffer_v1&& buffers, - const boost::regex& expr, +namespace detail { + +struct regex_match_flags +{ + template + operator T() const + { + return T::match_default | T::match_partial; + } +}; + +} // namespace detail + +template +inline std::size_t read_until(SyncReadStream& s, DynamicBuffer_v1&& buffers, + const boost::basic_regex& expr, constraint_t< is_dynamic_buffer_v1>::value >, @@ -249,10 +261,9 @@ inline std::size_t read_until(SyncReadStream& s, return bytes_transferred; } -template -std::size_t read_until(SyncReadStream& s, - DynamicBuffer_v1&& buffers, - const boost::regex& expr, asio::error_code& ec, +template +std::size_t read_until(SyncReadStream& s, DynamicBuffer_v1&& buffers, + const boost::basic_regex& expr, asio::error_code& ec, constraint_t< is_dynamic_buffer_v1>::value >, @@ -278,8 +289,8 @@ std::size_t read_until(SyncReadStream& s, boost::match_results>::allocator_type> match_results; - if (regex_search(start_pos, end, match_results, expr, - boost::match_default | boost::match_partial)) + if (regex_search(start_pos, end, match_results, + expr, detail::regex_match_flags())) { if (match_results[0].matched) { @@ -441,16 +452,18 @@ inline std::size_t read_until(SyncReadStream& s, #if defined(ASIO_HAS_BOOST_REGEX) -template +template inline std::size_t read_until(SyncReadStream& s, - asio::basic_streambuf& b, const boost::regex& expr) + asio::basic_streambuf& b, + const boost::basic_regex& expr) { return read_until(s, basic_streambuf_ref(b), expr); } -template +template inline std::size_t read_until(SyncReadStream& s, - asio::basic_streambuf& b, const boost::regex& expr, + asio::basic_streambuf& b, + const boost::basic_regex& expr, asio::error_code& ec) { return read_until(s, basic_streambuf_ref(b), expr, ec); @@ -629,9 +642,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, #if !defined(ASIO_NO_EXTENSIONS) #if defined(ASIO_HAS_BOOST_REGEX) -template -inline std::size_t read_until(SyncReadStream& s, - DynamicBuffer_v2 buffers, const boost::regex& expr, +template +inline std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, + const boost::basic_regex& expr, constraint_t< is_dynamic_buffer_v2::value >) @@ -643,9 +656,9 @@ inline std::size_t read_until(SyncReadStream& s, return bytes_transferred; } -template +template std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, - const boost::regex& expr, asio::error_code& ec, + const boost::basic_regex& expr, asio::error_code& ec, constraint_t< is_dynamic_buffer_v2::value >) @@ -668,8 +681,8 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, boost::match_results>::allocator_type> match_results; - if (regex_search(start_pos, end, match_results, expr, - boost::match_default | boost::match_partial)) + if (regex_search(start_pos, end, match_results, + expr, detail::regex_match_flags())) { if (match_results[0].matched) { @@ -1303,10 +1316,9 @@ namespace detail : public base_from_cancellation_state { public: - template - read_until_expr_op_v1(AsyncReadStream& stream, - BufferSequence&& buffers, - const boost::regex& expr, ReadHandler& handler) + template + read_until_expr_op_v1(AsyncReadStream& stream, BufferSequence&& buffers, + const boost::basic_regex& expr, ReadHandler& handler) : base_from_cancellation_state( handler, enable_partial_cancellation()), stream_(stream), @@ -1365,8 +1377,8 @@ namespace detail boost::match_results>::allocator_type> match_results; - bool match = regex_search(start_pos, end, match_results, expr_, - boost::match_default | boost::match_partial); + bool match = regex_search(start_pos, end, + match_results, expr_, regex_match_flags()); if (match && match_results[0].matched) { // Full match. We're done. @@ -1525,11 +1537,11 @@ struct associator inline auto async_read_until(AsyncReadStream& s, DynamicBuffer_v1&& buffers, - const boost::regex& expr, ReadToken&& token, + const boost::basic_regex& expr, ReadToken&& token, constraint_t< is_dynamic_buffer_v1>::value >, @@ -1849,12 +1861,12 @@ inline auto async_read_until(AsyncReadStream& s, #if defined(ASIO_HAS_BOOST_REGEX) -template inline auto async_read_until(AsyncReadStream& s, asio::basic_streambuf& b, - const boost::regex& expr, ReadToken&& token) + const boost::basic_regex& expr, ReadToken&& token) -> decltype( async_initiate( @@ -2407,10 +2419,9 @@ namespace detail : public base_from_cancellation_state { public: - template - read_until_expr_op_v2(AsyncReadStream& stream, - BufferSequence&& buffers, - const boost::regex& expr, ReadHandler& handler) + template + read_until_expr_op_v2(AsyncReadStream& stream, BufferSequence&& buffers, + const boost::basic_regex& expr, ReadHandler& handler) : base_from_cancellation_state( handler, enable_partial_cancellation()), stream_(stream), @@ -2474,8 +2485,8 @@ namespace detail boost::match_results>::allocator_type> match_results; - bool match = regex_search(start_pos, end, match_results, expr_, - boost::match_default | boost::match_partial); + bool match = regex_search(start_pos, end, + match_results, expr_, regex_match_flags()); if (match && match_results[0].matched) { // Full match. We're done. @@ -2638,11 +2649,11 @@ struct associator inline auto async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers, - const boost::regex& expr, ReadToken&& token, + const boost::basic_regex& expr, ReadToken&& token, constraint_t< is_dynamic_buffer_v2::value >) diff --git a/asio/include/asio/read_until.hpp b/asio/include/asio/read_until.hpp index 8e820f0fc0..7ce82d385a 100644 --- a/asio/include/asio/read_until.hpp +++ b/asio/include/asio/read_until.hpp @@ -365,10 +365,9 @@ std::size_t read_until(SyncReadStream& s, * This data may be the start of a new line, to be extracted by a subsequent * @c read_until operation. */ -template -std::size_t read_until(SyncReadStream& s, - DynamicBuffer_v1&& buffers, - const boost::regex& expr, +template +std::size_t read_until(SyncReadStream& s, DynamicBuffer_v1&& buffers, + const boost::basic_regex& expr, constraint_t< is_dynamic_buffer_v1>::value > = 0, @@ -412,10 +411,9 @@ std::size_t read_until(SyncReadStream& s, * expression. An application will typically leave that data in the dynamic * buffer sequence for a subsequent read_until operation to examine. */ -template -std::size_t read_until(SyncReadStream& s, - DynamicBuffer_v1&& buffers, - const boost::regex& expr, asio::error_code& ec, +template +std::size_t read_until(SyncReadStream& s, DynamicBuffer_v1&& buffers, + const boost::basic_regex& expr, asio::error_code& ec, constraint_t< is_dynamic_buffer_v1>::value > = 0, @@ -841,9 +839,10 @@ std::size_t read_until(SyncReadStream& s, * This data may be the start of a new line, to be extracted by a subsequent * @c read_until operation. */ -template +template std::size_t read_until(SyncReadStream& s, - asio::basic_streambuf& b, const boost::regex& expr); + asio::basic_streambuf& b, + const boost::basic_regex& expr); /// Read data into a streambuf until some part of the data it contains matches /// a regular expression. @@ -878,9 +877,10 @@ std::size_t read_until(SyncReadStream& s, * application will typically leave that data in the streambuf for a subsequent * read_until operation to examine. */ -template +template std::size_t read_until(SyncReadStream& s, - asio::basic_streambuf& b, const boost::regex& expr, + asio::basic_streambuf& b, + const boost::basic_regex& expr, asio::error_code& ec); #endif // defined(ASIO_HAS_BOOST_REGEX) @@ -1309,9 +1309,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, * This data may be the start of a new line, to be extracted by a subsequent * @c read_until operation. */ -template +template std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, - const boost::regex& expr, + const boost::basic_regex& expr, constraint_t< is_dynamic_buffer_v2::value > = 0); @@ -1352,9 +1352,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, * expression. An application will typically leave that data in the dynamic * buffer sequence for a subsequent read_until operation to examine. */ -template +template std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, - const boost::regex& expr, asio::error_code& ec, + const boost::basic_regex& expr, asio::error_code& ec, constraint_t< is_dynamic_buffer_v2::value > = 0); @@ -1897,12 +1897,12 @@ auto async_read_until(AsyncReadStream& s, * if they are also supported by the @c AsyncReadStream type's * @c async_read_some operation. */ -template > -auto async_read_until(AsyncReadStream& s, - DynamicBuffer_v1&& buffers, const boost::regex& expr, +auto async_read_until(AsyncReadStream& s, DynamicBuffer_v1&& buffers, + const boost::basic_regex& expr, ReadToken&& token = default_completion_token_t< typename AsyncReadStream::executor_type>(), constraint_t< @@ -2413,12 +2413,13 @@ auto async_read_until(AsyncReadStream& s, * if they are also supported by the @c AsyncReadStream type's * @c async_read_some operation. */ -template > auto async_read_until(AsyncReadStream& s, - asio::basic_streambuf& b, const boost::regex& expr, + asio::basic_streambuf& b, + const boost::basic_regex& expr, ReadToken&& token = default_completion_token_t< typename AsyncReadStream::executor_type>()) -> decltype( @@ -2925,12 +2926,12 @@ auto async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers, * if they are also supported by the @c AsyncReadStream type's * @c async_read_some operation. */ -template > -auto async_read_until(AsyncReadStream& s, - DynamicBuffer_v2 buffers, const boost::regex& expr, +auto async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers, + const boost::basic_regex& expr, ReadToken&& token = default_completion_token_t< typename AsyncReadStream::executor_type>(), constraint_t<