00001 // 00002 // completion_condition.hpp 00003 // ~~~~~~~~~~~~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com) 00006 // 00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 00011 #ifndef ASIO_COMPLETION_CONDITION_HPP 00012 #define ASIO_COMPLETION_CONDITION_HPP 00013 00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 00015 # pragma once 00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 00017 00018 #include "asio/detail/push_options.hpp" 00019 00020 #include "asio/detail/push_options.hpp" 00021 #include <cstddef> 00022 #include <boost/config.hpp> 00023 #include "asio/detail/pop_options.hpp" 00024 00025 namespace asio { 00026 00027 namespace detail { 00028 00029 class transfer_all_t 00030 { 00031 public: 00032 typedef bool result_type; 00033 00034 template <typename Error> 00035 bool operator()(const Error& err, std::size_t) 00036 { 00037 return !!err; 00038 } 00039 }; 00040 00041 class transfer_at_least_t 00042 { 00043 public: 00044 typedef bool result_type; 00045 00046 explicit transfer_at_least_t(std::size_t minimum) 00047 : minimum_(minimum) 00048 { 00049 } 00050 00051 template <typename Error> 00052 bool operator()(const Error& err, std::size_t bytes_transferred) 00053 { 00054 return !!err || bytes_transferred >= minimum_; 00055 } 00056 00057 private: 00058 std::size_t minimum_; 00059 }; 00060 00061 } // namespace detail 00062 00070 00074 #if defined(GENERATING_DOCUMENTATION) 00075 unspecified transfer_all(); 00076 #else 00077 inline detail::transfer_all_t transfer_all() 00078 { 00079 return detail::transfer_all_t(); 00080 } 00081 #endif 00082 00086 #if defined(GENERATING_DOCUMENTATION) 00087 unspecified transfer_at_least(std::size_t minimum); 00088 #else 00089 inline detail::transfer_at_least_t transfer_at_least(std::size_t minimum) 00090 { 00091 return detail::transfer_at_least_t(minimum); 00092 } 00093 #endif 00094 00097 } // namespace asio 00098 00099 #include "asio/detail/pop_options.hpp" 00100 00101 #endif // ASIO_COMPLETION_CONDITION_HPP
1.5.6