Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2008-01-07 22:33:09


Author: turkanis
Date: 2008-01-07 22:33:08 EST (Mon, 07 Jan 2008)
New Revision: 42599
URL: http://svn.boost.org/trac/boost/changeset/42599

Log:
factored Dinkumware detection out of positioning.hpp; unified (and corrected) the treatment of old and new Dinkumare; positioning.hpp to make it more intelligible
Added:
   branches/iostreams_dev/boost/iostreams/detail/config/fpos.hpp (contents, props changed)
Text files modified:
   branches/iostreams_dev/boost/iostreams/positioning.hpp | 83 +++++++++++++++++++--------------------
   1 files changed, 40 insertions(+), 43 deletions(-)

Added: branches/iostreams_dev/boost/iostreams/detail/config/fpos.hpp
==============================================================================
--- (empty file)
+++ branches/iostreams_dev/boost/iostreams/detail/config/fpos.hpp 2008-01-07 22:33:08 EST (Mon, 07 Jan 2008)
@@ -0,0 +1,30 @@
+/*
+ * Distributed under the Boost Software License, Version 1.0.(See accompanying
+ * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+ *
+ * See http://www.boost.org/libs/iostreams for documentation.
+
+ * File: boost/iostreams/detail/execute.hpp
+ * Date: Thu Dec 06 13:21:54 MST 2007
+ * Copyright: 2007 CodeRage
+ * Author: Jonathan Turkanis
+ *
+ * Defines the preprocessor symbol BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS for
+ * platforms that use the implementation of std::fpos from the Dinkumware
+ * Standard Library.
+ */
+
+#ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED
+#define BOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+# if (defined(_YVALS) || defined(_CPPLIB_VER)) && !defined(__SGI_STL_PORT) && \
+ !defined(_STLPORT_VERSION) && !defined(__QNX__)
+ /**/
+# define BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
+# endif
+
+#endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED

Modified: branches/iostreams_dev/boost/iostreams/positioning.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/positioning.hpp (original)
+++ branches/iostreams_dev/boost/iostreams/positioning.hpp 2008-01-07 22:33:08 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(_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