summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/read_until.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/read_until.hpp')
-rw-r--r--3rdparty/asio/include/asio/read_until.hpp843
1 files changed, 468 insertions, 375 deletions
diff --git a/3rdparty/asio/include/asio/read_until.hpp b/3rdparty/asio/include/asio/read_until.hpp
index bb1767ed6a6..97abbdbf0ea 100644
--- a/3rdparty/asio/include/asio/read_until.hpp
+++ b/3rdparty/asio/include/asio/read_until.hpp
@@ -2,7 +2,7 @@
// read_until.hpp
// ~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -32,19 +32,34 @@
#include "asio/detail/push_options.hpp"
namespace asio {
+namespace detail {
-namespace detail
+char (&has_result_type_helper(...))[2];
+
+template <typename T>
+char has_result_type_helper(T*, typename T::result_type* = 0);
+
+template <typename T>
+struct has_result_type
{
- char (&has_result_type_helper(...))[2];
+ enum { value = (sizeof((has_result_type_helper)((T*)(0))) == 1) };
+};
- template <typename T>
- char has_result_type_helper(T*, typename T::result_type* = 0);
+#if !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
+template <typename> class initiate_async_read_until_delim_v1;
+template <typename> class initiate_async_read_until_delim_string_v1;
+#if defined(ASIO_HAS_BOOST_REGEX)
+template <typename> class initiate_async_read_until_expr_v1;
+#endif // defined(ASIO_HAS_BOOST_REGEX)
+template <typename> class initiate_async_read_until_match_v1;
+#endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
+template <typename> class initiate_async_read_until_delim_v2;
+template <typename> class initiate_async_read_until_delim_string_v2;
+#if defined(ASIO_HAS_BOOST_REGEX)
+template <typename> class initiate_async_read_until_expr_v2;
+#endif // defined(ASIO_HAS_BOOST_REGEX)
+template <typename> class initiate_async_read_until_match_v2;
- template <typename T>
- struct has_result_type
- {
- enum { value = (sizeof((has_result_type_helper)((T*)(0))) == 1) };
- };
} // namespace detail
/// Type trait used to determine whether a type can be used as a match condition
@@ -58,8 +73,7 @@ struct is_match_condition
#else
enum
{
- value = asio::is_function<
- typename asio::remove_pointer<T>::type>::value
+ value = asio::is_function<remove_pointer_t<T>>::value
|| detail::has_result_type<T>::value
};
#endif
@@ -132,13 +146,13 @@ struct is_match_condition
*/
template <typename SyncReadStream, typename DynamicBuffer_v1>
std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, char delim,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ DynamicBuffer_v1&& buffers, char delim,
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
/// delimiter.
@@ -176,14 +190,14 @@ std::size_t read_until(SyncReadStream& s,
*/
template <typename SyncReadStream, typename DynamicBuffer_v1>
std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ DynamicBuffer_v1&& buffers,
char delim, asio::error_code& ec,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
/// delimiter.
@@ -238,14 +252,14 @@ std::size_t read_until(SyncReadStream& s,
*/
template <typename SyncReadStream, typename DynamicBuffer_v1>
std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ DynamicBuffer_v1&& buffers,
ASIO_STRING_VIEW_PARAM delim,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
/// delimiter.
@@ -283,15 +297,15 @@ std::size_t read_until(SyncReadStream& s,
*/
template <typename SyncReadStream, typename DynamicBuffer_v1>
std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ DynamicBuffer_v1&& buffers,
ASIO_STRING_VIEW_PARAM delim,
asio::error_code& ec,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
#if !defined(ASIO_NO_EXTENSIONS)
#if defined(ASIO_HAS_BOOST_REGEX) \
@@ -351,16 +365,15 @@ 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 <typename SyncReadStream, typename DynamicBuffer_v1>
-std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
- const boost::regex& expr,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+template <typename SyncReadStream, typename DynamicBuffer_v1, typename Traits>
+std::size_t read_until(SyncReadStream& s, DynamicBuffer_v1&& buffers,
+ const boost::basic_regex<char, Traits>& expr,
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
/// Read data into a dynamic buffer sequence until some part of the data it
/// contains matches a regular expression.
@@ -398,16 +411,15 @@ 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 <typename SyncReadStream, typename DynamicBuffer_v1>
-std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
- const boost::regex& expr, asio::error_code& ec,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+template <typename SyncReadStream, typename DynamicBuffer_v1, typename Traits>
+std::size_t read_until(SyncReadStream& s, DynamicBuffer_v1&& buffers,
+ const boost::basic_regex<char, Traits>& expr, asio::error_code& ec,
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
#endif // defined(ASIO_HAS_BOOST_REGEX)
// || defined(GENERATING_DOCUMENTATION)
@@ -517,17 +529,17 @@ std::size_t read_until(SyncReadStream& s,
template <typename SyncReadStream,
typename DynamicBuffer_v1, typename MatchCondition>
std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ DynamicBuffer_v1&& buffers,
MatchCondition match_condition,
- typename constraint<
+ constraint_t<
is_match_condition<MatchCondition>::value
- >::type = 0,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ > = 0,
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
/// Read data into a dynamic buffer sequence until a function object indicates a
/// match.
@@ -585,17 +597,17 @@ std::size_t read_until(SyncReadStream& s,
template <typename SyncReadStream,
typename DynamicBuffer_v1, typename MatchCondition>
std::size_t read_until(SyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ DynamicBuffer_v1&& buffers,
MatchCondition match_condition, asio::error_code& ec,
- typename constraint<
+ constraint_t<
is_match_condition<MatchCondition>::value
- >::type = 0,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ > = 0,
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0);
#if !defined(ASIO_NO_IOSTREAM)
@@ -827,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 <typename SyncReadStream, typename Allocator>
+template <typename SyncReadStream, typename Allocator, typename Traits>
std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const boost::regex& expr);
+ asio::basic_streambuf<Allocator>& b,
+ const boost::basic_regex<char, Traits>& expr);
/// Read data into a streambuf until some part of the data it contains matches
/// a regular expression.
@@ -864,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 <typename SyncReadStream, typename Allocator>
+template <typename SyncReadStream, typename Allocator, typename Traits>
std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
+ asio::basic_streambuf<Allocator>& b,
+ const boost::basic_regex<char, Traits>& expr,
asio::error_code& ec);
#endif // defined(ASIO_HAS_BOOST_REGEX)
@@ -975,7 +989,7 @@ std::size_t read_until(SyncReadStream& s,
template <typename SyncReadStream, typename Allocator, typename MatchCondition>
std::size_t read_until(SyncReadStream& s,
asio::basic_streambuf<Allocator>& b, MatchCondition match_condition,
- typename constraint<is_match_condition<MatchCondition>::value>::type = 0);
+ constraint_t<is_match_condition<MatchCondition>::value> = 0);
/// Read data into a streambuf until a function object indicates a match.
/**
@@ -1032,7 +1046,7 @@ template <typename SyncReadStream, typename Allocator, typename MatchCondition>
std::size_t read_until(SyncReadStream& s,
asio::basic_streambuf<Allocator>& b,
MatchCondition match_condition, asio::error_code& ec,
- typename constraint<is_match_condition<MatchCondition>::value>::type = 0);
+ constraint_t<is_match_condition<MatchCondition>::value> = 0);
#endif // !defined(ASIO_NO_IOSTREAM)
#endif // !defined(ASIO_NO_EXTENSIONS)
@@ -1093,9 +1107,9 @@ std::size_t read_until(SyncReadStream& s,
*/
template <typename SyncReadStream, typename DynamicBuffer_v2>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, char delim,
- typename constraint<
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
/// delimiter.
@@ -1134,9 +1148,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers, char delim,
template <typename SyncReadStream, typename DynamicBuffer_v2>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
char delim, asio::error_code& ec,
- typename constraint<
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
/// delimiter.
@@ -1192,9 +1206,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
template <typename SyncReadStream, typename DynamicBuffer_v2>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
ASIO_STRING_VIEW_PARAM delim,
- typename constraint<
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
/// delimiter.
@@ -1233,9 +1247,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
template <typename SyncReadStream, typename DynamicBuffer_v2>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
ASIO_STRING_VIEW_PARAM delim, asio::error_code& ec,
- typename constraint<
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
#if !defined(ASIO_NO_EXTENSIONS)
#if defined(ASIO_HAS_BOOST_REGEX) \
@@ -1295,12 +1309,12 @@ 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 <typename SyncReadStream, typename DynamicBuffer_v2>
+template <typename SyncReadStream, typename DynamicBuffer_v2, typename Traits>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
- const boost::regex& expr,
- typename constraint<
+ const boost::basic_regex<char, Traits>& expr,
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
/// Read data into a dynamic buffer sequence until some part of the data it
/// contains matches a regular expression.
@@ -1338,12 +1352,12 @@ 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 <typename SyncReadStream, typename DynamicBuffer_v2>
+template <typename SyncReadStream, typename DynamicBuffer_v2, typename Traits>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
- const boost::regex& expr, asio::error_code& ec,
- typename constraint<
+ const boost::basic_regex<char, Traits>& expr, asio::error_code& ec,
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
#endif // defined(ASIO_HAS_BOOST_REGEX)
// || defined(GENERATING_DOCUMENTATION)
@@ -1454,12 +1468,12 @@ template <typename SyncReadStream,
typename DynamicBuffer_v2, typename MatchCondition>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
MatchCondition match_condition,
- typename constraint<
+ constraint_t<
is_match_condition<MatchCondition>::value
- >::type = 0,
- typename constraint<
+ > = 0,
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
/// Read data into a dynamic buffer sequence until a function object indicates a
/// match.
@@ -1518,12 +1532,12 @@ template <typename SyncReadStream,
typename DynamicBuffer_v2, typename MatchCondition>
std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
MatchCondition match_condition, asio::error_code& ec,
- typename constraint<
+ constraint_t<
is_match_condition<MatchCondition>::value
- >::type = 0,
- typename constraint<
+ > = 0,
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0);
#endif // !defined(ASIO_NO_EXTENSIONS)
@@ -1545,9 +1559,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
/**
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until the dynamic buffer sequence's get area contains the
- * specified delimiter. The function call always returns immediately. The
- * asynchronous operation will continue until one of the following conditions
- * is true:
+ * specified delimiter. It is an initiating function for an @ref
+ * asynchronous_operation, and always returns immediately. The asynchronous
+ * operation will continue until one of the following conditions is true:
*
* @li The get area of the dynamic buffer sequence contains the specified
* delimiter.
@@ -1568,27 +1582,31 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param delim The delimiter character.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
*
* // The number of bytes in the dynamic buffer sequence's
* // get area up to and including the delimiter.
- * // 0 if an error occurred.
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond the delimiter. An application
* will typically leave that data in the dynamic buffer sequence for a
@@ -1635,31 +1653,32 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
*/
template <typename AsyncReadStream, typename DynamicBuffer_v1,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, char delim,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
+ DynamicBuffer_v1&& buffers, char delim,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_delim_v1<AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v1&&>(buffers), delim));
/// Start an asynchronous operation to read data into a dynamic buffer sequence
/// until it contains a specified delimiter.
/**
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until the dynamic buffer sequence's get area contains the
- * specified delimiter. The function call always returns immediately. The
- * asynchronous operation will continue until one of the following conditions
- * is true:
+ * specified delimiter. It is an initiating function for an @ref
+ * asynchronous_operation, and always returns immediately. The asynchronous
+ * operation will continue until one of the following conditions is true:
*
* @li The get area of the dynamic buffer sequence contains the specified
* delimiter.
@@ -1680,27 +1699,31 @@ async_read_until(AsyncReadStream& s,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param delim The delimiter string.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
*
* // The number of bytes in the dynamic buffer sequence's
* // get area up to and including the delimiter.
- * // 0 if an error occurred.
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond the delimiter. An application
* will typically leave that data in the dynamic buffer sequence for a
@@ -1747,23 +1770,26 @@ async_read_until(AsyncReadStream& s,
*/
template <typename AsyncReadStream, typename DynamicBuffer_v1,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
+ DynamicBuffer_v1&& buffers,
ASIO_STRING_VIEW_PARAM delim,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_delim_string_v1<
+ AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v1&&>(buffers),
+ static_cast<std::string>(delim)));
#if !defined(ASIO_NO_EXTENSIONS)
#if defined(ASIO_HAS_BOOST_REGEX) \
@@ -1774,9 +1800,10 @@ async_read_until(AsyncReadStream& s,
/**
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until the dynamic buffer sequence's get area contains some
- * data that matches a regular expression. The function call always returns
- * immediately. The asynchronous operation will continue until one of the
- * following conditions is true:
+ * data that matches a regular expression. It is an initiating function for an
+ * @ref asynchronous_operation, and always returns immediately. The
+ * asynchronous operation will continue until one of the following conditions
+ * is true:
*
* @li A substring of the dynamic buffer sequence's get area matches the regular
* expression.
@@ -1798,13 +1825,15 @@ async_read_until(AsyncReadStream& s,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param expr The regular expression.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -1816,10 +1845,13 @@ async_read_until(AsyncReadStream& s,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond that which matched the regular
* expression. An application will typically leave that data in the dynamic
@@ -1865,25 +1897,25 @@ async_read_until(AsyncReadStream& s,
* if they are also supported by the @c AsyncReadStream type's
* @c async_read_some operation.
*/
-template <typename AsyncReadStream, typename DynamicBuffer_v1,
+template <typename AsyncReadStream, typename DynamicBuffer_v1, typename Traits,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
- const boost::regex& expr,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s, DynamicBuffer_v1&& buffers,
+ const boost::basic_regex<char, Traits>& expr,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_expr_v1<AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v1&&>(buffers), expr));
#endif // defined(ASIO_HAS_BOOST_REGEX)
// || defined(GENERATING_DOCUMENTATION)
@@ -1894,9 +1926,9 @@ async_read_until(AsyncReadStream& s,
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until a user-defined match condition function object, when
* applied to the data contained in the dynamic buffer sequence, indicates a
- * successful match. The function call always returns immediately. The
- * asynchronous operation will continue until one of the following conditions
- * is true:
+ * successful match. It is an initiating function for an @ref
+ * asynchronous_operation, and always returns immediately. The asynchronous
+ * operation will continue until one of the following conditions is true:
*
* @li The match condition function object returns a std::pair where the second
* element evaluates to true.
@@ -1917,7 +1949,7 @@ async_read_until(AsyncReadStream& s,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param match_condition The function object to be called to determine whether
* a match exists. The signature of the function object must be:
@@ -1934,9 +1966,11 @@ async_read_until(AsyncReadStream& s,
* @c second member of the return value is true if a match has been found, false
* otherwise.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -1947,8 +1981,8 @@ async_read_until(AsyncReadStream& s,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
* @note After a successful async_read_until operation, the dynamic buffer
@@ -1956,6 +1990,9 @@ async_read_until(AsyncReadStream& s,
* object. An application will typically leave that data in the dynamic buffer
* sequence for a subsequent async_read_until operation to examine.
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note The default implementation of the @c is_match_condition type trait
* evaluates to true for function pointers and function objects with a
* @c result_type typedef. It must be specialised for other user-defined
@@ -2030,26 +2067,27 @@ async_read_until(AsyncReadStream& s,
template <typename AsyncReadStream,
typename DynamicBuffer_v1, typename MatchCondition,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
- MatchCondition match_condition,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
+ DynamicBuffer_v1&& buffers, MatchCondition match_condition,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
is_match_condition<MatchCondition>::value
- >::type = 0,
- typename constraint<
- is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0,
- typename constraint<
- !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
- >::type = 0);
+ > = 0,
+ constraint_t<
+ is_dynamic_buffer_v1<decay_t<DynamicBuffer_v1>>::value
+ > = 0,
+ constraint_t<
+ !is_dynamic_buffer_v2<decay_t<DynamicBuffer_v1>>::value
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_match_v1<AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v1&&>(buffers),
+ match_condition));
#if !defined(ASIO_NO_IOSTREAM)
@@ -2058,8 +2096,9 @@ async_read_until(AsyncReadStream& s,
/**
* This function is used to asynchronously read data into the specified
* streambuf until the streambuf's get area contains the specified delimiter.
- * The function call always returns immediately. The asynchronous operation
- * will continue until one of the following conditions is true:
+ * It is an initiating function for an @ref asynchronous_operation, and always
+ * returns immediately. The asynchronous operation will continue until one of
+ * the following conditions is true:
*
* @li The get area of the streambuf contains the specified delimiter.
*
@@ -2078,13 +2117,15 @@ async_read_until(AsyncReadStream& s,
*
* @param b A streambuf object into which the data will be read. Ownership of
* the streambuf is retained by the caller, which must guarantee that it remains
- * valid until the handler is called.
+ * valid until the completion handler is called.
*
* @param delim The delimiter character.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -2095,10 +2136,13 @@ async_read_until(AsyncReadStream& s,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the streambuf may
* contain additional data beyond the delimiter. An application will typically
* leave that data in the streambuf for a subsequent async_read_until operation
@@ -2144,24 +2188,26 @@ async_read_until(AsyncReadStream& s,
*/
template <typename AsyncReadStream, typename Allocator,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
asio::basic_streambuf<Allocator>& b, char delim,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type));
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>())
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_delim_v1<AsyncReadStream>>(),
+ token, basic_streambuf_ref<Allocator>(b), delim));
/// Start an asynchronous operation to read data into a streambuf until it
/// contains a specified delimiter.
/**
* This function is used to asynchronously read data into the specified
* streambuf until the streambuf's get area contains the specified delimiter.
- * The function call always returns immediately. The asynchronous operation
- * will continue until one of the following conditions is true:
+ * It is an initiating function for an @ref asynchronous_operation, and always
+ * returns immediately. The asynchronous operation will continue until one of
+ * the following conditions is true:
*
* @li The get area of the streambuf contains the specified delimiter.
*
@@ -2180,13 +2226,15 @@ async_read_until(AsyncReadStream& s,
*
* @param b A streambuf object into which the data will be read. Ownership of
* the streambuf is retained by the caller, which must guarantee that it remains
- * valid until the handler is called.
+ * valid until the completion handler is called.
*
* @param delim The delimiter string.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -2197,10 +2245,13 @@ async_read_until(AsyncReadStream& s,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the streambuf may
* contain additional data beyond the delimiter. An application will typically
* leave that data in the streambuf for a subsequent async_read_until operation
@@ -2246,17 +2297,20 @@ async_read_until(AsyncReadStream& s,
*/
template <typename AsyncReadStream, typename Allocator,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
asio::basic_streambuf<Allocator>& b,
ASIO_STRING_VIEW_PARAM delim,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type));
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>())
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_delim_string_v1<
+ AsyncReadStream>>(),
+ token, basic_streambuf_ref<Allocator>(b),
+ static_cast<std::string>(delim)));
#if defined(ASIO_HAS_BOOST_REGEX) \
|| defined(GENERATING_DOCUMENTATION)
@@ -2266,9 +2320,9 @@ async_read_until(AsyncReadStream& s,
/**
* This function is used to asynchronously read data into the specified
* streambuf until the streambuf's get area contains some data that matches a
- * regular expression. The function call always returns immediately. The
- * asynchronous operation will continue until one of the following conditions
- * is true:
+ * regular expression. It is an initiating function for an @ref
+ * asynchronous_operation, and always returns immediately. The asynchronous
+ * operation will continue until one of the following conditions is true:
*
* @li A substring of the streambuf's get area matches the regular expression.
*
@@ -2288,13 +2342,15 @@ async_read_until(AsyncReadStream& s,
*
* @param b A streambuf object into which the data will be read. Ownership of
* the streambuf is retained by the caller, which must guarantee that it remains
- * valid until the handler is called.
+ * valid until the completion handler is called.
*
* @param expr The regular expression.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -2306,10 +2362,13 @@ async_read_until(AsyncReadStream& s,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the streambuf may
* contain additional data beyond that which matched the regular expression. An
* application will typically leave that data in the streambuf for a subsequent
@@ -2354,18 +2413,20 @@ async_read_until(AsyncReadStream& s,
* if they are also supported by the @c AsyncReadStream type's
* @c async_read_some operation.
*/
-template <typename AsyncReadStream, typename Allocator,
+template <typename AsyncReadStream, typename Allocator, typename Traits,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type));
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
+ asio::basic_streambuf<Allocator>& b,
+ const boost::basic_regex<char, Traits>& expr,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>())
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_expr_v1<AsyncReadStream>>(),
+ token, basic_streambuf_ref<Allocator>(b), expr));
#endif // defined(ASIO_HAS_BOOST_REGEX)
// || defined(GENERATING_DOCUMENTATION)
@@ -2375,9 +2436,10 @@ async_read_until(AsyncReadStream& s,
/**
* This function is used to asynchronously read data into the specified
* streambuf until a user-defined match condition function object, when applied
- * to the data contained in the streambuf, indicates a successful match. The
- * function call always returns immediately. The asynchronous operation will
- * continue until one of the following conditions is true:
+ * to the data contained in the streambuf, indicates a successful match. It is
+ * an initiating function for an @ref asynchronous_operation, and always
+ * returns immediately. The asynchronous operation will continue until one of
+ * the following conditions is true:
*
* @li The match condition function object returns a std::pair where the second
* element evaluates to true.
@@ -2412,9 +2474,11 @@ async_read_until(AsyncReadStream& s,
* @c second member of the return value is true if a match has been found, false
* otherwise.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -2425,8 +2489,8 @@ async_read_until(AsyncReadStream& s,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
* @note After a successful async_read_until operation, the streambuf may
@@ -2434,6 +2498,9 @@ async_read_until(AsyncReadStream& s,
* application will typically leave that data in the streambuf for a subsequent
* async_read_until operation to examine.
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note The default implementation of the @c is_match_condition type trait
* evaluates to true for function pointers and function objects with a
* @c result_type typedef. It must be specialised for other user-defined
@@ -2506,18 +2573,18 @@ async_read_until(AsyncReadStream& s,
*/
template <typename AsyncReadStream, typename Allocator, typename MatchCondition,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- asio::basic_streambuf<Allocator>& b,
- MatchCondition match_condition,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<is_match_condition<MatchCondition>::value>::type = 0);
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
+ asio::basic_streambuf<Allocator>& b, MatchCondition match_condition,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<is_match_condition<MatchCondition>::value> = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_match_v1<AsyncReadStream>>(),
+ token, basic_streambuf_ref<Allocator>(b), match_condition));
#endif // !defined(ASIO_NO_IOSTREAM)
#endif // !defined(ASIO_NO_EXTENSIONS)
@@ -2528,9 +2595,9 @@ async_read_until(AsyncReadStream& s,
/**
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until the dynamic buffer sequence's get area contains the
- * specified delimiter. The function call always returns immediately. The
- * asynchronous operation will continue until one of the following conditions
- * is true:
+ * specified delimiter. It is an initiating function for an @ref
+ * asynchronous_operation, and always returns immediately. The asynchronous
+ * operation will continue until one of the following conditions is true:
*
* @li The get area of the dynamic buffer sequence contains the specified
* delimiter.
@@ -2551,13 +2618,15 @@ async_read_until(AsyncReadStream& s,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param delim The delimiter character.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -2568,10 +2637,13 @@ async_read_until(AsyncReadStream& s,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond the delimiter. An application
* will typically leave that data in the dynamic buffer sequence for a
@@ -2618,27 +2690,28 @@ async_read_until(AsyncReadStream& s,
*/
template <typename AsyncReadStream, typename DynamicBuffer_v2,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers, char delim,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers, char delim,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_delim_v2<AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v2&&>(buffers), delim));
/// Start an asynchronous operation to read data into a dynamic buffer sequence
/// until it contains a specified delimiter.
/**
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until the dynamic buffer sequence's get area contains the
- * specified delimiter. The function call always returns immediately. The
- * asynchronous operation will continue until one of the following conditions
- * is true:
+ * specified delimiter. It is an initiating function for an @ref
+ * asynchronous_operation, and always returns immediately. The asynchronous
+ * operation will continue until one of the following conditions is true:
*
* @li The get area of the dynamic buffer sequence contains the specified
* delimiter.
@@ -2659,27 +2732,31 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers, char delim,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param delim The delimiter string.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
*
* // The number of bytes in the dynamic buffer sequence's
* // get area up to and including the delimiter.
- * // 0 if an error occurred.
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond the delimiter. An application
* will typically leave that data in the dynamic buffer sequence for a
@@ -2726,19 +2803,22 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers, char delim,
*/
template <typename AsyncReadStream, typename DynamicBuffer_v2,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
ASIO_STRING_VIEW_PARAM delim,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_delim_string_v2<
+ AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v2&&>(buffers),
+ static_cast<std::string>(delim)));
#if !defined(ASIO_NO_EXTENSIONS)
#if defined(ASIO_HAS_BOOST_REGEX) \
@@ -2749,9 +2829,10 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
/**
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until the dynamic buffer sequence's get area contains some
- * data that matches a regular expression. The function call always returns
- * immediately. The asynchronous operation will continue until one of the
- * following conditions is true:
+ * data that matches a regular expression. It is an initiating function for an
+ * @ref asynchronous_operation, and always returns immediately. The
+ * asynchronous operation will continue until one of the following conditions
+ * is true:
*
* @li A substring of the dynamic buffer sequence's get area matches the regular
* expression.
@@ -2773,13 +2854,15 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param expr The regular expression.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -2791,10 +2874,13 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note After a successful async_read_until operation, the dynamic buffer
* sequence may contain additional data beyond that which matched the regular
* expression. An application will typically leave that data in the dynamic
@@ -2840,21 +2926,22 @@ 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 <typename AsyncReadStream, typename DynamicBuffer_v2,
+template <typename AsyncReadStream, typename DynamicBuffer_v2, typename Traits,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
- const boost::regex& expr,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
+ const boost::basic_regex<char, Traits>& expr,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_expr_v2<AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v2&&>(buffers), expr));
#endif // defined(ASIO_HAS_BOOST_REGEX)
// || defined(GENERATING_DOCUMENTATION)
@@ -2865,9 +2952,9 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
* This function is used to asynchronously read data into the specified dynamic
* buffer sequence until a user-defined match condition function object, when
* applied to the data contained in the dynamic buffer sequence, indicates a
- * successful match. The function call always returns immediately. The
- * asynchronous operation will continue until one of the following conditions
- * is true:
+ * successful match. It is an initiating function for an @ref
+ * asynchronous_operation, and always returns immediately. The asynchronous
+ * operation will continue until one of the following conditions is true:
*
* @li The match condition function object returns a std::pair where the second
* element evaluates to true.
@@ -2888,7 +2975,7 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
* @param buffers The dynamic buffer sequence into which the data will be read.
* Although the buffers object may be copied as necessary, ownership of the
* underlying memory blocks is retained by the caller, which must guarantee
- * that they remain valid until the handler is called.
+ * that they remain valid until the completion handler is called.
*
* @param match_condition The function object to be called to determine whether
* a match exists. The signature of the function object must be:
@@ -2905,9 +2992,11 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
* @c second member of the return value is true if a match has been found, false
* otherwise.
*
- * @param handler The handler to be called when the read operation completes.
- * Copies will be made of the handler as required. The function signature of the
- * handler must be:
+ * @param token The @ref completion_token that will be used to produce a
+ * completion handler, which will be called when the read completes.
+ * Potential completion tokens include @ref use_future, @ref use_awaitable,
+ * @ref yield_context, or a function object with the correct completion
+ * signature. The function signature of the completion handler must be:
* @code void handler(
* // Result of operation.
* const asio::error_code& error,
@@ -2918,8 +3007,8 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
* std::size_t bytes_transferred
* ); @endcode
* Regardless of whether the asynchronous operation completes immediately or
- * not, the handler will not be invoked from within this function. On
- * immediate completion, invocation of the handler will be performed in a
+ * not, the completion handler will not be invoked from within this function.
+ * On immediate completion, invocation of the handler will be performed in a
* manner equivalent to using asio::post().
*
* @note After a successful async_read_until operation, the dynamic buffer
@@ -2927,6 +3016,9 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
* object. An application will typically leave that data in the dynamic buffer
* sequence for a subsequent async_read_until operation to examine.
*
+ * @par Completion Signature
+ * @code void(asio::error_code, std::size_t) @endcode
+ *
* @note The default implementation of the @c is_match_condition type trait
* evaluates to true for function pointers and function objects with a
* @c result_type typedef. It must be specialised for other user-defined
@@ -3001,22 +3093,23 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
template <typename AsyncReadStream,
typename DynamicBuffer_v2, typename MatchCondition,
ASIO_COMPLETION_TOKEN_FOR(void (asio::error_code,
- std::size_t)) ReadHandler
- ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
- typename AsyncReadStream::executor_type)>
-ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
- MatchCondition match_condition,
- ASIO_MOVE_ARG(ReadHandler) handler
- ASIO_DEFAULT_COMPLETION_TOKEN(
- typename AsyncReadStream::executor_type),
- typename constraint<
+ std::size_t)) ReadToken = default_completion_token_t<
+ typename AsyncReadStream::executor_type>>
+auto async_read_until(AsyncReadStream& s,
+ DynamicBuffer_v2 buffers, MatchCondition match_condition,
+ ReadToken&& token = default_completion_token_t<
+ typename AsyncReadStream::executor_type>(),
+ constraint_t<
is_match_condition<MatchCondition>::value
- >::type = 0,
- typename constraint<
+ > = 0,
+ constraint_t<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
- >::type = 0);
+ > = 0)
+ -> decltype(
+ async_initiate<ReadToken,
+ void (asio::error_code, std::size_t)>(
+ declval<detail::initiate_async_read_until_match_v2<AsyncReadStream>>(),
+ token, static_cast<DynamicBuffer_v2&&>(buffers), match_condition));
#endif // !defined(ASIO_NO_EXTENSIONS)