diff options
Diffstat (limited to '3rdParty/Boost/boost/asio/impl')
m--------- | 3rdParty/Boost | 0 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/asio/impl/io_service.ipp | 226 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/asio/impl/read.ipp | 349 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/asio/impl/read_at.ipp | 367 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/asio/impl/read_until.ipp | 989 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/asio/impl/serial_port_base.ipp | 543 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/asio/impl/write.ipp | 296 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/asio/impl/write_at.ipp | 313 |
8 files changed, 0 insertions, 3083 deletions
diff --git a/3rdParty/Boost b/3rdParty/Boost new file mode 160000 +Subproject 3bbdbc8cf1996f23d9a366da8bac0f97be6ad79 diff --git a/3rdParty/Boost/boost/asio/impl/io_service.ipp b/3rdParty/Boost/boost/asio/impl/io_service.ipp deleted file mode 100644 index e936f36..0000000 --- a/3rdParty/Boost/boost/asio/impl/io_service.ipp +++ /dev/null @@ -1,226 +0,0 @@ -// -// io_service.ipp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2008 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_IO_SERVICE_IPP -#define BOOST_ASIO_IO_SERVICE_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include <boost/asio/detail/push_options.hpp> - -#include <boost/asio/detail/push_options.hpp> -#include <limits> -#include <boost/asio/detail/pop_options.hpp> - -#include <boost/asio/detail/dev_poll_reactor.hpp> -#include <boost/asio/detail/epoll_reactor.hpp> -#include <boost/asio/detail/kqueue_reactor.hpp> -#include <boost/asio/detail/select_reactor.hpp> -#include <boost/asio/detail/service_registry.hpp> -#include <boost/asio/detail/task_io_service.hpp> -#include <boost/asio/detail/throw_error.hpp> -#include <boost/asio/detail/win_iocp_io_service.hpp> - -namespace boost { -namespace asio { - -inline io_service::io_service() - : service_registry_(new boost::asio::detail::service_registry(*this)), - impl_(service_registry_->use_service<impl_type>()) -{ - impl_.init((std::numeric_limits<std::size_t>::max)()); -} - -inline io_service::io_service(std::size_t concurrency_hint) - : service_registry_(new boost::asio::detail::service_registry(*this)), - impl_(service_registry_->use_service<impl_type>()) -{ - impl_.init(concurrency_hint); -} - -inline io_service::~io_service() -{ - delete service_registry_; -} - -inline std::size_t io_service::run() -{ - boost::system::error_code ec; - std::size_t s = impl_.run(ec); - boost::asio::detail::throw_error(ec); - return s; -} - -inline std::size_t io_service::run(boost::system::error_code& ec) -{ - return impl_.run(ec); -} - -inline std::size_t io_service::run_one() -{ - boost::system::error_code ec; - std::size_t s = impl_.run_one(ec); - boost::asio::detail::throw_error(ec); - return s; -} - -inline std::size_t io_service::run_one(boost::system::error_code& ec) -{ - return impl_.run_one(ec); -} - -inline std::size_t io_service::poll() -{ - boost::system::error_code ec; - std::size_t s = impl_.poll(ec); - boost::asio::detail::throw_error(ec); - return s; -} - -inline std::size_t io_service::poll(boost::system::error_code& ec) -{ - return impl_.poll(ec); -} - -inline std::size_t io_service::poll_one() -{ - boost::system::error_code ec; - std::size_t s = impl_.poll_one(ec); - boost::asio::detail::throw_error(ec); - return s; -} - -inline std::size_t io_service::poll_one(boost::system::error_code& ec) -{ - return impl_.poll_one(ec); -} - -inline void io_service::stop() -{ - impl_.stop(); -} - -inline void io_service::reset() -{ - impl_.reset(); -} - -template <typename Handler> -inline void io_service::dispatch(Handler handler) -{ - impl_.dispatch(handler); -} - -template <typename Handler> -inline void io_service::post(Handler handler) -{ - impl_.post(handler); -} - -template <typename Handler> -#if defined(GENERATING_DOCUMENTATION) -unspecified -#else -inline detail::wrapped_handler<io_service&, Handler> -#endif -io_service::wrap(Handler handler) -{ - return detail::wrapped_handler<io_service&, Handler>(*this, handler); -} - -inline io_service::work::work(boost::asio::io_service& io_service) - : io_service_(io_service) -{ - io_service_.impl_.work_started(); -} - -inline io_service::work::work(const work& other) - : io_service_(other.io_service_) -{ - io_service_.impl_.work_started(); -} - -inline io_service::work::~work() -{ - io_service_.impl_.work_finished(); -} - -inline boost::asio::io_service& io_service::work::io_service() -{ - return io_service_; -} - -inline boost::asio::io_service& io_service::work::get_io_service() -{ - return io_service_; -} - -inline io_service::service::service(boost::asio::io_service& owner) - : owner_(owner), - type_info_(0), - next_(0) -{ -} - -inline io_service::service::~service() -{ -} - -inline boost::asio::io_service& io_service::service::io_service() -{ - return owner_; -} - -inline boost::asio::io_service& io_service::service::get_io_service() -{ - return owner_; -} - -template <typename Service> -inline Service& use_service(io_service& ios) -{ - // Check that Service meets the necessary type requirements. - (void)static_cast<io_service::service*>(static_cast<Service*>(0)); - (void)static_cast<const io_service::id*>(&Service::id); - - return ios.service_registry_->template use_service<Service>(); -} - -template <typename Service> -void add_service(io_service& ios, Service* svc) -{ - // Check that Service meets the necessary type requirements. - (void)static_cast<io_service::service*>(static_cast<Service*>(0)); - (void)static_cast<const io_service::id*>(&Service::id); - - if (&ios != &svc->io_service()) - boost::throw_exception(invalid_service_owner()); - if (!ios.service_registry_->template add_service<Service>(svc)) - boost::throw_exception(service_already_exists()); -} - -template <typename Service> -bool has_service(io_service& ios) -{ - // Check that Service meets the necessary type requirements. - (void)static_cast<io_service::service*>(static_cast<Service*>(0)); - (void)static_cast<const io_service::id*>(&Service::id); - - return ios.service_registry_->template has_service<Service>(); -} - -} // namespace asio -} // namespace boost - -#include <boost/asio/detail/pop_options.hpp> - -#endif // BOOST_ASIO_IO_SERVICE_IPP diff --git a/3rdParty/Boost/boost/asio/impl/read.ipp b/3rdParty/Boost/boost/asio/impl/read.ipp deleted file mode 100644 index 453f697..0000000 --- a/3rdParty/Boost/boost/asio/impl/read.ipp +++ /dev/null @@ -1,349 +0,0 @@ -// -// read.ipp -// ~~~~~~~~ -// -// Copyright (c) 2003-2008 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_READ_IPP -#define BOOST_ASIO_READ_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include <boost/asio/detail/push_options.hpp> - -#include <boost/asio/detail/push_options.hpp> -#include <algorithm> -#include <boost/asio/detail/pop_options.hpp> - -#include <boost/asio/buffer.hpp> -#include <boost/asio/completion_condition.hpp> -#include <boost/asio/error.hpp> -#include <boost/asio/detail/bind_handler.hpp> -#include <boost/asio/detail/consuming_buffers.hpp> -#include <boost/asio/detail/handler_alloc_helpers.hpp> -#include <boost/asio/detail/handler_invoke_helpers.hpp> -#include <boost/asio/detail/throw_error.hpp> - -namespace boost { -namespace asio { - -template <typename SyncReadStream, typename MutableBufferSequence, - typename CompletionCondition> -std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - ec = boost::system::error_code(); - boost::asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> tmp(buffers); - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - while (tmp.begin() != tmp.end()) - { - std::size_t bytes_transferred = s.read_some(tmp, ec); - tmp.consume(bytes_transferred); - total_transferred += bytes_transferred; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - } - return total_transferred; -} - -template <typename SyncReadStream, typename MutableBufferSequence> -inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read(s, buffers, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncReadStream, typename MutableBufferSequence, - typename CompletionCondition> -inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read(s, buffers, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncReadStream, typename Allocator, - typename CompletionCondition> -std::size_t read(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - ec = boost::system::error_code(); - std::size_t total_transferred = 0; - std::size_t max_size = detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred)); - std::size_t bytes_available = std::min<std::size_t>(512, - std::min<std::size_t>(max_size, b.max_size() - b.size())); - while (bytes_available > 0) - { - std::size_t bytes_transferred = s.read_some(b.prepare(bytes_available), ec); - b.commit(bytes_transferred); - total_transferred += bytes_transferred; - max_size = detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred)); - bytes_available = std::min<std::size_t>(512, - std::min<std::size_t>(max_size, b.max_size() - b.size())); - } - return total_transferred; -} - -template <typename SyncReadStream, typename Allocator> -inline std::size_t read(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read(s, b, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncReadStream, typename Allocator, - typename CompletionCondition> -inline std::size_t read(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read(s, b, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -namespace detail -{ - template <typename AsyncReadStream, typename MutableBufferSequence, - typename CompletionCondition, typename ReadHandler> - class read_handler - { - public: - typedef boost::asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> buffers_type; - - read_handler(AsyncReadStream& stream, const buffers_type& buffers, - CompletionCondition completion_condition, ReadHandler handler) - : stream_(stream), - buffers_(buffers), - total_transferred_(0), - completion_condition_(completion_condition), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - total_transferred_ += bytes_transferred; - buffers_.consume(bytes_transferred); - buffers_.set_max_size(detail::adapt_completion_condition_result( - completion_condition_(ec, total_transferred_))); - if (buffers_.begin() == buffers_.end()) - { - handler_(ec, total_transferred_); - } - else - { - stream_.async_read_some(buffers_, *this); - } - } - - //private: - AsyncReadStream& stream_; - buffers_type buffers_; - std::size_t total_transferred_; - CompletionCondition completion_condition_; - ReadHandler handler_; - }; - - template <typename AsyncReadStream, typename MutableBufferSequence, - typename CompletionCondition, typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_handler<AsyncReadStream, MutableBufferSequence, - CompletionCondition, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncReadStream, typename MutableBufferSequence, - typename CompletionCondition, typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_handler<AsyncReadStream, MutableBufferSequence, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncReadStream, - typename MutableBufferSequence, typename CompletionCondition, - typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_handler<AsyncReadStream, MutableBufferSequence, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncReadStream, typename MutableBufferSequence, - typename CompletionCondition, typename ReadHandler> -inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, ReadHandler handler) -{ - boost::asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> tmp(buffers); - - boost::system::error_code ec; - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - if (tmp.begin() == tmp.end()) - { - s.get_io_service().post(detail::bind_handler( - handler, ec, total_transferred)); - return; - } - - s.async_read_some(tmp, - detail::read_handler<AsyncReadStream, MutableBufferSequence, - CompletionCondition, ReadHandler>( - s, tmp, completion_condition, handler)); -} - -template <typename AsyncReadStream, typename MutableBufferSequence, - typename ReadHandler> -inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, - ReadHandler handler) -{ - async_read(s, buffers, transfer_all(), handler); -} - -namespace detail -{ - template <typename AsyncReadStream, typename Allocator, - typename CompletionCondition, typename ReadHandler> - class read_streambuf_handler - { - public: - read_streambuf_handler(AsyncReadStream& stream, - basic_streambuf<Allocator>& streambuf, - CompletionCondition completion_condition, ReadHandler handler) - : stream_(stream), - streambuf_(streambuf), - total_transferred_(0), - completion_condition_(completion_condition), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - total_transferred_ += bytes_transferred; - streambuf_.commit(bytes_transferred); - std::size_t max_size = detail::adapt_completion_condition_result( - completion_condition_(ec, total_transferred_)); - std::size_t bytes_available = std::min<std::size_t>(512, - std::min<std::size_t>(max_size, - streambuf_.max_size() - streambuf_.size())); - if (bytes_available == 0) - { - handler_(ec, total_transferred_); - } - else - { - stream_.async_read_some(streambuf_.prepare(bytes_available), *this); - } - } - - //private: - AsyncReadStream& stream_; - boost::asio::basic_streambuf<Allocator>& streambuf_; - std::size_t total_transferred_; - CompletionCondition completion_condition_; - ReadHandler handler_; - }; - - template <typename AsyncReadStream, typename Allocator, - typename CompletionCondition, typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_streambuf_handler<AsyncReadStream, Allocator, - CompletionCondition, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncReadStream, typename Allocator, - typename CompletionCondition, typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_streambuf_handler<AsyncReadStream, Allocator, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncReadStream, - typename Allocator, typename CompletionCondition, typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_streambuf_handler<AsyncReadStream, Allocator, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncReadStream, typename Allocator, - typename CompletionCondition, typename ReadHandler> -inline void async_read(AsyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, ReadHandler handler) -{ - boost::system::error_code ec; - std::size_t total_transferred = 0; - std::size_t max_size = detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred)); - std::size_t bytes_available = std::min<std::size_t>(512, - std::min<std::size_t>(max_size, b.max_size() - b.size())); - if (bytes_available == 0) - { - s.get_io_service().post(detail::bind_handler( - handler, ec, total_transferred)); - return; - } - - s.async_read_some(b.prepare(bytes_available), - detail::read_streambuf_handler<AsyncReadStream, Allocator, - CompletionCondition, ReadHandler>( - s, b, completion_condition, handler)); -} - -template <typename AsyncReadStream, typename Allocator, typename ReadHandler> -inline void async_read(AsyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, ReadHandler handler) -{ - async_read(s, b, transfer_all(), handler); -} - -} // namespace asio -} // namespace boost - -#include <boost/asio/detail/pop_options.hpp> - -#endif // BOOST_ASIO_READ_IPP diff --git a/3rdParty/Boost/boost/asio/impl/read_at.ipp b/3rdParty/Boost/boost/asio/impl/read_at.ipp deleted file mode 100644 index bf8a36d..0000000 --- a/3rdParty/Boost/boost/asio/impl/read_at.ipp +++ /dev/null @@ -1,367 +0,0 @@ -// -// read_at.ipp -// ~~~~~~~~~~~ -// -// Copyright (c) 2003-2008 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_READ_AT_IPP -#define BOOST_ASIO_READ_AT_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include <boost/asio/detail/push_options.hpp> - -#include <boost/asio/detail/push_options.hpp> -#include <algorithm> -#include <boost/asio/detail/pop_options.hpp> - -#include <boost/asio/buffer.hpp> -#include <boost/asio/completion_condition.hpp> -#include <boost/asio/error.hpp> -#include <boost/asio/detail/bind_handler.hpp> -#include <boost/asio/detail/consuming_buffers.hpp> -#include <boost/asio/detail/handler_alloc_helpers.hpp> -#include <boost/asio/detail/handler_invoke_helpers.hpp> -#include <boost/asio/detail/throw_error.hpp> - -namespace boost { -namespace asio { - -template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence, - typename CompletionCondition> -std::size_t read_at(SyncRandomAccessReadDevice& d, - boost::uint64_t offset, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - ec = boost::system::error_code(); - boost::asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> tmp(buffers); - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - while (tmp.begin() != tmp.end()) - { - std::size_t bytes_transferred = d.read_some_at( - offset + total_transferred, tmp, ec); - tmp.consume(bytes_transferred); - total_transferred += bytes_transferred; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - } - return total_transferred; -} - -template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence> -inline std::size_t read_at(SyncRandomAccessReadDevice& d, - boost::uint64_t offset, const MutableBufferSequence& buffers) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_at( - d, offset, buffers, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence, - typename CompletionCondition> -inline std::size_t read_at(SyncRandomAccessReadDevice& d, - boost::uint64_t offset, const MutableBufferSequence& buffers, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_at( - d, offset, buffers, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncRandomAccessReadDevice, typename Allocator, - typename CompletionCondition> -std::size_t read_at(SyncRandomAccessReadDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - std::size_t total_transferred = 0; - for (;;) - { - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - std::size_t bytes_transferred = d.read_some_at( - offset + total_transferred, b.prepare(bytes_available), ec); - b.commit(bytes_transferred); - total_transferred += bytes_transferred; - if (b.size() == b.max_size() - || completion_condition(ec, total_transferred)) - return total_transferred; - } -} - -template <typename SyncRandomAccessReadDevice, typename Allocator> -inline std::size_t read_at(SyncRandomAccessReadDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_at( - d, offset, b, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncRandomAccessReadDevice, typename Allocator, - typename CompletionCondition> -inline std::size_t read_at(SyncRandomAccessReadDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_at( - d, offset, b, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -namespace detail -{ - template <typename AsyncRandomAccessReadDevice, - typename MutableBufferSequence, typename CompletionCondition, - typename ReadHandler> - class read_at_handler - { - public: - typedef boost::asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> buffers_type; - - read_at_handler(AsyncRandomAccessReadDevice& stream, - boost::uint64_t offset, const buffers_type& buffers, - CompletionCondition completion_condition, ReadHandler handler) - : stream_(stream), - offset_(offset), - buffers_(buffers), - total_transferred_(0), - completion_condition_(completion_condition), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - total_transferred_ += bytes_transferred; - buffers_.consume(bytes_transferred); - buffers_.set_max_size(detail::adapt_completion_condition_result( - completion_condition_(ec, total_transferred_))); - if (buffers_.begin() == buffers_.end()) - { - handler_(ec, total_transferred_); - } - else - { - stream_.async_read_some_at( - offset_ + total_transferred_, buffers_, *this); - } - } - - //private: - AsyncRandomAccessReadDevice& stream_; - boost::uint64_t offset_; - buffers_type buffers_; - std::size_t total_transferred_; - CompletionCondition completion_condition_; - ReadHandler handler_; - }; - - template <typename AsyncRandomAccessReadDevice, - typename MutableBufferSequence, typename CompletionCondition, - typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_at_handler<AsyncRandomAccessReadDevice, MutableBufferSequence, - CompletionCondition, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncRandomAccessReadDevice, - typename MutableBufferSequence, typename CompletionCondition, - typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_at_handler<AsyncRandomAccessReadDevice, MutableBufferSequence, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncRandomAccessReadDevice, - typename MutableBufferSequence, typename CompletionCondition, - typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_at_handler<AsyncRandomAccessReadDevice, MutableBufferSequence, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, - typename CompletionCondition, typename ReadHandler> -inline void async_read_at(AsyncRandomAccessReadDevice& d, - boost::uint64_t offset, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, ReadHandler handler) -{ - boost::asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> tmp(buffers); - - boost::system::error_code ec; - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - if (tmp.begin() == tmp.end()) - { - d.get_io_service().post(detail::bind_handler( - handler, ec, total_transferred)); - return; - } - - d.async_read_some_at(offset, tmp, - detail::read_at_handler<AsyncRandomAccessReadDevice, - MutableBufferSequence, CompletionCondition, ReadHandler>( - d, offset, tmp, completion_condition, handler)); -} - -template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, - typename ReadHandler> -inline void async_read_at(AsyncRandomAccessReadDevice& d, - boost::uint64_t offset, const MutableBufferSequence& buffers, - ReadHandler handler) -{ - async_read_at(d, offset, buffers, transfer_all(), handler); -} - -namespace detail -{ - template <typename AsyncRandomAccessReadDevice, typename Allocator, - typename CompletionCondition, typename ReadHandler> - class read_at_streambuf_handler - { - public: - read_at_streambuf_handler(AsyncRandomAccessReadDevice& stream, - boost::uint64_t offset, basic_streambuf<Allocator>& streambuf, - CompletionCondition completion_condition, ReadHandler handler) - : stream_(stream), - offset_(offset), - streambuf_(streambuf), - total_transferred_(0), - completion_condition_(completion_condition), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - total_transferred_ += bytes_transferred; - streambuf_.commit(bytes_transferred); - std::size_t max_size = detail::adapt_completion_condition_result( - completion_condition_(ec, total_transferred_)); - std::size_t bytes_available = std::min<std::size_t>(512, - std::min<std::size_t>(max_size, - streambuf_.max_size() - streambuf_.size())); - if (bytes_available == 0) - { - handler_(ec, total_transferred_); - } - else - { - stream_.async_read_some_at(offset_ + total_transferred_, - streambuf_.prepare(bytes_available), *this); - } - } - - //private: - AsyncRandomAccessReadDevice& stream_; - boost::uint64_t offset_; - boost::asio::basic_streambuf<Allocator>& streambuf_; - std::size_t total_transferred_; - CompletionCondition completion_condition_; - ReadHandler handler_; - }; - - template <typename AsyncRandomAccessReadDevice, typename Allocator, - typename CompletionCondition, typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_at_streambuf_handler<AsyncRandomAccessReadDevice, Allocator, - CompletionCondition, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncRandomAccessReadDevice, typename Allocator, - typename CompletionCondition, typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_at_streambuf_handler<AsyncRandomAccessReadDevice, Allocator, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncRandomAccessReadDevice, - typename Allocator, typename CompletionCondition, typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_at_streambuf_handler<AsyncRandomAccessReadDevice, Allocator, - CompletionCondition, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncRandomAccessReadDevice, typename Allocator, - typename CompletionCondition, typename ReadHandler> -inline void async_read_at(AsyncRandomAccessReadDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, ReadHandler handler) -{ - boost::system::error_code ec; - std::size_t total_transferred = 0; - std::size_t max_size = detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred)); - std::size_t bytes_available = std::min<std::size_t>(512, - std::min<std::size_t>(max_size, b.max_size() - b.size())); - if (bytes_available == 0) - { - d.get_io_service().post(detail::bind_handler( - handler, ec, total_transferred)); - return; - } - - d.async_read_some_at(offset, b.prepare(bytes_available), - detail::read_at_streambuf_handler<AsyncRandomAccessReadDevice, Allocator, - CompletionCondition, ReadHandler>( - d, offset, b, completion_condition, handler)); -} - -template <typename AsyncRandomAccessReadDevice, typename Allocator, - typename ReadHandler> -inline void async_read_at(AsyncRandomAccessReadDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - ReadHandler handler) -{ - async_read_at(d, offset, b, transfer_all(), handler); -} - -} // namespace asio -} // namespace boost - -#include <boost/asio/detail/pop_options.hpp> - -#endif // BOOST_ASIO_READ_AT_IPP diff --git a/3rdParty/Boost/boost/asio/impl/read_until.ipp b/3rdParty/Boost/boost/asio/impl/read_until.ipp deleted file mode 100644 index df4a568..0000000 --- a/3rdParty/Boost/boost/asio/impl/read_until.ipp +++ /dev/null @@ -1,989 +0,0 @@ -// -// read_until.ipp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2008 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_READ_UNTIL_IPP -#define BOOST_ASIO_READ_UNTIL_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include <boost/asio/detail/push_options.hpp> - -#include <boost/asio/detail/push_options.hpp> -#include <algorithm> -#include <limits> -#include <string> -#include <utility> -#include <boost/asio/detail/pop_options.hpp> - -#include <boost/asio/buffer.hpp> -#include <boost/asio/buffers_iterator.hpp> -#include <boost/asio/detail/bind_handler.hpp> -#include <boost/asio/detail/handler_alloc_helpers.hpp> -#include <boost/asio/detail/handler_invoke_helpers.hpp> -#include <boost/asio/detail/throw_error.hpp> - -namespace boost { -namespace asio { - -template <typename SyncReadStream, typename Allocator> -inline std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, char delim) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_until(s, b, delim, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncReadStream, typename Allocator> -std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, char delim, - boost::system::error_code& ec) -{ - std::size_t next_search_start = 0; - for (;;) - { - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start; - iterator end = iterator::end(buffers); - - // Look for a match. - iterator iter = std::find(start, end, delim); - if (iter != end) - { - // Found a match. We're done. - ec = boost::system::error_code(); - return iter - begin + 1; - } - else - { - // No match. Next search can start with the new data. - next_search_start = end - begin; - } - - // Check if buffer is full. - if (b.size() == b.max_size()) - { - ec = error::not_found; - return 0; - } - - // Need more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - b.commit(s.read_some(b.prepare(bytes_available), ec)); - if (ec) - return 0; - } -} - -template <typename SyncReadStream, typename Allocator> -inline std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, const std::string& delim) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_until(s, b, delim, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -namespace detail -{ - // Algorithm that finds a subsequence of equal values in a sequence. Returns - // (iterator,true) if a full match was found, in which case the iterator - // points to the beginning of the match. Returns (iterator,false) if a - // partial match was found at the end of the first sequence, in which case - // the iterator points to the beginning of the partial match. Returns - // (last1,false) if no full or partial match was found. - template <typename Iterator1, typename Iterator2> - std::pair<Iterator1, bool> partial_search( - Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) - { - for (Iterator1 iter1 = first1; iter1 != last1; ++iter1) - { - Iterator1 test_iter1 = iter1; - Iterator2 test_iter2 = first2; - for (;; ++test_iter1, ++test_iter2) - { - if (test_iter2 == last2) - return std::make_pair(iter1, true); - if (test_iter1 == last1) - { - if (test_iter2 != first2) - return std::make_pair(iter1, false); - else - break; - } - if (*test_iter1 != *test_iter2) - break; - } - } - return std::make_pair(last1, false); - } -} // namespace detail - -template <typename SyncReadStream, typename Allocator> -std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, const std::string& delim, - boost::system::error_code& ec) -{ - std::size_t next_search_start = 0; - for (;;) - { - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start; - iterator end = iterator::end(buffers); - - // Look for a match. - std::pair<iterator, bool> result = boost::asio::detail::partial_search( - start, end, delim.begin(), delim.end()); - if (result.first != end) - { - if (result.second) - { - // Full match. We're done. - ec = boost::system::error_code(); - return result.first - begin + delim.length(); - } - else - { - // Partial match. Next search needs to start from beginning of match. - next_search_start = result.first - begin; - } - } - else - { - // No match. Next search can start with the new data. - next_search_start = end - begin; - } - - // Check if buffer is full. - if (b.size() == b.max_size()) - { - ec = error::not_found; - return 0; - } - - // Need more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - b.commit(s.read_some(b.prepare(bytes_available), ec)); - if (ec) - return 0; - } -} - -template <typename SyncReadStream, typename Allocator> -inline std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, const boost::regex& expr) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_until(s, b, expr, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncReadStream, typename Allocator> -std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, const boost::regex& expr, - boost::system::error_code& ec) -{ - std::size_t next_search_start = 0; - for (;;) - { - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start; - iterator end = iterator::end(buffers); - - // Look for a match. - boost::match_results<iterator> match_results; - if (boost::regex_search(start, end, match_results, expr, - boost::match_default | boost::match_partial)) - { - if (match_results[0].matched) - { - // Full match. We're done. - ec = boost::system::error_code(); - return match_results[0].second - begin; - } - else - { - // Partial match. Next search needs to start from beginning of match. - next_search_start = match_results[0].first - begin; - } - } - else - { - // No match. Next search can start with the new data. - next_search_start = end - begin; - } - - // Check if buffer is full. - if (b.size() == b.max_size()) - { - ec = error::not_found; - return 0; - } - - // Need more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - b.commit(s.read_some(b.prepare(bytes_available), ec)); - if (ec) - return 0; - } -} - -template <typename SyncReadStream, typename Allocator, typename MatchCondition> -std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, - MatchCondition match_condition, boost::system::error_code& ec, - typename boost::enable_if<is_match_condition<MatchCondition> >::type*) -{ - std::size_t next_search_start = 0; - for (;;) - { - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start; - iterator end = iterator::end(buffers); - - // Look for a match. - std::pair<iterator, bool> result = match_condition(start, end); - if (result.second) - { - // Full match. We're done. - ec = boost::system::error_code(); - return result.first - begin; - } - else if (result.first != end) - { - // Partial match. Next search needs to start from beginning of match. - next_search_start = result.first - begin; - } - else - { - // No match. Next search can start with the new data. - next_search_start = end - begin; - } - - // Check if buffer is full. - if (b.size() == b.max_size()) - { - ec = error::not_found; - return 0; - } - - // Need more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - b.commit(s.read_some(b.prepare(bytes_available), ec)); - if (ec) - return 0; - } -} - -template <typename SyncReadStream, typename Allocator, typename MatchCondition> -inline std::size_t read_until(SyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, MatchCondition match_condition, - typename boost::enable_if<is_match_condition<MatchCondition> >::type*) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = read_until(s, b, match_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -namespace detail -{ - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - class read_until_delim_handler - { - public: - read_until_delim_handler(AsyncReadStream& stream, - boost::asio::basic_streambuf<Allocator>& streambuf, char delim, - std::size_t next_search_start, ReadHandler handler) - : stream_(stream), - streambuf_(streambuf), - delim_(delim), - next_search_start_(next_search_start), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - // Check for errors. - if (ec) - { - std::size_t bytes = 0; - handler_(ec, bytes); - return; - } - - // Commit received data to streambuf's get area. - streambuf_.commit(bytes_transferred); - - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = streambuf_.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start_; - iterator end = iterator::end(buffers); - - // Look for a match. - iterator iter = std::find(start, end, delim_); - if (iter != end) - { - // Found a match. We're done. - std::size_t bytes = iter - begin + 1; - handler_(ec, bytes); - return; - } - - // No match. Check if buffer is full. - if (streambuf_.size() == streambuf_.max_size()) - { - std::size_t bytes = 0; - boost::system::error_code ec(error::not_found); - handler_(ec, bytes); - return; - } - - // Next search can start with the new data. - next_search_start_ = end - begin; - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, streambuf_.max_size() - streambuf_.size()); - stream_.async_read_some(streambuf_.prepare(bytes_available), *this); - } - - //private: - AsyncReadStream& stream_; - boost::asio::basic_streambuf<Allocator>& streambuf_; - char delim_; - std::size_t next_search_start_; - ReadHandler handler_; - }; - - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_until_delim_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_until_delim_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncReadStream, typename Allocator, - typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_until_delim_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncReadStream, typename Allocator, typename ReadHandler> -void async_read_until(AsyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, char delim, ReadHandler handler) -{ - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator end = iterator::end(buffers); - - // Look for a match. - iterator iter = std::find(begin, end, delim); - if (iter != end) - { - // Found a match. We're done. - boost::system::error_code ec; - std::size_t bytes = iter - begin + 1; - s.get_io_service().post(detail::bind_handler(handler, ec, bytes)); - return; - } - - // No match. Check if buffer is full. - if (b.size() == b.max_size()) - { - boost::system::error_code ec(error::not_found); - s.get_io_service().post(detail::bind_handler(handler, ec, 0)); - return; - } - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - s.async_read_some(b.prepare(bytes_available), - detail::read_until_delim_handler<AsyncReadStream, Allocator, ReadHandler>( - s, b, delim, end - begin, handler)); -} - -namespace detail -{ - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - class read_until_delim_string_handler - { - public: - read_until_delim_string_handler(AsyncReadStream& stream, - boost::asio::basic_streambuf<Allocator>& streambuf, - const std::string& delim, std::size_t next_search_start, - ReadHandler handler) - : stream_(stream), - streambuf_(streambuf), - delim_(delim), - next_search_start_(next_search_start), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - // Check for errors. - if (ec) - { - std::size_t bytes = 0; - handler_(ec, bytes); - return; - } - - // Commit received data to streambuf's get area. - streambuf_.commit(bytes_transferred); - - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = streambuf_.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start_; - iterator end = iterator::end(buffers); - - // Look for a match. - std::pair<iterator, bool> result = boost::asio::detail::partial_search( - start, end, delim_.begin(), delim_.end()); - if (result.first != end) - { - if (result.second) - { - // Full match. We're done. - std::size_t bytes = result.first - begin + delim_.length(); - handler_(ec, bytes); - return; - } - else - { - // Partial match. Next search needs to start from beginning of match. - next_search_start_ = result.first - begin; - } - } - else - { - // No match. Next search can start with the new data. - next_search_start_ = end - begin; - } - - // Check if buffer is full. - if (streambuf_.size() == streambuf_.max_size()) - { - std::size_t bytes = 0; - boost::system::error_code ec2(error::not_found); - handler_(ec2, bytes); - return; - } - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, streambuf_.max_size() - streambuf_.size()); - stream_.async_read_some(streambuf_.prepare(bytes_available), *this); - } - - //private: - AsyncReadStream& stream_; - boost::asio::basic_streambuf<Allocator>& streambuf_; - std::string delim_; - std::size_t next_search_start_; - ReadHandler handler_; - }; - - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_until_delim_string_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_until_delim_string_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncReadStream, - typename Allocator, typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_until_delim_string_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncReadStream, typename Allocator, typename ReadHandler> -void async_read_until(AsyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, const std::string& delim, - ReadHandler handler) -{ - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator end = iterator::end(buffers); - - // Look for a match. - std::size_t next_search_start; - std::pair<iterator, bool> result = boost::asio::detail::partial_search( - begin, end, delim.begin(), delim.end()); - if (result.first != end) - { - if (result.second) - { - // Full match. We're done. - boost::system::error_code ec; - std::size_t bytes = result.first - begin + delim.length(); - s.get_io_service().post(detail::bind_handler(handler, ec, bytes)); - return; - } - else - { - // Partial match. Next search needs to start from beginning of match. - next_search_start = result.first - begin; - } - } - else - { - // No match. Next search can start with the new data. - next_search_start = end - begin; - } - - // Check if buffer is full. - if (b.size() == b.max_size()) - { - boost::system::error_code ec(error::not_found); - s.get_io_service().post(detail::bind_handler(handler, ec, 0)); - return; - } - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - s.async_read_some(b.prepare(bytes_available), - detail::read_until_delim_string_handler< - AsyncReadStream, Allocator, ReadHandler>( - s, b, delim, next_search_start, handler)); -} - -namespace detail -{ - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - class read_until_expr_handler - { - public: - read_until_expr_handler(AsyncReadStream& stream, - boost::asio::basic_streambuf<Allocator>& streambuf, - const boost::regex& expr, std::size_t next_search_start, - ReadHandler handler) - : stream_(stream), - streambuf_(streambuf), - expr_(expr), - next_search_start_(next_search_start), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - // Check for errors. - if (ec) - { - std::size_t bytes = 0; - handler_(ec, bytes); - return; - } - - // Commit received data to streambuf's get area. - streambuf_.commit(bytes_transferred); - - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = streambuf_.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start_; - iterator end = iterator::end(buffers); - - // Look for a match. - boost::match_results<iterator> match_results; - if (boost::regex_search(start, end, match_results, expr_, - boost::match_default | boost::match_partial)) - { - if (match_results[0].matched) - { - // Full match. We're done. - std::size_t bytes = match_results[0].second - begin; - handler_(ec, bytes); - return; - } - else - { - // Partial match. Next search needs to start from beginning of match. - next_search_start_ = match_results[0].first - begin; - } - } - else - { - // No match. Next search can start with the new data. - next_search_start_ = end - begin; - } - - // Check if buffer is full. - if (streambuf_.size() == streambuf_.max_size()) - { - std::size_t bytes = 0; - boost::system::error_code ec(error::not_found); - handler_(ec, bytes); - return; - } - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, streambuf_.max_size() - streambuf_.size()); - stream_.async_read_some(streambuf_.prepare(bytes_available), *this); - } - - //private: - AsyncReadStream& stream_; - boost::asio::basic_streambuf<Allocator>& streambuf_; - boost::regex expr_; - std::size_t next_search_start_; - ReadHandler handler_; - }; - - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_until_expr_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncReadStream, typename Allocator, typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_until_expr_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncReadStream, typename Allocator, - typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_until_expr_handler<AsyncReadStream, - Allocator, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncReadStream, typename Allocator, typename ReadHandler> -void async_read_until(AsyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, const boost::regex& expr, - ReadHandler handler) -{ - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator end = iterator::end(buffers); - - // Look for a match. - std::size_t next_search_start; - boost::match_results<iterator> match_results; - if (boost::regex_search(begin, end, match_results, expr, - boost::match_default | boost::match_partial)) - { - if (match_results[0].matched) - { - // Full match. We're done. - boost::system::error_code ec; - std::size_t bytes = match_results[0].second - begin; - s.get_io_service().post(detail::bind_handler(handler, ec, bytes)); - return; - } - else - { - // Partial match. Next search needs to start from beginning of match. - next_search_start = match_results[0].first - begin; - } - } - else - { - // No match. Next search can start with the new data. - next_search_start = end - begin; - } - - // Check if buffer is full. - if (b.size() == b.max_size()) - { - boost::system::error_code ec(error::not_found); - s.get_io_service().post(detail::bind_handler(handler, ec, 0)); - return; - } - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - s.async_read_some(b.prepare(bytes_available), - detail::read_until_expr_handler<AsyncReadStream, Allocator, ReadHandler>( - s, b, expr, next_search_start, handler)); -} - -namespace detail -{ - template <typename AsyncReadStream, typename Allocator, - typename MatchCondition, typename ReadHandler> - class read_until_match_handler - { - public: - read_until_match_handler(AsyncReadStream& stream, - boost::asio::basic_streambuf<Allocator>& streambuf, - MatchCondition match_condition, std::size_t next_search_start, - ReadHandler handler) - : stream_(stream), - streambuf_(streambuf), - match_condition_(match_condition), - next_search_start_(next_search_start), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - // Check for errors. - if (ec) - { - std::size_t bytes = 0; - handler_(ec, bytes); - return; - } - - // Commit received data to streambuf's get area. - streambuf_.commit(bytes_transferred); - - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = streambuf_.data(); - iterator begin = iterator::begin(buffers); - iterator start = begin + next_search_start_; - iterator end = iterator::end(buffers); - - // Look for a match. - std::pair<iterator, bool> result = match_condition_(start, end); - if (result.second) - { - // Full match. We're done. - std::size_t bytes = result.first - begin; - handler_(ec, bytes); - return; - } - else if (result.first != end) - { - // Partial match. Next search needs to start from beginning of match. - next_search_start_ = result.first - begin; - } - else - { - // No match. Next search can start with the new data. - next_search_start_ = end - begin; - } - - // Check if buffer is full. - if (streambuf_.size() == streambuf_.max_size()) - { - std::size_t bytes = 0; - boost::system::error_code ec(error::not_found); - handler_(ec, bytes); - return; - } - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, streambuf_.max_size() - streambuf_.size()); - stream_.async_read_some(streambuf_.prepare(bytes_available), *this); - } - - //private: - AsyncReadStream& stream_; - boost::asio::basic_streambuf<Allocator>& streambuf_; - MatchCondition match_condition_; - std::size_t next_search_start_; - ReadHandler handler_; - }; - - template <typename AsyncReadStream, typename Allocator, - typename MatchCondition, typename ReadHandler> - inline void* asio_handler_allocate(std::size_t size, - read_until_match_handler<AsyncReadStream, - Allocator, MatchCondition, ReadHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncReadStream, typename Allocator, - typename MatchCondition, typename ReadHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_until_match_handler<AsyncReadStream, - Allocator, MatchCondition, ReadHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncReadStream, typename Allocator, - typename MatchCondition, typename ReadHandler> - inline void asio_handler_invoke(const Function& function, - read_until_match_handler<AsyncReadStream, - Allocator, MatchCondition, ReadHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncReadStream, typename Allocator, - typename MatchCondition, typename ReadHandler> -void async_read_until(AsyncReadStream& s, - boost::asio::basic_streambuf<Allocator>& b, - MatchCondition match_condition, ReadHandler handler, - typename boost::enable_if<is_match_condition<MatchCondition> >::type*) -{ - // Determine the range of the data to be searched. - typedef typename boost::asio::basic_streambuf< - Allocator>::const_buffers_type const_buffers_type; - typedef boost::asio::buffers_iterator<const_buffers_type> iterator; - const_buffers_type buffers = b.data(); - iterator begin = iterator::begin(buffers); - iterator end = iterator::end(buffers); - - // Look for a match. - std::size_t next_search_start; - std::pair<iterator, bool> result = match_condition(begin, end); - if (result.second) - { - // Full match. We're done. - boost::system::error_code ec; - std::size_t bytes = result.first - begin; - s.get_io_service().post(detail::bind_handler(handler, ec, bytes)); - return; - } - else if (result.first != end) - { - // Partial match. Next search needs to start from beginning of match. - next_search_start = result.first - begin; - } - else - { - // No match. Next search can start with the new data. - next_search_start = end - begin; - } - - // Check if buffer is full. - if (b.size() == b.max_size()) - { - boost::system::error_code ec(error::not_found); - s.get_io_service().post(detail::bind_handler(handler, ec, 0)); - return; - } - - // Start a new asynchronous read operation to obtain more data. - std::size_t bytes_available = - std::min<std::size_t>(512, b.max_size() - b.size()); - s.async_read_some(b.prepare(bytes_available), - detail::read_until_match_handler< - AsyncReadStream, Allocator, MatchCondition, ReadHandler>( - s, b, match_condition, next_search_start, handler)); -} - -} // namespace asio -} // namespace boost - -#include <boost/asio/detail/pop_options.hpp> - -#endif // BOOST_ASIO_READ_UNTIL_IPP diff --git a/3rdParty/Boost/boost/asio/impl/serial_port_base.ipp b/3rdParty/Boost/boost/asio/impl/serial_port_base.ipp deleted file mode 100644 index 0470ff2..0000000 --- a/3rdParty/Boost/boost/asio/impl/serial_port_base.ipp +++ /dev/null @@ -1,543 +0,0 @@ -// -// serial_port_base.ipp -// ~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2008 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 -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BOOST_ASIO_SERIAL_PORT_BASE_IPP -#define BOOST_ASIO_SERIAL_PORT_BASE_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include <boost/asio/detail/push_options.hpp> - -namespace boost { -namespace asio { - -inline serial_port_base::baud_rate::baud_rate(unsigned int rate) - : value_(rate) -{ -} - -inline unsigned int serial_port_base::baud_rate::value() const -{ - return value_; -} - -inline boost::system::error_code serial_port_base::baud_rate::store( - BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) const -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - storage.BaudRate = value_; -#else - speed_t baud; - switch (value_) - { - // Do POSIX-specified rates first. - case 0: baud = B0; break; - case 50: baud = B50; break; - case 75: baud = B75; break; - case 110: baud = B110; break; - case 134: baud = B134; break; - case 150: baud = B150; break; - case 200: baud = B200; break; - case 300: baud = B300; break; - case 600: baud = B600; break; - case 1200: baud = B1200; break; - case 1800: baud = B1800; break; - case 2400: baud = B2400; break; - case 4800: baud = B4800; break; - case 9600: baud = B9600; break; - case 19200: baud = B19200; break; - case 38400: baud = B38400; break; - // And now the extended ones conditionally. -# ifdef B7200 - case 7200: baud = B7200; break; -# endif -# ifdef B14400 - case 14400: baud = B14400; break; -# endif -# ifdef B57600 - case 57600: baud = B57600; break; -# endif -# ifdef B115200 - case 115200: baud = B115200; break; -# endif -# ifdef B230400 - case 230400: baud = B230400; break; -# endif -# ifdef B460800 - case 460800: baud = B460800; break; -# endif -# ifdef B500000 - case 500000: baud = B500000; break; -# endif -# ifdef B576000 - case 576000: baud = B576000; break; -# endif -# ifdef B921600 - case 921600: baud = B921600; break; -# endif -# ifdef B1000000 - case 1000000: baud = B1000000; break; -# endif -# ifdef B1152000 - case 1152000: baud = B1152000; break; -# endif -# ifdef B2000000 - case 2000000: baud = B2000000; break; -# endif -# ifdef B3000000 - case 3000000: baud = B3000000; break; -# endif -# ifdef B3500000 - case 3500000: baud = B3500000; break; -# endif -# ifdef B4000000 - case 4000000: baud = B4000000; break; -# endif - default: - baud = B0; - ec = boost::asio::error::invalid_argument; - return ec; - } -# if defined(_BSD_SOURCE) - ::cfsetspeed(&storage, baud); -# else - ::cfsetispeed(&storage, baud); - ::cfsetospeed(&storage, baud); -# endif -#endif - ec = boost::system::error_code(); - return ec; -} - -inline boost::system::error_code serial_port_base::baud_rate::load( - const BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - value_ = storage.BaudRate; -#else - speed_t baud = ::cfgetospeed(&storage); - switch (baud) - { - // First do those specified by POSIX. - case B0: value_ = 0; break; - case B50: value_ = 50; break; - case B75: value_ = 75; break; - case B110: value_ = 110; break; - case B134: value_ = 134; break; - case B150: value_ = 150; break; - case B200: value_ = 200; break; - case B300: value_ = 300; break; - case B600: value_ = 600; break; - case B1200: value_ = 1200; break; - case B1800: value_ = 1800; break; - case B2400: value_ = 2400; break; - case B4800: value_ = 4800; break; - case B9600: value_ = 9600; break; - case B19200: value_ = 19200; break; - case B38400: value_ = 38400; break; - // Now conditionally handle a bunch of extended rates. -# ifdef B7200 - case B7200: value_ = 7200; break; -# endif -# ifdef B14400 - case B14400: value_ = 14400; break; -# endif -# ifdef B57600 - case B57600: value_ = 57600; break; -# endif -# ifdef B115200 - case B115200: value_ = 115200; break; -# endif -# ifdef B230400 - case B230400: value_ = 230400; break; -# endif -# ifdef B460800 - case B460800: value_ = 460800; break; -# endif -# ifdef B500000 - case B500000: value_ = 500000; break; -# endif -# ifdef B576000 - case B576000: value_ = 576000; break; -# endif -# ifdef B921600 - case B921600: value_ = 921600; break; -# endif -# ifdef B1000000 - case B1000000: value_ = 1000000; break; -# endif -# ifdef B1152000 - case B1152000: value_ = 1152000; break; -# endif -# ifdef B2000000 - case B2000000: value_ = 2000000; break; -# endif -# ifdef B3000000 - case B3000000: value_ = 3000000; break; -# endif -# ifdef B3500000 - case B3500000: value_ = 3500000; break; -# endif -# ifdef B4000000 - case B4000000: value_ = 4000000; break; -# endif - default: - value_ = 0; - ec = boost::asio::error::invalid_argument; - return ec; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -inline serial_port_base::flow_control::flow_control( - serial_port_base::flow_control::type t) - : value_(t) -{ - if (t != none && t != software && t != hardware) - throw std::out_of_range("invalid flow_control value"); -} - -inline serial_port_base::flow_control::type -serial_port_base::flow_control::value() const -{ - return value_; -} - -inline boost::system::error_code serial_port_base::flow_control::store( - BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) const -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - storage.fOutxCtsFlow = FALSE; - storage.fOutxDsrFlow = FALSE; - storage.fTXContinueOnXoff = TRUE; - storage.fDtrControl = DTR_CONTROL_ENABLE; - storage.fDsrSensitivity = FALSE; - storage.fOutX = FALSE; - storage.fInX = FALSE; - storage.fRtsControl = RTS_CONTROL_ENABLE; - switch (value_) - { - case none: - break; - case software: - storage.fOutX = TRUE; - storage.fInX = TRUE; - break; - case hardware: - storage.fOutxCtsFlow = TRUE; - storage.fRtsControl = RTS_CONTROL_HANDSHAKE; - break; - default: - break; - } -#else - switch (value_) - { - case none: - storage.c_iflag &= ~(IXOFF | IXON); -# if defined(_BSD_SOURCE) - storage.c_cflag &= ~CRTSCTS; -# endif - break; - case software: - storage.c_iflag |= IXOFF | IXON; -# if defined(_BSD_SOURCE) - storage.c_cflag &= ~CRTSCTS; -# endif - break; - case hardware: -# if defined(_BSD_SOURCE) - storage.c_iflag &= ~(IXOFF | IXON); - storage.c_cflag |= CRTSCTS; - break; -# else - ec = boost::asio::error::operation_not_supported; - return ec; -# endif - default: - break; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -inline boost::system::error_code serial_port_base::flow_control::load( - const BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - if (storage.fOutX && storage.fInX) - { - value_ = software; - } - else if (storage.fOutxCtsFlow && storage.fRtsControl == RTS_CONTROL_HANDSHAKE) - { - value_ = hardware; - } - else - { - value_ = none; - } -#else - if (storage.c_iflag & (IXOFF | IXON)) - { - value_ = software; - } -# if defined(_BSD_SOURCE) - else if (storage.c_cflag & CRTSCTS) - { - value_ = hardware; - } -# endif - else - { - value_ = none; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -inline serial_port_base::parity::parity(serial_port_base::parity::type t) - : value_(t) -{ - if (t != none && t != odd && t != even) - throw std::out_of_range("invalid parity value"); -} - -inline serial_port_base::parity::type serial_port_base::parity::value() const -{ - return value_; -} - -inline boost::system::error_code serial_port_base::parity::store( - BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) const -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - switch (value_) - { - case none: - storage.fParity = FALSE; - storage.Parity = NOPARITY; - break; - case odd: - storage.fParity = TRUE; - storage.Parity = ODDPARITY; - break; - case even: - storage.fParity = TRUE; - storage.Parity = EVENPARITY; - break; - default: - break; - } -#else - switch (value_) - { - case none: - storage.c_iflag |= IGNPAR; - storage.c_cflag &= ~(PARENB | PARODD); - break; - case even: - storage.c_iflag &= ~(IGNPAR | PARMRK); - storage.c_iflag |= INPCK; - storage.c_cflag |= PARENB; - storage.c_cflag &= ~PARODD; - break; - case odd: - storage.c_iflag &= ~(IGNPAR | PARMRK); - storage.c_iflag |= INPCK; - storage.c_cflag |= (PARENB | PARODD); - break; - default: - break; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -inline boost::system::error_code serial_port_base::parity::load( - const BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - if (storage.Parity == EVENPARITY) - { - value_ = even; - } - else if (storage.Parity == ODDPARITY) - { - value_ = odd; - } - else - { - value_ = none; - } -#else - if (storage.c_cflag & PARENB) - { - if (storage.c_cflag & PARODD) - { - value_ = odd; - } - else - { - value_ = even; - } - } - else - { - value_ = none; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -inline serial_port_base::stop_bits::stop_bits( - serial_port_base::stop_bits::type t) - : value_(t) -{ - if (t != one && t != onepointfive && t != two) - throw std::out_of_range("invalid stop_bits value"); -} - -inline serial_port_base::stop_bits::type -serial_port_base::stop_bits::value() const -{ - return value_; -} - -inline boost::system::error_code serial_port_base::stop_bits::store( - BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) const -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - switch (value_) - { - case one: - storage.StopBits = ONESTOPBIT; - break; - case onepointfive: - storage.StopBits = ONE5STOPBITS; - break; - case two: - storage.StopBits = TWOSTOPBITS; - break; - default: - break; - } -#else - switch (value_) - { - case one: - storage.c_cflag &= ~CSTOPB; - break; - case two: - storage.c_cflag |= CSTOPB; - break; - default: - ec = boost::asio::error::operation_not_supported; - return ec; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -inline boost::system::error_code serial_port_base::stop_bits::load( - const BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - if (storage.StopBits == ONESTOPBIT) - { - value_ = one; - } - else if (storage.StopBits == ONE5STOPBITS) - { - value_ = onepointfive; - } - else if (storage.StopBits == TWOSTOPBITS) - { - value_ = two; - } - else - { - value_ = one; - } -#else - value_ = (storage.c_cflag & CSTOPB) ? two : one; -#endif - ec = boost::system::error_code(); - return ec; -} - -inline serial_port_base::character_size::character_size(unsigned int t) - : value_(t) -{ - if (t < 5 || t > 8) - throw std::out_of_range("invalid character_size value"); -} - -inline unsigned int serial_port_base::character_size::value() const -{ - return value_; -} - -inline boost::system::error_code serial_port_base::character_size::store( - BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) const -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - storage.ByteSize = value_; -#else - storage.c_cflag &= ~CSIZE; - switch (value_) - { - case 5: storage.c_cflag |= CS5; break; - case 6: storage.c_cflag |= CS6; break; - case 7: storage.c_cflag |= CS7; break; - case 8: storage.c_cflag |= CS8; break; - default: break; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -inline boost::system::error_code serial_port_base::character_size::load( - const BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec) -{ -#if defined(BOOST_WINDOWS) || defined(__CYGWIN__) - value_ = storage.ByteSize; -#else - if ((storage.c_cflag & CSIZE) == CS5) { value_ = 5; } - else if ((storage.c_cflag & CSIZE) == CS6) { value_ = 6; } - else if ((storage.c_cflag & CSIZE) == CS7) { value_ = 7; } - else if ((storage.c_cflag & CSIZE) == CS8) { value_ = 8; } - else - { - // Hmmm, use 8 for now. - value_ = 8; - } -#endif - ec = boost::system::error_code(); - return ec; -} - -} // namespace asio -} // namespace boost - -#include <boost/asio/detail/pop_options.hpp> - -#endif // BOOST_ASIO_SERIAL_PORT_BASE_IPP diff --git a/3rdParty/Boost/boost/asio/impl/write.ipp b/3rdParty/Boost/boost/asio/impl/write.ipp deleted file mode 100644 index 4434a91..0000000 --- a/3rdParty/Boost/boost/asio/impl/write.ipp +++ /dev/null @@ -1,296 +0,0 @@ -// -// write.ipp -// ~~~~~~~~~ -// -// Copyright (c) 2003-2008 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_WRITE_IPP -#define BOOST_ASIO_WRITE_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include <boost/asio/detail/push_options.hpp> - -#include <boost/asio/buffer.hpp> -#include <boost/asio/completion_condition.hpp> -#include <boost/asio/detail/bind_handler.hpp> -#include <boost/asio/detail/consuming_buffers.hpp> -#include <boost/asio/detail/handler_alloc_helpers.hpp> -#include <boost/asio/detail/handler_invoke_helpers.hpp> -#include <boost/asio/detail/throw_error.hpp> - -namespace boost { -namespace asio { - -template <typename SyncWriteStream, typename ConstBufferSequence, - typename CompletionCondition> -std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - ec = boost::system::error_code(); - boost::asio::detail::consuming_buffers< - const_buffer, ConstBufferSequence> tmp(buffers); - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - while (tmp.begin() != tmp.end()) - { - std::size_t bytes_transferred = s.write_some(tmp, ec); - tmp.consume(bytes_transferred); - total_transferred += bytes_transferred; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - } - return total_transferred; -} - -template <typename SyncWriteStream, typename ConstBufferSequence> -inline std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write(s, buffers, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncWriteStream, typename ConstBufferSequence, - typename CompletionCondition> -inline std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write(s, buffers, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncWriteStream, typename Allocator, - typename CompletionCondition> -std::size_t write(SyncWriteStream& s, - boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - std::size_t bytes_transferred = write(s, b.data(), completion_condition, ec); - b.consume(bytes_transferred); - return bytes_transferred; -} - -template <typename SyncWriteStream, typename Allocator> -inline std::size_t write(SyncWriteStream& s, - boost::asio::basic_streambuf<Allocator>& b) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write(s, b, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncWriteStream, typename Allocator, - typename CompletionCondition> -inline std::size_t write(SyncWriteStream& s, - boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write(s, b, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -namespace detail -{ - template <typename AsyncWriteStream, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> - class write_handler - { - public: - typedef boost::asio::detail::consuming_buffers< - const_buffer, ConstBufferSequence> buffers_type; - - write_handler(AsyncWriteStream& stream, const buffers_type& buffers, - CompletionCondition completion_condition, WriteHandler handler) - : stream_(stream), - buffers_(buffers), - total_transferred_(0), - completion_condition_(completion_condition), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - total_transferred_ += bytes_transferred; - buffers_.consume(bytes_transferred); - buffers_.set_max_size(detail::adapt_completion_condition_result( - completion_condition_(ec, total_transferred_))); - if (buffers_.begin() == buffers_.end()) - { - handler_(ec, total_transferred_); - } - else - { - stream_.async_write_some(buffers_, *this); - } - } - - //private: - AsyncWriteStream& stream_; - buffers_type buffers_; - std::size_t total_transferred_; - CompletionCondition completion_condition_; - WriteHandler handler_; - }; - - template <typename AsyncWriteStream, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> - inline void* asio_handler_allocate(std::size_t size, - write_handler<AsyncWriteStream, ConstBufferSequence, - CompletionCondition, WriteHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncWriteStream, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - write_handler<AsyncWriteStream, ConstBufferSequence, - CompletionCondition, WriteHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncWriteStream, - typename ConstBufferSequence, typename CompletionCondition, - typename WriteHandler> - inline void asio_handler_invoke(const Function& function, - write_handler<AsyncWriteStream, ConstBufferSequence, - CompletionCondition, WriteHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncWriteStream, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> -inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers, - CompletionCondition completion_condition, WriteHandler handler) -{ - boost::asio::detail::consuming_buffers< - const_buffer, ConstBufferSequence> tmp(buffers); - - boost::system::error_code ec; - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - if (tmp.begin() == tmp.end()) - { - s.get_io_service().post(detail::bind_handler( - handler, ec, total_transferred)); - return; - } - - s.async_write_some(tmp, - detail::write_handler<AsyncWriteStream, ConstBufferSequence, - CompletionCondition, WriteHandler>( - s, tmp, completion_condition, handler)); -} - -template <typename AsyncWriteStream, typename ConstBufferSequence, - typename WriteHandler> -inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers, - WriteHandler handler) -{ - async_write(s, buffers, transfer_all(), handler); -} - -namespace detail -{ - template <typename AsyncWriteStream, typename Allocator, - typename WriteHandler> - class write_streambuf_handler - { - public: - write_streambuf_handler(boost::asio::basic_streambuf<Allocator>& streambuf, - WriteHandler handler) - : streambuf_(streambuf), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - streambuf_.consume(bytes_transferred); - handler_(ec, bytes_transferred); - } - - //private: - boost::asio::basic_streambuf<Allocator>& streambuf_; - WriteHandler handler_; - }; - - template <typename AsyncWriteStream, typename Allocator, - typename WriteHandler> - inline void* asio_handler_allocate(std::size_t size, - write_streambuf_handler<AsyncWriteStream, - Allocator, WriteHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncWriteStream, typename Allocator, - typename WriteHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - write_streambuf_handler<AsyncWriteStream, - Allocator, WriteHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncWriteStream, typename Allocator, - typename WriteHandler> - inline void asio_handler_invoke(const Function& function, - write_streambuf_handler<AsyncWriteStream, - Allocator, WriteHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncWriteStream, typename Allocator, - typename CompletionCondition, typename WriteHandler> -inline void async_write(AsyncWriteStream& s, - boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, WriteHandler handler) -{ - async_write(s, b.data(), completion_condition, - detail::write_streambuf_handler< - AsyncWriteStream, Allocator, WriteHandler>(b, handler)); -} - -template <typename AsyncWriteStream, typename Allocator, typename WriteHandler> -inline void async_write(AsyncWriteStream& s, - boost::asio::basic_streambuf<Allocator>& b, WriteHandler handler) -{ - async_write(s, b, transfer_all(), handler); -} - -} // namespace asio -} // namespace boost - -#include <boost/asio/detail/pop_options.hpp> - -#endif // BOOST_ASIO_WRITE_IPP diff --git a/3rdParty/Boost/boost/asio/impl/write_at.ipp b/3rdParty/Boost/boost/asio/impl/write_at.ipp deleted file mode 100644 index ba00567..0000000 --- a/3rdParty/Boost/boost/asio/impl/write_at.ipp +++ /dev/null @@ -1,313 +0,0 @@ -// -// write_at.ipp -// ~~~~~~~~~~~~ -// -// Copyright (c) 2003-2008 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_WRITE_AT_IPP -#define BOOST_ASIO_WRITE_AT_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include <boost/asio/detail/push_options.hpp> - -#include <boost/asio/buffer.hpp> -#include <boost/asio/completion_condition.hpp> -#include <boost/asio/detail/bind_handler.hpp> -#include <boost/asio/detail/consuming_buffers.hpp> -#include <boost/asio/detail/handler_alloc_helpers.hpp> -#include <boost/asio/detail/handler_invoke_helpers.hpp> -#include <boost/asio/detail/throw_error.hpp> - -namespace boost { -namespace asio { - -template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence, - typename CompletionCondition> -std::size_t write_at(SyncRandomAccessWriteDevice& d, - boost::uint64_t offset, const ConstBufferSequence& buffers, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - ec = boost::system::error_code(); - boost::asio::detail::consuming_buffers< - const_buffer, ConstBufferSequence> tmp(buffers); - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - while (tmp.begin() != tmp.end()) - { - std::size_t bytes_transferred = d.write_some_at( - offset + total_transferred, tmp, ec); - tmp.consume(bytes_transferred); - total_transferred += bytes_transferred; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - } - return total_transferred; -} - -template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence> -inline std::size_t write_at(SyncRandomAccessWriteDevice& d, - boost::uint64_t offset, const ConstBufferSequence& buffers) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write_at( - d, offset, buffers, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence, - typename CompletionCondition> -inline std::size_t write_at(SyncRandomAccessWriteDevice& d, - boost::uint64_t offset, const ConstBufferSequence& buffers, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write_at( - d, offset, buffers, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncRandomAccessWriteDevice, typename Allocator, - typename CompletionCondition> -std::size_t write_at(SyncRandomAccessWriteDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, boost::system::error_code& ec) -{ - std::size_t bytes_transferred = write_at( - d, offset, b.data(), completion_condition, ec); - b.consume(bytes_transferred); - return bytes_transferred; -} - -template <typename SyncRandomAccessWriteDevice, typename Allocator> -inline std::size_t write_at(SyncRandomAccessWriteDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write_at(d, offset, b, transfer_all(), ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -template <typename SyncRandomAccessWriteDevice, typename Allocator, - typename CompletionCondition> -inline std::size_t write_at(SyncRandomAccessWriteDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition) -{ - boost::system::error_code ec; - std::size_t bytes_transferred = write_at( - d, offset, b, completion_condition, ec); - boost::asio::detail::throw_error(ec); - return bytes_transferred; -} - -namespace detail -{ - template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> - class write_at_handler - { - public: - typedef boost::asio::detail::consuming_buffers< - const_buffer, ConstBufferSequence> buffers_type; - - write_at_handler(AsyncRandomAccessWriteDevice& stream, - boost::uint64_t offset, const buffers_type& buffers, - CompletionCondition completion_condition, WriteHandler handler) - : stream_(stream), - buffers_(buffers), - offset_(offset), - total_transferred_(0), - completion_condition_(completion_condition), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - total_transferred_ += bytes_transferred; - buffers_.consume(bytes_transferred); - buffers_.set_max_size(detail::adapt_completion_condition_result( - completion_condition_(ec, total_transferred_))); - if (buffers_.begin() == buffers_.end()) - { - handler_(ec, total_transferred_); - } - else - { - stream_.async_write_some_at( - offset_ + total_transferred_, buffers_, *this); - } - } - - //private: - AsyncRandomAccessWriteDevice& stream_; - buffers_type buffers_; - boost::uint64_t offset_; - std::size_t total_transferred_; - CompletionCondition completion_condition_; - WriteHandler handler_; - }; - - template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> - inline void* asio_handler_allocate(std::size_t size, - write_at_handler<AsyncRandomAccessWriteDevice, ConstBufferSequence, - CompletionCondition, WriteHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - write_at_handler<AsyncRandomAccessWriteDevice, ConstBufferSequence, - CompletionCondition, WriteHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncRandomAccessWriteDevice, - typename ConstBufferSequence, typename CompletionCondition, - typename WriteHandler> - inline void asio_handler_invoke(const Function& function, - write_at_handler<AsyncRandomAccessWriteDevice, ConstBufferSequence, - CompletionCondition, WriteHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence, - typename CompletionCondition, typename WriteHandler> -inline void async_write_at(AsyncRandomAccessWriteDevice& d, - boost::uint64_t offset, const ConstBufferSequence& buffers, - CompletionCondition completion_condition, WriteHandler handler) -{ - boost::asio::detail::consuming_buffers< - const_buffer, ConstBufferSequence> tmp(buffers); - - boost::system::error_code ec; - std::size_t total_transferred = 0; - tmp.set_max_size(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - if (tmp.begin() == tmp.end()) - { - d.get_io_service().post(detail::bind_handler( - handler, ec, total_transferred)); - return; - } - - d.async_write_some_at(offset, tmp, - detail::write_at_handler<AsyncRandomAccessWriteDevice, - ConstBufferSequence, CompletionCondition, WriteHandler>( - d, offset, tmp, completion_condition, handler)); -} - -template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence, - typename WriteHandler> -inline void async_write_at(AsyncRandomAccessWriteDevice& d, - boost::uint64_t offset, const ConstBufferSequence& buffers, - WriteHandler handler) -{ - async_write_at(d, offset, buffers, transfer_all(), handler); -} - -namespace detail -{ - template <typename AsyncRandomAccessWriteDevice, typename Allocator, - typename WriteHandler> - class write_at_streambuf_handler - { - public: - write_at_streambuf_handler( - boost::asio::basic_streambuf<Allocator>& streambuf, - WriteHandler handler) - : streambuf_(streambuf), - handler_(handler) - { - } - - void operator()(const boost::system::error_code& ec, - std::size_t bytes_transferred) - { - streambuf_.consume(bytes_transferred); - handler_(ec, bytes_transferred); - } - - //private: - boost::asio::basic_streambuf<Allocator>& streambuf_; - WriteHandler handler_; - }; - - template <typename AsyncRandomAccessWriteDevice, typename Allocator, - typename WriteHandler> - inline void* asio_handler_allocate(std::size_t size, - write_at_streambuf_handler<AsyncRandomAccessWriteDevice, - Allocator, WriteHandler>* this_handler) - { - return boost_asio_handler_alloc_helpers::allocate( - size, &this_handler->handler_); - } - - template <typename AsyncRandomAccessWriteDevice, typename Allocator, - typename WriteHandler> - inline void asio_handler_deallocate(void* pointer, std::size_t size, - write_at_streambuf_handler<AsyncRandomAccessWriteDevice, - Allocator, WriteHandler>* this_handler) - { - boost_asio_handler_alloc_helpers::deallocate( - pointer, size, &this_handler->handler_); - } - - template <typename Function, typename AsyncRandomAccessWriteDevice, - typename Allocator, typename WriteHandler> - inline void asio_handler_invoke(const Function& function, - write_at_streambuf_handler<AsyncRandomAccessWriteDevice, - Allocator, WriteHandler>* this_handler) - { - boost_asio_handler_invoke_helpers::invoke( - function, &this_handler->handler_); - } -} // namespace detail - -template <typename AsyncRandomAccessWriteDevice, typename Allocator, - typename CompletionCondition, typename WriteHandler> -inline void async_write_at(AsyncRandomAccessWriteDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - CompletionCondition completion_condition, WriteHandler handler) -{ - async_write_at(d, offset, b.data(), completion_condition, - detail::write_at_streambuf_handler< - AsyncRandomAccessWriteDevice, Allocator, WriteHandler>(b, handler)); -} - -template <typename AsyncRandomAccessWriteDevice, typename Allocator, - typename WriteHandler> -inline void async_write_at(AsyncRandomAccessWriteDevice& d, - boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b, - WriteHandler handler) -{ - async_write_at(d, offset, b, transfer_all(), handler); -} - -} // namespace asio -} // namespace boost - -#include <boost/asio/detail/pop_options.hpp> - -#endif // BOOST_ASIO_WRITE_AT_IPP |