1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <HTML> |
---|
3 | <HEAD> |
---|
4 | <TITLE>Function Template seek</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">Function Template <CODE>seek</CODE></H1> |
---|
13 | <HR CLASS="banner"> |
---|
14 | |
---|
15 | <!-- End Banner --> |
---|
16 | |
---|
17 | <DL class="page-index"> |
---|
18 | <DT><A href="#overview">Overview</A></DT> |
---|
19 | <DT><A href="#headers">Headers</A></DT> |
---|
20 | <DT><A href="#reference">Reference</A></DT> |
---|
21 | </DL> |
---|
22 | |
---|
23 | <A NAME="overview"></A> |
---|
24 | <H2>Overview</H2> |
---|
25 | |
---|
26 | <P> |
---|
27 | 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/device.html">Device</A>.</P> |
---|
28 | </P> |
---|
29 | |
---|
30 | <A NAME="headers"></A> |
---|
31 | <H2>Headers</H2> |
---|
32 | |
---|
33 | <DL> |
---|
34 | <DT><A CLASS="header" HREF="../../../../boost/iostreams/operations.hpp"><CODE><boost/iostreams/operations.hpp></CODE></A></DT> |
---|
35 | <DT><A CLASS="header" HREF="../../../../boost/iostreams/seek.hpp"><CODE><boost/iostreams/seek.hpp></CODE></A></DT> |
---|
36 | </DL> |
---|
37 | |
---|
38 | <A NAME="reference"></A> |
---|
39 | <H2>Reference</H2> |
---|
40 | |
---|
41 | <A NAME="description"></A> |
---|
42 | <H4>Description</H4> |
---|
43 | |
---|
44 | Repositions one or both heads within the sequence controlled by a given instance of the template parameter <CODE>T</CODE>, returning the resulting stream position. |
---|
45 | |
---|
46 | <A NAME="synopsis"></A> |
---|
47 | <H4>Synopsis</H4> |
---|
48 | |
---|
49 | <PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams { |
---|
50 | |
---|
51 | <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#template_params">T</A>> |
---|
52 | std::streampos |
---|
53 | <A CLASS="documented" HREF="#semantics">seek</A>( T&, <A CLASS="documented" HREF="positioning.html#synopsis">stream_offset</A> <A CLASS="documented" HREF="#function_params">off</A>, std::ios_base::seekdir <A CLASS="documented" HREF="#function_params">way</A>, |
---|
54 | std::ios_base::openmode <A CLASS="documented" HREF="#function_params">which</A> = |
---|
55 | std::ios_base::in | std::ios_base::out ); |
---|
56 | |
---|
57 | } } <SPAN CLASS="comment">// End namespace boost::io</SPAN></PRE> |
---|
58 | |
---|
59 | <A NAME="template_params"></A> |
---|
60 | <H4>Template Parameters</H4> |
---|
61 | |
---|
62 | <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> |
---|
63 | <TR> |
---|
64 | <TR> |
---|
65 | <TD VALIGN="top"><I>T</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> |
---|
66 | <TD>A model of one of the <A HREF="../guide/concepts.html#device_concepts">Device</A> concepts which allows random access. |
---|
67 | </TR> |
---|
68 | </TABLE> |
---|
69 | |
---|
70 | <A NAME="function_params"></A> |
---|
71 | <H4>Function Parameters</H4> |
---|
72 | |
---|
73 | <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> |
---|
74 | <TR> |
---|
75 | <TR> |
---|
76 | <TD VALIGN="top"><I>off</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> |
---|
77 | <TD>A <A HREF="positioning.html#synopsis"><CODE>stream_offset</CODE></A> 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>. |
---|
78 | </TR> |
---|
79 | <TR> |
---|
80 | <TD VALIGN="top"><I>way</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> |
---|
81 | <TD><P>Determines the initial position to which the offset <I>off</I> is applied, as follows: |
---|
82 | <UL> |
---|
83 | <LI CLASS="square">if <I>way</I> is <CODE>std::ios_base::beg</CODE>, the initial position is the begining of the stream |
---|
84 | <LI CLASS="square">if <I>way</I> is <CODE>std::ios_base::cur</CODE>, the initial position is the current position |
---|
85 | <LI CLASS="square">if <I>way</I> is <CODE>std::ios_base::beg</CODE>, the initial position is the end of the stream |
---|
86 | </UL> |
---|
87 | </P> |
---|
88 | </TR> |
---|
89 | <TR> |
---|
90 | <TD VALIGN="top"><I>which</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> |
---|
91 | <TD>Determines whether the reading head, the writing head or both are repositioned. |
---|
92 | </TR> |
---|
93 | </TABLE> |
---|
94 | |
---|
95 | <A NAME="semantics"></A> |
---|
96 | <H4>Semantics</H4> |
---|
97 | |
---|
98 | <P>The semantics of <CODE>seek</CODE> depends on the <A HREF="../guide/traits.html#category">category</A> of <CODE>T</CODE> as follows:</P> |
---|
99 | |
---|
100 | <TABLE STYLE="margin-left:2em" BORDER=1 CELLPADDING=4> |
---|
101 | <TR><TH><CODE>category_of<T>::type</CODE></TH><TH>semantics</TH></TR> |
---|
102 | <TR> |
---|
103 | <TD VALIGN="top">convertible to <CODE>istream_tag</CODE> or <CODE>ostream_tag</CODE></TD> |
---|
104 | <TD>returns: |
---|
105 | <UL STYLE='margin-top:0'> |
---|
106 | <LI><CODE>t.rdbuf()->pubseekpos(<A HREF="positioning.html#offset_to_position">offset_to_position</A>(off))</CODE>, if <CODE>way</CODE> is <CODE>std::ios_base::beg</CODE> and <CODE>off</CODE> is outside the range of <CODE>std::streamoff</CODE>, and |
---|
107 | <LI><CODE>t.rdbuf()->pubseekoff(off, way)</CODE>, otherwise |
---|
108 | <UL> |
---|
109 | </TR> |
---|
110 | <TR> |
---|
111 | <TD VALIGN="top">convertible to <CODE>streambuf_tag</CODE></TD> |
---|
112 | <TD>returns: |
---|
113 | <UL STYLE='margin-top:0'> |
---|
114 | <LI><CODE>t.pubseekpos(<A HREF="positioning.html#offset_to_position">offset_to_position</A>(off))</CODE>, if <CODE>way</CODE> is <CODE>std::ios_base::beg</CODE> and <CODE>off</CODE> is outside the range of <CODE>std::streamoff</CODE>, and |
---|
115 | <LI><CODE>t.pubseekoff(off, way)</CODE>, otherwise |
---|
116 | <UL> |
---|
117 | </TR> |
---|
118 | <TR> |
---|
119 | <TD VALIGN="top">convertible to <CODE>input_seekable</CODE> but not to <CODE>output_seekable</CODE></TD> |
---|
120 | <TD>returns <CODE>t.seek(off, way)</CODE></TD> |
---|
121 | </TR> |
---|
122 | <TR> |
---|
123 | <TD VALIGN="top">convertible to <CODE>output_seekable</CODE> but not to <CODE>input_seekable</CODE></TD> |
---|
124 | <TD>returns <CODE>t.seek(off, way)</CODE></TD> |
---|
125 | </TR> |
---|
126 | <TR> |
---|
127 | <TD VALIGN="top">convertible to <CODE>dual_seekable</CODE> or to <CODE>bidirectional_seekable</CODE></TD> |
---|
128 | <TD>returns <CODE>t.seek(off, way, which)</CODE></TD> |
---|
129 | </TR> |
---|
130 | <TR> |
---|
131 | <TD VALIGN="top">convertible to <CODE>seekable</CODE></TD> |
---|
132 | <TD>returns <CODE>t.seek(off, way)</CODE></TD> |
---|
133 | </TR> |
---|
134 | <TR> |
---|
135 | <TD VALIGN="top"><I>otherwise</I></TD> |
---|
136 | <TD>compile-time error</TD> |
---|
137 | </TR> |
---|
138 | </TABLE> |
---|
139 | |
---|
140 | <P>In short: |
---|
141 | <UL> |
---|
142 | <LI CLASS="square">If <CODE>T</CODE> is a standard stream or stream buffer type, delegates to <CODE>std::basic_streambuf::pubseekoff</CODE> or <CODE>std::basic_streambuf::pubseekpos</CODE>, as appropriate. |
---|
143 | <LI CLASS="square">Otherwise, if the <A HREF="../guide/modes.html">mode</A> of <CODE>T</CODE> allows only one reading head, delegates to a member function <CODE>seek</CODE> which takes a <CODE>stream_offset</CODE> and a <CODE>seekdir</CODE> but no <CODE>openmode</CODE>. |
---|
144 | <LI CLASS="square">Otherwise, if the <A HREF="../guide/modes.html">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>stream_offset</CODE>, a <CODE>seekdir</CODE> and an <CODE>openmode</CODE>. |
---|
145 | <LI CLASS="square">If the <A HREF="../guide/modes.html">mode</A> of T does not permit random access, attempting to invoke <CODE>seek</CODE> is a compile-time error. |
---|
146 | </UL> |
---|
147 | |
---|
148 | <!-- Begin Footer --> |
---|
149 | |
---|
150 | <HR> |
---|
151 | <P CLASS="copyright">Revised |
---|
152 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> |
---|
153 | 20 May, 2004 |
---|
154 | <!--webbot bot="Timestamp" endspan i-checksum="38504" --> |
---|
155 | </P> |
---|
156 | |
---|
157 | <P CLASS="copyright">© Copyright <A HREF="http://www.kangaroologic.com" TARGET="_top">Jonathan Turkanis</A>, 2004</P> |
---|
158 | <P CLASS="copyright"> |
---|
159 | 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>) |
---|
160 | </P> |
---|
161 | |
---|
162 | <!-- End Footer --> |
---|
163 | |
---|
164 | </BODY> |
---|