BVB Source Codes

mars Show positioning.hpp Source code

Return Download mars: download positioning.hpp Source code - Download mars Source code - Type:.hpp
  1. // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
  2. // (C) Copyright 2003-2007 Jonathan Turkanis
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
  5.  
  6. // See http://www.boost.org/libs/iostreams for documentation.
  7.  
  8. // Thanks to Gareth Sylvester-Bradley for the Dinkumware versions of the
  9. // positioning functions.
  10.  
  11. #ifndef BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
  12. #define BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
  13.  
  14. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  15. # pragma once
  16. #endif
  17.  
  18. #include <boost/config.hpp>
  19. #include <boost/cstdint.hpp>
  20. #include <boost/integer_traits.hpp>
  21. #include <boost/iostreams/detail/config/codecvt.hpp> // mbstate_t.
  22. #include <boost/iostreams/detail/config/fpos.hpp>
  23. #include <boost/iostreams/detail/ios.hpp> // streamoff, streampos.
  24.  
  25. // Must come last.
  26. #include <boost/iostreams/detail/config/disable_warnings.hpp>
  27.  
  28. #ifdef BOOST_NO_STDC_NAMESPACE
  29. namespace std { using ::fpos_t; }
  30. #endif
  31.  
  32. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace iostreams {
  33.                    
  34. //------------------Definition of stream_offset-------------------------------//
  35.  
  36. typedef mars_boost::intmax_t stream_offset;
  37.  
  38. //------------------Definition of stream_offset_to_streamoff------------------//
  39.  
  40. inline std::streamoff stream_offset_to_streamoff(stream_offset off)
  41. { return static_cast<stream_offset>(off); }
  42.  
  43. //------------------Definition of offset_to_position--------------------------//
  44.  
  45. # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
  46.  
  47. inline std::streampos offset_to_position(stream_offset off) { return off; }
  48.  
  49. # else // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
  50.  
  51. inline std::streampos offset_to_position(stream_offset off)
  52. { return std::streampos(std::mbstate_t(), off); }
  53.  
  54. # endif // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
  55.  
  56. //------------------Definition of position_to_offset--------------------------//
  57.  
  58. // Hande custom pos_type's
  59. template<typename PosType>
  60. inline stream_offset position_to_offset(PosType pos)
  61. { return std::streamoff(pos); }
  62.  
  63. # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
  64.  
  65. inline stream_offset position_to_offset(std::streampos pos) { return pos; }
  66.  
  67. # else // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
  68.  
  69. // In the Dinkumware standard library, a std::streampos consists of two stream
  70. // offsets -- _Fpos, of type std::fpos_t, and _Myoff, of type std::streamoff --
  71. // together with a conversion state. A std::streampos is converted to a
  72. // mars_boost::iostreams::stream_offset by extracting the two stream offsets and
  73. // summing them. The value of _Fpos can be extracted using the implementation-
  74. // defined member functions seekpos() or get_fpos_t(), depending on the
  75. // Dinkumware version. The value of _Myoff cannot be extracted directly, but can
  76. // be calculated as the difference between the result of converting the
  77. // std::fpos to a std::streamoff and the result of converting the member _Fpos
  78. // to a long. The latter operation is accomplished with the macro _FPOSOFF,
  79. // which works correctly on platforms where std::fpos_t is an integral type and
  80. // platforms where it is a struct
  81.  
  82. // Converts a std::fpos_t to a stream_offset
  83. inline stream_offset fpos_t_to_offset(std::fpos_t pos)
  84. {
  85. #  if defined(_POSIX_) || (_INTEGRAL_MAX_BITS >= 64) || defined(__IBMCPP__)
  86.     return pos;
  87. #  else
  88.     return _FPOSOFF(pos);
  89. #  endif
  90. }
  91.  
  92. // Extracts the member _Fpos from a std::fpos
  93. inline std::fpos_t streampos_to_fpos_t(std::streampos pos)
  94. {
  95. #  if defined (_CPPLIB_VER) || defined(__IBMCPP__)
  96.     return pos.seekpos();
  97. #  else
  98.     return pos.get_fpos_t();
  99. #  endif
  100. }
  101.  
  102. inline stream_offset position_to_offset(std::streampos pos)
  103. {
  104.     return fpos_t_to_offset(streampos_to_fpos_t(pos)) +
  105.         static_cast<stream_offset>(
  106.             static_cast<std::streamoff>(pos) -
  107.             _FPOSOFF(streampos_to_fpos_t(pos))
  108.         );
  109. }
  110.  
  111. # endif // # ifndef BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS
  112.  
  113. } } // End namespaces iostreams, boost.
  114.  
  115. #include <boost/iostreams/detail/config/enable_warnings.hpp>
  116.  
  117. #endif // #ifndef BOOST_IOSTREAMS_POSITIONING_HPP_INCLUDED
  118.  
downloadpositioning.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top