annotate DEPENDENCIES/generic/include/boost/iostreams/positioning.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
Chris@16 2 // (C) Copyright 2003-2007 Jonathan Turkanis
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
Chris@16 5
Chris@16 6 // See http://www.boost.org/libs/iostreams for documentation.
Chris@16 7
Chris@16 8 // Thanks to Gareth Sylvester-Bradley for the Dinkumware versions of the
Chris@16 9 // positioning functions.
Chris@16 10
Chris@16 11 #ifndef BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
Chris@16 12 #define BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@16 15 # pragma once
Chris@16 16 #endif
Chris@16 17
Chris@16 18 #include <boost/config.hpp>
Chris@16 19 #include <boost/cstdint.hpp>
Chris@16 20 #include <boost/integer_traits.hpp>
Chris@16 21 #include <boost/iostreams/detail/config/codecvt.hpp> // mbstate_t.
Chris@16 22 #include <boost/iostreams/detail/config/fpos.hpp>
Chris@16 23 #include <boost/iostreams/detail/ios.hpp> // streamoff, streampos.
Chris@16 24
Chris@16 25 // Must come last.
Chris@16 26 #include <boost/iostreams/detail/config/disable_warnings.hpp>
Chris@16 27
Chris@16 28 #ifdef BOOST_NO_STDC_NAMESPACE
Chris@16 29 namespace std { using ::fpos_t; }
Chris@16 30 #endif
Chris@16 31
Chris@16 32 namespace boost { namespace iostreams {
Chris@16 33
Chris@16 34 //------------------Definition of stream_offset-------------------------------//
Chris@16 35
Chris@16 36 typedef boost::intmax_t stream_offset;
Chris@16 37
Chris@16 38 //------------------Definition of stream_offset_to_streamoff------------------//
Chris@16 39
Chris@16 40 inline std::streamoff stream_offset_to_streamoff(stream_offset off)
Chris@16 41 { return static_cast<stream_offset>(off); }
Chris@16 42
Chris@16 43 //------------------Definition of offset_to_position--------------------------//
Chris@16 44
Chris@16 45 # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
Chris@16 46
Chris@16 47 inline std::streampos offset_to_position(stream_offset off) { return off; }
Chris@16 48
Chris@16 49 # else // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
Chris@16 50
Chris@16 51 inline std::streampos offset_to_position(stream_offset off)
Chris@16 52 { return std::streampos(std::mbstate_t(), off); }
Chris@16 53
Chris@16 54 # endif // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
Chris@16 55
Chris@16 56 //------------------Definition of position_to_offset--------------------------//
Chris@16 57
Chris@16 58 // Hande custom pos_type's
Chris@16 59 template<typename PosType>
Chris@16 60 inline stream_offset position_to_offset(PosType pos)
Chris@16 61 { return std::streamoff(pos); }
Chris@16 62
Chris@16 63 # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
Chris@16 64
Chris@16 65 inline stream_offset position_to_offset(std::streampos pos) { return pos; }
Chris@16 66
Chris@16 67 # else // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
Chris@16 68
Chris@16 69 // In the Dinkumware standard library, a std::streampos consists of two stream
Chris@16 70 // offsets -- _Fpos, of type std::fpos_t, and _Myoff, of type std::streamoff --
Chris@16 71 // together with a conversion state. A std::streampos is converted to a
Chris@16 72 // boost::iostreams::stream_offset by extracting the two stream offsets and
Chris@16 73 // summing them. The value of _Fpos can be extracted using the implementation-
Chris@16 74 // defined member functions seekpos() or get_fpos_t(), depending on the
Chris@16 75 // Dinkumware version. The value of _Myoff cannot be extracted directly, but can
Chris@16 76 // be calculated as the difference between the result of converting the
Chris@16 77 // std::fpos to a std::streamoff and the result of converting the member _Fpos
Chris@16 78 // to a long. The latter operation is accomplished with the macro _FPOSOFF,
Chris@16 79 // which works correctly on platforms where std::fpos_t is an integral type and
Chris@16 80 // platforms where it is a struct
Chris@16 81
Chris@16 82 // Converts a std::fpos_t to a stream_offset
Chris@16 83 inline stream_offset fpos_t_to_offset(std::fpos_t pos)
Chris@16 84 {
Chris@16 85 # if defined(_POSIX_) || (_INTEGRAL_MAX_BITS >= 64) || defined(__IBMCPP__)
Chris@16 86 return pos;
Chris@16 87 # else
Chris@16 88 return _FPOSOFF(pos);
Chris@16 89 # endif
Chris@16 90 }
Chris@16 91
Chris@16 92 // Extracts the member _Fpos from a std::fpos
Chris@16 93 inline std::fpos_t streampos_to_fpos_t(std::streampos pos)
Chris@16 94 {
Chris@16 95 # if defined (_CPPLIB_VER) || defined(__IBMCPP__)
Chris@16 96 return pos.seekpos();
Chris@16 97 # else
Chris@16 98 return pos.get_fpos_t();
Chris@16 99 # endif
Chris@16 100 }
Chris@16 101
Chris@16 102 inline stream_offset position_to_offset(std::streampos pos)
Chris@16 103 {
Chris@16 104 return fpos_t_to_offset(streampos_to_fpos_t(pos)) +
Chris@16 105 static_cast<stream_offset>(
Chris@16 106 static_cast<std::streamoff>(pos) -
Chris@16 107 _FPOSOFF(streampos_to_fpos_t(pos))
Chris@16 108 );
Chris@16 109 }
Chris@16 110
Chris@16 111 # endif // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
Chris@16 112
Chris@16 113 } } // End namespaces iostreams, boost.
Chris@16 114
Chris@16 115 #include <boost/iostreams/detail/config/enable_warnings.hpp>
Chris@16 116
Chris@16 117 #endif // #ifndef BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED