seekable_filter.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>SeekableFilter</TITLE>
  5. <LINK REL="stylesheet" HREF="../../../../boost.css">
  6. <LINK REL="stylesheet" HREF="../theme/iostreams.css">
  7. </HEAD>
  8. <BODY>
  9. <!-- Begin Banner -->
  10. <H1 CLASS="title">SeekableFilter</H1>
  11. <HR CLASS="banner">
  12. <!-- End Banner -->
  13. <H2>Definition</H2>
  14. <P>
  15. A SeekableFilter is a <A HREF="filter.html">Filter</A> whose <A HREF="../guide/modes.html">mode</A> refines <A HREF="../guide/modes.html#seekable">seekable</A>.
  16. </P>
  17. <H2>Description</H2>
  18. <P>
  19. A SeekableFilter operates on the character sequence controlled by a <A HREF="seekable_device.html">SeekableDevice</A>, providing access to a filtered sequence having the same character type. It may expose the filtered sequence in two ways:
  20. <OL>
  21. <LI STYLE="list-style-type:lower-roman">
  22. by defining member function <CODE>get</CODE>, <CODE>put</CODE> and <CODE>seek</CODE>.
  23. </LI>
  24. <LI STYLE="list-style-type:lower-roman">
  25. by defining member functions <CODE>read</CODE>, <CODE>write</CODE> and <CODE>seek</CODE>.
  26. </LI>
  27. </OL>
  28. The second alternative is provided for enhanced performance. SeekableFilters implementing this alternative are referred to as <I>Multi-Character</I>. (<I>See</I> <A HREF="multi_character.html">Multi-Character Filter</A>.)
  29. </P>
  30. <H2>Refinement of</H2>
  31. <P><A HREF="input_filter.html">InputFilter</A>, <A HREF="output_filter.html">OutputFilter</A>.</P>
  32. <H2>Associated Types</H2>
  33. <TABLE CELLPADDING="5" BORDER="1">
  34. <TR><TD>Character type</TD><TD>The type of the characters in the filtered sequences</TD></TR>
  35. <TR>
  36. <TD>Category</TD>
  37. <TD>
  38. A type convertible to <A HREF="../guide/traits.html#category_tags"><CODE>filter_tag</CODE></A> and to <A HREF="../guide/modes.html#seekable"><CODE>seekable</CODE></A>
  39. </TD>
  40. </TR>
  41. <TR>
  42. <TD>Mode</TD>
  43. <TD>
  44. The unique <I>most-derived</I> <A HREF="../guide/modes.html#mode_tags">mode tag</A> to which Category is convertible
  45. </TD>
  46. </TR>
  47. </TABLE>
  48. <H2>Notation</H2>
  49. <TABLE CELLPADDING="2">
  50. <TR><TD><CODE>F</CODE></TD><TD>- A type which is a model of SeekableFilter</TD></TR>
  51. <TR><TD><CODE>D</CODE></TD><TD>- A type which is a model of <A HREF="device.html">Device</A>, with the same character type as <CODE>F</CODE> and with mode convertible to the mode of <CODE>F</CODE></TD></TR>
  52. <TR><TD><CODE>Ch</CODE></TD><TD>- The character type of <CODE>F</CODE></TD></TR>
  53. <TR><TD><CODE>Tr</CODE></A></TD><TD>- <A HREF="../classes/char_traits.html"><CODE>boost::iostreams::char_traits&lt;Ch&gt;</CODE></A></TD></TR>
  54. <TR><TD><CODE>f</CODE></TD><TD>- Object of type <CODE>F</CODE></TD></TR>
  55. <TR><TD><CODE>d</CODE></TD><TD>- Object of type <CODE>D</CODE></TD></TR>
  56. <TR><TD><CODE>c</CODE></TD><TD>- Object of type <CODE>Ch</CODE></TD></TR>
  57. <TR><TD><CODE>s1</CODE></TD><TD>- Object of type <CODE>Ch*</CODE></TD></TR>
  58. <TR><TD><CODE>s2</CODE></TD><TD>- Object of type <CODE>const Ch*</CODE></TD></TR>
  59. <TR><TD><CODE>n</CODE></TD><TD>- Object of type <CODE>std::streamsize</CODE></TD></TR>
  60. <TR><TD><CODE>off</CODE></TD><TD>- Object of type <A HREF="../functions/positioning.html#synopsis"><CODE>stream_offset</CODE></A></TD></TR>
  61. <TR><TD><CODE>way</CODE></TD><TD>- Object of type <CODE>std::ios_base::seekdir</CODE></TD></TR>
  62. <TR><TD><CODE>which</CODE></TD><TD>- Object of type <CODE>std::ios_base::openmode</CODE></TD></TR>
  63. <TR><TD><CODE>io</CODE></TD><TD>- Alias for namespace <CODE>boost::iostreams</CODE></TD></TR>
  64. </TABLE>
  65. <H2>Valid Expressions / Semantics</H2>
  66. <TABLE CELLPADDING="5" BORDER="1">
  67. <TR><TH>Expression</TH><TH>Expression Type</TH><TH>Category Precondition</TH><TH>Semantics</TH></TR>
  68. <TR>
  69. <TD>
  70. <PRE CLASS="plain_code"><CODE>typename <A HREF="../guide/traits.html#char_type_of_ref">char_type_of</A>&lt;F&gt;::type</CODE></PRE>
  71. </TD>
  72. <TD><CODE>typename</CODE> of the character type</TD>
  73. <TD ALIGN="center">-</TD><TD ALIGN="center">-</TD>
  74. </TR>
  75. <TR>
  76. <TD>
  77. <PRE CLASS="plain_code"><CODE>typename <A HREF="../guide/traits.html#category_ref">category_of</A>&lt;F&gt;::type</CODE></PRE>
  78. </TD>
  79. <TD><CODE>typename</CODE> of the category</TD>
  80. <TD ALIGN="center">-</TD><TD ALIGN="center">-</TD>
  81. </TR>
  82. <TR>
  83. <TD><PRE CLASS="plain_code"><CODE>f.get(d)</CODE></PRE></TD>
  84. <TD><CODE>Tr::int_type</CODE></TD>
  85. <TD ROWSPAN="2">
  86. Not convertible to <A HREF="../guide/traits.html#category_tags"><CODE>multi_char_tag</CODE></A>
  87. </TD>
  88. <TD>
  89. Returns the next character in the sequence controlled by <CODE>f</CODE>, or <CODE>Tr::eof()</CODE> if the end of the sequence has been reached. The sequence controlled by <CODE>d</CODE> may be accessed using <A HREF="../functions/read.html"><CODE>io::read</CODE></A> and <A HREF="../functions/putback.html"><CODE>io::putback</CODE></A>.
  90. <!-- reads up to <CODE>n</CODE> characters from the sequence controlled by <CODE>dev</CODE> into <CODE>s</CODE>, returning the number of characters read; returning a value less than n indicates end-of-sequence -->
  91. </TD>
  92. </TR>
  93. <TR>
  94. <TD><PRE CLASS="plain_code"><CODE>f.put(d, c)</CODE></PRE></TD>
  95. <TD><CODE>bool</CODE></TD>
  96. <TD>
  97. Writes the character <CODE>c</CODE> to the sequence controlled by <CODE>f</CODE>. The sequence controlled by <CODE>d</CODE> may be accessed using <A HREF="../functions/write.html"><CODE>io::write</CODE></A>.
  98. </TD>
  99. </TR>
  100. <TR>
  101. <TD><PRE CLASS="plain_code"><CODE>f.read(d, s1, n)</CODE></PRE></TD>
  102. <TD><PRE CLASS="plain_code"><CODE>std::streamsize</CODE></PRE></TD>
  103. <TD ROWSPAN="2">
  104. Convertible to <A HREF="../guide/traits.html#category_tags"><CODE>multi_char_tag</CODE></A>
  105. </TD>
  106. <TD>
  107. Reads up to <CODE></CODE> characters from the sequence controlled by <CODE>f</CODE> into the buffer <CODE>s1</CODE>, returning the number of characters read. Returning a value less than <CODE>n</CODE> indicates end-of-sequence. The sequence controlled by <CODE>d</CODE> may be accessed using <A HREF="../functions/read.html"><CODE>io::read</CODE></A> and <A HREF="../functions/putback.html"><CODE>io::putback</CODE></A>.
  108. </TD>
  109. </TR>
  110. <TR>
  111. <TD><PRE CLASS="plain_code"><CODE>f.write(d, s2, n)</CODE></PRE></TD>
  112. <TD><PRE CLASS="plain_code"><CODE>std::streamsize</CODE></PRE></TD>
  113. <TD>
  114. Writes n characters from the buffer <CODE>s2</CODE> to the sequence controlled by <CODE>f</CODE>. The sequence controlled by <CODE>d</CODE> may be accessed using <A HREF="../functions/write.html"><CODE>io::write</CODE></A>.
  115. </TD>
  116. </TR>
  117. <TR>
  118. <TD><PRE CLASS="plain_code"><CODE>f.seek(d, off, way)</CODE></PRE></TD>
  119. <TD><CODE>std::streampos</CODE></TD>
  120. <TD ALIGN="center">-</TD>
  121. <TD>
  122. <P CLASS="concept">
  123. Advances the read/write head by <CODE>off</CODE> characters, returning the new position, where the offset is calculated from:
  124. </P>
  125. <UL STYLE="margin:0,0,0,auto">
  126. <LI STYLE="list-style-type:disc;list-style-image:none">the start of the sequence if <CODE>way</CODE> is <CODE>ios_base::beg</CODE>
  127. <LI STYLE="list-style-type:disc;list-style-image:none">the current position if <CODE>way</CODE> is <CODE>ios_base::cur</CODE>
  128. <LI STYLE="list-style-type:disc;list-style-image:none">the end of the sequence if <CODE>way</CODE> is <CODE>ios_base::end</CODE>
  129. </UL>
  130. <P CLASS="concept">
  131. The sequence controlled by <CODE>d</CODE> may be accessed using <A HREF="../functions/read.html"><CODE>io::seek</CODE></A> and using <A HREF="../functions/putback.html"><CODE>io::write</CODE></A> if the <A HREF="../guide/modes.html">mode</A> of <CODE>F</CODE> is convertible to <A HREF="../guide/modes.html#output"><CODE>output</CODE></A>.
  132. </P>
  133. </TD>
  134. </TR>
  135. </TABLE>
  136. <H2>Exceptions</H2>
  137. <P>
  138. Errors which occur during the execution of <CODE>get</CODE>, <CODE>put</CODE>, <CODE>read</CODE>, <CODE>write</CODE> or <CODE>seek</CODE> are indicated by throwing exceptions. Reaching the end of the sequence is not an error, but attempting to write past the end of the sequence is.
  139. </P>
  140. <P>
  141. After an exception is thrown, a SeekableFilter must be in a consistent state; further i/o operations may throw exceptions but must have well-defined behaviour. Furthermore, unless it is <A HREF="closable.html">Closable</A>, it must be ready to begin processing a new character sequence.
  142. </P>
  143. <H2>Models</H2>
  144. <!-- Begin Footer -->
  145. <HR>
  146. <P CLASS="copyright">&copy; Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>&copy; Copyright 2004-2007 <a href="https://www.boost.org/users/people/jonathan_turkanis.html" target="_top">Jonathan Turkanis</a></P>
  147. <P CLASS="copyright">
  148. 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>)
  149. </P>
  150. <!-- End Footer -->
  151. </BODY>