Imported Upstream version 1.57.0
[platform/upstream/boost.git] / doc / html / boost_asio / reference / read_until / overload8.html
1 <html>
2 <head>
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">
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="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>
24 </div>
25 <div class="section">
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>
30 <p>
31           Read data into a streambuf until a function object indicates a match.
32         </p>
33 <pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</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">&gt;</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">&amp;</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">&lt;</span> <span class="identifier">Allocator</span> <span class="special">&gt;</span> <span class="special">&amp;</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">&amp;</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">&lt;</span> <span class="identifier">is_match_condition</span><span class="special">&lt;</span> <span class="identifier">MatchCondition</span> <span class="special">&gt;::</span><span class="identifier">value</span> <span class="special">&gt;::</span><span class="identifier">type</span> <span class="special">*</span>  <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
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.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>
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"><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">iterator</span><span class="special">,</span> <span class="keyword">bool</span><span class="special">&gt;</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>
87 </pre>
88 <p>
89                 where <code class="computeroutput"><span class="identifier">iterator</span></code> represents
90                 the type:
91 </p>
92 <pre class="programlisting"><span class="identifier">buffers_iterator</span><span class="special">&lt;</span><span class="identifier">basic_streambuf</span><span class="special">&lt;</span><span class="identifier">Allocator</span><span class="special">&gt;::</span><span class="identifier">const_buffers_type</span><span class="special">&gt;</span>
93 </pre>
94 <p>
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.
105               </p>
106 </dd>
107 <dt><span class="term">ec</span></dt>
108 <dd><p>
109                 Set to indicate what error occurred, if any.
110               </p></dd>
111 </dl>
112 </div>
113 <h6>
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
116           Value</a>
117         </h6>
118 <p>
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.
121         </p>
122 <h6>
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>
125         </h6>
126 <p>
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
130         </p>
131 <p>
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.
136         </p>
137 </div>
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 &#169; 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>)
143       </p>
144 </div></td>
145 </tr></table>
146 <hr>
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>
149 </div>
150 </body>
151 </html>