3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>read_until (8 of 8 overloads)</title>
5 <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.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="overload7.html" title="read_until (7 of 8 overloads)">
10 <link rel="next" href="../seq_packet_socket_service.html" title="seq_packet_socket_service">
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>
22 <div class="spirit-nav">
23 <a accesskey="p" href="overload7.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="../seq_packet_socket_service.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="boost_asio.reference.read_until.overload8"></a><a class="link" href="overload8.html" title="read_until (8 of 8 overloads)">read_until
28 (8 of 8 overloads)</a>
29 </h4></div></div></div>
31 Read data into a streambuf until a function object indicates a match.
33 <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
34 <span class="keyword">typename</span> <a class="link" href="../SyncReadStream.html" title="Buffer-oriented synchronous read stream requirements">SyncReadStream</a><span class="special">,</span>
35 <span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">,</span>
36 <span class="keyword">typename</span> <span class="identifier">MatchCondition</span><span class="special">></span>
37 <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">read_until</span><span class="special">(</span>
38 <span class="identifier">SyncReadStream</span> <span class="special">&</span> <span class="identifier">s</span><span class="special">,</span>
39 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">basic_streambuf</span><span class="special"><</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">b</span><span class="special">,</span>
40 <span class="identifier">MatchCondition</span> <span class="identifier">match_condition</span><span class="special">,</span>
41 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="special">&</span> <span class="identifier">ec</span><span class="special">,</span>
42 <span class="keyword">typename</span> <span class="identifier">enable_if</span><span class="special"><</span> <span class="identifier">is_match_condition</span><span class="special"><</span> <span class="identifier">MatchCondition</span> <span class="special">>::</span><span class="identifier">value</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">*</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
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:
50 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
52 The match condition function object returns a std::pair where the second
53 element evaluates to true.
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.
65 <a name="boost_asio.reference.read_until.overload8.h0"></a>
66 <span class="phrase"><a name="boost_asio.reference.read_until.overload8.parameters"></a></span><a class="link" href="overload8.html#boost_asio.reference.read_until.overload8.parameters">Parameters</a>
68 <div class="variablelist">
69 <p class="title"><b></b></p>
70 <dl class="variablelist">
71 <dt><span class="term">s</span></dt>
73 The stream from which the data is to be read. The type must support
74 the SyncReadStream concept.
76 <dt><span class="term">b</span></dt>
78 A streambuf object into which the data will be read.
80 <dt><span class="term">match_condition</span></dt>
83 The function object to be called to determine whether a match exists.
84 The signature of the function object must be:
86 <pre class="programlisting"><span class="identifier">pair</span><span class="special"><</span><span class="identifier">iterator</span><span class="special">,</span> <span class="keyword">bool</span><span class="special">></span> <span class="identifier">match_condition</span><span class="special">(</span><span class="identifier">iterator</span> <span class="identifier">begin</span><span class="special">,</span> <span class="identifier">iterator</span> <span class="identifier">end</span><span class="special">);</span>
89 where <code class="computeroutput"><span class="identifier">iterator</span></code> represents
92 <pre class="programlisting"><span class="identifier">buffers_iterator</span><span class="special"><</span><span class="identifier">basic_streambuf</span><span class="special"><</span><span class="identifier">Allocator</span><span class="special">>::</span><span class="identifier">const_buffers_type</span><span class="special">></span>
95 The iterator parameters <code class="computeroutput"><span class="identifier">begin</span></code>
96 and <code class="computeroutput"><span class="identifier">end</span></code> define the
97 range of bytes to be scanned to determine whether there is a match.
98 The <code class="computeroutput"><span class="identifier">first</span></code> member
99 of the return value is an iterator marking one-past-the-end of the
100 bytes that have been consumed by the match function. This iterator
101 is used to calculate the <code class="computeroutput"><span class="identifier">begin</span></code>
102 parameter for any subsequent invocation of the match condition. The
103 <code class="computeroutput"><span class="identifier">second</span></code> member of
104 the return value is true if a match has been found, false otherwise.
107 <dt><span class="term">ec</span></dt>
109 Set to indicate what error occurred, if any.
114 <a name="boost_asio.reference.read_until.overload8.h1"></a>
115 <span class="phrase"><a name="boost_asio.reference.read_until.overload8.return_value"></a></span><a class="link" href="overload8.html#boost_asio.reference.read_until.overload8.return_value">Return
119 The number of bytes in the streambuf's get area that have been fully consumed
120 by the match function. Returns 0 if an error occurred.
123 <a name="boost_asio.reference.read_until.overload8.h2"></a>
124 <span class="phrase"><a name="boost_asio.reference.read_until.overload8.remarks"></a></span><a class="link" href="overload8.html#boost_asio.reference.read_until.overload8.remarks">Remarks</a>
127 After a successful read_until operation, the streambuf may contain additional
128 data beyond that which matched the function object. An application will
129 typically leave that data in the streambuf for a subsequent
132 The default implementation of the <code class="computeroutput"><span class="identifier">is_match_condition</span></code>
133 type trait evaluates to true for function pointers and function objects
134 with a <code class="computeroutput"><span class="identifier">result_type</span></code> typedef.
135 It must be specialised for other user-defined function objects.
138 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
139 <td align="left"></td>
140 <td align="right"><div class="copyright-footer">Copyright © 2003-2014 Christopher M. Kohlhoff<p>
141 Distributed under the Boost Software License, Version 1.0. (See accompanying
142 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>)
147 <div class="spirit-nav">
148 <a accesskey="p" href="overload7.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="../seq_packet_socket_service.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>