1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>read_until (16 of 24 overloads)</title> 5<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../boost_asio.html" title="Boost.Asio"> 8<link rel="up" href="../read_until.html" title="read_until"> 9<link rel="prev" href="overload15.html" title="read_until (15 of 24 overloads)"> 10<link rel="next" href="overload17.html" title="read_until (17 of 24 overloads)"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="overload15.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../read_until.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="overload17.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="boost_asio.reference.read_until.overload16"></a><a class="link" href="overload16.html" title="read_until (16 of 24 overloads)">read_until 28 (16 of 24 overloads)</a> 29</h4></div></div></div> 30<p> 31 Read data into a streambuf until a function object indicates a match. 32 </p> 33<pre class="programlisting">template< 34 typename <a class="link" href="../SyncReadStream.html" title="Buffer-oriented synchronous read stream requirements">SyncReadStream</a>, 35 typename Allocator, 36 typename MatchCondition> 37std::size_t read_until( 38 SyncReadStream & s, 39 boost::asio::basic_streambuf< Allocator > & b, 40 MatchCondition match_condition, 41 boost::system::error_code & ec, 42 typename enable_if< is_match_condition< MatchCondition >::value >::type * = 0); 43</pre> 44<p> 45 This function is used to read data into the specified streambuf until a 46 user-defined match condition function object, when applied to the data 47 contained in the streambuf, indicates a successful match. The call will 48 block until one of the following conditions is true: 49 </p> 50<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 51<li class="listitem"> 52 The match condition function object returns a std::pair where the second 53 element evaluates to true. 54 </li> 55<li class="listitem"> 56 An error occurred. 57 </li> 58</ul></div> 59<p> 60 This operation is implemented in terms of zero or more calls to the stream's 61 read_some function. If the match condition function object already indicates 62 a match, the function returns immediately. 63 </p> 64<h6> 65<a name="boost_asio.reference.read_until.overload16.h0"></a> 66 <span class="phrase"><a name="boost_asio.reference.read_until.overload16.parameters"></a></span><a class="link" href="overload16.html#boost_asio.reference.read_until.overload16.parameters">Parameters</a> 67 </h6> 68<div class="variablelist"> 69<p class="title"><b></b></p> 70<dl class="variablelist"> 71<dt><span class="term">s</span></dt> 72<dd><p> 73 The stream from which the data is to be read. The type must support 74 the SyncReadStream concept. 75 </p></dd> 76<dt><span class="term">b</span></dt> 77<dd><p> 78 A streambuf object into which the data will be read. 79 </p></dd> 80<dt><span class="term">match_condition</span></dt> 81<dd> 82<p> 83 The function object to be called to determine whether a match exists. 84 The signature of the function object must be: 85</p> 86<pre class="programlisting">pair<iterator, bool> match_condition(iterator begin, iterator end); 87</pre> 88<p> 89 where <code class="computeroutput">iterator</code> represents the type: 90</p> 91<pre class="programlisting">buffers_iterator<basic_streambuf<Allocator>::const_buffers_type> 92</pre> 93<p> 94 The iterator parameters <code class="computeroutput">begin</code> and <code class="computeroutput">end</code> define 95 the range of bytes to be scanned to determine whether there is a 96 match. The <code class="computeroutput">first</code> member of the return value is an iterator 97 marking one-past-the-end of the bytes that have been consumed by 98 the match function. This iterator is used to calculate the <code class="computeroutput">begin</code> 99 parameter for any subsequent invocation of the match condition. The 100 <code class="computeroutput">second</code> member of the return value is true if a match 101 has been found, false otherwise. 102 </p> 103</dd> 104<dt><span class="term">ec</span></dt> 105<dd><p> 106 Set to indicate what error occurred, if any. 107 </p></dd> 108</dl> 109</div> 110<h6> 111<a name="boost_asio.reference.read_until.overload16.h1"></a> 112 <span class="phrase"><a name="boost_asio.reference.read_until.overload16.return_value"></a></span><a class="link" href="overload16.html#boost_asio.reference.read_until.overload16.return_value">Return 113 Value</a> 114 </h6> 115<p> 116 The number of bytes in the streambuf's get area that have been fully consumed 117 by the match function. Returns 0 if an error occurred. 118 </p> 119<h6> 120<a name="boost_asio.reference.read_until.overload16.h2"></a> 121 <span class="phrase"><a name="boost_asio.reference.read_until.overload16.remarks"></a></span><a class="link" href="overload16.html#boost_asio.reference.read_until.overload16.remarks">Remarks</a> 122 </h6> 123<p> 124 After a successful read_until operation, the streambuf may contain additional 125 data beyond that which matched the function object. An application will 126 typically leave that data in the streambuf for a subsequent read_until 127 operation to examine. 128 </p> 129<p> 130 The default implementation of the <code class="computeroutput">is_match_condition</code> type 131 trait evaluates to true for function pointers and function objects with 132 a <code class="computeroutput">result_type</code> typedef. It must be specialised for other user-defined 133 function objects. 134 </p> 135</div> 136<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 137<td align="left"></td> 138<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 139 Kohlhoff<p> 140 Distributed under the Boost Software License, Version 1.0. (See accompanying 141 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 142 </p> 143</div></td> 144</tr></table> 145<hr> 146<div class="spirit-nav"> 147<a accesskey="p" href="overload15.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../read_until.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="overload17.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 148</div> 149</body> 150</html> 151