将数据读取到 streambuf 中,直到函数对象指示匹配。
template< typename SyncReadStream, typename Allocator, typename MatchCondition> std::size_t read_until( SyncReadStream & s, boost::asio::basic_streambuf< Allocator > & b, MatchCondition match_condition, boost::system::error_code & ec, constraint_t< is_match_condition< MatchCondition >::value > = 0);
此函数用于将数据读取到指定的 streambuf 中,直到用户定义的匹配条件函数对象应用于 streambuf 中包含的数据时,表示匹配成功。调用将阻塞,直到以下任一条件为真
此操作通过零次或多次调用流的 read_some 函数来实现。如果匹配条件函数对象已指示匹配,则函数会立即返回。
要从中读取数据的流。类型必须支持 SyncReadStream 概念。
一个 streambuf 对象,数据将被读取到其中。
将要调用的函数对象,用于确定是否存在匹配。函数对象的签名必须为:
pair<iterator, bool> match_condition(iterator begin, iterator end);
其中 iterator 代表类型
buffers_iterator<basic_streambuf<Allocator>::const_buffers_type>
迭代器参数 begin 和 end 定义了要扫描以确定是否存在匹配的字节范围。返回值中的 first 成员是一个迭代器,指向匹配函数已消耗的字节的末尾之后一个字节。此迭代器用于计算匹配条件后续调用的 begin 参数。返回值的 second 成员为 true,表示已找到匹配项;否则为 false。
用于指示发生何种错误(如果有)。
匹配函数已完全消耗的 streambuf get 区域中的字节数。如果发生错误,则返回 0。
在成功的 read_until 操作之后,streambuf 可能包含超出匹配函数对象的数据。应用程序通常会将这些数据保留在 streambuf 中,以供后续的 read_until 操作检查。
is_match_condition 类型特征的默认实现对具有 result_type typedef 的函数指针和函数对象评估为 true。它必须为其他用户定义的函数对象进行特化。