| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|---|
| 2 | <HTML> |
|---|
| 3 | <HEAD> |
|---|
| 4 | <TITLE>Peekable</TITLE> |
|---|
| 5 | <LINK REL="stylesheet" HREF="../../../../boost.css"> |
|---|
| 6 | <LINK REL="stylesheet" HREF="../theme/iostreams.css"> |
|---|
| 7 | </HEAD> |
|---|
| 8 | <BODY> |
|---|
| 9 | |
|---|
| 10 | <!-- Begin Banner --> |
|---|
| 11 | |
|---|
| 12 | <H1 CLASS="title">Peekable</H1> |
|---|
| 13 | <HR CLASS="banner"> |
|---|
| 14 | |
|---|
| 15 | <!-- End Banner --> |
|---|
| 16 | |
|---|
| 17 | <H2>Description</H2> |
|---|
| 18 | |
|---|
| 19 | <P> |
|---|
| 20 | A Peekable <A HREF="device.html">Device</A> allows a character read from the input sequence to be putback. |
|---|
| 21 | </P> |
|---|
| 22 | |
|---|
| 23 | <P> |
|---|
| 24 | The name of the concept is based on the observation that a PeekableDevice allow the user to peek at the first character in the sequence it controls by calling <A HREF="../functions/get.html"><CODE>get</CODE></A> or <A HREF="../functions/read.html"><CODE>read</CODE></A> followed by <A HREF="../functions/putback.html"><CODE>putback</CODE></A>. The names Putbackable and InputRevertable were considered but rejected. |
|---|
| 25 | </P> |
|---|
| 26 | |
|---|
| 27 | <H2>Refinement of</H2> |
|---|
| 28 | |
|---|
| 29 | <A HREF="source.html">Source</A>. |
|---|
| 30 | |
|---|
| 31 | <A NAME="types"></A> |
|---|
| 32 | <H2>Associated Types</H2> |
|---|
| 33 | |
|---|
| 34 | Same as <A HREF="source.html">Source</A>. |
|---|
| 35 | |
|---|
| 36 | <H2>Notation</H2> |
|---|
| 37 | |
|---|
| 38 | <TABLE CELLPADDING="2"> |
|---|
| 39 | <TR><TD><CODE>P</CODE></TD><TD>-</TD><TD>A type which is a model of Peekable</TD></TR> |
|---|
| 40 | <TR><TD><CODE>p</CODE></TD><TD>-</TD><TD>Object of type <CODE>P</CODE></TD></TR> |
|---|
| 41 | <TR><TD><CODE>c</CODE></TD><TD>-</TD><TD>Object of type equal to the character type of <CODE>P</CODE></TD></TR> |
|---|
| 42 | <TR><TD><CODE>io</CODE></TD><TD>-</TD><TD>Alias for namespace <CODE>boost::iostreams</CODE></TD></TR> |
|---|
| 43 | </TABLE> |
|---|
| 44 | |
|---|
| 45 | <H2>Valid Expressions / Semantics</H2> |
|---|
| 46 | |
|---|
| 47 | <TABLE CELLPADDING="5" BORDER="1"> |
|---|
| 48 | <TR><TH>Expression</TH><TH>Expression Type</TH><TH>Precondition</TH><TH>Semantics</TH><TH>Postcondition</TH></TR> |
|---|
| 49 | <TR> |
|---|
| 50 | <TD> |
|---|
| 51 | <PRE CLASS="plain_code"><CODE><A HREF="../functions/putback.html">io::putback</A>(p, c)</CODE></PRE> |
|---|
| 52 | </TD> |
|---|
| 53 | <TD><CODE>bool</CODE></TD> |
|---|
| 54 | <TD> |
|---|
| 55 | One or more characters has been read from <CODE>p</CODE> using <A HREF="../functions/get.html"><CODE>io::get</CODE></A> or <A HREF="../functions/read.html"><CODE>io::read</CODE></A>, with no intervening i/o operations having been performed |
|---|
| 56 | </TD> |
|---|
| 57 | <TD> |
|---|
| 58 | Attempts to put back <CODE>c</CODE> to <CODE>p</CODE>, returning <CODE>true</CODE> for success |
|---|
| 59 | </TD> |
|---|
| 60 | <TD> |
|---|
| 61 | If putback returns <CODE>true</CODE>, the next character read from <CODE>p</CODE> using <A HREF="../functions/get.html"><CODE>io::get</CODE></A> or <A HREF="../functions/read.html"><CODE>io::read</CODE></A> will be equal to <CODE>c</CODE></A> |
|---|
| 62 | </TD> |
|---|
| 63 | </TR> |
|---|
| 64 | </TABLE> |
|---|
| 65 | |
|---|
| 66 | <H2>Exceptions</H2> |
|---|
| 67 | |
|---|
| 68 | <P> |
|---|
| 69 | Errors which occur during the execution of <A CLASS="code" HREF="../functions/putback.html"><CODE>putback</CODE></A> are be indicated by throwing exceptions. |
|---|
| 70 | </P> |
|---|
| 71 | |
|---|
| 72 | <H2>Models</H2> |
|---|
| 73 | <UL> |
|---|
| 74 | <LI>Standard input streams and stream buffers. |
|---|
| 75 | </UL> |
|---|
| 76 | |
|---|
| 77 | <!-- Begin Footer --> |
|---|
| 78 | |
|---|
| 79 | <HR> |
|---|
| 80 | <P CLASS="copyright">Revised |
|---|
| 81 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> |
|---|
| 82 | 20 May, 2004 |
|---|
| 83 | <!--webbot bot="Timestamp" endspan i-checksum="38504" --> |
|---|
| 84 | </P> |
|---|
| 85 | |
|---|
| 86 | <P CLASS="copyright">© Copyright <A HREF="http://www.kangaroologic.com" TARGET="_top">Jonathan Turkanis</A>, 2004</P> |
|---|
| 87 | <P CLASS="copyright"> |
|---|
| 88 | Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>) |
|---|
| 89 | </P> |
|---|
| 90 | |
|---|
| 91 | <!-- End Footer --> |
|---|
| 92 | |
|---|
| 93 | </BODY> |
|---|