BVB Source Codes

mars Show flush.hpp Source code

Return Download mars: download flush.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. #ifndef BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED
  9. #define BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED
  10.  
  11. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  12. # pragma once
  13. #endif
  14.  
  15. #include <boost/config.hpp>  // DEDUCED_TYPENAME, MSVC.
  16. #include <boost/detail/workaround.hpp>
  17. #include <boost/iostreams/detail/dispatch.hpp>
  18. #include <boost/iostreams/detail/streambuf.hpp>
  19. #include <boost/iostreams/detail/wrap_unwrap.hpp>
  20. #include <boost/iostreams/operations_fwd.hpp>
  21. #include <boost/iostreams/traits.hpp>
  22. #include <boost/mpl/if.hpp>
  23.  
  24. // Must come last.
  25. #include <boost/iostreams/detail/config/disable_warnings.hpp>
  26.  
  27. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace iostreams {
  28.  
  29. namespace detail {
  30.  
  31. template<typename T>
  32. struct flush_device_impl;
  33.  
  34. template<typename T>
  35. struct flush_filter_impl;
  36.  
  37. } // End namespace detail.
  38.  
  39. template<typename T>
  40. bool flush(T& t)
  41. { return detail::flush_device_impl<T>::flush(detail::unwrap(t)); }
  42.  
  43. template<typename T, typename Sink>
  44. bool flush(T& t, Sink& snk)
  45. { return detail::flush_filter_impl<T>::flush(detail::unwrap(t), snk); }
  46.  
  47. namespace detail {
  48.  
  49. //------------------Definition of flush_device_impl---------------------------//
  50.  
  51. template<typename T>
  52. struct flush_device_impl
  53.     : mpl::if_<
  54.           is_custom<T>,
  55.           operations<T>,
  56.           flush_device_impl<
  57.               BOOST_DEDUCED_TYPENAME
  58.               dispatch<
  59.                   T, ostream_tag, streambuf_tag, flushable_tag, any_tag
  60.               >::type
  61.           >
  62.       >::type
  63.     { };
  64.  
  65. template<>
  66. struct flush_device_impl<ostream_tag> {
  67.     template<typename T>
  68.     static bool flush(T& t)
  69.     { return t.rdbuf()->BOOST_IOSTREAMS_PUBSYNC() == 0; }
  70. };
  71.  
  72. template<>
  73. struct flush_device_impl<streambuf_tag> {
  74.     template<typename T>
  75.     static bool flush(T& t)
  76.     { return t.BOOST_IOSTREAMS_PUBSYNC() == 0; }
  77. };
  78.  
  79. template<>
  80. struct flush_device_impl<flushable_tag> {
  81.     template<typename T>
  82.     static bool flush(T& t) { return t.flush(); }
  83. };
  84.  
  85. template<>
  86. struct flush_device_impl<any_tag> {
  87.     template<typename T>
  88.     static bool flush(T&) { return true; }
  89. };
  90.  
  91. //------------------Definition of flush_filter_impl---------------------------//
  92.  
  93. template<typename T>
  94. struct flush_filter_impl
  95.     : mpl::if_<
  96.           is_custom<T>,
  97.           operations<T>,
  98.           flush_filter_impl<
  99.               BOOST_DEDUCED_TYPENAME
  100.               dispatch<
  101.                   T, flushable_tag, any_tag
  102.               >::type
  103.           >
  104.       >::type
  105.     { };
  106.  
  107. template<>
  108. struct flush_filter_impl<flushable_tag> {
  109.     template<typename T, typename Sink>
  110.     static bool flush(T& t, Sink& snk) { return t.flush(snk); }
  111. };
  112.  
  113. template<>
  114. struct flush_filter_impl<any_tag> {
  115.     template<typename T, typename Sink>
  116.     static bool flush(T&, Sink&) { return false; }
  117. };
  118.  
  119. } // End namespace detail.
  120.  
  121. } } // End namespaces iostreams, boost.
  122.  
  123. #include <boost/iostreams/detail/config/enable_warnings.hpp>
  124.  
  125. #endif // #ifndef BOOST_IOSTREAMS_FLUSH_HPP_INCLUDED
  126.  
downloadflush.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