1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/iostreams/positioning.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,102 @@
1.4 +// (C) Copyright Jonathan Turkanis 2003.
1.5 +// Distributed under the Boost Software License, Version 1.0. (See accompanying
1.6 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
1.7 +
1.8 +// See http://www.boost.org/libs/iostreams for documentation.
1.9 +
1.10 +// Thanks to Gareth Sylvester-Bradley for the Dinkumware versions of the
1.11 +// positioning functions.
1.12 +
1.13 +#ifndef BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
1.14 +#define BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
1.15 +
1.16 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
1.17 +# pragma once
1.18 +#endif
1.19 +
1.20 +#include <boost/config.hpp>
1.21 +#include <boost/cstdint.hpp>
1.22 +#include <boost/integer_traits.hpp>
1.23 +#include <boost/iostreams/detail/config/codecvt.hpp> // mbstate_t.
1.24 +#include <boost/iostreams/detail/ios.hpp> // streamoff, streampos.
1.25 +
1.26 +// Must come last.
1.27 +#include <boost/iostreams/detail/config/disable_warnings.hpp>
1.28 +
1.29 +#ifdef BOOST_NO_STDC_NAMESPACE
1.30 +namespace std { using ::fpos_t; }
1.31 +#endif
1.32 +
1.33 +namespace boost { namespace iostreams {
1.34 +
1.35 +typedef boost::intmax_t stream_offset;
1.36 +
1.37 +inline std::streamoff stream_offset_to_streamoff(stream_offset off)
1.38 +{ return static_cast<stream_offset>(off); }
1.39 +
1.40 +template<typename PosType> // Hande custom pos_type's.
1.41 +inline stream_offset position_to_offset(PosType pos)
1.42 +{ return std::streamoff(pos); }
1.43 +
1.44 +#if ((defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)) && \
1.45 + !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) \
1.46 + && !defined(__QNX__) \
1.47 + /**/
1.48 +
1.49 + /* Dinkumware */
1.50 +
1.51 +inline std::streampos offset_to_position(stream_offset off)
1.52 +{
1.53 + // Use implementation-specific constructor.
1.54 + return std::streampos(std::mbstate_t(), off);
1.55 +}
1.56 +
1.57 +inline stream_offset fpos_t_to_offset(std::fpos_t pos)
1.58 +{ // Helper function.
1.59 +#if defined(_POSIX_) || (_INTEGRAL_MAX_BITS >= 64)
1.60 + return pos;
1.61 +#else
1.62 + return _FPOSOFF(pos);
1.63 +#endif
1.64 +}
1.65 +
1.66 +# if defined(_CPPLIB_VER) //--------------------------------------------------//
1.67 +
1.68 + /* Recent Dinkumware */
1.69 +
1.70 +inline stream_offset position_to_offset(std::streampos pos)
1.71 +{
1.72 + // Use implementation-specific member function seekpos().
1.73 + return fpos_t_to_offset(pos.seekpos()) +
1.74 + stream_offset(std::streamoff(pos)) -
1.75 + stream_offset(std::streamoff(pos.seekpos()));
1.76 +}
1.77 +
1.78 +# else // # if defined(_CPPLIB_VER) //----------------------------------------//
1.79 +
1.80 + /* Old Dinkumware */
1.81 +
1.82 +inline stream_offset position_to_offset(std::streampos pos)
1.83 +{
1.84 + // use implementation-specific member function get_fpos_t().
1.85 + return fpos_t_to_offset(pos.get_fpos_t()) +
1.86 + stream_offset(std::streamoff(pos)) -
1.87 + stream_offset(std::streamoff(pos.get_fpos_t()));
1.88 +}
1.89 +
1.90 +# endif // # if defined(_CPPLIB_VER) //---------------------------------------//
1.91 +#else // Dinkumware //--------------------------------------------------------//
1.92 +
1.93 + /* Non-Dinkumware */
1.94 +
1.95 +inline std::streampos offset_to_position(stream_offset off) { return off; }
1.96 +
1.97 +inline stream_offset position_to_offset(std::streampos pos) { return pos; }
1.98 +
1.99 +#endif // Dinkumware //-------------------------------------------------------//
1.100 +
1.101 +} } // End namespaces iostreams, boost.
1.102 +
1.103 +#include <boost/iostreams/detail/config/enable_warnings.hpp>
1.104 +
1.105 +#endif // #ifndef BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED