File indexing completed on 2025-01-18 09:38:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
0012 #define BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
0013
0014 #if defined(_MSC_VER)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/config.hpp>
0019 #include <boost/cstdint.hpp>
0020 #include <boost/integer_traits.hpp>
0021 #include <boost/iostreams/detail/config/codecvt.hpp> // mbstate_t.
0022 #include <boost/iostreams/detail/config/fpos.hpp>
0023 #include <boost/iostreams/detail/ios.hpp> // streamoff, streampos.
0024
0025
0026 #include <boost/iostreams/detail/config/disable_warnings.hpp>
0027
0028 #ifdef BOOST_NO_STDC_NAMESPACE
0029 namespace std { using ::fpos_t; }
0030 #endif
0031
0032 namespace boost { namespace iostreams {
0033
0034
0035
0036 typedef boost::intmax_t stream_offset;
0037
0038
0039
0040 inline std::streamoff stream_offset_to_streamoff(stream_offset off)
0041 { return static_cast<stream_offset>(off); }
0042
0043
0044
0045 # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
0046
0047 inline std::streampos offset_to_position(stream_offset off) { return off; }
0048
0049 # else
0050
0051 inline std::streampos offset_to_position(stream_offset off)
0052 { return std::streampos(std::mbstate_t(), off); }
0053
0054 # endif
0055
0056
0057
0058
0059 template<typename PosType>
0060 inline stream_offset position_to_offset(PosType pos)
0061 { return std::streamoff(pos); }
0062
0063 # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
0064
0065 inline stream_offset position_to_offset(std::streampos pos) { return pos; }
0066
0067 # else
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 inline stream_offset fpos_t_to_offset(std::fpos_t pos)
0084 {
0085 # if defined(_POSIX_) || (_INTEGRAL_MAX_BITS >= 64) || defined(__IBMCPP__)
0086 return pos;
0087 # else
0088 return BOOST_IOSTREAMS_FPOSOFF(pos);
0089 # endif
0090 }
0091
0092
0093 inline std::fpos_t streampos_to_fpos_t(std::streampos pos)
0094 {
0095 # if defined (_CPPLIB_VER) || defined(__IBMCPP__)
0096 return pos.seekpos();
0097 # else
0098 return pos.get_fpos_t();
0099 # endif
0100 }
0101
0102 inline stream_offset position_to_offset(std::streampos pos)
0103 {
0104 return fpos_t_to_offset(streampos_to_fpos_t(pos)) +
0105 static_cast<stream_offset>(
0106 static_cast<std::streamoff>(pos) -
0107 BOOST_IOSTREAMS_FPOSOFF(streampos_to_fpos_t(pos))
0108 );
0109 }
0110
0111 # endif
0112
0113 } }
0114
0115 #include <boost/iostreams/detail/config/enable_warnings.hpp>
0116
0117 #endif