| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | 
|---|
| 2 | <HTML> | 
|---|
| 3 | <HEAD> | 
|---|
| 4 |     <TITLE>Stream Offsets</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">Stream Offsets</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="#acknowledgments">Acknowledgments</A> | 
|---|
| 20 |   <DT><A href="#headers">Headers</A></DT> | 
|---|
| 21 |   <DT><A href="#reference">Reference</A></DT> | 
|---|
| 22 | </DL> | 
|---|
| 23 |  | 
|---|
| 24 | <HR> | 
|---|
| 25 |  | 
|---|
| 26 | <A NAME="overview"></A> | 
|---|
| 27 | <H2>Overview</H2> | 
|---|
| 28 |  | 
|---|
| 29 | <P> | 
|---|
| 30 |     The header <A CLASS="header" HREF="../../../../boost/iostreams/positioning.hpp"><CODE><boost/iostreams/positioning.hpp></CODE></A> provides the definition of the integral type <CODE>boost::iostreams::stream_offset</CODE>, capable of holding arbitrary stream offsets on most platforms, together with the definition of two functions, <CODE>offset_to_position</CODE> and <CODE>position_to_offset</CODE>, for converting between <CODE>stream_offset</CODE> and <CODE>std::streampos</CODE>. | 
|---|
| 31 | </P> | 
|---|
| 32 |  | 
|---|
| 33 | <P> | 
|---|
| 34 |     The type <CODE>std::streampos</CODE> is required to be able to hold an arbitrary stream position, but it is not an intergral type. Although <CODE>std::streampos</CODE> is interconvertible with the integral type <CODE>std::streamoff</CODE>, the conversion from <CODE>std::streampos</CODE> to <CODE>std::streamoff</CODE> may not be faithful for large (64-bit) values. The integral type <CODE>boost::iostreams::stream_offset</CODE> is intended as a replacement for <CODE>std::streamoff</CODE>, with the implicit conversions to and from <CODE>std::streampos</CODE> being replaced by explicit conversion functions. | 
|---|
| 35 | </P> | 
|---|
| 36 |  | 
|---|
| 37 | <P> | 
|---|
| 38 |     The implementation of <CODE>offset_to_position</CODE> and <CODE>position_to_offset</CODE> relies on implementation defined behavior, and is guaranteed to work correctly for large values only for standard libraries which define <CODE>std::streamoff</CODE> to be 64-bit type or for which the Boost Iostreams library has been explicitly configured. | 
|---|
| 39 | </P> | 
|---|
| 40 |  | 
|---|
| 41 | <A NAME="acknowledgments"></A> | 
|---|
| 42 | <H2>Acknowledgments</H2> | 
|---|
| 43 |  | 
|---|
| 44 | <P>Gareth Sylvester-Bradley suggested the treatment of large stream offsets used by the Boost Iostreams library and supplied the implementation of <CODE>offset_to_position</CODE> and <CODE>position_to_offset</CODE> used with the Dinkumware standard library.</P> | 
|---|
| 45 |  | 
|---|
| 46 | <A NAME="headers"></A> | 
|---|
| 47 | <H2>Headers</H2> | 
|---|
| 48 |  | 
|---|
| 49 | <DL class="page-index"> | 
|---|
| 50 |   <DT><A CLASS="header" HREF="../../../../boost/iostreams/positioning.hpp"><CODE><boost/iostreams/positioning.hpp></CODE></A></DT> | 
|---|
| 51 | </DL> | 
|---|
| 52 |  | 
|---|
| 53 | <A NAME="reference"></A> | 
|---|
| 54 | <H2>Reference</H2> | 
|---|
| 55 |  | 
|---|
| 56 | <A NAME="synopsis"></A> | 
|---|
| 57 | <H4>Synopsis</H4> | 
|---|
| 58 |  | 
|---|
| 59 | <PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams { | 
|---|
| 60 |  | 
|---|
| 61 | <SPAN CLASS='keyword'>typedef</SPAN> <A CLASS='documented' HREF='../../../integer/cstdint.htm' TARGET='_top'>boost::intmax_t</A> stream_offset; | 
|---|
| 62 | std::streampos <A CLASS='documented' HREF='#offset_to_position'>offset_to_position</A>(stream_offset n); | 
|---|
| 63 | stream_offset <A CLASS='documented' HREF='#position_to_offset'>position_to_offset</A>(std::streampos pos); | 
|---|
| 64 |  | 
|---|
| 65 | } } <SPAN CLASS='comment'>// End namespace boost::io</SPAN></PRE> | 
|---|
| 66 |  | 
|---|
| 67 | <A NAME="offset_to_position"></A> | 
|---|
| 68 | <H4>Function template <CODE>offset_to_position</CODE></H4> | 
|---|
| 69 |  | 
|---|
| 70 | <PRE CLASS="broken_ie">std::streampos offset_to_position(stream_offset n);</PRE> | 
|---|
| 71 |  | 
|---|
| 72 | <P>Returns a <CODE>std::streampos</CODE> representing the <CODE>n</CODE><I>th</I> position in a stream.</P> | 
|---|
| 73 |  | 
|---|
| 74 | <A NAME="position_to_offset"></A> | 
|---|
| 75 | <H4>Function template <CODE>position_to_offset</CODE></H4> | 
|---|
| 76 |  | 
|---|
| 77 | <PRE CLASS="broken_ie">stream_offset position_to_offset(std::streampos pos);</PRE> | 
|---|
| 78 |  | 
|---|
| 79 | <P>Returns a <CODE>stream_offset</CODE> representing the same character position as <CODE>pos</CODE>, disregarding any code-conversion state.</P> | 
|---|
| 80 |  | 
|---|
| 81 | <!-- Begin Footer --> | 
|---|
| 82 |  | 
|---|
| 83 | <HR> | 
|---|
| 84 | <P CLASS="copyright">Revised | 
|---|
| 85 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> | 
|---|
| 86 | 20 May, 2004 | 
|---|
| 87 | <!--webbot bot="Timestamp" endspan i-checksum="38504" --> | 
|---|
| 88 | </P> | 
|---|
| 89 |  | 
|---|
| 90 | <P CLASS="copyright">© Copyright <A HREF="http://www.kangaroologic.com" TARGET="_top">Jonathan Turkanis</A>, 2004</P> | 
|---|
| 91 | <P CLASS="copyright">  | 
|---|
| 92 |     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>) | 
|---|
| 93 | </P> | 
|---|
| 94 |  | 
|---|
| 95 | <!-- End Footer --> | 
|---|
| 96 |  | 
|---|
| 97 | </BODY> | 
|---|