From 491ddd570a752cf9bda85933bed0c6942e39b1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 23 Dec 2012 14:16:26 +0100 Subject: Update Boost to 1.52.0. Change-Id: I1e56bea2600bf2ed9c5b3aba8c4f9d2a0f350e77 diff --git a/3rdParty/Boost/01_fix_return_type_warning.diff b/3rdParty/Boost/01_fix_return_type_warning.diff new file mode 100644 index 0000000..3f1fe83 --- /dev/null +++ b/3rdParty/Boost/01_fix_return_type_warning.diff @@ -0,0 +1,13 @@ +diff --git a/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp b/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp +index 4321a26..c83eac1 100644 +--- a/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp ++++ b/3rdParty/Boost/src/libs/thread/src/pthread/thread.cpp +@@ -27,6 +27,8 @@ + + #include "./timeconv.inl" + ++#pragma GCC diagnostic ignored "-Wreturn-type" ++ + namespace boost + { + namespace detail diff --git a/3rdParty/Boost/SConscript b/3rdParty/Boost/SConscript index f0d438b..6578736 100644 --- a/3rdParty/Boost/SConscript +++ b/3rdParty/Boost/SConscript @@ -65,17 +65,14 @@ elif env.get("BOOST_BUNDLED", False) : "src/libs/signals/src/signal_base.cpp", "src/libs/signals/src/slot.cpp", "src/libs/signals/src/trackable.cpp", - "src/libs/filesystem/v3/src/codecvt_error_category.cpp", - "src/libs/filesystem/v3/src/operations.cpp", - "src/libs/filesystem/v3/src/path.cpp", - "src/libs/filesystem/v3/src/path_traits.cpp", - "src/libs/filesystem/v3/src/portability.cpp", - "src/libs/filesystem/v3/src/unique_path.cpp", - "src/libs/filesystem/v3/src/windows_file_codecvt.cpp", -# "src/libs/filesystem/v2/src/v2_operations.cpp", -# "src/libs/filesystem/v2/src/v2_path.cpp", -# "src/libs/filesystem/v2/src/v2_portability.cpp", - "src/libs/filesystem/v3/src/filesystem_utf8_codecvt_facet.cpp", + "src/libs/filesystem/src/codecvt_error_category.cpp", + "src/libs/filesystem/src/operations.cpp", + "src/libs/filesystem/src/path.cpp", + "src/libs/filesystem/src/path_traits.cpp", + "src/libs/filesystem/src/portability.cpp", + "src/libs/filesystem/src/unique_path.cpp", + "src/libs/filesystem/src/windows_file_codecvt.cpp", + "src/libs/filesystem/src/filesystem_utf8_codecvt_facet.cpp", "src/libs/regex/src/c_regex_traits.cpp", "src/libs/regex/src/cpp_regex_traits.cpp", "src/libs/regex/src/cregex.cpp", diff --git a/3rdParty/Boost/src/boost/algorithm/string/detail/case_conv.hpp b/3rdParty/Boost/src/boost/algorithm/string/detail/case_conv.hpp index 5b0064f..42621c7 100644 --- a/3rdParty/Boost/src/boost/algorithm/string/detail/case_conv.hpp +++ b/3rdParty/Boost/src/boost/algorithm/string/detail/case_conv.hpp @@ -15,6 +15,8 @@ #include #include +#include + namespace boost { namespace algorithm { namespace detail { @@ -37,7 +39,7 @@ namespace boost { CharT operator ()( CharT Ch ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::tolower( Ch); + return std::tolower( static_cast::type> ( Ch )); #else return std::tolower( Ch, *m_Loc ); #endif @@ -57,7 +59,7 @@ namespace boost { CharT operator ()( CharT Ch ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) - return std::toupper( Ch); + return std::toupper( static_cast::type> ( Ch )); #else return std::toupper( Ch, *m_Loc ); #endif diff --git a/3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp b/3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp index fb43955..704d9d2 100644 --- a/3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp +++ b/3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp @@ -126,7 +126,7 @@ namespace boost { } // Use fixed storage - ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); + ::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); } // Destructor @@ -206,7 +206,7 @@ namespace boost { } // Copy the data - ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); + ::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size); return *this; } diff --git a/3rdParty/Boost/src/boost/algorithm/string/detail/formatter.hpp b/3rdParty/Boost/src/boost/algorithm/string/detail/formatter.hpp index bd6a780..8e7b727 100644 --- a/3rdParty/Boost/src/boost/algorithm/string/detail/formatter.hpp +++ b/3rdParty/Boost/src/boost/algorithm/string/detail/formatter.hpp @@ -87,6 +87,31 @@ namespace boost { } }; +// dissect format functor ----------------------------------------------------// + + // dissect format functor + template + struct dissect_formatF + { + public: + // Construction + dissect_formatF(FinderT Finder) : + m_Finder(Finder) {} + + // Operation + template + inline iterator_range< + BOOST_STRING_TYPENAME range_const_iterator::type> + operator()(const RangeT& Replace) const + { + return m_Finder(::boost::begin(Replace), ::boost::end(Replace)); + } + + private: + FinderT m_Finder; + }; + + } // namespace detail } // namespace algorithm } // namespace boost diff --git a/3rdParty/Boost/src/boost/algorithm/string/find.hpp b/3rdParty/Boost/src/boost/algorithm/string/find.hpp index 304646d..cc99ca1 100644 --- a/3rdParty/Boost/src/boost/algorithm/string/find.hpp +++ b/3rdParty/Boost/src/boost/algorithm/string/find.hpp @@ -228,13 +228,13 @@ namespace boost { //! Find head algorithm /*! Get the head of the input. Head is a prefix of the string of the - given size. If the input is shorter then required, whole input if considered + given size. If the input is shorter then required, whole input is considered to be the head. \param Input An input string \param N Length of the head For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. + For N<0, at most size(Input)-|N| characters are extracted. \return An \c iterator_range delimiting the match. Returned iterator is either \c Range1T::iterator or @@ -258,13 +258,13 @@ namespace boost { //! Find tail algorithm /*! Get the tail of the input. Tail is a suffix of the string of the - given size. If the input is shorter then required, whole input if considered + given size. If the input is shorter then required, whole input is considered to be the tail. \param Input An input string \param N Length of the tail. For N>=0, at most N characters are extracted. - For N<0, size(Input)-|N| characters are extracted. + For N<0, at most size(Input)-|N| characters are extracted. \return An \c iterator_range delimiting the match. Returned iterator is either \c RangeT::iterator or diff --git a/3rdParty/Boost/src/boost/algorithm/string/formatter.hpp b/3rdParty/Boost/src/boost/algorithm/string/formatter.hpp index 50006df..ab5921e 100644 --- a/3rdParty/Boost/src/boost/algorithm/string/formatter.hpp +++ b/3rdParty/Boost/src/boost/algorithm/string/formatter.hpp @@ -36,7 +36,7 @@ namespace boost { //! Constant formatter /*! - Construct the \c const_formatter. Const formatter always returns + Constructs a \c const_formatter. Const formatter always returns the same value, regardless of the parameter. \param Format A predefined value used as a result for formating @@ -55,7 +55,7 @@ namespace boost { //! Identity formatter /*! - Construct the \c identity_formatter. Identity formatter always returns + Constructs an \c identity_formatter. Identity formatter always returns the parameter. \return An instance of the \c identity_formatter object. @@ -73,7 +73,7 @@ namespace boost { //! Empty formatter /*! - Construct the \c empty_formatter. Empty formatter always returns an empty + Constructs an \c empty_formatter. Empty formatter always returns an empty sequence. \param Input container used to select a correct value_type for the @@ -89,6 +89,22 @@ namespace boost { BOOST_STRING_TYPENAME range_value::type>(); } + //! Empty formatter + /*! + Constructs a \c dissect_formatter. Dissect formatter uses a specified finder + to extract a portion of the formatted sequence. The first finder's match is returned + as a result + + \param Finder a finder used to select a portion of the formated sequence + \return An instance of the \c dissect_formatter object. + */ + template + inline detail::dissect_formatF< FinderT > + dissect_formatter(const FinderT& Finder) + { + return detail::dissect_formatF(Finder); + } + } // namespace algorithm @@ -96,6 +112,7 @@ namespace boost { using algorithm::const_formatter; using algorithm::identity_formatter; using algorithm::empty_formatter; + using algorithm::dissect_formatter; } // namespace boost diff --git a/3rdParty/Boost/src/boost/algorithm/string/iter_find.hpp b/3rdParty/Boost/src/boost/algorithm/string/iter_find.hpp index 9e0245f..e106528 100644 --- a/3rdParty/Boost/src/boost/algorithm/string/iter_find.hpp +++ b/3rdParty/Boost/src/boost/algorithm/string/iter_find.hpp @@ -60,7 +60,7 @@ namespace boost { a match). \param Input A container which will be searched. \param Finder A Finder object used for searching - \return A reference the result + \return A reference to the result \note Prior content of the result will be overwritten. */ @@ -122,7 +122,7 @@ namespace boost { Each match is used as a separator of segments. These segments are then returned in the result. - \param Result A 'container container' to container the result of search. + \param Result A 'container container' to contain the result of search. Both outer and inner container must have constructor taking a pair of iterators as an argument. Typical type of the result is @@ -131,7 +131,7 @@ namespace boost { a match). \param Input A container which will be searched. \param Finder A finder object used for searching - \return A reference the result + \return A reference to the result \note Prior content of the result will be overwritten. */ diff --git a/3rdParty/Boost/src/boost/array.hpp b/3rdParty/Boost/src/boost/array.hpp index 85b63a2..fa06fa9 100644 --- a/3rdParty/Boost/src/boost/array.hpp +++ b/3rdParty/Boost/src/boost/array.hpp @@ -13,6 +13,7 @@ * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * + * 14 Apr 2012 - (mtc) Added support for boost::hash * 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility. * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. * See or Trac issue #3168 @@ -46,6 +47,7 @@ // Handles broken standard libraries better than #include #include +#include #include // FIXES for broken compilers @@ -118,13 +120,13 @@ namespace boost { // operator[] reference operator[](size_type i) { - BOOST_ASSERT( i < N && "out of range" ); + BOOST_ASSERT_MSG( i < N, "out of range" ); return elems[i]; } const_reference operator[](size_type i) const { - BOOST_ASSERT( i < N && "out of range" ); + BOOST_ASSERT_MSG( i < N, "out of range" ); return elems[i]; } @@ -322,7 +324,7 @@ namespace boost { static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); boost::throw_exception(e); -#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC) +#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__)) // // We need to return something here to keep // some compilers happy: however we will never @@ -427,6 +429,13 @@ namespace boost { } #endif + + template + std::size_t hash_value(const array& arr) + { + return boost::hash_range(arr.begin(), arr.end()); + } + } /* namespace boost */ diff --git a/3rdParty/Boost/src/boost/asio.hpp b/3rdParty/Boost/src/boost/asio.hpp index 2681806..8205c55 100644 --- a/3rdParty/Boost/src/boost/asio.hpp +++ b/3rdParty/Boost/src/boost/asio.hpp @@ -2,7 +2,7 @@ // asio.hpp // ~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -21,12 +21,15 @@ #include #include #include +#include #include +#include #include #include #include #include #include +#include #include #include #include @@ -36,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -76,9 +80,12 @@ #include #include #include +#include #include #include #include +#include +#include #include #include #include @@ -86,9 +93,14 @@ #include #include #include +#include +#include #include +#include #include #include +#include +#include #include #include #include diff --git a/3rdParty/Boost/src/boost/asio/basic_datagram_socket.hpp b/3rdParty/Boost/src/boost/asio/basic_datagram_socket.hpp index a79967f..a773315 100644 --- a/3rdParty/Boost/src/boost/asio/basic_datagram_socket.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_datagram_socket.hpp @@ -2,7 +2,7 @@ // basic_datagram_socket.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -42,8 +43,12 @@ class basic_datagram_socket : public basic_socket { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename DatagramSocketService::native_handle_type native_type; + /// The native representation of a socket. - typedef typename DatagramSocketService::native_type native_type; + typedef typename DatagramSocketService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -121,12 +126,48 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_datagram_socket(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_socket) + const protocol_type& protocol, const native_handle_type& native_socket) : basic_socket( io_service, protocol, native_socket) { } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_datagram_socket from another. + /** + * This constructor moves a datagram socket from one object to another. + * + * @param other The other basic_datagram_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_datagram_socket(io_service&) constructor. + */ + basic_datagram_socket(basic_datagram_socket&& other) + : basic_socket( + BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other)) + { + } + + /// Move-assign a basic_datagram_socket from another. + /** + * This assignment operator moves a datagram socket from one object to + * another. + * + * @param other The other basic_datagram_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_datagram_socket(io_service&) constructor. + */ + basic_datagram_socket& operator=(basic_datagram_socket&& other) + { + basic_socket::operator=( + BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Send some data on a connected socket. /** * This function is used to send data on the datagram socket. The function @@ -153,8 +194,9 @@ public: std::size_t send(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.send(this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -180,9 +222,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -207,7 +249,8 @@ public: std::size_t send(const ConstBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send(this->implementation, buffers, flags, ec); + return this->get_service().send( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous send on a connected socket. @@ -247,9 +290,15 @@ public: * std::vector. */ template - void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + void async_send(const ConstBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send on a connected socket. @@ -283,9 +332,15 @@ public: */ template void async_send(const ConstBufferSequence& buffers, - socket_base::message_flags flags, WriteHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Send a datagram to the specified endpoint. @@ -318,9 +373,9 @@ public: const endpoint_type& destination) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, 0, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -345,9 +400,9 @@ public: const endpoint_type& destination, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, flags, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -372,7 +427,7 @@ public: const endpoint_type& destination, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send_to(this->implementation, + return this->get_service().send_to(this->get_implementation(), buffers, destination, flags, ec); } @@ -415,10 +470,15 @@ public: */ template void async_send_to(const ConstBufferSequence& buffers, - const endpoint_type& destination, WriteHandler handler) + const endpoint_type& destination, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, 0, - handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send. @@ -451,10 +511,14 @@ public: template void async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, - flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Receive some data on a connected socket. @@ -485,9 +549,9 @@ public: std::size_t receive(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -514,9 +578,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -542,7 +606,8 @@ public: std::size_t receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive(this->implementation, buffers, flags, ec); + return this->get_service().receive( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous receive on a connected socket. @@ -582,9 +647,15 @@ public: * std::vector. */ template - void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + void async_receive(const MutableBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive on a connected socket. @@ -617,9 +688,15 @@ public: */ template void async_receive(const MutableBufferSequence& buffers, - socket_base::message_flags flags, ReadHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Receive a datagram with the endpoint of the sender. @@ -653,9 +730,9 @@ public: endpoint_type& sender_endpoint) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, 0, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -680,9 +757,9 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, flags, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -707,8 +784,8 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive_from(this->implementation, buffers, - sender_endpoint, flags, ec); + return this->get_service().receive_from(this->get_implementation(), + buffers, sender_endpoint, flags, ec); } /// Start an asynchronous receive. @@ -749,10 +826,15 @@ public: */ template void async_receive_from(const MutableBufferSequence& buffers, - endpoint_type& sender_endpoint, ReadHandler handler) + endpoint_type& sender_endpoint, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive. @@ -787,10 +869,14 @@ public: template void async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, socket_base::message_flags flags, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; diff --git a/3rdParty/Boost/src/boost/asio/basic_deadline_timer.hpp b/3rdParty/Boost/src/boost/asio/basic_deadline_timer.hpp index 452999d..6baeb7a 100644 --- a/3rdParty/Boost/src/boost/asio/basic_deadline_timer.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_deadline_timer.hpp @@ -2,7 +2,7 @@ // basic_deadline_timer.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -161,7 +162,7 @@ public: { boost::system::error_code ec; this->service.expires_at(this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_at"); } /// Constructor to set a particular expiry time relative to now. @@ -180,7 +181,7 @@ public: { boost::system::error_code ec; this->service.expires_from_now(this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_from_now"); } /// Cancel any asynchronous operations that are waiting on the timer. @@ -209,7 +210,7 @@ public: { boost::system::error_code ec; std::size_t s = this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "cancel"); return s; } @@ -240,6 +241,67 @@ public: return this->service.cancel(this->implementation, ec); } + /// Cancels one asynchronous operation that is waiting on the timer. + /** + * This function forces the completion of one pending asynchronous wait + * operation against the timer. Handlers are cancelled in FIFO order. The + * handler for the cancelled operation will be invoked with the + * boost::asio::error::operation_aborted error code. + * + * Cancelling the timer does not change the expiry time. + * + * @return The number of asynchronous operations that were cancelled. That is, + * either 0 or 1. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note If the timer has already expired when cancel_one() is called, then + * the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t cancel_one() + { + boost::system::error_code ec; + std::size_t s = this->service.cancel_one(this->implementation, ec); + boost::asio::detail::throw_error(ec, "cancel_one"); + return s; + } + + /// Cancels one asynchronous operation that is waiting on the timer. + /** + * This function forces the completion of one pending asynchronous wait + * operation against the timer. Handlers are cancelled in FIFO order. The + * handler for the cancelled operation will be invoked with the + * boost::asio::error::operation_aborted error code. + * + * Cancelling the timer does not change the expiry time. + * + * @param ec Set to indicate what error occurred, if any. + * + * @return The number of asynchronous operations that were cancelled. That is, + * either 0 or 1. + * + * @note If the timer has already expired when cancel_one() is called, then + * the handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + std::size_t cancel_one(boost::system::error_code& ec) + { + return this->service.cancel_one(this->implementation, ec); + } + /// Get the timer's expiry time as an absolute time. /** * This function may be used to obtain the timer's current expiry time. @@ -277,7 +339,7 @@ public: boost::system::error_code ec; std::size_t s = this->service.expires_at( this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_at"); return s; } @@ -346,7 +408,7 @@ public: boost::system::error_code ec; std::size_t s = this->service.expires_from_now( this->implementation, expiry_time, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "expires_from_now"); return s; } @@ -390,7 +452,7 @@ public: { boost::system::error_code ec; this->service.wait(this->implementation, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "wait"); } /// Perform a blocking wait on the timer. @@ -430,9 +492,14 @@ public: * boost::asio::io_service::post(). */ template - void async_wait(WaitHandler handler) + void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler) { - this->service.async_wait(this->implementation, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WaitHandler. + BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check; + + this->service.async_wait(this->implementation, + BOOST_ASIO_MOVE_CAST(WaitHandler)(handler)); } }; diff --git a/3rdParty/Boost/src/boost/asio/basic_io_object.hpp b/3rdParty/Boost/src/boost/asio/basic_io_object.hpp index 8e137e7..0464335 100644 --- a/3rdParty/Boost/src/boost/asio/basic_io_object.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_io_object.hpp @@ -2,7 +2,7 @@ // basic_io_object.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -16,7 +16,6 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include -#include #include #include @@ -24,10 +23,42 @@ namespace boost { namespace asio { +#if defined(BOOST_ASIO_HAS_MOVE) +namespace detail +{ + // Type trait used to determine whether a service supports move. + template + class service_has_move + { + private: + typedef IoObjectService service_type; + typedef typename service_type::implementation_type implementation_type; + + template + static auto eval(T* t, U* u) -> decltype(t->move_construct(*u, *u), char()); + static char (&eval(...))[2]; + + public: + static const bool value = + sizeof(service_has_move::eval( + static_cast(0), + static_cast(0))) == 1; + }; +} +#endif // defined(BOOST_ASIO_HAS_MOVE) + /// Base class for all I/O objects. +/** + * @note All I/O objects are non-copyable. However, when using C++0x, certain + * I/O objects do support move construction and move assignment. + */ +#if !defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) template +#else +template ::value> +#endif class basic_io_object - : private noncopyable { public: /// The type of the service that will be used to provide I/O operations. @@ -36,20 +67,6 @@ public: /// The underlying implementation type of I/O object. typedef typename service_type::implementation_type implementation_type; - /// (Deprecated: use get_io_service().) Get the io_service associated with - /// the object. - /** - * This function may be used to obtain the io_service object that the I/O - * object uses to dispatch handlers for asynchronous operations. - * - * @return A reference to the io_service object that the I/O object will use - * to dispatch handlers. Ownership is not transferred to the caller. - */ - boost::asio::io_service& io_service() - { - return service.get_io_service(); - } - /// Get the io_service associated with the object. /** * This function may be used to obtain the io_service object that the I/O @@ -67,7 +84,7 @@ protected: /// Construct a basic_io_object. /** * Performs: - * @code service.construct(implementation); @endcode + * @code get_service().construct(get_implementation()); @endcode */ explicit basic_io_object(boost::asio::io_service& io_service) : service(boost::asio::use_service(io_service)) @@ -75,22 +92,147 @@ protected: service.construct(implementation); } +#if defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_io_object. + /** + * Performs: + * @code get_service().move_construct( + * get_implementation(), other.get_implementation()); @endcode + * + * @note Available only for services that support movability, + */ + basic_io_object(basic_io_object&& other); + + /// Move-assign a basic_io_object. + /** + * Performs: + * @code get_service().move_assign(get_implementation(), + * other.get_service(), other.get_implementation()); @endcode + * + * @note Available only for services that support movability, + */ + basic_io_object& operator=(basic_io_object&& other); +#endif // defined(GENERATING_DOCUMENTATION) + /// Protected destructor to prevent deletion through this type. /** * Performs: - * @code service.destroy(implementation); @endcode + * @code get_service().destroy(get_implementation()); @endcode */ ~basic_io_object() { service.destroy(implementation); } - /// The service associated with the I/O object. + /// Get the service associated with the I/O object. + service_type& get_service() + { + return service; + } + + /// Get the service associated with the I/O object. + const service_type& get_service() const + { + return service; + } + + /// (Deprecated: Use get_service().) The service associated with the I/O + /// object. + /** + * @note Available only for services that do not support movability. + */ service_type& service; - /// The underlying implementation of the I/O object. + /// Get the underlying implementation of the I/O object. + implementation_type& get_implementation() + { + return implementation; + } + + /// Get the underlying implementation of the I/O object. + const implementation_type& get_implementation() const + { + return implementation; + } + + /// (Deprecated: Use get_implementation().) The underlying implementation of + /// the I/O object. implementation_type implementation; + +private: + basic_io_object(const basic_io_object&); + basic_io_object& operator=(const basic_io_object&); +}; + +#if defined(BOOST_ASIO_HAS_MOVE) +// Specialisation for movable objects. +template +class basic_io_object +{ +public: + typedef IoObjectService service_type; + typedef typename service_type::implementation_type implementation_type; + + boost::asio::io_service& get_io_service() + { + return service_->get_io_service(); + } + +protected: + explicit basic_io_object(boost::asio::io_service& io_service) + : service_(&boost::asio::use_service(io_service)) + { + service_->construct(implementation); + } + + basic_io_object(basic_io_object&& other) + : service_(&other.get_service()) + { + service_->move_construct(implementation, other.implementation); + } + + ~basic_io_object() + { + service_->destroy(implementation); + } + + basic_io_object& operator=(basic_io_object&& other) + { + service_->move_assign(implementation, + *other.service_, other.implementation); + service_ = other.service_; + return *this; + } + + service_type& get_service() + { + return *service_; + } + + const service_type& get_service() const + { + return *service_; + } + + implementation_type& get_implementation() + { + return implementation; + } + + const implementation_type& get_implementation() const + { + return implementation; + } + + implementation_type implementation; + +private: + basic_io_object(const basic_io_object&); + void operator=(const basic_io_object&); + + IoObjectService* service_; }; +#endif // defined(BOOST_ASIO_HAS_MOVE) } // namespace asio } // namespace boost diff --git a/3rdParty/Boost/src/boost/asio/basic_raw_socket.hpp b/3rdParty/Boost/src/boost/asio/basic_raw_socket.hpp index 0e58e7f..90f66c0 100644 --- a/3rdParty/Boost/src/boost/asio/basic_raw_socket.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_raw_socket.hpp @@ -2,7 +2,7 @@ // basic_raw_socket.hpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -42,8 +43,12 @@ class basic_raw_socket : public basic_socket { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename RawSocketService::native_handle_type native_type; + /// The native representation of a socket. - typedef typename RawSocketService::native_type native_type; + typedef typename RawSocketService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -121,12 +126,47 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_raw_socket(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_socket) + const protocol_type& protocol, const native_handle_type& native_socket) : basic_socket( io_service, protocol, native_socket) { } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_raw_socket from another. + /** + * This constructor moves a raw socket from one object to another. + * + * @param other The other basic_raw_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_raw_socket(io_service&) constructor. + */ + basic_raw_socket(basic_raw_socket&& other) + : basic_socket( + BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other)) + { + } + + /// Move-assign a basic_raw_socket from another. + /** + * This assignment operator moves a raw socket from one object to another. + * + * @param other The other basic_raw_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_raw_socket(io_service&) constructor. + */ + basic_raw_socket& operator=(basic_raw_socket&& other) + { + basic_socket::operator=( + BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Send some data on a connected socket. /** * This function is used to send data on the raw socket. The function call @@ -152,8 +192,9 @@ public: std::size_t send(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.send(this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -178,9 +219,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "send"); return s; } @@ -204,7 +245,8 @@ public: std::size_t send(const ConstBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send(this->implementation, buffers, flags, ec); + return this->get_service().send( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous send on a connected socket. @@ -243,9 +285,15 @@ public: * std::vector. */ template - void async_send(const ConstBufferSequence& buffers, WriteHandler handler) + void async_send(const ConstBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send on a connected socket. @@ -278,9 +326,15 @@ public: */ template void async_send(const ConstBufferSequence& buffers, - socket_base::message_flags flags, WriteHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Send raw data to the specified endpoint. @@ -313,9 +367,9 @@ public: const endpoint_type& destination) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, 0, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -340,9 +394,9 @@ public: const endpoint_type& destination, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.send_to( - this->implementation, buffers, destination, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().send_to( + this->get_implementation(), buffers, destination, flags, ec); + boost::asio::detail::throw_error(ec, "send_to"); return s; } @@ -367,7 +421,7 @@ public: const endpoint_type& destination, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.send_to(this->implementation, + return this->get_service().send_to(this->get_implementation(), buffers, destination, flags, ec); } @@ -410,10 +464,15 @@ public: */ template void async_send_to(const ConstBufferSequence& buffers, - const endpoint_type& destination, WriteHandler handler) + const endpoint_type& destination, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, 0, - handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Start an asynchronous send. @@ -446,10 +505,14 @@ public: template void async_send_to(const ConstBufferSequence& buffers, const endpoint_type& destination, socket_base::message_flags flags, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_send_to(this->implementation, buffers, destination, - flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send_to(this->get_implementation(), buffers, + destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Receive some data on a connected socket. @@ -480,9 +543,9 @@ public: std::size_t receive(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -509,9 +572,9 @@ public: socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive( - this->implementation, buffers, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "receive"); return s; } @@ -537,7 +600,8 @@ public: std::size_t receive(const MutableBufferSequence& buffers, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive(this->implementation, buffers, flags, ec); + return this->get_service().receive( + this->get_implementation(), buffers, flags, ec); } /// Start an asynchronous receive on a connected socket. @@ -577,9 +641,15 @@ public: * std::vector. */ template - void async_receive(const MutableBufferSequence& buffers, ReadHandler handler) + void async_receive(const MutableBufferSequence& buffers, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive on a connected socket. @@ -612,9 +682,15 @@ public: */ template void async_receive(const MutableBufferSequence& buffers, - socket_base::message_flags flags, ReadHandler handler) + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive(this->implementation, buffers, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Receive raw data with the endpoint of the sender. @@ -648,9 +724,9 @@ public: endpoint_type& sender_endpoint) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, 0, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, 0, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -675,9 +751,9 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags) { boost::system::error_code ec; - std::size_t s = this->service.receive_from( - this->implementation, buffers, sender_endpoint, flags, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().receive_from( + this->get_implementation(), buffers, sender_endpoint, flags, ec); + boost::asio::detail::throw_error(ec, "receive_from"); return s; } @@ -702,8 +778,8 @@ public: endpoint_type& sender_endpoint, socket_base::message_flags flags, boost::system::error_code& ec) { - return this->service.receive_from(this->implementation, buffers, - sender_endpoint, flags, ec); + return this->get_service().receive_from(this->get_implementation(), + buffers, sender_endpoint, flags, ec); } /// Start an asynchronous receive. @@ -744,10 +820,15 @@ public: */ template void async_receive_from(const MutableBufferSequence& buffers, - endpoint_type& sender_endpoint, ReadHandler handler) + endpoint_type& sender_endpoint, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } /// Start an asynchronous receive. @@ -782,10 +863,14 @@ public: template void async_receive_from(const MutableBufferSequence& buffers, endpoint_type& sender_endpoint, socket_base::message_flags flags, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_receive_from(this->implementation, buffers, - sender_endpoint, flags, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive_from(this->get_implementation(), buffers, + sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; diff --git a/3rdParty/Boost/src/boost/asio/basic_seq_packet_socket.hpp b/3rdParty/Boost/src/boost/asio/basic_seq_packet_socket.hpp new file mode 100644 index 0000000..a638c71 --- /dev/null +++ b/3rdParty/Boost/src/boost/asio/basic_seq_packet_socket.hpp @@ -0,0 +1,514 @@ +// +// basic_seq_packet_socket.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// 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) +// + +#ifndef BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP +#define BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace asio { + +/// Provides sequenced packet socket functionality. +/** + * The basic_seq_packet_socket class template provides asynchronous and blocking + * sequenced packet socket functionality. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + */ +template > +class basic_seq_packet_socket + : public basic_socket +{ +public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename SeqPacketSocketService::native_handle_type native_type; + + /// The native representation of a socket. + typedef typename SeqPacketSocketService::native_handle_type + native_handle_type; + + /// The protocol type. + typedef Protocol protocol_type; + + /// The endpoint type. + typedef typename Protocol::endpoint endpoint_type; + + /// Construct a basic_seq_packet_socket without opening it. + /** + * This constructor creates a sequenced packet socket without opening it. The + * socket needs to be opened and then connected or accepted before data can + * be sent or received on it. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + */ + explicit basic_seq_packet_socket(boost::asio::io_service& io_service) + : basic_socket(io_service) + { + } + + /// Construct and open a basic_seq_packet_socket. + /** + * This constructor creates and opens a sequenced_packet socket. The socket + * needs to be connected or accepted before data can be sent or received on + * it. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_seq_packet_socket(boost::asio::io_service& io_service, + const protocol_type& protocol) + : basic_socket(io_service, protocol) + { + } + + /// Construct a basic_seq_packet_socket, opening it and binding it to the + /// given local endpoint. + /** + * This constructor creates a sequenced packet socket and automatically opens + * it bound to the specified endpoint on the local machine. The protocol used + * is the protocol associated with the given endpoint. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + * + * @param endpoint An endpoint on the local machine to which the sequenced + * packet socket will be bound. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_seq_packet_socket(boost::asio::io_service& io_service, + const endpoint_type& endpoint) + : basic_socket(io_service, endpoint) + { + } + + /// Construct a basic_seq_packet_socket on an existing native socket. + /** + * This constructor creates a sequenced packet socket object to hold an + * existing native socket. + * + * @param io_service The io_service object that the sequenced packet socket + * will use to dispatch handlers for any asynchronous operations performed on + * the socket. + * + * @param protocol An object specifying protocol parameters to be used. + * + * @param native_socket The new underlying socket implementation. + * + * @throws boost::system::system_error Thrown on failure. + */ + basic_seq_packet_socket(boost::asio::io_service& io_service, + const protocol_type& protocol, const native_handle_type& native_socket) + : basic_socket( + io_service, protocol, native_socket) + { + } + +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_seq_packet_socket from another. + /** + * This constructor moves a sequenced packet socket from one object to + * another. + * + * @param other The other basic_seq_packet_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_seq_packet_socket(io_service&) constructor. + */ + basic_seq_packet_socket(basic_seq_packet_socket&& other) + : basic_socket( + BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other)) + { + } + + /// Move-assign a basic_seq_packet_socket from another. + /** + * This assignment operator moves a sequenced packet socket from one object to + * another. + * + * @param other The other basic_seq_packet_socket object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_seq_packet_socket(io_service&) constructor. + */ + basic_seq_packet_socket& operator=(basic_seq_packet_socket&& other) + { + basic_socket::operator=( + BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + + /// Send some data on the socket. + /** + * This function is used to send data on the sequenced packet socket. The + * function call will block until the data has been sent successfully, or an + * until error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @returns The number of bytes sent. + * + * @throws boost::system::system_error Thrown on failure. + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.send(boost::asio::buffer(data, size), 0); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags) + { + boost::system::error_code ec; + std::size_t s = this->get_service().send( + this->get_implementation(), buffers, flags, ec); + boost::asio::detail::throw_error(ec, "send"); + return s; + } + + /// Send some data on the socket. + /** + * This function is used to send data on the sequenced packet socket. The + * function call will block the data has been sent successfully, or an until + * error occurs. + * + * @param buffers One or more data buffers to be sent on the socket. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes sent. Returns 0 if an error occurred. + * + * @note The send operation may not transmit all of the data to the peer. + * Consider using the @ref write function if you need to ensure that all data + * is written before the blocking operation completes. + */ + template + std::size_t send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, boost::system::error_code& ec) + { + return this->get_service().send( + this->get_implementation(), buffers, flags, ec); + } + + /// Start an asynchronous send. + /** + * This function is used to asynchronously send data on the sequenced packet + * socket. The function call always returns immediately. + * + * @param buffers One or more data buffers to be sent on the socket. Although + * the buffers object may be copied as necessary, ownership of the underlying + * memory blocks is retained by the caller, which must guarantee that they + * remain valid until the handler is called. + * + * @param flags Flags specifying how the send call is to be made. + * + * @param handler The handler to be called when the send operation completes. + * Copies will be made of the handler as required. The function signature of + * the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes sent. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To send a single data buffer use the @ref buffer function as follows: + * @code + * socket.async_send(boost::asio::buffer(data, size), 0, handler); + * @endcode + * See the @ref buffer documentation for information on sending multiple + * buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + void async_send(const ConstBufferSequence& buffers, + socket_base::message_flags flags, + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_send(this->get_implementation(), + buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); + } + + /// Receive some data on the socket. + /** + * This function is used to receive data on the sequenced packet socket. The + * function call will block until data has been received successfully, or + * until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param out_flags After the receive call completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.receive(boost::asio::buffer(data, size), out_flags); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags& out_flags) + { + boost::system::error_code ec; + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, 0, out_flags, ec); + boost::asio::detail::throw_error(ec, "receive"); + return s; + } + + /// Receive some data on the socket. + /** + * This function is used to receive data on the sequenced packet socket. The + * function call will block until data has been received successfully, or + * until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param in_flags Flags specifying how the receive call is to be made. + * + * @param out_flags After the receive call completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. + * + * @returns The number of bytes received. + * + * @throws boost::system::system_error Thrown on failure. An error code of + * boost::asio::error::eof indicates that the connection was closed by the + * peer. + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that the + * requested amount of data is read before the blocking operation completes. + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.receive(boost::asio::buffer(data, size), 0, out_flags); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags in_flags, + socket_base::message_flags& out_flags) + { + boost::system::error_code ec; + std::size_t s = this->get_service().receive( + this->get_implementation(), buffers, in_flags, out_flags, ec); + boost::asio::detail::throw_error(ec, "receive"); + return s; + } + + /// Receive some data on a connected socket. + /** + * This function is used to receive data on the sequenced packet socket. The + * function call will block until data has been received successfully, or + * until an error occurs. + * + * @param buffers One or more buffers into which the data will be received. + * + * @param in_flags Flags specifying how the receive call is to be made. + * + * @param out_flags After the receive call completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. + * + * @param ec Set to indicate what error occurred, if any. + * + * @returns The number of bytes received. Returns 0 if an error occurred. + * + * @note The receive operation may not receive all of the requested number of + * bytes. Consider using the @ref read function if you need to ensure that the + * requested amount of data is read before the blocking operation completes. + */ + template + std::size_t receive(const MutableBufferSequence& buffers, + socket_base::message_flags in_flags, + socket_base::message_flags& out_flags, boost::system::error_code& ec) + { + return this->get_service().receive(this->get_implementation(), + buffers, in_flags, out_flags, ec); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive data from the sequenced + * packet socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param out_flags Once the asynchronous operation completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. The caller must guarantee that the referenced + * variable remains valid until the handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive(boost::asio::buffer(data, size), out_flags, handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + void async_receive(const MutableBufferSequence& buffers, + socket_base::message_flags& out_flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), buffers, + 0, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); + } + + /// Start an asynchronous receive. + /** + * This function is used to asynchronously receive data from the sequenced + * data socket. The function call always returns immediately. + * + * @param buffers One or more buffers into which the data will be received. + * Although the buffers object may be copied as necessary, ownership of the + * underlying memory blocks is retained by the caller, which must guarantee + * that they remain valid until the handler is called. + * + * @param in_flags Flags specifying how the receive call is to be made. + * + * @param out_flags Once the asynchronous operation completes, contains flags + * associated with the received data. For example, if the + * socket_base::message_end_of_record bit is set then the received data marks + * the end of a record. The caller must guarantee that the referenced + * variable remains valid until the handler is called. + * + * @param handler The handler to be called when the receive operation + * completes. Copies will be made of the handler as required. The function + * signature of the handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * std::size_t bytes_transferred // Number of bytes received. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + * + * @par Example + * To receive into a single data buffer use the @ref buffer function as + * follows: + * @code + * socket.async_receive( + * boost::asio::buffer(data, size), + * 0, out_flags, handler); + * @endcode + * See the @ref buffer documentation for information on receiving into + * multiple buffers in one go, and how to use it with arrays, boost::array or + * std::vector. + */ + template + void async_receive(const MutableBufferSequence& buffers, + socket_base::message_flags in_flags, + socket_base::message_flags& out_flags, + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_receive(this->get_implementation(), buffers, + in_flags, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); + } +}; + +} // namespace asio +} // namespace boost + +#include + +#endif // BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP diff --git a/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp b/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp index 744fd3b..31ee955 100644 --- a/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_serial_port.hpp @@ -2,7 +2,7 @@ // basic_serial_port.hpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -48,8 +49,12 @@ class basic_serial_port public serial_port_base { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// serial port. + typedef typename SerialPortService::native_handle_type native_type; + /// The native representation of a serial port. - typedef typename SerialPortService::native_type native_type; + typedef typename SerialPortService::native_handle_type native_handle_type; /// A basic_serial_port is always the lowest layer. typedef basic_serial_port lowest_layer_type; @@ -82,8 +87,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, device, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), device, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct and open a basic_serial_port. @@ -102,8 +107,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, device, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), device, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct a basic_serial_port on an existing native serial port. @@ -119,13 +124,49 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_serial_port(boost::asio::io_service& io_service, - const native_type& native_serial_port) + const native_handle_type& native_serial_port) : basic_io_object(io_service) { boost::system::error_code ec; - this->service.assign(this->implementation, native_serial_port, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + native_serial_port, ec); + boost::asio::detail::throw_error(ec, "assign"); + } + +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_serial_port from another. + /** + * This constructor moves a serial port from one object to another. + * + * @param other The other basic_serial_port object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_serial_port(io_service&) constructor. + */ + basic_serial_port(basic_serial_port&& other) + : basic_io_object( + BOOST_ASIO_MOVE_CAST(basic_serial_port)(other)) + { + } + + /// Move-assign a basic_serial_port from another. + /** + * This assignment operator moves a serial port from one object to another. + * + * @param other The other basic_serial_port object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_serial_port(io_service&) constructor. + */ + basic_serial_port& operator=(basic_serial_port&& other) + { + basic_io_object::operator=( + BOOST_ASIO_MOVE_CAST(basic_serial_port)(other)); + return *this; } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Get a reference to the lowest layer. /** @@ -166,8 +207,8 @@ public: void open(const std::string& device) { boost::system::error_code ec; - this->service.open(this->implementation, device, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), device, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Open the serial port using the specified device name. @@ -182,7 +223,7 @@ public: boost::system::error_code open(const std::string& device, boost::system::error_code& ec) { - return this->service.open(this->implementation, device, ec); + return this->get_service().open(this->get_implementation(), device, ec); } /// Assign an existing native serial port to the serial port. @@ -193,11 +234,12 @@ public: * * @throws boost::system::system_error Thrown on failure. */ - void assign(const native_type& native_serial_port) + void assign(const native_handle_type& native_serial_port) { boost::system::error_code ec; - this->service.assign(this->implementation, native_serial_port, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + native_serial_port, ec); + boost::asio::detail::throw_error(ec, "assign"); } /// Assign an existing native serial port to the serial port. @@ -208,16 +250,17 @@ public: * * @param ec Set to indicate what error occurred, if any. */ - boost::system::error_code assign(const native_type& native_serial_port, + boost::system::error_code assign(const native_handle_type& native_serial_port, boost::system::error_code& ec) { - return this->service.assign(this->implementation, native_serial_port, ec); + return this->get_service().assign(this->get_implementation(), + native_serial_port, ec); } /// Determine whether the serial port is open. bool is_open() const { - return this->service.is_open(this->implementation); + return this->get_service().is_open(this->get_implementation()); } /// Close the serial port. @@ -231,8 +274,8 @@ public: void close() { boost::system::error_code ec; - this->service.close(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().close(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "close"); } /// Close the serial port. @@ -245,10 +288,11 @@ public: */ boost::system::error_code close(boost::system::error_code& ec) { - return this->service.close(this->implementation, ec); + return this->get_service().close(this->get_implementation(), ec); } - /// Get the native serial port representation. + /// (Deprecated: Use native_handle().) Get the native serial port + /// representation. /** * This function may be used to obtain the underlying representation of the * serial port. This is intended to allow access to native serial port @@ -256,7 +300,18 @@ public: */ native_type native() { - return this->service.native(this->implementation); + return this->get_service().native_handle(this->get_implementation()); + } + + /// Get the native serial port representation. + /** + * This function may be used to obtain the underlying representation of the + * serial port. This is intended to allow access to native serial port + * functionality that is not otherwise provided. + */ + native_handle_type native_handle() + { + return this->get_service().native_handle(this->get_implementation()); } /// Cancel all asynchronous operations associated with the serial port. @@ -270,8 +325,8 @@ public: void cancel() { boost::system::error_code ec; - this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().cancel(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "cancel"); } /// Cancel all asynchronous operations associated with the serial port. @@ -284,7 +339,7 @@ public: */ boost::system::error_code cancel(boost::system::error_code& ec) { - return this->service.cancel(this->implementation, ec); + return this->get_service().cancel(this->get_implementation(), ec); } /// Send a break sequence to the serial port. @@ -297,8 +352,8 @@ public: void send_break() { boost::system::error_code ec; - this->service.send_break(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().send_break(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "send_break"); } /// Send a break sequence to the serial port. @@ -310,7 +365,7 @@ public: */ boost::system::error_code send_break(boost::system::error_code& ec) { - return this->service.send_break(this->implementation, ec); + return this->get_service().send_break(this->get_implementation(), ec); } /// Set an option on the serial port. @@ -332,8 +387,8 @@ public: void set_option(const SettableSerialPortOption& option) { boost::system::error_code ec; - this->service.set_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().set_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "set_option"); } /// Set an option on the serial port. @@ -355,7 +410,8 @@ public: boost::system::error_code set_option(const SettableSerialPortOption& option, boost::system::error_code& ec) { - return this->service.set_option(this->implementation, option, ec); + return this->get_service().set_option( + this->get_implementation(), option, ec); } /// Get an option from the serial port. @@ -378,8 +434,8 @@ public: void get_option(GettableSerialPortOption& option) { boost::system::error_code ec; - this->service.get_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().get_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "get_option"); } /// Get an option from the serial port. @@ -402,7 +458,8 @@ public: boost::system::error_code get_option(GettableSerialPortOption& option, boost::system::error_code& ec) { - return this->service.get_option(this->implementation, option, ec); + return this->get_service().get_option( + this->get_implementation(), option, ec); } /// Write some data to the serial port. @@ -436,8 +493,9 @@ public: std::size_t write_some(const ConstBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.write_some(this->implementation, buffers, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().write_some( + this->get_implementation(), buffers, ec); + boost::asio::detail::throw_error(ec, "write_some"); return s; } @@ -461,7 +519,8 @@ public: std::size_t write_some(const ConstBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.write_some(this->implementation, buffers, ec); + return this->get_service().write_some( + this->get_implementation(), buffers, ec); } /// Start an asynchronous write. @@ -501,9 +560,14 @@ public: */ template void async_write_some(const ConstBufferSequence& buffers, - WriteHandler handler) + BOOST_ASIO_MOVE_ARG(WriteHandler) handler) { - this->service.async_write_some(this->implementation, buffers, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a WriteHandler. + BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; + + this->get_service().async_write_some(this->get_implementation(), + buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)); } /// Read some data from the serial port. @@ -538,8 +602,9 @@ public: std::size_t read_some(const MutableBufferSequence& buffers) { boost::system::error_code ec; - std::size_t s = this->service.read_some(this->implementation, buffers, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().read_some( + this->get_implementation(), buffers, ec); + boost::asio::detail::throw_error(ec, "read_some"); return s; } @@ -564,7 +629,8 @@ public: std::size_t read_some(const MutableBufferSequence& buffers, boost::system::error_code& ec) { - return this->service.read_some(this->implementation, buffers, ec); + return this->get_service().read_some( + this->get_implementation(), buffers, ec); } /// Start an asynchronous read. @@ -605,9 +671,14 @@ public: */ template void async_read_some(const MutableBufferSequence& buffers, - ReadHandler handler) + BOOST_ASIO_MOVE_ARG(ReadHandler) handler) { - this->service.async_read_some(this->implementation, buffers, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ReadHandler. + BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; + + this->get_service().async_read_some(this->get_implementation(), + buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler)); } }; diff --git a/3rdParty/Boost/src/boost/asio/basic_signal_set.hpp b/3rdParty/Boost/src/boost/asio/basic_signal_set.hpp new file mode 100644 index 0000000..ddbef87 --- /dev/null +++ b/3rdParty/Boost/src/boost/asio/basic_signal_set.hpp @@ -0,0 +1,384 @@ +// +// basic_signal_set.hpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// 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) +// + +#ifndef BOOST_ASIO_BASIC_SIGNAL_SET_HPP +#define BOOST_ASIO_BASIC_SIGNAL_SET_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + +#include + +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace asio { + +/// Provides signal functionality. +/** + * The basic_signal_set class template provides the ability to perform an + * asynchronous wait for one or more signals to occur. + * + * Most applications will use the boost::asio::signal_set typedef. + * + * @par Thread Safety + * @e Distinct @e objects: Safe.@n + * @e Shared @e objects: Unsafe. + * + * @par Example + * Performing an asynchronous wait: + * @code + * void handler( + * const boost::system::error_code& error, + * int signal_number) + * { + * if (!error) + * { + * // A signal occurred. + * } + * } + * + * ... + * + * // Construct a signal set registered for process termination. + * boost::asio::signal_set signals(io_service, SIGINT, SIGTERM); + * + * // Start an asynchronous wait for one of the signals to occur. + * signals.async_wait(handler); + * @endcode + * + * @par Queueing of signal notifications + * + * If a signal is registered with a signal_set, and the signal occurs when + * there are no waiting handlers, then the signal notification is queued. The + * next async_wait operation on that signal_set will dequeue the notification. + * If multiple notifications are queued, subsequent async_wait operations + * dequeue them one at a time. Signal notifications are dequeued in order of + * ascending signal number. + * + * If a signal number is removed from a signal_set (using the @c remove or @c + * erase member functions) then any queued notifications for that signal are + * discarded. + * + * @par Multiple registration of signals + * + * The same signal number may be registered with different signal_set objects. + * When the signal occurs, one handler is called for each signal_set object. + * + * Note that multiple registration only works for signals that are registered + * using Asio. The application must not also register a signal handler using + * functions such as @c signal() or @c sigaction(). + * + * @par Signal masking on POSIX platforms + * + * POSIX allows signals to be blocked using functions such as @c sigprocmask() + * and @c pthread_sigmask(). For signals to be delivered, programs must ensure + * that any signals registered using signal_set objects are unblocked in at + * least one thread. + */ +template +class basic_signal_set + : public basic_io_object +{ +public: + /// Construct a signal set without adding any signals. + /** + * This constructor creates a signal set without registering for any signals. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + */ + explicit basic_signal_set(boost::asio::io_service& io_service) + : basic_io_object(io_service) + { + } + + /// Construct a signal set and add one signal. + /** + * This constructor creates a signal set and registers for one signal. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + * + * @param signal_number_1 The signal number to be added. + * + * @note This constructor is equivalent to performing: + * @code boost::asio::signal_set signals(io_service); + * signals.add(signal_number_1); @endcode + */ + basic_signal_set(boost::asio::io_service& io_service, int signal_number_1) + : basic_io_object(io_service) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number_1, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Construct a signal set and add two signals. + /** + * This constructor creates a signal set and registers for two signals. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + * + * @param signal_number_1 The first signal number to be added. + * + * @param signal_number_2 The second signal number to be added. + * + * @note This constructor is equivalent to performing: + * @code boost::asio::signal_set signals(io_service); + * signals.add(signal_number_1); + * signals.add(signal_number_2); @endcode + */ + basic_signal_set(boost::asio::io_service& io_service, int signal_number_1, + int signal_number_2) + : basic_io_object(io_service) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number_1, ec); + boost::asio::detail::throw_error(ec, "add"); + this->service.add(this->implementation, signal_number_2, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Construct a signal set and add three signals. + /** + * This constructor creates a signal set and registers for three signals. + * + * @param io_service The io_service object that the signal set will use to + * dispatch handlers for any asynchronous operations performed on the set. + * + * @param signal_number_1 The first signal number to be added. + * + * @param signal_number_2 The second signal number to be added. + * + * @param signal_number_3 The third signal number to be added. + * + * @note This constructor is equivalent to performing: + * @code boost::asio::signal_set signals(io_service); + * signals.add(signal_number_1); + * signals.add(signal_number_2); + * signals.add(signal_number_3); @endcode + */ + basic_signal_set(boost::asio::io_service& io_service, int signal_number_1, + int signal_number_2, int signal_number_3) + : basic_io_object(io_service) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number_1, ec); + boost::asio::detail::throw_error(ec, "add"); + this->service.add(this->implementation, signal_number_2, ec); + boost::asio::detail::throw_error(ec, "add"); + this->service.add(this->implementation, signal_number_3, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Add a signal to a signal_set. + /** + * This function adds the specified signal to the set. It has no effect if the + * signal is already in the set. + * + * @param signal_number The signal to be added to the set. + * + * @throws boost::system::system_error Thrown on failure. + */ + void add(int signal_number) + { + boost::system::error_code ec; + this->service.add(this->implementation, signal_number, ec); + boost::asio::detail::throw_error(ec, "add"); + } + + /// Add a signal to a signal_set. + /** + * This function adds the specified signal to the set. It has no effect if the + * signal is already in the set. + * + * @param signal_number The signal to be added to the set. + * + * @param ec Set to indicate what error occurred, if any. + */ + boost::system::error_code add(int signal_number, + boost::system::error_code& ec) + { + return this->service.add(this->implementation, signal_number, ec); + } + + /// Remove a signal from a signal_set. + /** + * This function removes the specified signal from the set. It has no effect + * if the signal is not in the set. + * + * @param signal_number The signal to be removed from the set. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note Removes any notifications that have been queued for the specified + * signal number. + */ + void remove(int signal_number) + { + boost::system::error_code ec; + this->service.remove(this->implementation, signal_number, ec); + boost::asio::detail::throw_error(ec, "remove"); + } + + /// Remove a signal from a signal_set. + /** + * This function removes the specified signal from the set. It has no effect + * if the signal is not in the set. + * + * @param signal_number The signal to be removed from the set. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note Removes any notifications that have been queued for the specified + * signal number. + */ + boost::system::error_code remove(int signal_number, + boost::system::error_code& ec) + { + return this->service.remove(this->implementation, signal_number, ec); + } + + /// Remove all signals from a signal_set. + /** + * This function removes all signals from the set. It has no effect if the set + * is already empty. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note Removes all queued notifications. + */ + void clear() + { + boost::system::error_code ec; + this->service.clear(this->implementation, ec); + boost::asio::detail::throw_error(ec, "clear"); + } + + /// Remove all signals from a signal_set. + /** + * This function removes all signals from the set. It has no effect if the set + * is already empty. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note Removes all queued notifications. + */ + boost::system::error_code clear(boost::system::error_code& ec) + { + return this->service.clear(this->implementation, ec); + } + + /// Cancel all operations associated with the signal set. + /** + * This function forces the completion of any pending asynchronous wait + * operations against the signal set. The handler for each cancelled + * operation will be invoked with the boost::asio::error::operation_aborted + * error code. + * + * Cancellation does not alter the set of registered signals. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note If a registered signal occurred before cancel() is called, then the + * handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + void cancel() + { + boost::system::error_code ec; + this->service.cancel(this->implementation, ec); + boost::asio::detail::throw_error(ec, "cancel"); + } + + /// Cancel all operations associated with the signal set. + /** + * This function forces the completion of any pending asynchronous wait + * operations against the signal set. The handler for each cancelled + * operation will be invoked with the boost::asio::error::operation_aborted + * error code. + * + * Cancellation does not alter the set of registered signals. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note If a registered signal occurred before cancel() is called, then the + * handlers for asynchronous wait operations will: + * + * @li have already been invoked; or + * + * @li have been queued for invocation in the near future. + * + * These handlers can no longer be cancelled, and therefore are passed an + * error code that indicates the successful completion of the wait operation. + */ + boost::system::error_code cancel(boost::system::error_code& ec) + { + return this->service.cancel(this->implementation, ec); + } + + /// Start an asynchronous operation to wait for a signal to be delivered. + /** + * This function may be used to initiate an asynchronous wait against the + * signal set. It always returns immediately. + * + * For each call to async_wait(), the supplied handler will be called exactly + * once. The handler will be called when: + * + * @li One of the registered signals in the signal set occurs; or + * + * @li The signal set was cancelled, in which case the handler is passed the + * error code boost::asio::error::operation_aborted. + * + * @param handler The handler to be called when the signal occurs. Copies + * will be made of the handler as required. The function signature of the + * handler must be: + * @code void handler( + * const boost::system::error_code& error, // Result of operation. + * int signal_number // Indicates which signal occurred. + * ); @endcode + * Regardless of whether the asynchronous operation completes immediately or + * not, the handler will not be invoked from within this function. Invocation + * of the handler will be performed in a manner equivalent to using + * boost::asio::io_service::post(). + */ + template + void async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler) + { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a SignalHandler. + BOOST_ASIO_SIGNAL_HANDLER_CHECK(SignalHandler, handler) type_check; + + this->service.async_wait(this->implementation, + BOOST_ASIO_MOVE_CAST(SignalHandler)(handler)); + } +}; + +} // namespace asio +} // namespace boost + +#include + +#endif // BOOST_ASIO_BASIC_SIGNAL_SET_HPP diff --git a/3rdParty/Boost/src/boost/asio/basic_socket.hpp b/3rdParty/Boost/src/boost/asio/basic_socket.hpp index 11ce5c9..c9e2045 100644 --- a/3rdParty/Boost/src/boost/asio/basic_socket.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_socket.hpp @@ -2,7 +2,7 @@ // basic_socket.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -41,8 +42,12 @@ class basic_socket public socket_base { public: + /// (Deprecated: Use native_handle_type.) The native representation of a + /// socket. + typedef typename SocketService::native_handle_type native_type; + /// The native representation of a socket. - typedef typename SocketService::native_type native_type; + typedef typename SocketService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -81,8 +86,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct a basic_socket, opening it and binding it to the given local @@ -105,10 +110,11 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, endpoint.protocol(), ec); - boost::asio::detail::throw_error(ec); - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); + const protocol_type protocol = endpoint.protocol(); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); } /// Construct a basic_socket on an existing native socket. @@ -125,14 +131,50 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_socket(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_socket) + const protocol_type& protocol, const native_handle_type& native_socket) : basic_io_object(io_service) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_socket, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_socket, ec); + boost::asio::detail::throw_error(ec, "assign"); } +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_socket from another. + /** + * This constructor moves a socket from one object to another. + * + * @param other The other basic_socket object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket(io_service&) constructor. + */ + basic_socket(basic_socket&& other) + : basic_io_object( + BOOST_ASIO_MOVE_CAST(basic_socket)(other)) + { + } + + /// Move-assign a basic_socket from another. + /** + * This assignment operator moves a socket from one object to another. + * + * @param other The other basic_socket object from which the move will + * occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket(io_service&) constructor. + */ + basic_socket& operator=(basic_socket&& other) + { + basic_io_object::operator=( + BOOST_ASIO_MOVE_CAST(basic_socket)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Get a reference to the lowest layer. /** * This function returns a reference to the lowest layer in a stack of @@ -178,8 +220,8 @@ public: void open(const protocol_type& protocol = protocol_type()) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Open the socket using the specified protocol. @@ -204,7 +246,7 @@ public: boost::system::error_code open(const protocol_type& protocol, boost::system::error_code& ec) { - return this->service.open(this->implementation, protocol, ec); + return this->get_service().open(this->get_implementation(), protocol, ec); } /// Assign an existing native socket to the socket. @@ -217,11 +259,13 @@ public: * * @throws boost::system::system_error Thrown on failure. */ - void assign(const protocol_type& protocol, const native_type& native_socket) + void assign(const protocol_type& protocol, + const native_handle_type& native_socket) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_socket, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_socket, ec); + boost::asio::detail::throw_error(ec, "assign"); } /// Assign an existing native socket to the socket. @@ -235,16 +279,16 @@ public: * @param ec Set to indicate what error occurred, if any. */ boost::system::error_code assign(const protocol_type& protocol, - const native_type& native_socket, boost::system::error_code& ec) + const native_handle_type& native_socket, boost::system::error_code& ec) { - return this->service.assign(this->implementation, + return this->get_service().assign(this->get_implementation(), protocol, native_socket, ec); } /// Determine whether the socket is open. bool is_open() const { - return this->service.is_open(this->implementation); + return this->get_service().is_open(this->get_implementation()); } /// Close the socket. @@ -253,7 +297,8 @@ public: * or connect operations will be cancelled immediately, and will complete * with the boost::asio::error::operation_aborted error. * - * @throws boost::system::system_error Thrown on failure. + * @throws boost::system::system_error Thrown on failure. Note that, even if + * the function indicates an error, the underlying descriptor is closed. * * @note For portable behaviour with respect to graceful closure of a * connected socket, call shutdown() before closing the socket. @@ -261,8 +306,8 @@ public: void close() { boost::system::error_code ec; - this->service.close(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().close(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "close"); } /// Close the socket. @@ -271,7 +316,8 @@ public: * or connect operations will be cancelled immediately, and will complete * with the boost::asio::error::operation_aborted error. * - * @param ec Set to indicate what error occurred, if any. + * @param ec Set to indicate what error occurred, if any. Note that, even if + * the function indicates an error, the underlying descriptor is closed. * * @par Example * @code @@ -290,10 +336,10 @@ public: */ boost::system::error_code close(boost::system::error_code& ec) { - return this->service.close(this->implementation, ec); + return this->get_service().close(this->get_implementation(), ec); } - /// Get the native socket representation. + /// (Deprecated: Use native_handle().) Get the native socket representation. /** * This function may be used to obtain the underlying representation of the * socket. This is intended to allow access to native socket functionality @@ -301,7 +347,18 @@ public: */ native_type native() { - return this->service.native(this->implementation); + return this->get_service().native_handle(this->get_implementation()); + } + + /// Get the native socket representation. + /** + * This function may be used to obtain the underlying representation of the + * socket. This is intended to allow access to native socket functionality + * that is not otherwise provided. + */ + native_handle_type native_handle() + { + return this->get_service().native_handle(this->get_implementation()); } /// Cancel all asynchronous operations associated with the socket. @@ -348,8 +405,8 @@ public: void cancel() { boost::system::error_code ec; - this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().cancel(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "cancel"); } /// Cancel all asynchronous operations associated with the socket. @@ -395,7 +452,7 @@ public: #endif boost::system::error_code cancel(boost::system::error_code& ec) { - return this->service.cancel(this->implementation, ec); + return this->get_service().cancel(this->get_implementation(), ec); } /// Determine whether the socket is at the out-of-band data mark. @@ -411,8 +468,8 @@ public: bool at_mark() const { boost::system::error_code ec; - bool b = this->service.at_mark(this->implementation, ec); - boost::asio::detail::throw_error(ec); + bool b = this->get_service().at_mark(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "at_mark"); return b; } @@ -428,7 +485,7 @@ public: */ bool at_mark(boost::system::error_code& ec) const { - return this->service.at_mark(this->implementation, ec); + return this->get_service().at_mark(this->get_implementation(), ec); } /// Determine the number of bytes available for reading. @@ -444,8 +501,9 @@ public: std::size_t available() const { boost::system::error_code ec; - std::size_t s = this->service.available(this->implementation, ec); - boost::asio::detail::throw_error(ec); + std::size_t s = this->get_service().available( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "available"); return s; } @@ -461,7 +519,7 @@ public: */ std::size_t available(boost::system::error_code& ec) const { - return this->service.available(this->implementation, ec); + return this->get_service().available(this->get_implementation(), ec); } /// Bind the socket to the given local endpoint. @@ -485,8 +543,8 @@ public: void bind(const endpoint_type& endpoint) { boost::system::error_code ec; - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); } /// Bind the socket to the given local endpoint. @@ -515,7 +573,7 @@ public: boost::system::error_code bind(const endpoint_type& endpoint, boost::system::error_code& ec) { - return this->service.bind(this->implementation, endpoint, ec); + return this->get_service().bind(this->get_implementation(), endpoint, ec); } /// Connect the socket to the specified endpoint. @@ -546,11 +604,12 @@ public: boost::system::error_code ec; if (!is_open()) { - this->service.open(this->implementation, peer_endpoint.protocol(), ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), + peer_endpoint.protocol(), ec); + boost::asio::detail::throw_error(ec, "connect"); } - this->service.connect(this->implementation, peer_endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().connect(this->get_implementation(), peer_endpoint, ec); + boost::asio::detail::throw_error(ec, "connect"); } /// Connect the socket to the specified endpoint. @@ -586,14 +645,15 @@ public: { if (!is_open()) { - if (this->service.open(this->implementation, + if (this->get_service().open(this->get_implementation(), peer_endpoint.protocol(), ec)) { return ec; } } - return this->service.connect(this->implementation, peer_endpoint, ec); + return this->get_service().connect( + this->get_implementation(), peer_endpoint, ec); } /// Start an asynchronous connect. @@ -638,21 +698,28 @@ public: * @endcode */ template - void async_connect(const endpoint_type& peer_endpoint, ConnectHandler handler) + void async_connect(const endpoint_type& peer_endpoint, + BOOST_ASIO_MOVE_ARG(ConnectHandler) handler) { + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a ConnectHandler. + BOOST_ASIO_CONNECT_HANDLER_CHECK(ConnectHandler, handler) type_check; + if (!is_open()) { boost::system::error_code ec; - if (this->service.open(this->implementation, - peer_endpoint.protocol(), ec)) + const protocol_type protocol = peer_endpoint.protocol(); + if (this->get_service().open(this->get_implementation(), protocol, ec)) { this->get_io_service().post( - boost::asio::detail::bind_handler(handler, ec)); + boost::asio::detail::bind_handler( + BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler), ec)); return; } } - this->service.async_connect(this->implementation, peer_endpoint, handler); + this->get_service().async_connect(this->get_implementation(), + peer_endpoint, BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler)); } /// Set an option on the socket. @@ -693,8 +760,8 @@ public: void set_option(const SettableSocketOption& option) { boost::system::error_code ec; - this->service.set_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().set_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "set_option"); } /// Set an option on the socket. @@ -740,7 +807,8 @@ public: boost::system::error_code set_option(const SettableSocketOption& option, boost::system::error_code& ec) { - return this->service.set_option(this->implementation, option, ec); + return this->get_service().set_option( + this->get_implementation(), option, ec); } /// Get an option from the socket. @@ -782,8 +850,8 @@ public: void get_option(GettableSocketOption& option) const { boost::system::error_code ec; - this->service.get_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().get_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "get_option"); } /// Get an option from the socket. @@ -830,7 +898,8 @@ public: boost::system::error_code get_option(GettableSocketOption& option, boost::system::error_code& ec) const { - return this->service.get_option(this->implementation, option, ec); + return this->get_service().get_option( + this->get_implementation(), option, ec); } /// Perform an IO control command on the socket. @@ -859,8 +928,8 @@ public: void io_control(IoControlCommand& command) { boost::system::error_code ec; - this->service.io_control(this->implementation, command, ec); - boost::asio::detail::throw_error(ec); + this->get_service().io_control(this->get_implementation(), command, ec); + boost::asio::detail::throw_error(ec, "io_control"); } /// Perform an IO control command on the socket. @@ -894,7 +963,338 @@ public: boost::system::error_code io_control(IoControlCommand& command, boost::system::error_code& ec) { - return this->service.io_control(this->implementation, command, ec); + return this->get_service().io_control( + this->get_implementation(), command, ec); + } + + /// Gets the non-blocking mode of the socket. + /** + * @returns @c true if the socket's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + bool non_blocking() const + { + return this->get_service().non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the socket. + /** + * @param mode If @c true, the socket's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + void non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().non_blocking(this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "non_blocking"); + } + + /// Sets the non-blocking mode of the socket. + /** + * @param mode If @c true, the socket's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + boost::system::error_code non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().non_blocking( + this->get_implementation(), mode, ec); + } + + /// Gets the non-blocking mode of the native socket implementation. + /** + * This function is used to retrieve the non-blocking mode of the underlying + * native socket. This mode has no effect on the behaviour of the socket + * object's synchronous operations. + * + * @returns @c true if the underlying socket is in non-blocking mode and + * direct system calls may fail with boost::asio::error::would_block (or the + * equivalent system error). + * + * @note The current non-blocking mode is cached by the socket object. + * Consequently, the return value may be incorrect if the non-blocking mode + * was set directly on the native socket. + * + * @par Example + * This function is intended to allow the encapsulation of arbitrary + * non-blocking system calls as asynchronous operations, in a way that is + * transparent to the user of the socket object. The following example + * illustrates how Linux's @c sendfile system call might be encapsulated: + * @code template + * struct sendfile_op + * { + * tcp::socket& sock_; + * int fd_; + * Handler handler_; + * off_t offset_; + * std::size_t total_bytes_transferred_; + * + * // Function call operator meeting WriteHandler requirements. + * // Used as the handler for the async_write_some operation. + * void operator()(boost::system::error_code ec, std::size_t) + * { + * // Put the underlying socket into non-blocking mode. + * if (!ec) + * if (!sock_.native_non_blocking()) + * sock_.native_non_blocking(true, ec); + * + * if (!ec) + * { + * for (;;) + * { + * // Try the system call. + * errno = 0; + * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536); + * ec = boost::system::error_code(n < 0 ? errno : 0, + * boost::asio::error::get_system_category()); + * total_bytes_transferred_ += ec ? 0 : n; + * + * // Retry operation immediately if interrupted by signal. + * if (ec == boost::asio::error::interrupted) + * continue; + * + * // Check if we need to run the operation again. + * if (ec == boost::asio::error::would_block + * || ec == boost::asio::error::try_again) + * { + * // We have to wait for the socket to become ready again. + * sock_.async_write_some(boost::asio::null_buffers(), *this); + * return; + * } + * + * if (ec || n == 0) + * { + * // An error occurred, or we have reached the end of the file. + * // Either way we must exit the loop so we can call the handler. + * break; + * } + * + * // Loop around to try calling sendfile again. + * } + * } + * + * // Pass result back to user's handler. + * handler_(ec, total_bytes_transferred_); + * } + * }; + * + * template + * void async_sendfile(tcp::socket& sock, int fd, Handler h) + * { + * sendfile_op op = { sock, fd, h, 0, 0 }; + * sock.async_write_some(boost::asio::null_buffers(), op); + * } @endcode + */ + bool native_non_blocking() const + { + return this->get_service().native_non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the native socket implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native socket. It has no effect on the behaviour of the socket object's + * synchronous operations. + * + * @param mode If @c true, the underlying socket is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @throws boost::system::system_error Thrown on failure. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + * + * @par Example + * This function is intended to allow the encapsulation of arbitrary + * non-blocking system calls as asynchronous operations, in a way that is + * transparent to the user of the socket object. The following example + * illustrates how Linux's @c sendfile system call might be encapsulated: + * @code template + * struct sendfile_op + * { + * tcp::socket& sock_; + * int fd_; + * Handler handler_; + * off_t offset_; + * std::size_t total_bytes_transferred_; + * + * // Function call operator meeting WriteHandler requirements. + * // Used as the handler for the async_write_some operation. + * void operator()(boost::system::error_code ec, std::size_t) + * { + * // Put the underlying socket into non-blocking mode. + * if (!ec) + * if (!sock_.native_non_blocking()) + * sock_.native_non_blocking(true, ec); + * + * if (!ec) + * { + * for (;;) + * { + * // Try the system call. + * errno = 0; + * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536); + * ec = boost::system::error_code(n < 0 ? errno : 0, + * boost::asio::error::get_system_category()); + * total_bytes_transferred_ += ec ? 0 : n; + * + * // Retry operation immediately if interrupted by signal. + * if (ec == boost::asio::error::interrupted) + * continue; + * + * // Check if we need to run the operation again. + * if (ec == boost::asio::error::would_block + * || ec == boost::asio::error::try_again) + * { + * // We have to wait for the socket to become ready again. + * sock_.async_write_some(boost::asio::null_buffers(), *this); + * return; + * } + * + * if (ec || n == 0) + * { + * // An error occurred, or we have reached the end of the file. + * // Either way we must exit the loop so we can call the handler. + * break; + * } + * + * // Loop around to try calling sendfile again. + * } + * } + * + * // Pass result back to user's handler. + * handler_(ec, total_bytes_transferred_); + * } + * }; + * + * template + * void async_sendfile(tcp::socket& sock, int fd, Handler h) + * { + * sendfile_op op = { sock, fd, h, 0, 0 }; + * sock.async_write_some(boost::asio::null_buffers(), op); + * } @endcode + */ + void native_non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "native_non_blocking"); + } + + /// Sets the non-blocking mode of the native socket implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native socket. It has no effect on the behaviour of the socket object's + * synchronous operations. + * + * @param mode If @c true, the underlying socket is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @param ec Set to indicate what error occurred, if any. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + * + * @par Example + * This function is intended to allow the encapsulation of arbitrary + * non-blocking system calls as asynchronous operations, in a way that is + * transparent to the user of the socket object. The following example + * illustrates how Linux's @c sendfile system call might be encapsulated: + * @code template + * struct sendfile_op + * { + * tcp::socket& sock_; + * int fd_; + * Handler handler_; + * off_t offset_; + * std::size_t total_bytes_transferred_; + * + * // Function call operator meeting WriteHandler requirements. + * // Used as the handler for the async_write_some operation. + * void operator()(boost::system::error_code ec, std::size_t) + * { + * // Put the underlying socket into non-blocking mode. + * if (!ec) + * if (!sock_.native_non_blocking()) + * sock_.native_non_blocking(true, ec); + * + * if (!ec) + * { + * for (;;) + * { + * // Try the system call. + * errno = 0; + * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536); + * ec = boost::system::error_code(n < 0 ? errno : 0, + * boost::asio::error::get_system_category()); + * total_bytes_transferred_ += ec ? 0 : n; + * + * // Retry operation immediately if interrupted by signal. + * if (ec == boost::asio::error::interrupted) + * continue; + * + * // Check if we need to run the operation again. + * if (ec == boost::asio::error::would_block + * || ec == boost::asio::error::try_again) + * { + * // We have to wait for the socket to become ready again. + * sock_.async_write_some(boost::asio::null_buffers(), *this); + * return; + * } + * + * if (ec || n == 0) + * { + * // An error occurred, or we have reached the end of the file. + * // Either way we must exit the loop so we can call the handler. + * break; + * } + * + * // Loop around to try calling sendfile again. + * } + * } + * + * // Pass result back to user's handler. + * handler_(ec, total_bytes_transferred_); + * } + * }; + * + * template + * void async_sendfile(tcp::socket& sock, int fd, Handler h) + * { + * sendfile_op op = { sock, fd, h, 0, 0 }; + * sock.async_write_some(boost::asio::null_buffers(), op); + * } @endcode + */ + boost::system::error_code native_non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); } /// Get the local endpoint of the socket. @@ -915,8 +1315,9 @@ public: endpoint_type local_endpoint() const { boost::system::error_code ec; - endpoint_type ep = this->service.local_endpoint(this->implementation, ec); - boost::asio::detail::throw_error(ec); + endpoint_type ep = this->get_service().local_endpoint( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "local_endpoint"); return ep; } @@ -943,7 +1344,7 @@ public: */ endpoint_type local_endpoint(boost::system::error_code& ec) const { - return this->service.local_endpoint(this->implementation, ec); + return this->get_service().local_endpoint(this->get_implementation(), ec); } /// Get the remote endpoint of the socket. @@ -964,8 +1365,9 @@ public: endpoint_type remote_endpoint() const { boost::system::error_code ec; - endpoint_type ep = this->service.remote_endpoint(this->implementation, ec); - boost::asio::detail::throw_error(ec); + endpoint_type ep = this->get_service().remote_endpoint( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "remote_endpoint"); return ep; } @@ -992,7 +1394,7 @@ public: */ endpoint_type remote_endpoint(boost::system::error_code& ec) const { - return this->service.remote_endpoint(this->implementation, ec); + return this->get_service().remote_endpoint(this->get_implementation(), ec); } /// Disable sends or receives on the socket. @@ -1015,8 +1417,8 @@ public: void shutdown(shutdown_type what) { boost::system::error_code ec; - this->service.shutdown(this->implementation, what, ec); - boost::asio::detail::throw_error(ec); + this->get_service().shutdown(this->get_implementation(), what, ec); + boost::asio::detail::throw_error(ec, "shutdown"); } /// Disable sends or receives on the socket. @@ -1044,7 +1446,7 @@ public: boost::system::error_code shutdown(shutdown_type what, boost::system::error_code& ec) { - return this->service.shutdown(this->implementation, what, ec); + return this->get_service().shutdown(this->get_implementation(), what, ec); } protected: diff --git a/3rdParty/Boost/src/boost/asio/basic_socket_acceptor.hpp b/3rdParty/Boost/src/boost/asio/basic_socket_acceptor.hpp index a877bc3..5a3b0f7 100644 --- a/3rdParty/Boost/src/boost/asio/basic_socket_acceptor.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_socket_acceptor.hpp @@ -2,7 +2,7 @@ // basic_socket_acceptor.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -55,8 +56,12 @@ class basic_socket_acceptor public socket_base { public: + /// (Deprecated: Use native_handle_type.) The native representation of an + /// acceptor. + typedef typename SocketAcceptorService::native_handle_type native_type; + /// The native representation of an acceptor. - typedef typename SocketAcceptorService::native_type native_type; + typedef typename SocketAcceptorService::native_handle_type native_handle_type; /// The protocol type. typedef Protocol protocol_type; @@ -96,8 +101,8 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Construct an acceptor opened on the given endpoint. @@ -132,19 +137,20 @@ public: : basic_io_object(io_service) { boost::system::error_code ec; - this->service.open(this->implementation, endpoint.protocol(), ec); - boost::asio::detail::throw_error(ec); + const protocol_type protocol = endpoint.protocol(); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); if (reuse_addr) { - this->service.set_option(this->implementation, + this->get_service().set_option(this->get_implementation(), socket_base::reuse_address(true), ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "set_option"); } - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); - this->service.listen(this->implementation, + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); + this->get_service().listen(this->get_implementation(), socket_base::max_connections, ec); - boost::asio::detail::throw_error(ec); + boost::asio::detail::throw_error(ec, "listen"); } /// Construct a basic_socket_acceptor on an existing native acceptor. @@ -163,14 +169,50 @@ public: * @throws boost::system::system_error Thrown on failure. */ basic_socket_acceptor(boost::asio::io_service& io_service, - const protocol_type& protocol, const native_type& native_acceptor) + const protocol_type& protocol, const native_handle_type& native_acceptor) : basic_io_object(io_service) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_acceptor, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_acceptor, ec); + boost::asio::detail::throw_error(ec, "assign"); + } + +#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Move-construct a basic_socket_acceptor from another. + /** + * This constructor moves an acceptor from one object to another. + * + * @param other The other basic_socket_acceptor object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket_acceptor(io_service&) constructor. + */ + basic_socket_acceptor(basic_socket_acceptor&& other) + : basic_io_object( + BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other)) + { } + /// Move-assign a basic_socket_acceptor from another. + /** + * This assignment operator moves an acceptor from one object to another. + * + * @param other The other basic_socket_acceptor object from which the move + * will occur. + * + * @note Following the move, the moved-from object is in the same state as if + * constructed using the @c basic_socket_acceptor(io_service&) constructor. + */ + basic_socket_acceptor& operator=(basic_socket_acceptor&& other) + { + basic_io_object::operator=( + BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other)); + return *this; + } +#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) + /// Open the acceptor using the specified protocol. /** * This function opens the socket acceptor so that it will use the specified @@ -189,8 +231,8 @@ public: void open(const protocol_type& protocol = protocol_type()) { boost::system::error_code ec; - this->service.open(this->implementation, protocol, ec); - boost::asio::detail::throw_error(ec); + this->get_service().open(this->get_implementation(), protocol, ec); + boost::asio::detail::throw_error(ec, "open"); } /// Open the acceptor using the specified protocol. @@ -216,7 +258,7 @@ public: boost::system::error_code open(const protocol_type& protocol, boost::system::error_code& ec) { - return this->service.open(this->implementation, protocol, ec); + return this->get_service().open(this->get_implementation(), protocol, ec); } /// Assigns an existing native acceptor to the acceptor. @@ -229,11 +271,13 @@ public: * * @throws boost::system::system_error Thrown on failure. */ - void assign(const protocol_type& protocol, const native_type& native_acceptor) + void assign(const protocol_type& protocol, + const native_handle_type& native_acceptor) { boost::system::error_code ec; - this->service.assign(this->implementation, protocol, native_acceptor, ec); - boost::asio::detail::throw_error(ec); + this->get_service().assign(this->get_implementation(), + protocol, native_acceptor, ec); + boost::asio::detail::throw_error(ec, "assign"); } /// Assigns an existing native acceptor to the acceptor. @@ -247,16 +291,16 @@ public: * @param ec Set to indicate what error occurred, if any. */ boost::system::error_code assign(const protocol_type& protocol, - const native_type& native_acceptor, boost::system::error_code& ec) + const native_handle_type& native_acceptor, boost::system::error_code& ec) { - return this->service.assign(this->implementation, + return this->get_service().assign(this->get_implementation(), protocol, native_acceptor, ec); } /// Determine whether the acceptor is open. bool is_open() const { - return this->service.is_open(this->implementation); + return this->get_service().is_open(this->get_implementation()); } /// Bind the acceptor to the given local endpoint. @@ -279,8 +323,8 @@ public: void bind(const endpoint_type& endpoint) { boost::system::error_code ec; - this->service.bind(this->implementation, endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().bind(this->get_implementation(), endpoint, ec); + boost::asio::detail::throw_error(ec, "bind"); } /// Bind the acceptor to the given local endpoint. @@ -308,7 +352,7 @@ public: boost::system::error_code bind(const endpoint_type& endpoint, boost::system::error_code& ec) { - return this->service.bind(this->implementation, endpoint, ec); + return this->get_service().bind(this->get_implementation(), endpoint, ec); } /// Place the acceptor into the state where it will listen for new @@ -324,8 +368,8 @@ public: void listen(int backlog = socket_base::max_connections) { boost::system::error_code ec; - this->service.listen(this->implementation, backlog, ec); - boost::asio::detail::throw_error(ec); + this->get_service().listen(this->get_implementation(), backlog, ec); + boost::asio::detail::throw_error(ec, "listen"); } /// Place the acceptor into the state where it will listen for new @@ -352,7 +396,7 @@ public: */ boost::system::error_code listen(int backlog, boost::system::error_code& ec) { - return this->service.listen(this->implementation, backlog, ec); + return this->get_service().listen(this->get_implementation(), backlog, ec); } /// Close the acceptor. @@ -368,8 +412,8 @@ public: void close() { boost::system::error_code ec; - this->service.close(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().close(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "close"); } /// Close the acceptor. @@ -396,10 +440,10 @@ public: */ boost::system::error_code close(boost::system::error_code& ec) { - return this->service.close(this->implementation, ec); + return this->get_service().close(this->get_implementation(), ec); } - /// Get the native acceptor representation. + /// (Deprecated: Use native_handle().) Get the native acceptor representation. /** * This function may be used to obtain the underlying representation of the * acceptor. This is intended to allow access to native acceptor functionality @@ -407,7 +451,18 @@ public: */ native_type native() { - return this->service.native(this->implementation); + return this->get_service().native_handle(this->get_implementation()); + } + + /// Get the native acceptor representation. + /** + * This function may be used to obtain the underlying representation of the + * acceptor. This is intended to allow access to native acceptor functionality + * that is not otherwise provided. + */ + native_handle_type native_handle() + { + return this->get_service().native_handle(this->get_implementation()); } /// Cancel all asynchronous operations associated with the acceptor. @@ -421,8 +476,8 @@ public: void cancel() { boost::system::error_code ec; - this->service.cancel(this->implementation, ec); - boost::asio::detail::throw_error(ec); + this->get_service().cancel(this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "cancel"); } /// Cancel all asynchronous operations associated with the acceptor. @@ -435,7 +490,7 @@ public: */ boost::system::error_code cancel(boost::system::error_code& ec) { - return this->service.cancel(this->implementation, ec); + return this->get_service().cancel(this->get_implementation(), ec); } /// Set an option on the acceptor. @@ -463,8 +518,8 @@ public: void set_option(const SettableSocketOption& option) { boost::system::error_code ec; - this->service.set_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().set_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "set_option"); } /// Set an option on the acceptor. @@ -497,7 +552,8 @@ public: boost::system::error_code set_option(const SettableSocketOption& option, boost::system::error_code& ec) { - return this->service.set_option(this->implementation, option, ec); + return this->get_service().set_option( + this->get_implementation(), option, ec); } /// Get an option from the acceptor. @@ -526,8 +582,8 @@ public: void get_option(GettableSocketOption& option) { boost::system::error_code ec; - this->service.get_option(this->implementation, option, ec); - boost::asio::detail::throw_error(ec); + this->get_service().get_option(this->get_implementation(), option, ec); + boost::asio::detail::throw_error(ec, "get_option"); } /// Get an option from the acceptor. @@ -561,7 +617,189 @@ public: boost::system::error_code get_option(GettableSocketOption& option, boost::system::error_code& ec) { - return this->service.get_option(this->implementation, option, ec); + return this->get_service().get_option( + this->get_implementation(), option, ec); + } + + /// Perform an IO control command on the acceptor. + /** + * This function is used to execute an IO control command on the acceptor. + * + * @param command The IO control command to be performed on the acceptor. + * + * @throws boost::system::system_error Thrown on failure. + * + * @sa IoControlCommand @n + * boost::asio::socket_base::non_blocking_io + * + * @par Example + * Getting the number of bytes ready to read: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::non_blocking_io command(true); + * socket.io_control(command); + * @endcode + */ + template + void io_control(IoControlCommand& command) + { + boost::system::error_code ec; + this->get_service().io_control(this->get_implementation(), command, ec); + boost::asio::detail::throw_error(ec, "io_control"); + } + + /// Perform an IO control command on the acceptor. + /** + * This function is used to execute an IO control command on the acceptor. + * + * @param command The IO control command to be performed on the acceptor. + * + * @param ec Set to indicate what error occurred, if any. + * + * @sa IoControlCommand @n + * boost::asio::socket_base::non_blocking_io + * + * @par Example + * Getting the number of bytes ready to read: + * @code + * boost::asio::ip::tcp::acceptor acceptor(io_service); + * ... + * boost::asio::ip::tcp::acceptor::non_blocking_io command(true); + * boost::system::error_code ec; + * socket.io_control(command, ec); + * if (ec) + * { + * // An error occurred. + * } + * @endcode + */ + template + boost::system::error_code io_control(IoControlCommand& command, + boost::system::error_code& ec) + { + return this->get_service().io_control( + this->get_implementation(), command, ec); + } + + /// Gets the non-blocking mode of the acceptor. + /** + * @returns @c true if the acceptor's synchronous operations will fail with + * boost::asio::error::would_block if they are unable to perform the requested + * operation immediately. If @c false, synchronous operations will block + * until complete. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + bool non_blocking() const + { + return this->get_service().non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the acceptor. + /** + * @param mode If @c true, the acceptor's synchronous operations will fail + * with boost::asio::error::would_block if they are unable to perform the + * requested operation immediately. If @c false, synchronous operations will + * block until complete. + * + * @throws boost::system::system_error Thrown on failure. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + void non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().non_blocking(this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "non_blocking"); + } + + /// Sets the non-blocking mode of the acceptor. + /** + * @param mode If @c true, the acceptor's synchronous operations will fail + * with boost::asio::error::would_block if they are unable to perform the + * requested operation immediately. If @c false, synchronous operations will + * block until complete. + * + * @param ec Set to indicate what error occurred, if any. + * + * @note The non-blocking mode has no effect on the behaviour of asynchronous + * operations. Asynchronous operations will never fail with the error + * boost::asio::error::would_block. + */ + boost::system::error_code non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().non_blocking( + this->get_implementation(), mode, ec); + } + + /// Gets the non-blocking mode of the native acceptor implementation. + /** + * This function is used to retrieve the non-blocking mode of the underlying + * native acceptor. This mode has no effect on the behaviour of the acceptor + * object's synchronous operations. + * + * @returns @c true if the underlying acceptor is in non-blocking mode and + * direct system calls may fail with boost::asio::error::would_block (or the + * equivalent system error). + * + * @note The current non-blocking mode is cached by the acceptor object. + * Consequently, the return value may be incorrect if the non-blocking mode + * was set directly on the native acceptor. + */ + bool native_non_blocking() const + { + return this->get_service().native_non_blocking(this->get_implementation()); + } + + /// Sets the non-blocking mode of the native acceptor implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native acceptor. It has no effect on the behaviour of the acceptor object's + * synchronous operations. + * + * @param mode If @c true, the underlying acceptor is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @throws boost::system::system_error Thrown on failure. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + */ + void native_non_blocking(bool mode) + { + boost::system::error_code ec; + this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); + boost::asio::detail::throw_error(ec, "native_non_blocking"); + } + + /// Sets the non-blocking mode of the native acceptor implementation. + /** + * This function is used to modify the non-blocking mode of the underlying + * native acceptor. It has no effect on the behaviour of the acceptor object's + * synchronous operations. + * + * @param mode If @c true, the underlying acceptor is put into non-blocking + * mode and direct system calls may fail with boost::asio::error::would_block + * (or the equivalent system error). + * + * @param ec Set to indicate what error occurred, if any. If the @c mode is + * @c false, but the current value of @c non_blocking() is @c true, this + * function fails with boost::asio::error::invalid_argument, as the + * combination does not make sense. + */ + boost::system::error_code native_non_blocking( + bool mode, boost::system::error_code& ec) + { + return this->get_service().native_non_blocking( + this->get_implementation(), mode, ec); } /// Get the local endpoint of the acceptor. @@ -582,8 +820,9 @@ public: endpoint_type local_endpoint() const { boost::system::error_code ec; - endpoint_type ep = this->service.local_endpoint(this->implementation, ec); - boost::asio::detail::throw_error(ec); + endpoint_type ep = this->get_service().local_endpoint( + this->get_implementation(), ec); + boost::asio::detail::throw_error(ec, "local_endpoint"); return ep; } @@ -611,7 +850,7 @@ public: */ endpoint_type local_endpoint(boost::system::error_code& ec) const { - return this->service.local_endpoint(this->implementation, ec); + return this->get_service().local_endpoint(this->get_implementation(), ec); } /// Accept a new connection. @@ -636,8 +875,8 @@ public: void accept(basic_socket& peer) { boost::system::error_code ec; - this->service.accept(this->implementation, peer, 0, ec); - boost::asio::detail::throw_error(ec); + this->get_service().accept(this->get_implementation(), peer, 0, ec); + boost::asio::detail::throw_error(ec, "accept"); } /// Accept a new connection. @@ -668,7 +907,7 @@ public: basic_socket& peer, boost::system::error_code& ec) { - return this->service.accept(this->implementation, peer, 0, ec); + return this->get_service().accept(this->get_implementation(), peer, 0, ec); } /// Start an asynchronous accept. @@ -711,9 +950,14 @@ public: */ template void async_accept(basic_socket& peer, - AcceptHandler handler) + BOOST_ASIO_MOVE_ARG(AcceptHandler) handler) { - this->service.async_accept(this->implementation, peer, 0, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a AcceptHandler. + BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check; + + this->get_service().async_accept(this->get_implementation(), + peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler)); } /// Accept a new connection and obtain the endpoint of the peer @@ -744,8 +988,9 @@ public: endpoint_type& peer_endpoint) { boost::system::error_code ec; - this->service.accept(this->implementation, peer, &peer_endpoint, ec); - boost::asio::detail::throw_error(ec); + this->get_service().accept(this->get_implementation(), + peer, &peer_endpoint, ec); + boost::asio::detail::throw_error(ec, "accept"); } /// Accept a new connection and obtain the endpoint of the peer @@ -781,7 +1026,8 @@ public: basic_socket& peer, endpoint_type& peer_endpoint, boost::system::error_code& ec) { - return this->service.accept(this->implementation, peer, &peer_endpoint, ec); + return this->get_service().accept( + this->get_implementation(), peer, &peer_endpoint, ec); } /// Start an asynchronous accept. @@ -812,10 +1058,14 @@ public: */ template void async_accept(basic_socket& peer, - endpoint_type& peer_endpoint, AcceptHandler handler) + endpoint_type& peer_endpoint, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler) { - this->service.async_accept(this->implementation, - peer, &peer_endpoint, handler); + // If you get an error on the following line it means that your handler does + // not meet the documented type requirements for a AcceptHandler. + BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check; + + this->get_service().async_accept(this->get_implementation(), peer, + &peer_endpoint, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler)); } }; diff --git a/3rdParty/Boost/src/boost/asio/basic_socket_iostream.hpp b/3rdParty/Boost/src/boost/asio/basic_socket_iostream.hpp index 142f404..6fae085 100644 --- a/3rdParty/Boost/src/boost/asio/basic_socket_iostream.hpp +++ b/3rdParty/Boost/src/boost/asio/basic_socket_iostream.hpp @@ -2,7 +2,7 @@ // basic_socket_iostream.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // 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) @@ -19,36 +19,41 @@ #if !defined(BOOST_NO_IOSTREAM) -#include -#include -#include -#include #include #include #include -#if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) -#define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5 -#endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) +#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) + +# include +# include +# include +# include + +# if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) +# define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5 +# endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY) // A macro that should expand to: // template // explicit basic_socket_iostream(T1 x1, ..., Tn xn) // : basic_iostream(&this->boost::base_from_member< -// basic_socket_streambuf >::member) +// basic_socket_streambuf >::member) // { // if (rdbuf()->connect(x1, ..., xn) == 0) // this->setstate(std::ios_base::failbit); // } // This macro should only persist within this file. -#define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \ +# define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \ template \ explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \ : std::basic_iostream(&this->boost::base_from_member< \ - basic_socket_streambuf >::member) \ + basic_socket_streambuf >::member) \ { \ - tie(this); \ + this->setf(std::ios_base::unitbuf); \ if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \ this->setstate(std::ios_base::failbit); \ } \ @@ -63,7 +68,7 @@ // } // This macro should only persist within this file. -#define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \ +# define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \ template \ void connect(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \ { \ @@ -72,6 +77,8 @@ } \ /**/ +#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) + #include namespace boost { @@ -79,19 +86,33 @@ namespace asio { /// Iostream interface for a socket. template > + typename StreamSocketService = stream_socket_service, + typename Time = boost::posix_time::ptime, + typename TimeTraits = boost::asio::time_traits