Files
iostreams/doc/functions/seek.html
Jonathan Turkanis 6bcd9ddf17 renamed io_category
[SVN r29092]
2005-05-20 04:11:12 +00:00

157 lines
6.9 KiB
HTML
Executable File

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Function Template seek</TITLE>
<LINK REL="stylesheet" HREF="../../../../boost.css">
<LINK REL="stylesheet" HREF="../theme/iostreams.css">
</HEAD>
<BODY>
<!-- Begin Banner -->
<H1 CLASS="title">Function Template <CODE>seek</CODE></H1>
<HR CLASS="banner">
<!-- End Banner -->
<DL class="page-index">
<DT><A href="#overview">Overview</A></DT>
<DT><A href="#headers">Headers</A></DT>
<DT><A href="#reference">Reference</A></DT>
</DL>
<A NAME="overview">
<H2>Overview</H2>
<P>
The function template <CODE>seek</CODE> is used by the Iostreams Library to perform random access withing a sequence controlled by a <A HREF="../concepts.html#device_concepts.html">Device</A> or by a standard stream or stream buffer. <CODE>seek</CODE> is designed to be overloaded or specialized for <A HREF="../concepts.html#device_concepts.html">Device</A> types external to the Iostreams Library. The default implementation, however, should be suitable for most purposes.</P>
</P>
<P>
<I>Note:</I> Unlike <CODE>read</CODE> and <CODE>write</CODE>, <CODE>seek</CODE> has no overload for Filter types. Filters which perform random access are required to have a member function <CODE>seek</CODE>.
</P>
<A NAME="headers">
<H2>Headers</H2>
<DL>
<DT><A CLASS="header" HREF="../../../../boost/iostreams/operations.hpp"><CODE>&lt;boost/iostreams/operations.hpp&gt;</CODE></A></DT>
</DL>
<A NAME="reference">
<H2>Reference</H2>
<A NAME="description">
<H4>Description</H4>
Repositions one or both heads within the sequence controlled by a given instance of the template parameter <CODE>T</CODE>, returning the resulting position.
<A NAME="synopsis">
<H4>Synopsis</H4>
<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {
<SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">T</A>&gt;
std::streamoff <A CLASS="documented" HREF="#semantics">seek</A>( T&, std::streamoff <A CLASS="documented" HREF="#function_params">off</A>, std::ios_base::seekdir <A CLASS="documented" HREF="#function_params">way</A>,
std::ios_base::openmode <A CLASS="documented" HREF="#function_params">which</A> =
std::ios_base::in | std::ios_base::out );
} } <SPAN CLASS="comment">// End namespace boost::io</SPAN></PRE>
<A NAME="template_params"></A>
<H4>Template Parameters</H4>
<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
<TR>
<TR>
<TD VALIGN="top"><I>T</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
<TD>A model of one of the <A HREF="../concepts.html#device_concepts">Device</A> concepts which allows random access, or a standard stream or stream buffer type.
</TR>
</TABLE>
<A NAME="function_params"></A>
<H4>Function Parameters</H4>
<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
<TR>
<TR>
<TD VALIGN="top"><I>off</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
<TD>A <CODE>std::streamoff</CODE> value indicating the number of characters by which the appropriate reading or writing heads should be advanced. The initial position is determined by the parameter <I>way</I>.
</TR>
<TR>
<TD VALIGN="top"><I>way</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
<TD><P>Determines the initial position to which the offset <I>off</I> is applied, as follows:
<UL>
<LI CLASS="square">if <I>way</I> is <CODE>std::ios_base::beg</CODE>, the initial position is the begining of the stream
<LI CLASS="square">if <I>way</I> is <CODE>std::ios_base::cur</CODE>, the initial position is the current position
<LI CLASS="square">if <I>way</I> is <CODE>std::ios_base::beg</CODE>, the initial position is the end of the stream
</UL>
</P>
</TR>
<TR>
<TD VALIGN="top"><I>which</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
<TD>Determines whether the reading head, the writing head or both are repositioned.
</TR>
</TABLE>
<A NAME="semantics"></A>
<H4>Semantics</H4>
<P>The semantics of <CODE>seek</CODE> depends on the <A HREF="../traits.html#category">category</A> of <CODE>T</CODE> as follows:</P>
<TABLE STYLE="margin-left:2em" BORDER=1 CELLPADDING=4>
<TR><TH><CODE>category_of&lt;T&gt;::type</CODE></TH><TH>semantics</TH></TR>
<TR>
<TD VALIGN="top">convertible to <CODE>istream_tag</CODE> or <CODE>ostream_tag</CODE></TD>
<TD>returns <CODE>t.rdbuf()->pubseekoff(off, way)</CODE></TD>
</TR>
<TR>
<TD VALIGN="top">convertible to <CODE>streambuf_tag</CODE></TD>
<TD>returns <CODE>t.pubseekoff(off, way)</CODE></TD>
</TR>
<TR>
<TD VALIGN="top">convertible to <CODE>input_seekable</CODE> but not to <CODE>output_seekable</CODE></TD>
<TD>returns <CODE>t.seek(off, way)</CODE></TD>
</TR>
<TR>
<TD VALIGN="top">convertible to <CODE>output_seekable</CODE> but not to <CODE>input_seekable</CODE></TD>
<TD>returns <CODE>t.seek(off, way)</CODE></TD>
</TR>
<TR>
<TD VALIGN="top">convertible to <CODE>dual_seekable</CODE> or to <CODE>bidirectional_seekable</CODE></TD>
<TD>returns <CODE>t.seek(off, way, which)</CODE></TD>
</TR>
<TR>
<TD VALIGN="top">convertible to <CODE>seekable</CODE></TD>
<TD>returns <CODE>t.seek(off, way)</CODE></TD>
</TR>
<TR>
<TD VALIGN="top"><I>otherwise</I></TD>
<TD>compile-time error</TD>
</TR>
</TABLE>
<P>In short:
<UL>
<LI CLASS="square">If <CODE>T</CODE> is a standard stream or stream buffer type, delegates to <CODE>std::basic_streambuf::pubseekoff</CODE>.
<LI CLASS="square">Otherwise, if the <A HREF="../modes.html">i/o mode</A> of <CODE>T</CODE> allows only one reading head, delegates to a member function <CODE>seek</CODE> which takes a <CODE>streamoff</CODE> and a <CODE>seekdir</CODE> but no <CODE>openmode</CODE>.
<LI CLASS="square">Otherwise, if the <A HREF="../modes.html">i/o mode</A> of <CODE>T</CODE> allows random access with two reading heads, delegates to a member function <CODE>seek</CODE> which takes a <CODE>streamoff</CODE>, a <CODE>seekdir</CODE> and an <CODE>openmode</CODE>.
<LI CLASS="square">If the <A HREF="../modes.html">i/o mode</A> of T does not permit random access, attempting to invoke <CODE>seek</CODE> is a compile-time error.
</UL>
<!-- Begin Footer -->
<HR>
<P CLASS="copyright">Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
20 May, 2004
<!--webbot bot="Timestamp" endspan i-checksum="38504" -->
</P>
<P CLASS="copyright">&copy; Copyright Jonathan Turkanis, 2004</P>
<P CLASS="copyright">
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>)
</P>
<!-- End Footer -->
</BODY>