$search
00001 // 00002 // read_until.hpp 00003 // ~~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2008 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_READ_UNTIL_HPP 00012 #define ASIO_READ_UNTIL_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 <boost/regex.hpp> 00024 #include <boost/type_traits/is_function.hpp> 00025 #include <boost/type_traits/remove_pointer.hpp> 00026 #include <boost/utility/enable_if.hpp> 00027 #include <string> 00028 #include "asio/detail/pop_options.hpp" 00029 00030 #include "asio/basic_streambuf.hpp" 00031 #include "asio/error.hpp" 00032 00033 namespace asio { 00034 00035 namespace detail 00036 { 00037 template <typename T> 00038 struct has_result_type 00039 { 00040 struct big { char a[100]; }; 00041 template <typename U> static big helper(U, ...); 00042 template <typename U> static char helper(U, typename U::result_type* = 0); 00043 static const T& ref(); 00044 enum { value = (sizeof((helper)((ref)())) == 1) }; 00045 }; 00046 } // namespace detail 00047 00050 template <typename T> 00051 struct is_match_condition 00052 { 00053 #if defined(GENERATING_DOCUMENTATION) 00054 00055 static const bool value; 00056 #else 00057 enum 00058 { 00059 value = boost::is_function<typename boost::remove_pointer<T>::type>::value 00060 || detail::has_result_type<T>::value 00061 }; 00062 #endif 00063 }; 00064 00072 00074 00111 template <typename SyncReadStream, typename Allocator> 00112 std::size_t read_until(SyncReadStream& s, 00113 asio::basic_streambuf<Allocator>& b, char delim); 00114 00116 00145 template <typename SyncReadStream, typename Allocator> 00146 std::size_t read_until(SyncReadStream& s, 00147 asio::basic_streambuf<Allocator>& b, char delim, 00148 asio::error_code& ec); 00149 00151 00188 template <typename SyncReadStream, typename Allocator> 00189 std::size_t read_until(SyncReadStream& s, 00190 asio::basic_streambuf<Allocator>& b, const std::string& delim); 00191 00193 00222 template <typename SyncReadStream, typename Allocator> 00223 std::size_t read_until(SyncReadStream& s, 00224 asio::basic_streambuf<Allocator>& b, const std::string& delim, 00225 asio::error_code& ec); 00226 00229 00267 template <typename SyncReadStream, typename Allocator> 00268 std::size_t read_until(SyncReadStream& s, 00269 asio::basic_streambuf<Allocator>& b, const boost::regex& expr); 00270 00273 00304 template <typename SyncReadStream, typename Allocator> 00305 std::size_t read_until(SyncReadStream& s, 00306 asio::basic_streambuf<Allocator>& b, const boost::regex& expr, 00307 asio::error_code& ec); 00308 00310 00408 template <typename SyncReadStream, typename Allocator, typename MatchCondition> 00409 std::size_t read_until(SyncReadStream& s, 00410 asio::basic_streambuf<Allocator>& b, MatchCondition match_condition, 00411 typename boost::enable_if<is_match_condition<MatchCondition> >::type* = 0); 00412 00414 00463 template <typename SyncReadStream, typename Allocator, typename MatchCondition> 00464 std::size_t read_until(SyncReadStream& s, 00465 asio::basic_streambuf<Allocator>& b, 00466 MatchCondition match_condition, asio::error_code& ec, 00467 typename boost::enable_if<is_match_condition<MatchCondition> >::type* = 0); 00468 00478 00481 00543 template <typename AsyncReadStream, typename Allocator, typename ReadHandler> 00544 void async_read_until(AsyncReadStream& s, 00545 asio::basic_streambuf<Allocator>& b, 00546 char delim, ReadHandler handler); 00547 00550 00612 template <typename AsyncReadStream, typename Allocator, typename ReadHandler> 00613 void async_read_until(AsyncReadStream& s, 00614 asio::basic_streambuf<Allocator>& b, const std::string& delim, 00615 ReadHandler handler); 00616 00619 00684 template <typename AsyncReadStream, typename Allocator, typename ReadHandler> 00685 void async_read_until(AsyncReadStream& s, 00686 asio::basic_streambuf<Allocator>& b, const boost::regex& expr, 00687 ReadHandler handler); 00688 00691 00808 template <typename AsyncReadStream, typename Allocator, 00809 typename MatchCondition, typename ReadHandler> 00810 void async_read_until(AsyncReadStream& s, 00811 asio::basic_streambuf<Allocator>& b, 00812 MatchCondition match_condition, ReadHandler handler, 00813 typename boost::enable_if<is_match_condition<MatchCondition> >::type* = 0); 00814 00817 } // namespace asio 00818 00819 #include "asio/impl/read_until.ipp" 00820 00821 #include "asio/detail/pop_options.hpp" 00822 00823 #endif // ASIO_READ_UNTIL_HPP