本文整理汇总了C++中asio::basic_streambuf::max_size方法的典型用法代码示例。如果您正苦于以下问题:C++ basic_streambuf::max_size方法的具体用法?C++ basic_streambuf::max_size怎么用?C++ basic_streambuf::max_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asio::basic_streambuf
的用法示例。
在下文中一共展示了basic_streambuf::max_size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_until
std::size_t read_until(SyncReadStream& s,
asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
asio::error_code& ec)
{
std::size_t search_position = 0;
for (;;)
{
// Determine the range of the data to be searched.
typedef typename asio::basic_streambuf<
Allocator>::const_buffers_type const_buffers_type;
typedef asio::buffers_iterator<const_buffers_type> iterator;
const_buffers_type buffers = b.data();
iterator begin = iterator::begin(buffers);
iterator start_pos = begin + search_position;
iterator end = iterator::end(buffers);
// Look for a match.
boost::match_results<iterator,
typename std::vector<boost::sub_match<iterator> >::allocator_type>
match_results;
if (regex_search(start_pos, end, match_results, expr,
boost::match_default | boost::match_partial))
{
if (match_results[0].matched)
{
// Full match. We're done.
ec = asio::error_code();
return match_results[0].second - begin;
}
else
{
// Partial match. Next search needs to start from beginning of match.
search_position = match_results[0].first - begin;
}
}
else
{
// No match. Next search can start with the new data.
search_position = end - begin;
}
// Check if buffer is full.
if (b.size() == b.max_size())
{
ec = error::not_found;
return 0;
}
// Need more data.
std::size_t bytes_to_read = read_size_helper(b, 65536);
b.commit(s.read_some(b.prepare(bytes_to_read), ec));
if (ec)
return 0;
}
}