You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2018/03/23 00:56:33 UTC
[13/51] [abbrv] [partial] hadoop git commit: Revert "Merge branch
'trunk' into HDFS-7240"
http://git-wip-us.apache.org/repos/asf/hadoop/blob/7a542fb3/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_at.hpp
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_at.hpp b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_at.hpp
deleted file mode 100644
index 0ce36bc..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_at.hpp
+++ /dev/null
@@ -1,810 +0,0 @@
-//
-// impl/read_at.hpp
-// ~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2014 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 ASIO_IMPL_READ_AT_HPP
-#define ASIO_IMPL_READ_AT_HPP
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-
-#include <algorithm>
-#include "asio/buffer.hpp"
-#include "asio/completion_condition.hpp"
-#include "asio/detail/array_fwd.hpp"
-#include "asio/detail/base_from_completion_cond.hpp"
-#include "asio/detail/bind_handler.hpp"
-#include "asio/detail/consuming_buffers.hpp"
-#include "asio/detail/dependent_type.hpp"
-#include "asio/detail/handler_alloc_helpers.hpp"
-#include "asio/detail/handler_cont_helpers.hpp"
-#include "asio/detail/handler_invoke_helpers.hpp"
-#include "asio/detail/handler_type_requirements.hpp"
-#include "asio/detail/throw_error.hpp"
-#include "asio/error.hpp"
-
-#include "asio/detail/push_options.hpp"
-
-namespace asio {
-
-template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
- typename CompletionCondition>
-std::size_t read_at(SyncRandomAccessReadDevice& d,
- uint64_t offset, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition, asio::error_code& ec)
-{
- ec = asio::error_code();
- asio::detail::consuming_buffers<
- mutable_buffer, MutableBufferSequence> tmp(buffers);
- std::size_t total_transferred = 0;
- tmp.prepare(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.prepare(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,
- uint64_t offset, const MutableBufferSequence& buffers)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_at(
- d, offset, buffers, transfer_all(), ec);
- asio::detail::throw_error(ec, "read_at");
- return bytes_transferred;
-}
-
-template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
-inline std::size_t read_at(SyncRandomAccessReadDevice& d,
- uint64_t offset, const MutableBufferSequence& buffers,
- asio::error_code& ec)
-{
- return read_at(d, offset, buffers, transfer_all(), ec);
-}
-
-template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
- typename CompletionCondition>
-inline std::size_t read_at(SyncRandomAccessReadDevice& d,
- uint64_t offset, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_at(
- d, offset, buffers, completion_condition, ec);
- asio::detail::throw_error(ec, "read_at");
- return bytes_transferred;
-}
-
-#if !defined(ASIO_NO_IOSTREAM)
-
-template <typename SyncRandomAccessReadDevice, typename Allocator,
- typename CompletionCondition>
-std::size_t read_at(SyncRandomAccessReadDevice& d,
- uint64_t offset, asio::basic_streambuf<Allocator>& b,
- CompletionCondition completion_condition, asio::error_code& ec)
-{
- ec = asio::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 = read_size_helper(b, max_size);
- while (bytes_available > 0)
- {
- 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;
- max_size = detail::adapt_completion_condition_result(
- completion_condition(ec, total_transferred));
- bytes_available = read_size_helper(b, max_size);
- }
- return total_transferred;
-}
-
-template <typename SyncRandomAccessReadDevice, typename Allocator>
-inline std::size_t read_at(SyncRandomAccessReadDevice& d,
- uint64_t offset, asio::basic_streambuf<Allocator>& b)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_at(
- d, offset, b, transfer_all(), ec);
- asio::detail::throw_error(ec, "read_at");
- return bytes_transferred;
-}
-
-template <typename SyncRandomAccessReadDevice, typename Allocator>
-inline std::size_t read_at(SyncRandomAccessReadDevice& d,
- uint64_t offset, asio::basic_streambuf<Allocator>& b,
- asio::error_code& ec)
-{
- return read_at(d, offset, b, transfer_all(), ec);
-}
-
-template <typename SyncRandomAccessReadDevice, typename Allocator,
- typename CompletionCondition>
-inline std::size_t read_at(SyncRandomAccessReadDevice& d,
- uint64_t offset, asio::basic_streambuf<Allocator>& b,
- CompletionCondition completion_condition)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_at(
- d, offset, b, completion_condition, ec);
- asio::detail::throw_error(ec, "read_at");
- return bytes_transferred;
-}
-
-#endif // !defined(ASIO_NO_IOSTREAM)
-
-namespace detail
-{
- template <typename AsyncRandomAccessReadDevice,
- typename MutableBufferSequence, typename CompletionCondition,
- typename ReadHandler>
- class read_at_op
- : detail::base_from_completion_cond<CompletionCondition>
- {
- public:
- read_at_op(AsyncRandomAccessReadDevice& device,
- uint64_t offset, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
- device_(device),
- offset_(offset),
- buffers_(buffers),
- start_(0),
- total_transferred_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_at_op(const read_at_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffers_(other.buffers_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(other.handler_)
- {
- }
-
- read_at_op(read_at_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffers_(other.buffers_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- switch (start_ = start)
- {
- case 1:
- buffers_.prepare(this->check_for_completion(ec, total_transferred_));
- for (;;)
- {
- device_.async_read_some_at(offset_ + total_transferred_,
- buffers_, ASIO_MOVE_CAST(read_at_op)(*this));
- return; default:
- total_transferred_ += bytes_transferred;
- buffers_.consume(bytes_transferred);
- buffers_.prepare(this->check_for_completion(ec, total_transferred_));
- if ((!ec && bytes_transferred == 0)
- || buffers_.begin() == buffers_.end())
- break;
- }
-
- handler_(ec, static_cast<const std::size_t&>(total_transferred_));
- }
- }
-
- //private:
- AsyncRandomAccessReadDevice& device_;
- uint64_t offset_;
- asio::detail::consuming_buffers<
- mutable_buffer, MutableBufferSequence> buffers_;
- int start_;
- std::size_t total_transferred_;
- ReadHandler handler_;
- };
-
- template <typename AsyncRandomAccessReadDevice,
- typename CompletionCondition, typename ReadHandler>
- class read_at_op<AsyncRandomAccessReadDevice,
- asio::mutable_buffers_1, CompletionCondition, ReadHandler>
- : detail::base_from_completion_cond<CompletionCondition>
- {
- public:
- read_at_op(AsyncRandomAccessReadDevice& device,
- uint64_t offset, const asio::mutable_buffers_1& buffers,
- CompletionCondition completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
- device_(device),
- offset_(offset),
- buffer_(buffers),
- start_(0),
- total_transferred_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_at_op(const read_at_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffer_(other.buffer_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(other.handler_)
- {
- }
-
- read_at_op(read_at_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffer_(other.buffer_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- std::size_t n = 0;
- switch (start_ = start)
- {
- case 1:
- n = this->check_for_completion(ec, total_transferred_);
- for (;;)
- {
- device_.async_read_some_at(offset_ + total_transferred_,
- asio::buffer(buffer_ + total_transferred_, n),
- ASIO_MOVE_CAST(read_at_op)(*this));
- return; default:
- total_transferred_ += bytes_transferred;
- if ((!ec && bytes_transferred == 0)
- || (n = this->check_for_completion(ec, total_transferred_)) == 0
- || total_transferred_ == asio::buffer_size(buffer_))
- break;
- }
-
- handler_(ec, static_cast<const std::size_t&>(total_transferred_));
- }
- }
-
- //private:
- AsyncRandomAccessReadDevice& device_;
- uint64_t offset_;
- asio::mutable_buffer buffer_;
- int start_;
- std::size_t total_transferred_;
- ReadHandler handler_;
- };
-
- template <typename AsyncRandomAccessReadDevice, typename Elem,
- typename CompletionCondition, typename ReadHandler>
- class read_at_op<AsyncRandomAccessReadDevice, boost::array<Elem, 2>,
- CompletionCondition, ReadHandler>
- : detail::base_from_completion_cond<CompletionCondition>
- {
- public:
- read_at_op(AsyncRandomAccessReadDevice& device,
- uint64_t offset, const boost::array<Elem, 2>& buffers,
- CompletionCondition completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
- device_(device),
- offset_(offset),
- buffers_(buffers),
- start_(0),
- total_transferred_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_at_op(const read_at_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffers_(other.buffers_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(other.handler_)
- {
- }
-
- read_at_op(read_at_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffers_(other.buffers_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- typename asio::detail::dependent_type<Elem,
- boost::array<asio::mutable_buffer, 2> >::type bufs = {{
- asio::mutable_buffer(buffers_[0]),
- asio::mutable_buffer(buffers_[1]) }};
- std::size_t buffer_size0 = asio::buffer_size(bufs[0]);
- std::size_t buffer_size1 = asio::buffer_size(bufs[1]);
- std::size_t n = 0;
- switch (start_ = start)
- {
- case 1:
- n = this->check_for_completion(ec, total_transferred_);
- for (;;)
- {
- bufs[0] = asio::buffer(bufs[0] + total_transferred_, n);
- bufs[1] = asio::buffer(
- bufs[1] + (total_transferred_ < buffer_size0
- ? 0 : total_transferred_ - buffer_size0),
- n - asio::buffer_size(bufs[0]));
- device_.async_read_some_at(offset_ + total_transferred_,
- bufs, ASIO_MOVE_CAST(read_at_op)(*this));
- return; default:
- total_transferred_ += bytes_transferred;
- if ((!ec && bytes_transferred == 0)
- || (n = this->check_for_completion(ec, total_transferred_)) == 0
- || total_transferred_ == buffer_size0 + buffer_size1)
- break;
- }
-
- handler_(ec, static_cast<const std::size_t&>(total_transferred_));
- }
- }
-
- //private:
- AsyncRandomAccessReadDevice& device_;
- uint64_t offset_;
- boost::array<Elem, 2> buffers_;
- int start_;
- std::size_t total_transferred_;
- ReadHandler handler_;
- };
-
-#if defined(ASIO_HAS_STD_ARRAY)
-
- template <typename AsyncRandomAccessReadDevice, typename Elem,
- typename CompletionCondition, typename ReadHandler>
- class read_at_op<AsyncRandomAccessReadDevice, std::array<Elem, 2>,
- CompletionCondition, ReadHandler>
- : detail::base_from_completion_cond<CompletionCondition>
- {
- public:
- read_at_op(AsyncRandomAccessReadDevice& device,
- uint64_t offset, const std::array<Elem, 2>& buffers,
- CompletionCondition completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
- device_(device),
- offset_(offset),
- buffers_(buffers),
- start_(0),
- total_transferred_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_at_op(const read_at_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffers_(other.buffers_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(other.handler_)
- {
- }
-
- read_at_op(read_at_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- buffers_(other.buffers_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- typename asio::detail::dependent_type<Elem,
- std::array<asio::mutable_buffer, 2> >::type bufs = {{
- asio::mutable_buffer(buffers_[0]),
- asio::mutable_buffer(buffers_[1]) }};
- std::size_t buffer_size0 = asio::buffer_size(bufs[0]);
- std::size_t buffer_size1 = asio::buffer_size(bufs[1]);
- std::size_t n = 0;
- switch (start_ = start)
- {
- case 1:
- n = this->check_for_completion(ec, total_transferred_);
- for (;;)
- {
- bufs[0] = asio::buffer(bufs[0] + total_transferred_, n);
- bufs[1] = asio::buffer(
- bufs[1] + (total_transferred_ < buffer_size0
- ? 0 : total_transferred_ - buffer_size0),
- n - asio::buffer_size(bufs[0]));
- device_.async_read_some_at(offset_ + total_transferred_,
- bufs, ASIO_MOVE_CAST(read_at_op)(*this));
- return; default:
- total_transferred_ += bytes_transferred;
- if ((!ec && bytes_transferred == 0)
- || (n = this->check_for_completion(ec, total_transferred_)) == 0
- || total_transferred_ == buffer_size0 + buffer_size1)
- break;
- }
-
- handler_(ec, static_cast<const std::size_t&>(total_transferred_));
- }
- }
-
- //private:
- AsyncRandomAccessReadDevice& device_;
- uint64_t offset_;
- std::array<Elem, 2> buffers_;
- int start_;
- std::size_t total_transferred_;
- ReadHandler handler_;
- };
-
-#endif // defined(ASIO_HAS_STD_ARRAY)
-
- template <typename AsyncRandomAccessReadDevice,
- typename MutableBufferSequence, typename CompletionCondition,
- typename ReadHandler>
- inline void* asio_handler_allocate(std::size_t size,
- read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
- CompletionCondition, ReadHandler>* this_handler)
- {
- return 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_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
- CompletionCondition, ReadHandler>* this_handler)
- {
- asio_handler_alloc_helpers::deallocate(
- pointer, size, this_handler->handler_);
- }
-
- template <typename AsyncRandomAccessReadDevice,
- typename MutableBufferSequence, typename CompletionCondition,
- typename ReadHandler>
- inline bool asio_handler_is_continuation(
- read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
- CompletionCondition, ReadHandler>* this_handler)
- {
- return this_handler->start_ == 0 ? true
- : asio_handler_cont_helpers::is_continuation(
- this_handler->handler_);
- }
-
- template <typename Function, typename AsyncRandomAccessReadDevice,
- typename MutableBufferSequence, typename CompletionCondition,
- typename ReadHandler>
- inline void asio_handler_invoke(Function& function,
- read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
- CompletionCondition, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-
- template <typename Function, typename AsyncRandomAccessReadDevice,
- typename MutableBufferSequence, typename CompletionCondition,
- typename ReadHandler>
- inline void asio_handler_invoke(const Function& function,
- read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
- CompletionCondition, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-
- template <typename AsyncRandomAccessReadDevice,
- typename MutableBufferSequence, typename CompletionCondition,
- typename ReadHandler>
- inline read_at_op<AsyncRandomAccessReadDevice,
- MutableBufferSequence, CompletionCondition, ReadHandler>
- make_read_at_op(AsyncRandomAccessReadDevice& d,
- uint64_t offset, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition, ReadHandler handler)
- {
- return read_at_op<AsyncRandomAccessReadDevice,
- MutableBufferSequence, CompletionCondition, ReadHandler>(
- d, offset, buffers, completion_condition, handler);
- }
-} // namespace detail
-
-template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
- typename CompletionCondition, typename ReadHandler>
-inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_at(AsyncRandomAccessReadDevice& d,
- uint64_t offset, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition,
- ASIO_MOVE_ARG(ReadHandler) handler)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
- CompletionCondition, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- d, offset, buffers, completion_condition, init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
- typename ReadHandler>
-inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_at(AsyncRandomAccessReadDevice& d,
- uint64_t offset, const MutableBufferSequence& buffers,
- ASIO_MOVE_ARG(ReadHandler) handler)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
- detail::transfer_all_t, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- d, offset, buffers, transfer_all(), init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-#if !defined(ASIO_NO_IOSTREAM)
-
-namespace detail
-{
- template <typename AsyncRandomAccessReadDevice, typename Allocator,
- typename CompletionCondition, typename ReadHandler>
- class read_at_streambuf_op
- : detail::base_from_completion_cond<CompletionCondition>
- {
- public:
- read_at_streambuf_op(AsyncRandomAccessReadDevice& device,
- uint64_t offset, basic_streambuf<Allocator>& streambuf,
- CompletionCondition completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
- device_(device),
- offset_(offset),
- streambuf_(streambuf),
- start_(0),
- total_transferred_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_at_streambuf_op(const read_at_streambuf_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- streambuf_(other.streambuf_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(other.handler_)
- {
- }
-
- read_at_streambuf_op(read_at_streambuf_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
- device_(other.device_),
- offset_(other.offset_),
- streambuf_(other.streambuf_),
- start_(other.start_),
- total_transferred_(other.total_transferred_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- std::size_t max_size, bytes_available;
- switch (start_ = start)
- {
- case 1:
- max_size = this->check_for_completion(ec, total_transferred_);
- bytes_available = read_size_helper(streambuf_, max_size);
- for (;;)
- {
- device_.async_read_some_at(offset_ + total_transferred_,
- streambuf_.prepare(bytes_available),
- ASIO_MOVE_CAST(read_at_streambuf_op)(*this));
- return; default:
- total_transferred_ += bytes_transferred;
- streambuf_.commit(bytes_transferred);
- max_size = this->check_for_completion(ec, total_transferred_);
- bytes_available = read_size_helper(streambuf_, max_size);
- if ((!ec && bytes_transferred == 0) || bytes_available == 0)
- break;
- }
-
- handler_(ec, static_cast<const std::size_t&>(total_transferred_));
- }
- }
-
- //private:
- AsyncRandomAccessReadDevice& device_;
- uint64_t offset_;
- asio::basic_streambuf<Allocator>& streambuf_;
- int start_;
- std::size_t total_transferred_;
- ReadHandler handler_;
- };
-
- template <typename AsyncRandomAccessReadDevice, typename Allocator,
- typename CompletionCondition, typename ReadHandler>
- inline void* asio_handler_allocate(std::size_t size,
- read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
- CompletionCondition, ReadHandler>* this_handler)
- {
- return 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_op<AsyncRandomAccessReadDevice, Allocator,
- CompletionCondition, ReadHandler>* this_handler)
- {
- asio_handler_alloc_helpers::deallocate(
- pointer, size, this_handler->handler_);
- }
-
- template <typename AsyncRandomAccessReadDevice, typename Allocator,
- typename CompletionCondition, typename ReadHandler>
- inline bool asio_handler_is_continuation(
- read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
- CompletionCondition, ReadHandler>* this_handler)
- {
- return this_handler->start_ == 0 ? true
- : asio_handler_cont_helpers::is_continuation(
- this_handler->handler_);
- }
-
- template <typename Function, typename AsyncRandomAccessReadDevice,
- typename Allocator, typename CompletionCondition, typename ReadHandler>
- inline void asio_handler_invoke(Function& function,
- read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
- CompletionCondition, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, 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_op<AsyncRandomAccessReadDevice, Allocator,
- CompletionCondition, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-} // namespace detail
-
-template <typename AsyncRandomAccessReadDevice, typename Allocator,
- typename CompletionCondition, typename ReadHandler>
-inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_at(AsyncRandomAccessReadDevice& d,
- uint64_t offset, asio::basic_streambuf<Allocator>& b,
- CompletionCondition completion_condition,
- ASIO_MOVE_ARG(ReadHandler) handler)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
- CompletionCondition, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- d, offset, b, completion_condition, init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-template <typename AsyncRandomAccessReadDevice, typename Allocator,
- typename ReadHandler>
-inline ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_at(AsyncRandomAccessReadDevice& d,
- uint64_t offset, asio::basic_streambuf<Allocator>& b,
- ASIO_MOVE_ARG(ReadHandler) handler)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
- detail::transfer_all_t, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- d, offset, b, transfer_all(), init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-#endif // !defined(ASIO_NO_IOSTREAM)
-
-} // namespace asio
-
-#include "asio/detail/pop_options.hpp"
-
-#endif // ASIO_IMPL_READ_AT_HPP
http://git-wip-us.apache.org/repos/asf/hadoop/blob/7a542fb3/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_until.hpp
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_until.hpp b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_until.hpp
deleted file mode 100644
index 88f3b50..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read_until.hpp
+++ /dev/null
@@ -1,1147 +0,0 @@
-//
-// impl/read_until.hpp
-// ~~~~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2014 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 ASIO_IMPL_READ_UNTIL_HPP
-#define ASIO_IMPL_READ_UNTIL_HPP
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-
-#include <algorithm>
-#include <string>
-#include <vector>
-#include <utility>
-#include "asio/buffer.hpp"
-#include "asio/buffers_iterator.hpp"
-#include "asio/detail/bind_handler.hpp"
-#include "asio/detail/handler_alloc_helpers.hpp"
-#include "asio/detail/handler_cont_helpers.hpp"
-#include "asio/detail/handler_invoke_helpers.hpp"
-#include "asio/detail/handler_type_requirements.hpp"
-#include "asio/detail/limits.hpp"
-#include "asio/detail/throw_error.hpp"
-
-#include "asio/detail/push_options.hpp"
-
-namespace asio {
-
-template <typename SyncReadStream, typename Allocator>
-inline std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, char delim)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_until(s, b, delim, ec);
- asio::detail::throw_error(ec, "read_until");
- return bytes_transferred;
-}
-
-template <typename SyncReadStream, typename Allocator>
-std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, char delim,
- asio::error_code& ec)
-{
- std::size_t search_position = 0;
- for (;;)
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = b.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- iterator iter = std::find(start_pos, end, delim);
- if (iter != end)
- {
- // Found a match. We're done.
- ec = asio::error_code();
- return iter - begin + 1;
- }
- else
- {
- // No match. Next search can start with the new data.
- search_position = 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_to_read = read_size_helper(b, 65536);
- b.commit(s.read_some(b.prepare(bytes_to_read), ec));
- if (ec)
- return 0;
- }
-}
-
-template <typename SyncReadStream, typename Allocator>
-inline std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const std::string& delim)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_until(s, b, delim, ec);
- asio::detail::throw_error(ec, "read_until");
- 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,
- asio::basic_streambuf<Allocator>& b, const std::string& delim,
- asio::error_code& ec)
-{
- std::size_t search_position = 0;
- for (;;)
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = b.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- std::pair<iterator, bool> result = detail::partial_search(
- start_pos, end, delim.begin(), delim.end());
- if (result.first != end)
- {
- if (result.second)
- {
- // Full match. We're done.
- ec = asio::error_code();
- return result.first - begin + delim.length();
- }
- else
- {
- // Partial match. Next search needs to start from beginning of match.
- search_position = result.first - begin;
- }
- }
- else
- {
- // No match. Next search can start with the new data.
- search_position = 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_to_read = read_size_helper(b, 65536);
- b.commit(s.read_some(b.prepare(bytes_to_read), ec));
- if (ec)
- return 0;
- }
-}
-
-#if defined(ASIO_HAS_BOOST_REGEX)
-
-template <typename SyncReadStream, typename Allocator>
-inline std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const boost::regex& expr)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_until(s, b, expr, ec);
- asio::detail::throw_error(ec, "read_until");
- return bytes_transferred;
-}
-
-template <typename SyncReadStream, typename Allocator>
-std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
- asio::error_code& ec)
-{
- std::size_t search_position = 0;
- for (;;)
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = b.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- boost::match_results<iterator,
- typename std::vector<boost::sub_match<iterator> >::allocator_type>
- match_results;
- if (regex_search(start_pos, end, match_results, expr,
- boost::match_default | boost::match_partial))
- {
- if (match_results[0].matched)
- {
- // Full match. We're done.
- ec = asio::error_code();
- return match_results[0].second - begin;
- }
- else
- {
- // Partial match. Next search needs to start from beginning of match.
- search_position = match_results[0].first - begin;
- }
- }
- else
- {
- // No match. Next search can start with the new data.
- search_position = 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_to_read = read_size_helper(b, 65536);
- b.commit(s.read_some(b.prepare(bytes_to_read), ec));
- if (ec)
- return 0;
- }
-}
-
-#endif // defined(ASIO_HAS_BOOST_REGEX)
-
-template <typename SyncReadStream, typename Allocator, typename MatchCondition>
-std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b,
- MatchCondition match_condition, asio::error_code& ec,
- typename enable_if<is_match_condition<MatchCondition>::value>::type*)
-{
- std::size_t search_position = 0;
- for (;;)
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = b.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- std::pair<iterator, bool> result = match_condition(start_pos, end);
- if (result.second)
- {
- // Full match. We're done.
- ec = asio::error_code();
- return result.first - begin;
- }
- else if (result.first != end)
- {
- // Partial match. Next search needs to start from beginning of match.
- search_position = result.first - begin;
- }
- else
- {
- // No match. Next search can start with the new data.
- search_position = 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_to_read = read_size_helper(b, 65536);
- b.commit(s.read_some(b.prepare(bytes_to_read), ec));
- if (ec)
- return 0;
- }
-}
-
-template <typename SyncReadStream, typename Allocator, typename MatchCondition>
-inline std::size_t read_until(SyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, MatchCondition match_condition,
- typename enable_if<is_match_condition<MatchCondition>::value>::type*)
-{
- asio::error_code ec;
- std::size_t bytes_transferred = read_until(s, b, match_condition, ec);
- asio::detail::throw_error(ec, "read_until");
- return bytes_transferred;
-}
-
-namespace detail
-{
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- class read_until_delim_op
- {
- public:
- read_until_delim_op(AsyncReadStream& stream,
- asio::basic_streambuf<Allocator>& streambuf,
- char delim, ReadHandler& handler)
- : stream_(stream),
- streambuf_(streambuf),
- delim_(delim),
- start_(0),
- search_position_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_until_delim_op(const read_until_delim_op& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- delim_(other.delim_),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(other.handler_)
- {
- }
-
- read_until_delim_op(read_until_delim_op&& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- delim_(other.delim_),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- const std::size_t not_found = (std::numeric_limits<std::size_t>::max)();
- std::size_t bytes_to_read;
- switch (start_ = start)
- {
- case 1:
- for (;;)
- {
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = streambuf_.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position_;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- iterator iter = std::find(start_pos, end, delim_);
- if (iter != end)
- {
- // Found a match. We're done.
- search_position_ = iter - begin + 1;
- bytes_to_read = 0;
- }
-
- // No match yet. Check if buffer is full.
- else if (streambuf_.size() == streambuf_.max_size())
- {
- search_position_ = not_found;
- bytes_to_read = 0;
- }
-
- // Need to read some more data.
- else
- {
- // Next search can start with the new data.
- search_position_ = end - begin;
- bytes_to_read = read_size_helper(streambuf_, 65536);
- }
- }
-
- // Check if we're done.
- if (!start && bytes_to_read == 0)
- break;
-
- // Start a new asynchronous read operation to obtain more data.
- stream_.async_read_some(streambuf_.prepare(bytes_to_read),
- ASIO_MOVE_CAST(read_until_delim_op)(*this));
- return; default:
- streambuf_.commit(bytes_transferred);
- if (ec || bytes_transferred == 0)
- break;
- }
-
- const asio::error_code result_ec =
- (search_position_ == not_found)
- ? error::not_found : ec;
-
- const std::size_t result_n =
- (ec || search_position_ == not_found)
- ? 0 : search_position_;
-
- handler_(result_ec, result_n);
- }
- }
-
- //private:
- AsyncReadStream& stream_;
- asio::basic_streambuf<Allocator>& streambuf_;
- char delim_;
- int start_;
- std::size_t search_position_;
- ReadHandler handler_;
- };
-
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- inline void* asio_handler_allocate(std::size_t size,
- read_until_delim_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- return 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_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- asio_handler_alloc_helpers::deallocate(
- pointer, size, this_handler->handler_);
- }
-
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- inline bool asio_handler_is_continuation(
- read_until_delim_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- return this_handler->start_ == 0 ? true
- : asio_handler_cont_helpers::is_continuation(
- this_handler->handler_);
- }
-
- template <typename Function, typename AsyncReadStream, typename Allocator,
- typename ReadHandler>
- inline void asio_handler_invoke(Function& function,
- read_until_delim_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-
- template <typename Function, typename AsyncReadStream, typename Allocator,
- typename ReadHandler>
- inline void asio_handler_invoke(const Function& function,
- read_until_delim_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-} // namespace detail
-
-template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, char delim,
- ASIO_MOVE_ARG(ReadHandler) handler)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_until_delim_op<AsyncReadStream,
- Allocator, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- s, b, delim, init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-namespace detail
-{
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- class read_until_delim_string_op
- {
- public:
- read_until_delim_string_op(AsyncReadStream& stream,
- asio::basic_streambuf<Allocator>& streambuf,
- const std::string& delim, ReadHandler& handler)
- : stream_(stream),
- streambuf_(streambuf),
- delim_(delim),
- start_(0),
- search_position_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_until_delim_string_op(const read_until_delim_string_op& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- delim_(other.delim_),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(other.handler_)
- {
- }
-
- read_until_delim_string_op(read_until_delim_string_op&& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- delim_(ASIO_MOVE_CAST(std::string)(other.delim_)),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- const std::size_t not_found = (std::numeric_limits<std::size_t>::max)();
- std::size_t bytes_to_read;
- switch (start_ = start)
- {
- case 1:
- for (;;)
- {
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = streambuf_.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position_;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- std::pair<iterator, bool> result = detail::partial_search(
- start_pos, end, delim_.begin(), delim_.end());
- if (result.first != end && result.second)
- {
- // Full match. We're done.
- search_position_ = result.first - begin + delim_.length();
- bytes_to_read = 0;
- }
-
- // No match yet. Check if buffer is full.
- else if (streambuf_.size() == streambuf_.max_size())
- {
- search_position_ = not_found;
- bytes_to_read = 0;
- }
-
- // Need to read some more data.
- else
- {
- if (result.first != end)
- {
- // Partial match. Next search needs to start from beginning of
- // match.
- search_position_ = result.first - begin;
- }
- else
- {
- // Next search can start with the new data.
- search_position_ = end - begin;
- }
-
- bytes_to_read = read_size_helper(streambuf_, 65536);
- }
- }
-
- // Check if we're done.
- if (!start && bytes_to_read == 0)
- break;
-
- // Start a new asynchronous read operation to obtain more data.
- stream_.async_read_some(streambuf_.prepare(bytes_to_read),
- ASIO_MOVE_CAST(read_until_delim_string_op)(*this));
- return; default:
- streambuf_.commit(bytes_transferred);
- if (ec || bytes_transferred == 0)
- break;
- }
-
- const asio::error_code result_ec =
- (search_position_ == not_found)
- ? error::not_found : ec;
-
- const std::size_t result_n =
- (ec || search_position_ == not_found)
- ? 0 : search_position_;
-
- handler_(result_ec, result_n);
- }
- }
-
- //private:
- AsyncReadStream& stream_;
- asio::basic_streambuf<Allocator>& streambuf_;
- std::string delim_;
- int start_;
- std::size_t search_position_;
- ReadHandler handler_;
- };
-
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- inline void* asio_handler_allocate(std::size_t size,
- read_until_delim_string_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- return 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_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- asio_handler_alloc_helpers::deallocate(
- pointer, size, this_handler->handler_);
- }
-
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- inline bool asio_handler_is_continuation(
- read_until_delim_string_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- return this_handler->start_ == 0 ? true
- : asio_handler_cont_helpers::is_continuation(
- this_handler->handler_);
- }
-
- template <typename Function, typename AsyncReadStream,
- typename Allocator, typename ReadHandler>
- inline void asio_handler_invoke(Function& function,
- read_until_delim_string_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-
- template <typename Function, typename AsyncReadStream,
- typename Allocator, typename ReadHandler>
- inline void asio_handler_invoke(const Function& function,
- read_until_delim_string_op<AsyncReadStream,
- Allocator, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-} // namespace detail
-
-template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const std::string& delim,
- ASIO_MOVE_ARG(ReadHandler) handler)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_until_delim_string_op<AsyncReadStream,
- Allocator, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- s, b, delim, init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-#if defined(ASIO_HAS_BOOST_REGEX)
-
-namespace detail
-{
- template <typename AsyncReadStream, typename Allocator,
- typename RegEx, typename ReadHandler>
- class read_until_expr_op
- {
- public:
- read_until_expr_op(AsyncReadStream& stream,
- asio::basic_streambuf<Allocator>& streambuf,
- const boost::regex& expr, ReadHandler& handler)
- : stream_(stream),
- streambuf_(streambuf),
- expr_(expr),
- start_(0),
- search_position_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_until_expr_op(const read_until_expr_op& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- expr_(other.expr_),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(other.handler_)
- {
- }
-
- read_until_expr_op(read_until_expr_op&& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- expr_(other.expr_),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- const std::size_t not_found = (std::numeric_limits<std::size_t>::max)();
- std::size_t bytes_to_read;
- switch (start_ = start)
- {
- case 1:
- for (;;)
- {
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = streambuf_.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position_;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- boost::match_results<iterator,
- typename std::vector<boost::sub_match<iterator> >::allocator_type>
- match_results;
- bool match = regex_search(start_pos, end, match_results, expr_,
- boost::match_default | boost::match_partial);
- if (match && match_results[0].matched)
- {
- // Full match. We're done.
- search_position_ = match_results[0].second - begin;
- bytes_to_read = 0;
- }
-
- // No match yet. Check if buffer is full.
- else if (streambuf_.size() == streambuf_.max_size())
- {
- search_position_ = not_found;
- bytes_to_read = 0;
- }
-
- // Need to read some more data.
- else
- {
- if (match)
- {
- // Partial match. Next search needs to start from beginning of
- // match.
- search_position_ = match_results[0].first - begin;
- }
- else
- {
- // Next search can start with the new data.
- search_position_ = end - begin;
- }
-
- bytes_to_read = read_size_helper(streambuf_, 65536);
- }
- }
-
- // Check if we're done.
- if (!start && bytes_to_read == 0)
- break;
-
- // Start a new asynchronous read operation to obtain more data.
- stream_.async_read_some(streambuf_.prepare(bytes_to_read),
- ASIO_MOVE_CAST(read_until_expr_op)(*this));
- return; default:
- streambuf_.commit(bytes_transferred);
- if (ec || bytes_transferred == 0)
- break;
- }
-
- const asio::error_code result_ec =
- (search_position_ == not_found)
- ? error::not_found : ec;
-
- const std::size_t result_n =
- (ec || search_position_ == not_found)
- ? 0 : search_position_;
-
- handler_(result_ec, result_n);
- }
- }
-
- //private:
- AsyncReadStream& stream_;
- asio::basic_streambuf<Allocator>& streambuf_;
- RegEx expr_;
- int start_;
- std::size_t search_position_;
- ReadHandler handler_;
- };
-
- template <typename AsyncReadStream, typename Allocator,
- typename RegEx, typename ReadHandler>
- inline void* asio_handler_allocate(std::size_t size,
- read_until_expr_op<AsyncReadStream,
- Allocator, RegEx, ReadHandler>* this_handler)
- {
- return asio_handler_alloc_helpers::allocate(
- size, this_handler->handler_);
- }
-
- template <typename AsyncReadStream, typename Allocator,
- typename RegEx, typename ReadHandler>
- inline void asio_handler_deallocate(void* pointer, std::size_t size,
- read_until_expr_op<AsyncReadStream,
- Allocator, RegEx, ReadHandler>* this_handler)
- {
- asio_handler_alloc_helpers::deallocate(
- pointer, size, this_handler->handler_);
- }
-
- template <typename AsyncReadStream, typename Allocator,
- typename RegEx, typename ReadHandler>
- inline bool asio_handler_is_continuation(
- read_until_expr_op<AsyncReadStream,
- Allocator, RegEx, ReadHandler>* this_handler)
- {
- return this_handler->start_ == 0 ? true
- : asio_handler_cont_helpers::is_continuation(
- this_handler->handler_);
- }
-
- template <typename Function, typename AsyncReadStream, typename Allocator,
- typename RegEx, typename ReadHandler>
- inline void asio_handler_invoke(Function& function,
- read_until_expr_op<AsyncReadStream,
- Allocator, RegEx, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-
- template <typename Function, typename AsyncReadStream, typename Allocator,
- typename RegEx, typename ReadHandler>
- inline void asio_handler_invoke(const Function& function,
- read_until_expr_op<AsyncReadStream,
- Allocator, RegEx, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-} // namespace detail
-
-template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
- ASIO_MOVE_ARG(ReadHandler) handler)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_until_expr_op<AsyncReadStream, Allocator,
- boost::regex, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- s, b, expr, init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-#endif // defined(ASIO_HAS_BOOST_REGEX)
-
-namespace detail
-{
- template <typename AsyncReadStream, typename Allocator,
- typename MatchCondition, typename ReadHandler>
- class read_until_match_op
- {
- public:
- read_until_match_op(AsyncReadStream& stream,
- asio::basic_streambuf<Allocator>& streambuf,
- MatchCondition match_condition, ReadHandler& handler)
- : stream_(stream),
- streambuf_(streambuf),
- match_condition_(match_condition),
- start_(0),
- search_position_(0),
- handler_(ASIO_MOVE_CAST(ReadHandler)(handler))
- {
- }
-
-#if defined(ASIO_HAS_MOVE)
- read_until_match_op(const read_until_match_op& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- match_condition_(other.match_condition_),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(other.handler_)
- {
- }
-
- read_until_match_op(read_until_match_op&& other)
- : stream_(other.stream_),
- streambuf_(other.streambuf_),
- match_condition_(other.match_condition_),
- start_(other.start_),
- search_position_(other.search_position_),
- handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_))
- {
- }
-#endif // defined(ASIO_HAS_MOVE)
-
- void operator()(const asio::error_code& ec,
- std::size_t bytes_transferred, int start = 0)
- {
- const std::size_t not_found = (std::numeric_limits<std::size_t>::max)();
- std::size_t bytes_to_read;
- switch (start_ = start)
- {
- case 1:
- for (;;)
- {
- {
- // Determine the range of the data to be searched.
- typedef typename asio::basic_streambuf<
- Allocator>::const_buffers_type const_buffers_type;
- typedef asio::buffers_iterator<const_buffers_type> iterator;
- const_buffers_type buffers = streambuf_.data();
- iterator begin = iterator::begin(buffers);
- iterator start_pos = begin + search_position_;
- iterator end = iterator::end(buffers);
-
- // Look for a match.
- std::pair<iterator, bool> result = match_condition_(start_pos, end);
- if (result.second)
- {
- // Full match. We're done.
- search_position_ = result.first - begin;
- bytes_to_read = 0;
- }
-
- // No match yet. Check if buffer is full.
- else if (streambuf_.size() == streambuf_.max_size())
- {
- search_position_ = not_found;
- bytes_to_read = 0;
- }
-
- // Need to read some more data.
- else
- {
- if (result.first != end)
- {
- // Partial match. Next search needs to start from beginning of
- // match.
- search_position_ = result.first - begin;
- }
- else
- {
- // Next search can start with the new data.
- search_position_ = end - begin;
- }
-
- bytes_to_read = read_size_helper(streambuf_, 65536);
- }
- }
-
- // Check if we're done.
- if (!start && bytes_to_read == 0)
- break;
-
- // Start a new asynchronous read operation to obtain more data.
- stream_.async_read_some(streambuf_.prepare(bytes_to_read),
- ASIO_MOVE_CAST(read_until_match_op)(*this));
- return; default:
- streambuf_.commit(bytes_transferred);
- if (ec || bytes_transferred == 0)
- break;
- }
-
- const asio::error_code result_ec =
- (search_position_ == not_found)
- ? error::not_found : ec;
-
- const std::size_t result_n =
- (ec || search_position_ == not_found)
- ? 0 : search_position_;
-
- handler_(result_ec, result_n);
- }
- }
-
- //private:
- AsyncReadStream& stream_;
- asio::basic_streambuf<Allocator>& streambuf_;
- MatchCondition match_condition_;
- int start_;
- std::size_t search_position_;
- ReadHandler handler_;
- };
-
- template <typename AsyncReadStream, typename Allocator,
- typename MatchCondition, typename ReadHandler>
- inline void* asio_handler_allocate(std::size_t size,
- read_until_match_op<AsyncReadStream,
- Allocator, MatchCondition, ReadHandler>* this_handler)
- {
- return 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_op<AsyncReadStream,
- Allocator, MatchCondition, ReadHandler>* this_handler)
- {
- asio_handler_alloc_helpers::deallocate(
- pointer, size, this_handler->handler_);
- }
-
- template <typename AsyncReadStream, typename Allocator,
- typename MatchCondition, typename ReadHandler>
- inline bool asio_handler_is_continuation(
- read_until_match_op<AsyncReadStream,
- Allocator, MatchCondition, ReadHandler>* this_handler)
- {
- return this_handler->start_ == 0 ? true
- : asio_handler_cont_helpers::is_continuation(
- this_handler->handler_);
- }
-
- template <typename Function, typename AsyncReadStream, typename Allocator,
- typename MatchCondition, typename ReadHandler>
- inline void asio_handler_invoke(Function& function,
- read_until_match_op<AsyncReadStream,
- Allocator, MatchCondition, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, 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_op<AsyncReadStream,
- Allocator, MatchCondition, ReadHandler>* this_handler)
- {
- asio_handler_invoke_helpers::invoke(
- function, this_handler->handler_);
- }
-} // namespace detail
-
-template <typename AsyncReadStream, typename Allocator,
- typename MatchCondition, typename ReadHandler>
-ASIO_INITFN_RESULT_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))
-async_read_until(AsyncReadStream& s,
- asio::basic_streambuf<Allocator>& b,
- MatchCondition match_condition, ASIO_MOVE_ARG(ReadHandler) handler,
- typename enable_if<is_match_condition<MatchCondition>::value>::type*)
-{
- // If you get an error on the following line it means that your handler does
- // not meet the documented type requirements for a ReadHandler.
- ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
-
- detail::async_result_init<
- ReadHandler, void (asio::error_code, std::size_t)> init(
- ASIO_MOVE_CAST(ReadHandler)(handler));
-
- detail::read_until_match_op<AsyncReadStream, Allocator,
- MatchCondition, ASIO_HANDLER_TYPE(ReadHandler,
- void (asio::error_code, std::size_t))>(
- s, b, match_condition, init.handler)(
- asio::error_code(), 0, 1);
-
- return init.result.get();
-}
-
-} // namespace asio
-
-#include "asio/detail/pop_options.hpp"
-
-#endif // ASIO_IMPL_READ_UNTIL_HPP
http://git-wip-us.apache.org/repos/asf/hadoop/blob/7a542fb3/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.hpp
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.hpp b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.hpp
deleted file mode 100644
index bfdb08d..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// impl/serial_port_base.hpp
-// ~~~~~~~~~~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2014 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 ASIO_IMPL_SERIAL_PORT_BASE_HPP
-#define ASIO_IMPL_SERIAL_PORT_BASE_HPP
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-
-#include "asio/detail/push_options.hpp"
-
-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 serial_port_base::flow_control::type
-serial_port_base::flow_control::value() const
-{
- return value_;
-}
-
-inline serial_port_base::parity::type serial_port_base::parity::value() const
-{
- return value_;
-}
-
-inline serial_port_base::stop_bits::type
-serial_port_base::stop_bits::value() const
-{
- return value_;
-}
-
-inline unsigned int serial_port_base::character_size::value() const
-{
- return value_;
-}
-
-} // namespace asio
-
-#include "asio/detail/pop_options.hpp"
-
-#endif // ASIO_IMPL_SERIAL_PORT_BASE_HPP
http://git-wip-us.apache.org/repos/asf/hadoop/blob/7a542fb3/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.ipp
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.ipp b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.ipp
deleted file mode 100644
index 60bed7f..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/serial_port_base.ipp
+++ /dev/null
@@ -1,554 +0,0 @@
-//
-// impl/serial_port_base.ipp
-// ~~~~~~~~~~~~~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2014 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 ASIO_IMPL_SERIAL_PORT_BASE_IPP
-#define ASIO_IMPL_SERIAL_PORT_BASE_IPP
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-
-#include "asio/detail/config.hpp"
-
-#if defined(ASIO_HAS_SERIAL_PORT)
-
-#include <stdexcept>
-#include "asio/error.hpp"
-#include "asio/serial_port_base.hpp"
-#include "asio/detail/throw_exception.hpp"
-
-#if defined(GENERATING_DOCUMENTATION)
-# define ASIO_OPTION_STORAGE implementation_defined
-#elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
-# define ASIO_OPTION_STORAGE DCB
-#else
-# define ASIO_OPTION_STORAGE termios
-#endif
-
-#include "asio/detail/push_options.hpp"
-
-namespace asio {
-
-asio::error_code serial_port_base::baud_rate::store(
- ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
-{
-#if defined(ASIO_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:
- ec = asio::error::invalid_argument;
- return ec;
- }
-# if defined(_BSD_SOURCE)
- ::cfsetspeed(&storage, baud);
-# else
- ::cfsetispeed(&storage, baud);
- ::cfsetospeed(&storage, baud);
-# endif
-#endif
- ec = asio::error_code();
- return ec;
-}
-
-asio::error_code serial_port_base::baud_rate::load(
- const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
-{
-#if defined(ASIO_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 = asio::error::invalid_argument;
- return ec;
- }
-#endif
- ec = asio::error_code();
- return ec;
-}
-
-serial_port_base::flow_control::flow_control(
- serial_port_base::flow_control::type t)
- : value_(t)
-{
- if (t != none && t != software && t != hardware)
- {
- std::out_of_range ex("invalid flow_control value");
- asio::detail::throw_exception(ex);
- }
-}
-
-asio::error_code serial_port_base::flow_control::store(
- ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
-{
-#if defined(ASIO_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;
-# elif defined(__QNXNTO__)
- storage.c_cflag &= ~(IHFLOW | OHFLOW);
-# endif
- break;
- case software:
- storage.c_iflag |= IXOFF | IXON;
-# if defined(_BSD_SOURCE)
- storage.c_cflag &= ~CRTSCTS;
-# elif defined(__QNXNTO__)
- storage.c_cflag &= ~(IHFLOW | OHFLOW);
-# endif
- break;
- case hardware:
-# if defined(_BSD_SOURCE)
- storage.c_iflag &= ~(IXOFF | IXON);
- storage.c_cflag |= CRTSCTS;
- break;
-# elif defined(__QNXNTO__)
- storage.c_iflag &= ~(IXOFF | IXON);
- storage.c_cflag |= (IHFLOW | OHFLOW);
- break;
-# else
- ec = asio::error::operation_not_supported;
- return ec;
-# endif
- default:
- break;
- }
-#endif
- ec = asio::error_code();
- return ec;
-}
-
-asio::error_code serial_port_base::flow_control::load(
- const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
-{
-#if defined(ASIO_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;
- }
-# elif defined(__QNXNTO__)
- else if (storage.c_cflag & IHFLOW && storage.c_cflag & OHFLOW)
- {
- value_ = hardware;
- }
-# endif
- else
- {
- value_ = none;
- }
-#endif
- ec = asio::error_code();
- return ec;
-}
-
-serial_port_base::parity::parity(serial_port_base::parity::type t)
- : value_(t)
-{
- if (t != none && t != odd && t != even)
- {
- std::out_of_range ex("invalid parity value");
- asio::detail::throw_exception(ex);
- }
-}
-
-asio::error_code serial_port_base::parity::store(
- ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
-{
-#if defined(ASIO_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 = asio::error_code();
- return ec;
-}
-
-asio::error_code serial_port_base::parity::load(
- const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
-{
-#if defined(ASIO_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 = asio::error_code();
- return ec;
-}
-
-serial_port_base::stop_bits::stop_bits(
- serial_port_base::stop_bits::type t)
- : value_(t)
-{
- if (t != one && t != onepointfive && t != two)
- {
- std::out_of_range ex("invalid stop_bits value");
- asio::detail::throw_exception(ex);
- }
-}
-
-asio::error_code serial_port_base::stop_bits::store(
- ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
-{
-#if defined(ASIO_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 = asio::error::operation_not_supported;
- return ec;
- }
-#endif
- ec = asio::error_code();
- return ec;
-}
-
-asio::error_code serial_port_base::stop_bits::load(
- const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
-{
-#if defined(ASIO_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 = asio::error_code();
- return ec;
-}
-
-serial_port_base::character_size::character_size(unsigned int t)
- : value_(t)
-{
- if (t < 5 || t > 8)
- {
- std::out_of_range ex("invalid character_size value");
- asio::detail::throw_exception(ex);
- }
-}
-
-asio::error_code serial_port_base::character_size::store(
- ASIO_OPTION_STORAGE& storage, asio::error_code& ec) const
-{
-#if defined(ASIO_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 = asio::error_code();
- return ec;
-}
-
-asio::error_code serial_port_base::character_size::load(
- const ASIO_OPTION_STORAGE& storage, asio::error_code& ec)
-{
-#if defined(ASIO_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 = asio::error_code();
- return ec;
-}
-
-} // namespace asio
-
-#include "asio/detail/pop_options.hpp"
-
-#undef ASIO_OPTION_STORAGE
-
-#endif // defined(ASIO_HAS_SERIAL_PORT)
-
-#endif // ASIO_IMPL_SERIAL_PORT_BASE_IPP
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org