|
Boost-Commit : |
From: technews_at_[hidden]
Date: 2008-01-07 22:49:24
Author: turkanis
Date: 2008-01-07 22:49:23 EST (Mon, 07 Jan 2008)
New Revision: 42600
URL: http://svn.boost.org/trac/boost/changeset/42600
Log:
merged changes from branches/iostreams_dev revisions 42595-42599; applied Dinkumware implementation of positioning functions to IBM Visual Age; simplified and corrected implementation
Added:
trunk/boost/iostreams/detail/config/fpos.hpp
- copied unchanged from r42599, /branches/iostreams_dev/boost/iostreams/detail/config/fpos.hpp
Text files modified:
trunk/boost/iostreams/positioning.hpp | 83 +++++++++++++++++++--------------------
1 files changed, 40 insertions(+), 43 deletions(-)
Modified: trunk/boost/iostreams/positioning.hpp
==============================================================================
--- trunk/boost/iostreams/positioning.hpp (original)
+++ trunk/boost/iostreams/positioning.hpp 2008-01-07 22:49:23 EST (Mon, 07 Jan 2008)
@@ -18,6 +18,7 @@
#include <boost/cstdint.hpp>
#include <boost/integer_traits.hpp>
#include <boost/iostreams/detail/config/codecvt.hpp> // mbstate_t.
+#include <boost/iostreams/detail/config/fpos.hpp>
#include <boost/iostreams/detail/ios.hpp> // streamoff, streampos.
// Must come last.
@@ -28,74 +29,70 @@
#endif
namespace boost { namespace iostreams {
+
+//------------------Definition of stream_offset-------------------------------//
typedef boost::intmax_t stream_offset;
+//------------------Definition of stream_offset_to_streamoff------------------//
+
inline std::streamoff stream_offset_to_streamoff(stream_offset off)
{ return static_cast<stream_offset>(off); }
-template<typename PosType> // Hande custom pos_type's.
+//------------------Definition of offset_to_position--------------------------//
+
+# ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
+
+inline std::streampos offset_to_position(stream_offset off) { return off; }
+
+# else // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
+
+inline std::streampos offset_to_position(stream_offset off)
+{ return std::streampos(std::mbstate_t(), off); }
+
+# endif // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
+
+//------------------Definition of position_to_offset--------------------------//
+
+// Hande custom pos_type's
+template<typename PosType>
inline stream_offset position_to_offset(PosType pos)
{ return std::streamoff(pos); }
-#if ((defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)) && \
- !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) \
- && !defined(__QNX__) \
- /**/
+# ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
- /* Dinkumware */
+inline stream_offset position_to_offset(std::streampos pos) { return pos; }
-inline std::streampos offset_to_position(stream_offset off)
-{
- // Use implementation-specific constructor.
- return std::streampos(std::mbstate_t(), off);
-}
+# else // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
+// Helper function
inline stream_offset fpos_t_to_offset(std::fpos_t pos)
-{ // Helper function.
-#if defined(_POSIX_) || (_INTEGRAL_MAX_BITS >= 64)
+{
+# if defined(_POSIX_) || (_INTEGRAL_MAX_BITS >= 64)
return pos;
-#else
+# else
return _FPOSOFF(pos);
-#endif
+# endif
}
-# if defined(_CPPLIB_VER) //--------------------------------------------------//
-
- /* Recent Dinkumware */
-
-inline stream_offset position_to_offset(std::streampos pos)
+// Helper function
+inline std::fpos_t streampos_to_fpos_t(std::streampos pos)
{
- // Use implementation-specific member function seekpos().
- return fpos_t_to_offset(pos.seekpos()) +
- static_cast<stream_offset>(static_cast<std::streamoff>(pos)) -
- static_cast<stream_offset>(_FPOSOFF(pos.seekpos()));
+# ifdef _CPPLIB_VER
+ return pos.seekpos();
+# else
+ return pos.get_fpos_t();
+# endif
}
-# else // # if defined(_CPPLIB_VER) //----------------------------------------//
-
- /* Old Dinkumware */
-
inline stream_offset position_to_offset(std::streampos pos)
{
- // use implementation-specific member function get_fpos_t().
- return fpos_t_to_offset(pos.get_fpos_t()) +
+ return fpos_t_to_offset(streampos_to_fpos_t(pos)) +
static_cast<stream_offset>(static_cast<std::streamoff>(pos)) -
- static_cast<stream_offset>(
- static_cast<std::streamoff>(pos.get_fpos_t())
- );
+ static_cast<stream_offset>(_FPOSOFF(streampos_to_fpos_t(pos)));
}
-# endif // # if defined(_CPPLIB_VER) //---------------------------------------//
-#else // Dinkumware //--------------------------------------------------------//
-
- /* Non-Dinkumware */
-
-inline std::streampos offset_to_position(stream_offset off) { return off; }
-
-inline stream_offset position_to_offset(std::streampos pos) { return pos; }
-
-#endif // Dinkumware //-------------------------------------------------------//
+# endif // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
} } // End namespaces iostreams, boost.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk