Updated Boost libraries to version 1.49, and recompiled them with NDK r8d
This commit is contained in:
@@ -7,18 +7,7 @@ ifneq ($(LOCAL_MODULE),boost)
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
|
||||
ifneq ($(NDK_R5_TOOLCHAIN),)
|
||||
LOCAL_SRC_FILES := lib/arm-linux-androideabi-4.4.3/lib$(LOCAL_MODULE).a
|
||||
LOCAL_SRC_FILES := lib/arm-linux-androideabi-4.6/lib$(LOCAL_MODULE).a
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
else
|
||||
LOCAL_SRC_FILES := dummy.c
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
$(abspath $(LOCAL_PATH)/../../obj/local/armeabi/lib$(LOCAL_MODULE).a): $(LOCAL_PATH)/lib/arm-eabi-4.4.0/lib$(LOCAL_MODULE).a OVERRIDE_CUSTOM_LIB
|
||||
cp -f $< $@
|
||||
$(abspath $(LOCAL_PATH)/../../obj/local/armeabi-v7a/lib$(LOCAL_MODULE).a): $(LOCAL_PATH)/lib/arm-eabi-4.4.0/lib$(LOCAL_MODULE).a OVERRIDE_CUSTOM_LIB
|
||||
cp -f $< $@
|
||||
.PHONY: OVERRIDE_CUSTOM_LIB
|
||||
OVERRIDE_CUSTOM_LIB:
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
int
|
||||
SDL_main(int argc, char *argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)
|
||||
#endif
|
||||
|
||||
#define BOOST_ACCUMULATORS_GCC_VERSION \
|
||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <limits>
|
||||
#include <functional>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
@@ -277,6 +278,8 @@ namespace boost { namespace numeric
|
||||
struct as_min_base
|
||||
: std::unary_function<Arg, typename remove_const<Arg>::type>
|
||||
{
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized);
|
||||
|
||||
typename remove_const<Arg>::type operator ()(Arg &) const
|
||||
{
|
||||
return (std::numeric_limits<typename remove_const<Arg>::type>::min)();
|
||||
@@ -287,6 +290,8 @@ namespace boost { namespace numeric
|
||||
struct as_min_base<Arg, typename enable_if<is_floating_point<Arg> >::type>
|
||||
: std::unary_function<Arg, typename remove_const<Arg>::type>
|
||||
{
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized);
|
||||
|
||||
typename remove_const<Arg>::type operator ()(Arg &) const
|
||||
{
|
||||
return -(std::numeric_limits<typename remove_const<Arg>::type>::max)();
|
||||
@@ -297,6 +302,8 @@ namespace boost { namespace numeric
|
||||
struct as_max_base
|
||||
: std::unary_function<Arg, typename remove_const<Arg>::type>
|
||||
{
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized);
|
||||
|
||||
typename remove_const<Arg>::type operator ()(Arg &) const
|
||||
{
|
||||
return (std::numeric_limits<typename remove_const<Arg>::type>::max)();
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <boost/accumulators/statistics/skewness.hpp>
|
||||
#include <boost/accumulators/statistics/stats.hpp>
|
||||
#include <boost/accumulators/statistics/sum.hpp>
|
||||
#include <boost/accumulators/statistics/sum_kahan.hpp>
|
||||
#include <boost/accumulators/statistics/tail.hpp>
|
||||
#include <boost/accumulators/statistics/tail_quantile.hpp>
|
||||
#include <boost/accumulators/statistics/tail_mean.hpp>
|
||||
@@ -48,6 +49,7 @@
|
||||
#include <boost/accumulators/statistics/weighted_p_square_quantile.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_skewness.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_sum.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_sum_kahan.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_tail_quantile.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_tail_mean.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_tail_variate_means.hpp>
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// sum_kahan.hpp
|
||||
//
|
||||
// Copyright 2010 Gaetano Mendola, 2011 Simon West. 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_ACCUMULATORS_STATISTICS_SUM_KAHAN_HPP_EAN_26_07_2010
|
||||
#define BOOST_ACCUMULATORS_STATISTICS_SUM_KAHAN_HPP_EAN_26_07_2010
|
||||
|
||||
#include <boost/accumulators/framework/accumulator_base.hpp>
|
||||
#include <boost/accumulators/framework/parameters/sample.hpp>
|
||||
#include <boost/accumulators/statistics_fwd.hpp>
|
||||
#include <boost/accumulators/statistics/sum.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_sum_kahan.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
|
||||
namespace impl
|
||||
{
|
||||
|
||||
#if _MSC_VER > 1400
|
||||
# pragma float_control(push)
|
||||
# pragma float_control(precise, on)
|
||||
#endif
|
||||
|
||||
template<typename Sample, typename Tag>
|
||||
struct sum_kahan_impl
|
||||
: accumulator_base
|
||||
{
|
||||
typedef Sample result_type;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// sum_kahan_impl
|
||||
/**
|
||||
@brief Kahan summation algorithm
|
||||
|
||||
The Kahan summation algorithm reduces the numerical error obtained with standard
|
||||
sequential sum.
|
||||
|
||||
*/
|
||||
template<typename Args>
|
||||
sum_kahan_impl(Args const & args)
|
||||
: sum(args[parameter::keyword<Tag>::get() | Sample()]),
|
||||
compensation(boost::numeric_cast<Sample>(0.0))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Args>
|
||||
void
|
||||
#if BOOST_ACCUMULATORS_GCC_VERSION > 40305
|
||||
__attribute__((__optimize__("no-associative-math")))
|
||||
#endif
|
||||
operator ()(Args const & args)
|
||||
{
|
||||
const Sample myTmp1 = args[parameter::keyword<Tag>::get()] - this->compensation;
|
||||
const Sample myTmp2 = this->sum + myTmp1;
|
||||
this->compensation = (myTmp2 - this->sum) - myTmp1;
|
||||
this->sum = myTmp2;
|
||||
}
|
||||
|
||||
result_type result(dont_care) const
|
||||
{
|
||||
return this->sum;
|
||||
}
|
||||
|
||||
private:
|
||||
Sample sum;
|
||||
Sample compensation;
|
||||
};
|
||||
|
||||
#if _MSC_VER > 1400
|
||||
# pragma float_control(pop)
|
||||
#endif
|
||||
|
||||
} // namespace impl
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// tag::sum_kahan
|
||||
// tag::sum_of_weights_kahan
|
||||
// tag::sum_of_variates_kahan
|
||||
//
|
||||
namespace tag
|
||||
{
|
||||
|
||||
struct sum_kahan
|
||||
: depends_on<>
|
||||
{
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
typedef impl::sum_kahan_impl< mpl::_1, tag::sample > impl;
|
||||
};
|
||||
|
||||
struct sum_of_weights_kahan
|
||||
: depends_on<>
|
||||
{
|
||||
typedef mpl::true_ is_weight_accumulator;
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
typedef accumulators::impl::sum_kahan_impl<mpl::_2, tag::weight> impl;
|
||||
};
|
||||
|
||||
template<typename VariateType, typename VariateTag>
|
||||
struct sum_of_variates_kahan
|
||||
: depends_on<>
|
||||
{
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
typedef mpl::always<accumulators::impl::sum_kahan_impl<VariateType, VariateTag> > impl;
|
||||
};
|
||||
|
||||
} // namespace tag
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// extract::sum_kahan
|
||||
// extract::sum_of_weights_kahan
|
||||
// extract::sum_of_variates_kahan
|
||||
//
|
||||
namespace extract
|
||||
{
|
||||
extractor<tag::sum_kahan> const sum_kahan = {};
|
||||
extractor<tag::sum_of_weights_kahan> const sum_of_weights_kahan = {};
|
||||
extractor<tag::abstract_sum_of_variates> const sum_of_variates_kahan = {};
|
||||
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_kahan)
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_weights_kahan)
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_variates_kahan)
|
||||
} // namespace extract
|
||||
|
||||
using extract::sum_kahan;
|
||||
using extract::sum_of_weights_kahan;
|
||||
using extract::sum_of_variates_kahan;
|
||||
|
||||
// sum(kahan) -> sum_kahan
|
||||
template<>
|
||||
struct as_feature<tag::sum(kahan)>
|
||||
{
|
||||
typedef tag::sum_kahan type;
|
||||
};
|
||||
|
||||
// sum_of_weights(kahan) -> sum_of_weights_kahan
|
||||
template<>
|
||||
struct as_feature<tag::sum_of_weights(kahan)>
|
||||
{
|
||||
typedef tag::sum_of_weights_kahan type;
|
||||
};
|
||||
|
||||
// So that sum_kahan can be automatically substituted with
|
||||
// weighted_sum_kahan when the weight parameter is non-void.
|
||||
template<>
|
||||
struct as_weighted_feature<tag::sum_kahan>
|
||||
{
|
||||
typedef tag::weighted_sum_kahan type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct feature_of<tag::weighted_sum_kahan>
|
||||
: feature_of<tag::sum>
|
||||
{};
|
||||
|
||||
// for the purposes of feature-based dependency resolution,
|
||||
// sum_kahan provides the same feature as sum
|
||||
template<>
|
||||
struct feature_of<tag::sum_kahan>
|
||||
: feature_of<tag::sum>
|
||||
{
|
||||
};
|
||||
|
||||
// for the purposes of feature-based dependency resolution,
|
||||
// sum_of_weights_kahan provides the same feature as sum_of_weights
|
||||
template<>
|
||||
struct feature_of<tag::sum_of_weights_kahan>
|
||||
: feature_of<tag::sum_of_weights>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename VariateType, typename VariateTag>
|
||||
struct feature_of<tag::sum_of_variates_kahan<VariateType, VariateTag> >
|
||||
: feature_of<tag::abstract_sum_of_variates>
|
||||
{
|
||||
};
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006
|
||||
#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_P_SQUARE_QUANTILE_HPP_DE_01_01_2006
|
||||
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// weighted_sum_kahan.hpp
|
||||
//
|
||||
// Copyright 2011 Simon West. 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_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_KAHAN_HPP_EAN_11_05_2011
|
||||
#define BOOST_ACCUMULATORS_STATISTICS_WEIGHTED_SUM_KAHAN_HPP_EAN_11_05_2011
|
||||
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/accumulators/framework/accumulator_base.hpp>
|
||||
#include <boost/accumulators/framework/extractor.hpp>
|
||||
#include <boost/accumulators/numeric/functional.hpp>
|
||||
#include <boost/accumulators/framework/parameters/sample.hpp>
|
||||
#include <boost/accumulators/framework/parameters/weight.hpp>
|
||||
#include <boost/accumulators/framework/accumulators/external_accumulator.hpp>
|
||||
#include <boost/accumulators/framework/depends_on.hpp>
|
||||
#include <boost/accumulators/statistics_fwd.hpp>
|
||||
#include <boost/accumulators/statistics/weighted_sum.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
namespace boost { namespace accumulators
|
||||
{
|
||||
|
||||
namespace impl
|
||||
{
|
||||
#if _MSC_VER > 1400
|
||||
# pragma float_control(push)
|
||||
# pragma float_control(precise, on)
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// weighted_sum_kahan_impl
|
||||
template<typename Sample, typename Weight, typename Tag>
|
||||
struct weighted_sum_kahan_impl
|
||||
: accumulator_base
|
||||
{
|
||||
typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
|
||||
|
||||
// for boost::result_of
|
||||
typedef weighted_sample result_type;
|
||||
|
||||
template<typename Args>
|
||||
weighted_sum_kahan_impl(Args const &args)
|
||||
: weighted_sum_(
|
||||
args[parameter::keyword<Tag>::get() | Sample()] * numeric::one<Weight>::value),
|
||||
compensation(boost::numeric_cast<weighted_sample>(0.0))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Args>
|
||||
void
|
||||
#if BOOST_ACCUMULATORS_GCC_VERSION > 40305
|
||||
__attribute__((__optimize__("no-associative-math")))
|
||||
#endif
|
||||
operator ()(Args const &args)
|
||||
{
|
||||
const weighted_sample myTmp1 = args[parameter::keyword<Tag>::get()] * args[weight] - this->compensation;
|
||||
const weighted_sample myTmp2 = this->weighted_sum_ + myTmp1;
|
||||
this->compensation = (myTmp2 - this->weighted_sum_) - myTmp1;
|
||||
this->weighted_sum_ = myTmp2;
|
||||
|
||||
}
|
||||
|
||||
result_type result(dont_care) const
|
||||
{
|
||||
return this->weighted_sum_;
|
||||
}
|
||||
|
||||
private:
|
||||
weighted_sample weighted_sum_;
|
||||
weighted_sample compensation;
|
||||
};
|
||||
|
||||
#if _MSC_VER > 1400
|
||||
# pragma float_control(pop)
|
||||
#endif
|
||||
|
||||
} // namespace impl
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// tag::weighted_sum_kahan
|
||||
// tag::weighted_sum_of_variates_kahan
|
||||
//
|
||||
namespace tag
|
||||
{
|
||||
struct weighted_sum_kahan
|
||||
: depends_on<>
|
||||
{
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
typedef accumulators::impl::weighted_sum_kahan_impl<mpl::_1, mpl::_2, tag::sample> impl;
|
||||
};
|
||||
|
||||
template<typename VariateType, typename VariateTag>
|
||||
struct weighted_sum_of_variates_kahan
|
||||
: depends_on<>
|
||||
{
|
||||
/// INTERNAL ONLY
|
||||
///
|
||||
typedef accumulators::impl::weighted_sum_kahan_impl<VariateType, mpl::_2, VariateTag> impl;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// extract::weighted_sum_kahan
|
||||
// extract::weighted_sum_of_variates_kahan
|
||||
//
|
||||
namespace extract
|
||||
{
|
||||
extractor<tag::weighted_sum_kahan> const weighted_sum_kahan = {};
|
||||
extractor<tag::abstract_weighted_sum_of_variates> const weighted_sum_of_variates_kahan = {};
|
||||
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_kahan)
|
||||
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_sum_of_variates_kahan)
|
||||
}
|
||||
|
||||
using extract::weighted_sum_kahan;
|
||||
using extract::weighted_sum_of_variates_kahan;
|
||||
|
||||
// weighted_sum(kahan) -> weighted_sum_kahan
|
||||
template<>
|
||||
struct as_feature<tag::weighted_sum(kahan)>
|
||||
{
|
||||
typedef tag::weighted_sum_kahan type;
|
||||
};
|
||||
|
||||
template<typename VariateType, typename VariateTag>
|
||||
struct feature_of<tag::weighted_sum_of_variates_kahan<VariateType, VariateTag> >
|
||||
: feature_of<tag::abstract_weighted_sum_of_variates>
|
||||
{
|
||||
};
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
||||
#endif
|
||||
@@ -109,6 +109,10 @@ namespace tag
|
||||
struct sum_of_weights;
|
||||
template<typename VariateType, typename VariateTag>
|
||||
struct sum_of_variates;
|
||||
struct sum_kahan;
|
||||
struct sum_of_weights_kahan;
|
||||
template<typename VariateType, typename VariateTag>
|
||||
struct sum_of_variates_kahan;
|
||||
template<typename LeftRight>
|
||||
struct tail;
|
||||
template<typename LeftRight>
|
||||
@@ -263,6 +267,9 @@ namespace impl
|
||||
template<typename Sample, typename Tag = tag::sample>
|
||||
struct sum_impl;
|
||||
|
||||
template<typename Sample, typename Tag>
|
||||
struct sum_kahan_impl;
|
||||
|
||||
template<typename Sample, typename LeftRight>
|
||||
struct tail_impl;
|
||||
|
||||
@@ -338,6 +345,9 @@ namespace impl
|
||||
template<typename Sample, typename Weight, typename Tag>
|
||||
struct weighted_sum_impl;
|
||||
|
||||
template<typename Sample, typename Weight, typename Tag>
|
||||
struct weighted_sum_kahan_impl;
|
||||
|
||||
template<typename Sample, typename Weight, typename LeftRight>
|
||||
struct non_coherent_weighted_tail_mean_impl;
|
||||
|
||||
@@ -414,6 +424,9 @@ struct quadratic {};
|
||||
struct regular {};
|
||||
struct for_median {};
|
||||
|
||||
// modifier for sum_kahan, sum_of_weights_kahan, sum_of_variates_kahan, weighted_sum_kahan
|
||||
struct kahan {};
|
||||
|
||||
}} // namespace boost::accumulators
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <locale>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
@@ -37,7 +39,7 @@ namespace boost {
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::tolower( Ch);
|
||||
return std::tolower( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
|
||||
#else
|
||||
return std::tolower<CharT>( Ch, *m_Loc );
|
||||
#endif
|
||||
@@ -57,7 +59,7 @@ namespace boost {
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper( Ch);
|
||||
return std::toupper( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
|
||||
#else
|
||||
return std::toupper<CharT>( Ch, *m_Loc );
|
||||
#endif
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace boost {
|
||||
}
|
||||
|
||||
// Use fixed storage
|
||||
::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
|
||||
::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -206,7 +206,7 @@ namespace boost {
|
||||
}
|
||||
|
||||
// Copy the data
|
||||
::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
|
||||
::std::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -74,17 +74,17 @@ namespace boost {
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult )
|
||||
{
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,14 +137,14 @@ namespace boost {
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
return ::boost::algorithm::detail::find_format_copy_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return Input;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// replace implementation ----------------------------------------------------//
|
||||
@@ -189,12 +189,12 @@ namespace boost {
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
::boost::algorithm::detail::find_format_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
::boost::algorithm::detail::find_format_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -84,18 +84,18 @@ namespace boost {
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult )
|
||||
{
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Output,
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// find_format_all_copy implementation ----------------------------------------------//
|
||||
@@ -161,15 +161,15 @@ namespace boost {
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
return ::boost::algorithm::detail::find_format_all_copy_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return Input;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// find_format_all implementation ------------------------------------------------//
|
||||
@@ -257,13 +257,13 @@ namespace boost {
|
||||
FindResultT FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
::boost::algorithm::detail::find_format_all_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
::boost::algorithm::detail::find_format_all_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace boost {
|
||||
{
|
||||
iterator_range<ForwardIteratorT>::operator=(FindResult);
|
||||
if( !this->empty() ) {
|
||||
m_FormatResult=m_Formatter(FindResult);
|
||||
m_FormatResult=m_Formatter(FindResult);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
@@ -87,6 +87,31 @@ namespace boost {
|
||||
}
|
||||
};
|
||||
|
||||
// dissect format functor ----------------------------------------------------//
|
||||
|
||||
// dissect format functor
|
||||
template<typename FinderT>
|
||||
struct dissect_formatF
|
||||
{
|
||||
public:
|
||||
// Construction
|
||||
dissect_formatF(FinderT Finder) :
|
||||
m_Finder(Finder) {}
|
||||
|
||||
// Operation
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
|
||||
operator()(const RangeT& Replace) const
|
||||
{
|
||||
return m_Finder(::boost::begin(Replace), ::boost::end(Replace));
|
||||
}
|
||||
|
||||
private:
|
||||
FinderT m_Finder;
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
@@ -259,7 +259,11 @@ namespace boost {
|
||||
m_End(End),
|
||||
m_bEof(false)
|
||||
{
|
||||
increment();
|
||||
// force the correct behavior for empty sequences and yield at least one token
|
||||
if(Begin!=End)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
}
|
||||
//! Constructor
|
||||
/*!
|
||||
@@ -278,7 +282,11 @@ namespace boost {
|
||||
m_Next=::boost::begin(lit_col);
|
||||
m_End=::boost::end(lit_col);
|
||||
|
||||
increment();
|
||||
// force the correct behavior for empty sequences and yield at least one token
|
||||
if(m_Next!=m_End)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace boost {
|
||||
|
||||
//! Constant formatter
|
||||
/*!
|
||||
Construct the \c const_formatter. Const formatter always returns
|
||||
Constructs a \c const_formatter. Const formatter always returns
|
||||
the same value, regardless of the parameter.
|
||||
|
||||
\param Format A predefined value used as a result for formating
|
||||
@@ -55,7 +55,7 @@ namespace boost {
|
||||
|
||||
//! Identity formatter
|
||||
/*!
|
||||
Construct the \c identity_formatter. Identity formatter always returns
|
||||
Constructs an \c identity_formatter. Identity formatter always returns
|
||||
the parameter.
|
||||
|
||||
\return An instance of the \c identity_formatter object.
|
||||
@@ -73,7 +73,7 @@ namespace boost {
|
||||
|
||||
//! Empty formatter
|
||||
/*!
|
||||
Construct the \c empty_formatter. Empty formatter always returns an empty
|
||||
Constructs an \c empty_formatter. Empty formatter always returns an empty
|
||||
sequence.
|
||||
|
||||
\param Input container used to select a correct value_type for the
|
||||
@@ -89,6 +89,22 @@ namespace boost {
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>();
|
||||
}
|
||||
|
||||
//! Empty formatter
|
||||
/*!
|
||||
Constructs a \c dissect_formatter. Dissect formatter uses a specified finder
|
||||
to extract a portion of the formatted sequence. The first finder's match is returned
|
||||
as a result
|
||||
|
||||
\param Finder a finder used to select a portion of the formated sequence
|
||||
\return An instance of the \c dissect_formatter object.
|
||||
*/
|
||||
template<typename FinderT>
|
||||
inline detail::dissect_formatF< FinderT >
|
||||
dissect_formatter(const FinderT& Finder)
|
||||
{
|
||||
return detail::dissect_formatF<FinderT>(Finder);
|
||||
}
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
@@ -96,6 +112,7 @@ namespace boost {
|
||||
using algorithm::const_formatter;
|
||||
using algorithm::identity_formatter;
|
||||
using algorithm::empty_formatter;
|
||||
using algorithm::dissect_formatter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
217
project/jni/boost/include/boost/algorithm/string/trim_all.hpp
Normal file
217
project/jni/boost/include/boost/algorithm/string/trim_all.hpp
Normal file
@@ -0,0 +1,217 @@
|
||||
// Boost string_algo library trim.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003.
|
||||
//
|
||||
// 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)
|
||||
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_TRIM_ALL_HPP
|
||||
#define BOOST_STRING_TRIM_ALL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <locale>
|
||||
|
||||
/*! \file
|
||||
Defines trim_all algorithms.
|
||||
|
||||
Just like \c trim, \c trim_all removes all trailing and leading spaces from a
|
||||
sequence (string). In addition, spaces in the middle of the sequence are truncated
|
||||
to just one character. Space is recognized using given locales.
|
||||
|
||||
\c trim_fill acts as trim_all, but the spaces in the middle are replaces with
|
||||
a user-define sequence of character.
|
||||
|
||||
Parametric (\c _if) variants use a predicate (functor) to select which characters
|
||||
are to be trimmed..
|
||||
Functions take a selection predicate as a parameter, which is used to determine
|
||||
whether a character is a space. Common predicates are provided in classification.hpp header.
|
||||
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// multi line trim ----------------------------------------------- //
|
||||
|
||||
//! Trim All - parametric
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline SequenceT trim_all_copy_if(const SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
return
|
||||
::boost::find_format_all_copy(
|
||||
::boost::trim_copy_if(Input, IsSpace),
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::dissect_formatter(::boost::head_finder(1)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim All
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
*/
|
||||
template<typename SequenceT, typename PredicateT>
|
||||
inline void trim_all_if(SequenceT& Input, PredicateT IsSpace)
|
||||
{
|
||||
::boost::trim_if(Input, IsSpace);
|
||||
::boost::find_format_all(
|
||||
Input,
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::dissect_formatter(::boost::head_finder(1)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim All
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT trim_all_copy(const SequenceT& Input, const std::locale& Loc =std::locale())
|
||||
{
|
||||
return trim_all_copy_if(Input, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
//! Trim All
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
compress all other spaces to a single character.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void trim_all(SequenceT& Input, const std::locale& Loc =std::locale())
|
||||
{
|
||||
trim_all_if(Input, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill - parametric
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT, typename PredicateT>
|
||||
inline SequenceT trim_fill_copy_if(const SequenceT& Input, const RangeT& Fill, PredicateT IsSpace)
|
||||
{
|
||||
return
|
||||
::boost::find_format_all_copy(
|
||||
::boost::trim_copy_if(Input, IsSpace),
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::const_formatter(::boost::as_literal(Fill)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param IsSpace An unary predicate identifying spaces
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT, typename PredicateT>
|
||||
inline void trim_fill_if(SequenceT& Input, const RangeT& Fill, PredicateT IsSpace)
|
||||
{
|
||||
::boost::trim_if(Input, IsSpace);
|
||||
::boost::find_format_all(
|
||||
Input,
|
||||
::boost::token_finder(IsSpace, ::boost::token_compress_on),
|
||||
::boost::const_formatter(::boost::as_literal(Fill)));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The result is a trimmed copy of the input
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT trim_fill_copy(const SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale())
|
||||
{
|
||||
return trim_fill_copy_if(Input, Fill, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
//! Trim Fill
|
||||
/*!
|
||||
Remove all leading and trailing spaces from the input and
|
||||
replace all every block of consecutive spaces with a fill string
|
||||
defined by user.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Fill A string used to fill the inner spaces
|
||||
\param Loc A locale used for 'space' classification
|
||||
\return A trimmed copy of the input
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void trim_fill(SequenceT& Input, const RangeT& Fill, const std::locale& Loc =std::locale())
|
||||
{
|
||||
trim_fill_if(Input, Fill, ::boost::is_space(Loc));
|
||||
}
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::trim_all;
|
||||
using algorithm::trim_all_if;
|
||||
using algorithm::trim_all_copy;
|
||||
using algorithm::trim_all_copy_if;
|
||||
using algorithm::trim_fill;
|
||||
using algorithm::trim_fill_if;
|
||||
using algorithm::trim_fill_copy;
|
||||
using algorithm::trim_fill_copy_if;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_TRIM_ALL_HPP
|
||||
@@ -17,7 +17,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <exception>
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <string>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/cstdint.hpp> // size_t
|
||||
#include <boost/noncopyable.hpp>
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
public:
|
||||
library_version_type(): t(0) {};
|
||||
explicit library_version_type(const unsigned int & t_) : t(t_){
|
||||
assert(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
}
|
||||
library_version_type(const library_version_type & t_) :
|
||||
t(t_.t)
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
// should be private - but MPI fails if it's not!!!
|
||||
version_type(): t(0) {};
|
||||
explicit version_type(const unsigned int & t_) : t(t_){
|
||||
assert(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
}
|
||||
version_type(const version_type & t_) :
|
||||
t(t_.t)
|
||||
@@ -113,10 +113,10 @@ public:
|
||||
// should be private - but then can't use BOOST_STRONG_TYPE below
|
||||
class_id_type() : t(0) {};
|
||||
explicit class_id_type(const int t_) : t(t_){
|
||||
assert(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
}
|
||||
explicit class_id_type(const std::size_t t_) : t(t_){
|
||||
// assert(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
// BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
}
|
||||
class_id_type(const class_id_type & t_) :
|
||||
t(t_.t)
|
||||
@@ -151,7 +151,7 @@ private:
|
||||
public:
|
||||
object_id_type(): t(0) {};
|
||||
explicit object_id_type(const unsigned int & t_) : t(t_){
|
||||
assert(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
|
||||
}
|
||||
object_id_type(const object_id_type & t_) :
|
||||
t(t_.t)
|
||||
@@ -254,7 +254,7 @@ BOOST_ARCHIVE_SIGNATURE();
|
||||
#define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \
|
||||
class D : public T { \
|
||||
public: \
|
||||
explicit D(const T t) : T(t){} \
|
||||
explicit D(const T tt) : T(tt){} \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ public:
|
||||
|
||||
// include these to trap a change in binary format which
|
||||
// isn't specifically handled
|
||||
BOOST_STATIC_ASSERT(sizeof(tracking_type) == sizeof(bool));
|
||||
// upto 32K classes
|
||||
BOOST_STATIC_ASSERT(sizeof(class_id_type) == sizeof(int_least16_t));
|
||||
BOOST_STATIC_ASSERT(sizeof(class_id_reference_type) == sizeof(int_least16_t));
|
||||
@@ -83,6 +82,19 @@ public:
|
||||
// binary files don't include the optional information
|
||||
void load_override(class_id_optional_type & /* t */, int){}
|
||||
|
||||
void load_override(tracking_type & t, int /*version*/){
|
||||
library_version_type lvt = this->get_library_version();
|
||||
if(boost::archive::library_version_type(6) < lvt){
|
||||
int_least8_t x=0;
|
||||
* this->This() >> x;
|
||||
t = boost::archive::tracking_type(x);
|
||||
}
|
||||
else{
|
||||
bool x=0;
|
||||
* this->This() >> x;
|
||||
t = boost::archive::tracking_type(x);
|
||||
}
|
||||
}
|
||||
void load_override(class_id_type & t, int version){
|
||||
library_version_type lvt = this->get_library_version();
|
||||
if(boost::archive::library_version_type(7) < lvt){
|
||||
@@ -134,10 +146,23 @@ public:
|
||||
}
|
||||
else
|
||||
if(boost::archive::library_version_type(6) < lvt){
|
||||
uint_least8_t x=0;
|
||||
* this->This() >> x;
|
||||
t = boost::archive::version_type(x);
|
||||
}
|
||||
else
|
||||
if(boost::archive::library_version_type(5) < lvt){
|
||||
uint_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = boost::archive::version_type(x);
|
||||
}
|
||||
else
|
||||
if(boost::archive::library_version_type(2) < lvt){
|
||||
// upto 255 versions
|
||||
unsigned char x=0;
|
||||
* this->This() >> x;
|
||||
t = version_type(x);
|
||||
}
|
||||
else{
|
||||
unsigned int x=0;
|
||||
* this->This() >> x;
|
||||
@@ -147,7 +172,8 @@ public:
|
||||
|
||||
void load_override(boost::serialization::item_version_type & t, int version){
|
||||
library_version_type lvt = this->get_library_version();
|
||||
if(boost::archive::library_version_type(7) < lvt){
|
||||
// if(boost::archive::library_version_type(7) < lvt){
|
||||
if(boost::archive::library_version_type(6) < lvt){
|
||||
this->detail_common_iarchive::load_override(t, version);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <locale>
|
||||
#include <cstring> // std::memcpy
|
||||
#include <cstddef> // std::size_t
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
void load(bool & t){
|
||||
load_binary(& t, sizeof(t));
|
||||
int i = t;
|
||||
assert(0 == i || 1 == i);
|
||||
BOOST_ASSERT(0 == i || 1 == i);
|
||||
(void)i; // warning suppression for release builds.
|
||||
}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
@@ -151,7 +151,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
|
||||
std::size_t count
|
||||
){
|
||||
// note: an optimizer should eliminate the following for char files
|
||||
assert(
|
||||
BOOST_ASSERT(
|
||||
static_cast<std::streamsize>(count / sizeof(Elem))
|
||||
<= boost::integer_traits<std::streamsize>::const_max
|
||||
);
|
||||
@@ -165,7 +165,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
|
||||
archive_exception(archive_exception::input_stream_error)
|
||||
);
|
||||
// note: an optimizer should eliminate the following for char files
|
||||
assert(count % sizeof(Elem) <= boost::integer_traits<std::streamsize>::const_max);
|
||||
BOOST_ASSERT(count % sizeof(Elem) <= boost::integer_traits<std::streamsize>::const_max);
|
||||
s = static_cast<std::streamsize>(count % sizeof(Elem));
|
||||
if(0 < s){
|
||||
// if(is.fail())
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
|
||||
// ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/serialization/pfto.hpp>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ON PLATFORM APART FROM THE ONE THEY ARE CREATE ON
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <locale>
|
||||
#include <streambuf> // basic_streambuf
|
||||
#include <string>
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
// trap usage of invalid uninitialized boolean which would
|
||||
// otherwise crash on load.
|
||||
void save(const bool t){
|
||||
assert(0 == static_cast<int>(t) || 1 == static_cast<int>(t));
|
||||
BOOST_ASSERT(0 == static_cast<int>(t) || 1 == static_cast<int>(t));
|
||||
save_binary(& t, sizeof(t));
|
||||
}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
@@ -146,7 +146,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
|
||||
const void *address,
|
||||
std::size_t count
|
||||
){
|
||||
//assert(
|
||||
//BOOST_ASSERT(
|
||||
// static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)()) >= count
|
||||
//);
|
||||
// note: if the following assertions fail
|
||||
@@ -160,7 +160,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
|
||||
// figure number of elements to output - round up
|
||||
count = ( count + sizeof(Elem) - 1)
|
||||
/ sizeof(Elem);
|
||||
assert(count <= std::size_t(boost::integer_traits<std::streamsize>::const_max));
|
||||
BOOST_ASSERT(count <= std::size_t(boost::integer_traits<std::streamsize>::const_max));
|
||||
std::streamsize scount = m_sb.sputn(
|
||||
static_cast<const Elem *>(address),
|
||||
static_cast<std::streamsize>(count)
|
||||
@@ -173,7 +173,7 @@ basic_binary_oprimitive<Archive, Elem, Tr>::save_binary(
|
||||
// static_cast<const BOOST_DEDUCED_TYPENAME OStream::char_type *>(address),
|
||||
// count
|
||||
//);
|
||||
//assert(os.good());
|
||||
//BOOST_ASSERT(os.good());
|
||||
}
|
||||
|
||||
} //namespace boost
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// in such cases. So we can't use basic_ostream<IStream::char_type> but rather
|
||||
// use two template parameters
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <locale>
|
||||
#include <cstddef> // size_t
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// in such cases. So we can't use basic_ostream<OStream::char_type> but rather
|
||||
// use two template parameters
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/serialization/pfto.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <boost/config/no_tr1/cmath.hpp> // isnan
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // size_t
|
||||
|
||||
#include <boost/config.hpp>
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
void save(const bool t){
|
||||
// trap usage of invalid uninitialized boolean which would
|
||||
// otherwise crash on load.
|
||||
assert(0 == static_cast<int>(t) || 1 == static_cast<int>(t));
|
||||
BOOST_ASSERT(0 == static_cast<int>(t) || 1 == static_cast<int>(t));
|
||||
if(os.fail())
|
||||
boost::serialization::throw_exception(
|
||||
archive_exception(archive_exception::output_stream_error)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // NULL
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
@@ -42,7 +42,7 @@ protected:
|
||||
) :
|
||||
m_eti(& eti)
|
||||
{
|
||||
assert(NULL != & eti);
|
||||
BOOST_ASSERT(NULL != & eti);
|
||||
}
|
||||
public:
|
||||
inline bool
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // NULL
|
||||
|
||||
#include <boost/config.hpp>
|
||||
@@ -186,7 +186,7 @@ BOOST_DLLEXPORT void pointer_oserializer<Archive, T>::save_object_ptr(
|
||||
basic_oarchive & ar,
|
||||
const void * x
|
||||
) const {
|
||||
assert(NULL != x);
|
||||
BOOST_ASSERT(NULL != x);
|
||||
// make sure call is routed through the highest interface that might
|
||||
// be specialized by the user.
|
||||
T * t = static_cast<T *>(const_cast<void *>(x));
|
||||
@@ -384,7 +384,7 @@ struct save_pointer_type {
|
||||
|
||||
// retrieve the true type of the object pointed to
|
||||
// if this assertion fails its an error in this library
|
||||
assert(NULL != this_type);
|
||||
BOOST_ASSERT(NULL != this_type);
|
||||
|
||||
const boost::serialization::extended_type_info * true_type =
|
||||
i.get_derived_extended_type_info(t);
|
||||
@@ -433,12 +433,12 @@ struct save_pointer_type {
|
||||
archive_serializer_map<Archive>
|
||||
>::get_const_instance().find(*true_type)
|
||||
);
|
||||
assert(NULL != bpos);
|
||||
BOOST_ASSERT(NULL != bpos);
|
||||
if(NULL == bpos)
|
||||
boost::serialization::throw_exception(
|
||||
archive_exception(
|
||||
archive_exception::unregistered_class,
|
||||
bpos->get_debug_info()
|
||||
"derived class not registered or exported"
|
||||
)
|
||||
);
|
||||
ar.save_pointer(vp, bpos);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // size_t, NULL
|
||||
#include <cstring> // memcpy
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ basic_text_iprimitive<IStream>::load_binary(
|
||||
if(0 == count)
|
||||
return;
|
||||
|
||||
assert(
|
||||
BOOST_ASSERT(
|
||||
static_cast<std::size_t>((std::numeric_limits<std::streamsize>::max)())
|
||||
> (count + sizeof(CharType) - 1)/sizeof(CharType)
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
@@ -32,7 +32,7 @@ basic_text_oarchive<Archive>::newtoken()
|
||||
{
|
||||
switch(delimiter){
|
||||
default:
|
||||
assert(false);
|
||||
BOOST_ASSERT(false);
|
||||
break;
|
||||
case eol:
|
||||
this->This()->put('\n');
|
||||
|
||||
@@ -55,26 +55,8 @@
|
||||
# pragma warning (disable : 4786) // too long name, harmless warning
|
||||
#endif
|
||||
|
||||
//#define BOOST_SPIRIT_DEBUG
|
||||
#include <boost/spirit/core/non_terminal/rule.hpp>
|
||||
|
||||
// the following hack is to evade a bogus error generated by using the
|
||||
// word "arg" when bind.hpp has been included
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
||||
#define arg xarg
|
||||
#endif
|
||||
|
||||
// spirit stuff
|
||||
#if (defined __BORLANDC__) && (__BORLANDC__ < 0x593) \
|
||||
|| (defined _MSC_VER) && (_MSC_VER <= 1300)
|
||||
#include <boost/spirit/utility/chset.hpp>
|
||||
#else
|
||||
#include <boost/spirit/include/classic_rule.hpp>
|
||||
#include <boost/spirit/include/classic_chset.hpp>
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
||||
#undef arg
|
||||
#endif
|
||||
|
||||
#include <boost/archive/basic_archive.hpp>
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
@@ -97,12 +79,12 @@ public:
|
||||
private:
|
||||
typedef BOOST_DEDUCED_TYPENAME std::basic_istream<CharType> IStream;
|
||||
typedef BOOST_DEDUCED_TYPENAME std::basic_string<CharType> StringType;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::chset<CharType> chset_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::chlit<CharType> chlit_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::scanner<
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chset<CharType> chset_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chlit<CharType> chlit_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::scanner<
|
||||
BOOST_DEDUCED_TYPENAME std::basic_string<CharType>::iterator
|
||||
> scanner_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::rule<scanner_t> rule_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::rule<scanner_t> rule_t;
|
||||
// Start grammar definition
|
||||
rule_t
|
||||
Reference,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // NULL
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace std{
|
||||
#include <boost/config.hpp> // msvc 6.0 needs this to suppress warnings
|
||||
#ifndef BOOST_NO_STD_WSTREAMBUF
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/detail/workaround.hpp> // Dinkumware and RogueWave
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#include <exception>
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
msg = "attempt to decode a value not in base64 char set";
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
BOOST_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
return msg;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
@@ -49,7 +49,7 @@ struct from_6_bit {
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"+/";
|
||||
assert(t < 64);
|
||||
BOOST_ASSERT(t < 64);
|
||||
return lookup_table[static_cast<size_t>(t)];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
#include <boost/serialization/throw_exception.hpp>
|
||||
@@ -39,7 +39,7 @@ template<class CharType>
|
||||
struct to_6_bit {
|
||||
typedef CharType result_type;
|
||||
CharType operator()(CharType t) const{
|
||||
const char lookup_table[] = {
|
||||
const signed char lookup_table[] = {
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
|
||||
@@ -47,7 +47,7 @@ struct tri_state {
|
||||
} m_state;
|
||||
// convert to bool
|
||||
operator bool (){
|
||||
assert(is_indeterminant != m_state);
|
||||
BOOST_ASSERT(is_indeterminant != m_state);
|
||||
return is_true == m_state ? true : false;
|
||||
}
|
||||
// assign from bool
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <exception>
|
||||
#endif //BOOST_NO_EXCEPTIONS
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
msg = "invalid multbyte/wide char conversion";
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
BOOST_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
return msg;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // NULL
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdlib> // for wctomb()
|
||||
|
||||
@@ -90,9 +90,9 @@ class mb_from_wchar
|
||||
#else
|
||||
m_bend = std::wctomb(m_buffer, value);
|
||||
#endif
|
||||
assert(-1 != m_bend);
|
||||
assert((std::size_t)m_bend <= sizeof(m_buffer));
|
||||
assert(m_bend > 0);
|
||||
BOOST_ASSERT(-1 != m_bend);
|
||||
BOOST_ASSERT((std::size_t)m_bend <= sizeof(m_buffer));
|
||||
BOOST_ASSERT(m_bend > 0);
|
||||
m_bnext = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
// character and 8 bit bytes. Lowest common multiple is 24 => 4 6 bit characters
|
||||
// or 3 8 bit characters
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME & PTFO
|
||||
#include <boost/serialization/pfto.hpp>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cctype>
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdlib> // mblen
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
#include <boost/serialization/pfto.hpp>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#include <exception>
|
||||
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
@@ -87,7 +87,8 @@ protected:
|
||||
init();
|
||||
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
text_iarchive_impl(std::istream & is, unsigned int flags);
|
||||
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
// don't import inline definitions! leave this as a reminder.
|
||||
//BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~text_iarchive_impl(){};
|
||||
};
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ protected:
|
||||
#endif
|
||||
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
text_oarchive_impl(std::ostream & os, unsigned int flags);
|
||||
BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
// don't import inline definitions! leave this as a reminder.
|
||||
//BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~text_oarchive_impl(){};
|
||||
public:
|
||||
BOOST_ARCHIVE_DECL(void)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <cstdlib> // getenv
|
||||
#include <cstddef> // NULL
|
||||
//#include <cassert>
|
||||
//#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
@@ -38,7 +38,7 @@ inline const char * tmpdir(){
|
||||
if(NULL == dirname)
|
||||
dirname = std::getenv("TEMP");
|
||||
if(NULL == dirname){
|
||||
//assert(false); // no temp directory found
|
||||
//BOOST_ASSERT(false); // no temp directory found
|
||||
dirname = ".";
|
||||
}
|
||||
return dirname;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#include <exception>
|
||||
#include <cassert>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
|
||||
@@ -126,8 +126,7 @@ public:
|
||||
} // namespace boost
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4511 4512)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility.
|
||||
* 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group.
|
||||
* See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
|
||||
* Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow)
|
||||
@@ -69,10 +70,13 @@ namespace boost {
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// iterator support
|
||||
iterator begin() { return elems; }
|
||||
const_iterator begin() const { return elems; }
|
||||
iterator end() { return elems+N; }
|
||||
const_iterator end() const { return elems+N; }
|
||||
iterator begin() { return elems; }
|
||||
const_iterator begin() const { return elems; }
|
||||
const_iterator cbegin() const { return elems; }
|
||||
|
||||
iterator end() { return elems+N; }
|
||||
const_iterator end() const { return elems+N; }
|
||||
const_iterator cend() const { return elems+N; }
|
||||
|
||||
// reverse iterator support
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
||||
@@ -99,10 +103,17 @@ namespace boost {
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
const_reverse_iterator crbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
const_reverse_iterator crend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
// operator[]
|
||||
reference operator[](size_type i)
|
||||
@@ -200,10 +211,13 @@ namespace boost {
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// iterator support
|
||||
iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); }
|
||||
const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||
iterator end() { return begin(); }
|
||||
const_iterator end() const { return begin(); }
|
||||
iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); }
|
||||
const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||
const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||
|
||||
iterator end() { return begin(); }
|
||||
const_iterator end() const { return begin(); }
|
||||
const_iterator cend() const { return cbegin(); }
|
||||
|
||||
// reverse iterator support
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
||||
@@ -230,10 +244,17 @@ namespace boost {
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
const_reverse_iterator crbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
const_reverse_iterator crend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
// operator[]
|
||||
reference operator[](size_type /*i*/)
|
||||
@@ -301,7 +322,7 @@ namespace boost {
|
||||
static reference failed_rangecheck () {
|
||||
std::out_of_range e("attempt to access element of an empty array");
|
||||
boost::throw_exception(e);
|
||||
#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC)
|
||||
#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__))
|
||||
//
|
||||
// We need to return something here to keep
|
||||
// some compilers happy: however we will never
|
||||
@@ -346,7 +367,34 @@ namespace boost {
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
// Specific for boost::array: simply returns its elems data member.
|
||||
#if defined(__SUNPRO_CC)
|
||||
// Trac ticket #4757; the Sun Solaris compiler can't handle
|
||||
// syntax like 'T(&get_c_array(boost::array<T,N>& arg))[N]'
|
||||
//
|
||||
// We can't just use this for all compilers, because the
|
||||
// borland compilers can't handle this form.
|
||||
namespace detail {
|
||||
template <typename T, std::size_t N> struct c_array
|
||||
{
|
||||
typedef T type[N];
|
||||
};
|
||||
}
|
||||
|
||||
// Specific for boost::array: simply returns its elems data member.
|
||||
template <typename T, std::size_t N>
|
||||
typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg)
|
||||
{
|
||||
return arg.elems;
|
||||
}
|
||||
|
||||
// Specific for boost::array: simply returns its elems data member.
|
||||
template <typename T, std::size_t N>
|
||||
typename const detail::c_array<T,N>::type& get_c_array(const boost::array<T,N>& arg)
|
||||
{
|
||||
return arg.elems;
|
||||
}
|
||||
#else
|
||||
// Specific for boost::array: simply returns its elems data member.
|
||||
template <typename T, std::size_t N>
|
||||
T(&get_c_array(boost::array<T,N>& arg))[N]
|
||||
{
|
||||
@@ -359,7 +407,8 @@ namespace boost {
|
||||
{
|
||||
return arg.elems;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// Overload for std::array, assuming that std::array will have
|
||||
// explicit conversion functions as discussed at the WG21 meeting
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// asio.hpp
|
||||
// ~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -21,12 +21,15 @@
|
||||
#include <boost/asio/basic_deadline_timer.hpp>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/basic_raw_socket.hpp>
|
||||
#include <boost/asio/basic_seq_packet_socket.hpp>
|
||||
#include <boost/asio/basic_serial_port.hpp>
|
||||
#include <boost/asio/basic_signal_set.hpp>
|
||||
#include <boost/asio/basic_socket_acceptor.hpp>
|
||||
#include <boost/asio/basic_socket_iostream.hpp>
|
||||
#include <boost/asio/basic_socket_streambuf.hpp>
|
||||
#include <boost/asio/basic_stream_socket.hpp>
|
||||
#include <boost/asio/basic_streambuf.hpp>
|
||||
#include <boost/asio/basic_waitable_timer.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/buffered_read_stream_fwd.hpp>
|
||||
#include <boost/asio/buffered_read_stream.hpp>
|
||||
@@ -36,6 +39,7 @@
|
||||
#include <boost/asio/buffered_write_stream.hpp>
|
||||
#include <boost/asio/buffers_iterator.hpp>
|
||||
#include <boost/asio/completion_condition.hpp>
|
||||
#include <boost/asio/connect.hpp>
|
||||
#include <boost/asio/datagram_socket_service.hpp>
|
||||
#include <boost/asio/deadline_timer_service.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
@@ -76,9 +80,12 @@
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/asio/read_at.hpp>
|
||||
#include <boost/asio/read_until.hpp>
|
||||
#include <boost/asio/seq_packet_socket_service.hpp>
|
||||
#include <boost/asio/serial_port.hpp>
|
||||
#include <boost/asio/serial_port_base.hpp>
|
||||
#include <boost/asio/serial_port_service.hpp>
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <boost/asio/signal_set_service.hpp>
|
||||
#include <boost/asio/socket_acceptor_service.hpp>
|
||||
#include <boost/asio/socket_base.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
@@ -86,9 +93,14 @@
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <boost/asio/time_traits.hpp>
|
||||
#include <boost/asio/version.hpp>
|
||||
#include <boost/asio/wait_traits.hpp>
|
||||
#include <boost/asio/waitable_timer_service.hpp>
|
||||
#include <boost/asio/windows/basic_handle.hpp>
|
||||
#include <boost/asio/windows/basic_object_handle.hpp>
|
||||
#include <boost/asio/windows/basic_random_access_handle.hpp>
|
||||
#include <boost/asio/windows/basic_stream_handle.hpp>
|
||||
#include <boost/asio/windows/object_handle.hpp>
|
||||
#include <boost/asio/windows/object_handle_service.hpp>
|
||||
#include <boost/asio/windows/overlapped_ptr.hpp>
|
||||
#include <boost/asio/windows/random_access_handle.hpp>
|
||||
#include <boost/asio/windows/random_access_handle_service.hpp>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_datagram_socket.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <cstddef>
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/datagram_socket_service.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
|
||||
@@ -42,8 +43,12 @@ class basic_datagram_socket
|
||||
: public basic_socket<Protocol, DatagramSocketService>
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// socket.
|
||||
typedef typename DatagramSocketService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of a socket.
|
||||
typedef typename DatagramSocketService::native_type native_type;
|
||||
typedef typename DatagramSocketService::native_handle_type native_handle_type;
|
||||
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
@@ -121,12 +126,48 @@ public:
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_datagram_socket(boost::asio::io_service& io_service,
|
||||
const protocol_type& protocol, const native_type& native_socket)
|
||||
const protocol_type& protocol, const native_handle_type& native_socket)
|
||||
: basic_socket<Protocol, DatagramSocketService>(
|
||||
io_service, protocol, native_socket)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_datagram_socket from another.
|
||||
/**
|
||||
* This constructor moves a datagram socket from one object to another.
|
||||
*
|
||||
* @param other The other basic_datagram_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_datagram_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_datagram_socket(basic_datagram_socket&& other)
|
||||
: basic_socket<Protocol, DatagramSocketService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_datagram_socket from another.
|
||||
/**
|
||||
* This assignment operator moves a datagram socket from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_datagram_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_datagram_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_datagram_socket& operator=(basic_datagram_socket&& other)
|
||||
{
|
||||
basic_socket<Protocol, DatagramSocketService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Send some data on a connected socket.
|
||||
/**
|
||||
* This function is used to send data on the datagram socket. The function
|
||||
@@ -153,8 +194,9 @@ public:
|
||||
std::size_t send(const ConstBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send(this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -180,9 +222,9 @@ public:
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send(
|
||||
this->implementation, buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -207,7 +249,8 @@ public:
|
||||
std::size_t send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.send(this->implementation, buffers, flags, ec);
|
||||
return this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous send on a connected socket.
|
||||
@@ -247,9 +290,15 @@ public:
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
|
||||
void async_send(const ConstBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous send on a connected socket.
|
||||
@@ -283,9 +332,15 @@ public:
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, WriteHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send(this->implementation, buffers, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Send a datagram to the specified endpoint.
|
||||
@@ -318,9 +373,9 @@ public:
|
||||
const endpoint_type& destination)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send_to(
|
||||
this->implementation, buffers, destination, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send_to(
|
||||
this->get_implementation(), buffers, destination, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "send_to");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -345,9 +400,9 @@ public:
|
||||
const endpoint_type& destination, socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send_to(
|
||||
this->implementation, buffers, destination, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send_to(
|
||||
this->get_implementation(), buffers, destination, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "send_to");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -372,7 +427,7 @@ public:
|
||||
const endpoint_type& destination, socket_base::message_flags flags,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.send_to(this->implementation,
|
||||
return this->get_service().send_to(this->get_implementation(),
|
||||
buffers, destination, flags, ec);
|
||||
}
|
||||
|
||||
@@ -415,10 +470,15 @@ public:
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send_to(const ConstBufferSequence& buffers,
|
||||
const endpoint_type& destination, WriteHandler handler)
|
||||
const endpoint_type& destination,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send_to(this->implementation, buffers, destination, 0,
|
||||
handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send_to(this->get_implementation(), buffers,
|
||||
destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous send.
|
||||
@@ -451,10 +511,14 @@ public:
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send_to(const ConstBufferSequence& buffers,
|
||||
const endpoint_type& destination, socket_base::message_flags flags,
|
||||
WriteHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send_to(this->implementation, buffers, destination,
|
||||
flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send_to(this->get_implementation(), buffers,
|
||||
destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive some data on a connected socket.
|
||||
@@ -485,9 +549,9 @@ public:
|
||||
std::size_t receive(const MutableBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive(
|
||||
this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -514,9 +578,9 @@ public:
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive(
|
||||
this->implementation, buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -542,7 +606,8 @@ public:
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.receive(this->implementation, buffers, flags, ec);
|
||||
return this->get_service().receive(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive on a connected socket.
|
||||
@@ -582,9 +647,15 @@ public:
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive on a connected socket.
|
||||
@@ -617,9 +688,15 @@ public:
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags flags, ReadHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive(this->implementation, buffers, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive a datagram with the endpoint of the sender.
|
||||
@@ -653,9 +730,9 @@ public:
|
||||
endpoint_type& sender_endpoint)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive_from(
|
||||
this->implementation, buffers, sender_endpoint, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive_from(
|
||||
this->get_implementation(), buffers, sender_endpoint, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive_from");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -680,9 +757,9 @@ public:
|
||||
endpoint_type& sender_endpoint, socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive_from(
|
||||
this->implementation, buffers, sender_endpoint, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive_from(
|
||||
this->get_implementation(), buffers, sender_endpoint, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive_from");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -707,8 +784,8 @@ public:
|
||||
endpoint_type& sender_endpoint, socket_base::message_flags flags,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.receive_from(this->implementation, buffers,
|
||||
sender_endpoint, flags, ec);
|
||||
return this->get_service().receive_from(this->get_implementation(),
|
||||
buffers, sender_endpoint, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
@@ -749,10 +826,15 @@ public:
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive_from(const MutableBufferSequence& buffers,
|
||||
endpoint_type& sender_endpoint, ReadHandler handler)
|
||||
endpoint_type& sender_endpoint,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive_from(this->implementation, buffers,
|
||||
sender_endpoint, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive_from(this->get_implementation(), buffers,
|
||||
sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
@@ -787,10 +869,14 @@ public:
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive_from(const MutableBufferSequence& buffers,
|
||||
endpoint_type& sender_endpoint, socket_base::message_flags flags,
|
||||
ReadHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive_from(this->implementation, buffers,
|
||||
sender_endpoint, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive_from(this->get_implementation(), buffers,
|
||||
sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_deadline_timer.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <cstddef>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/deadline_timer_service.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
|
||||
@@ -161,7 +162,7 @@ public:
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_at(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_at");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
@@ -180,7 +181,7 @@ public:
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_from_now(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_from_now");
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
@@ -209,7 +210,7 @@ public:
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -240,6 +241,67 @@ public:
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Cancels one asynchronous operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.cancel_one(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel_one");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Cancels one asynchronous operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel_one(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
@@ -277,7 +339,7 @@ public:
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_at(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_at");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -346,7 +408,7 @@ public:
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_from_now(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_from_now");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -390,7 +452,7 @@ public:
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.wait(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "wait");
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
@@ -430,9 +492,14 @@ public:
|
||||
* boost::asio::io_service::post().
|
||||
*/
|
||||
template <typename WaitHandler>
|
||||
void async_wait(WaitHandler handler)
|
||||
void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
|
||||
{
|
||||
this->service.async_wait(this->implementation, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WaitHandler.
|
||||
BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
|
||||
|
||||
this->service.async_wait(this->implementation,
|
||||
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_io_object.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -16,7 +16,6 @@
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
@@ -24,10 +23,42 @@
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
namespace detail
|
||||
{
|
||||
// Type trait used to determine whether a service supports move.
|
||||
template <typename IoObjectService>
|
||||
class service_has_move
|
||||
{
|
||||
private:
|
||||
typedef IoObjectService service_type;
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
template <typename T, typename U>
|
||||
static auto eval(T* t, U* u) -> decltype(t->move_construct(*u, *u), char());
|
||||
static char (&eval(...))[2];
|
||||
|
||||
public:
|
||||
static const bool value =
|
||||
sizeof(service_has_move::eval(
|
||||
static_cast<service_type*>(0),
|
||||
static_cast<implementation_type*>(0))) == 1;
|
||||
};
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
/// Base class for all I/O objects.
|
||||
/**
|
||||
* @note All I/O objects are non-copyable. However, when using C++0x, certain
|
||||
* I/O objects do support move construction and move assignment.
|
||||
*/
|
||||
#if !defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
template <typename IoObjectService>
|
||||
#else
|
||||
template <typename IoObjectService,
|
||||
bool Movable = detail::service_has_move<IoObjectService>::value>
|
||||
#endif
|
||||
class basic_io_object
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the service that will be used to provide I/O operations.
|
||||
@@ -36,20 +67,6 @@ public:
|
||||
/// The underlying implementation type of I/O object.
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
/**
|
||||
* This function may be used to obtain the io_service object that the I/O
|
||||
* object uses to dispatch handlers for asynchronous operations.
|
||||
*
|
||||
* @return A reference to the io_service object that the I/O object will use
|
||||
* to dispatch handlers. Ownership is not transferred to the caller.
|
||||
*/
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return service.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
/**
|
||||
* This function may be used to obtain the io_service object that the I/O
|
||||
@@ -67,7 +84,7 @@ protected:
|
||||
/// Construct a basic_io_object.
|
||||
/**
|
||||
* Performs:
|
||||
* @code service.construct(implementation); @endcode
|
||||
* @code get_service().construct(get_implementation()); @endcode
|
||||
*/
|
||||
explicit basic_io_object(boost::asio::io_service& io_service)
|
||||
: service(boost::asio::use_service<IoObjectService>(io_service))
|
||||
@@ -75,23 +92,148 @@ protected:
|
||||
service.construct(implementation);
|
||||
}
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_io_object.
|
||||
/**
|
||||
* Performs:
|
||||
* @code get_service().move_construct(
|
||||
* get_implementation(), other.get_implementation()); @endcode
|
||||
*
|
||||
* @note Available only for services that support movability,
|
||||
*/
|
||||
basic_io_object(basic_io_object&& other);
|
||||
|
||||
/// Move-assign a basic_io_object.
|
||||
/**
|
||||
* Performs:
|
||||
* @code get_service().move_assign(get_implementation(),
|
||||
* other.get_service(), other.get_implementation()); @endcode
|
||||
*
|
||||
* @note Available only for services that support movability,
|
||||
*/
|
||||
basic_io_object& operator=(basic_io_object&& other);
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Protected destructor to prevent deletion through this type.
|
||||
/**
|
||||
* Performs:
|
||||
* @code service.destroy(implementation); @endcode
|
||||
* @code get_service().destroy(get_implementation()); @endcode
|
||||
*/
|
||||
~basic_io_object()
|
||||
{
|
||||
service.destroy(implementation);
|
||||
}
|
||||
|
||||
/// The service associated with the I/O object.
|
||||
/// Get the service associated with the I/O object.
|
||||
service_type& get_service()
|
||||
{
|
||||
return service;
|
||||
}
|
||||
|
||||
/// Get the service associated with the I/O object.
|
||||
const service_type& get_service() const
|
||||
{
|
||||
return service;
|
||||
}
|
||||
|
||||
/// (Deprecated: Use get_service().) The service associated with the I/O
|
||||
/// object.
|
||||
/**
|
||||
* @note Available only for services that do not support movability.
|
||||
*/
|
||||
service_type& service;
|
||||
|
||||
/// The underlying implementation of the I/O object.
|
||||
/// Get the underlying implementation of the I/O object.
|
||||
implementation_type& get_implementation()
|
||||
{
|
||||
return implementation;
|
||||
}
|
||||
|
||||
/// Get the underlying implementation of the I/O object.
|
||||
const implementation_type& get_implementation() const
|
||||
{
|
||||
return implementation;
|
||||
}
|
||||
|
||||
/// (Deprecated: Use get_implementation().) The underlying implementation of
|
||||
/// the I/O object.
|
||||
implementation_type implementation;
|
||||
|
||||
private:
|
||||
basic_io_object(const basic_io_object&);
|
||||
basic_io_object& operator=(const basic_io_object&);
|
||||
};
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
// Specialisation for movable objects.
|
||||
template <typename IoObjectService>
|
||||
class basic_io_object<IoObjectService, true>
|
||||
{
|
||||
public:
|
||||
typedef IoObjectService service_type;
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return service_->get_io_service();
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit basic_io_object(boost::asio::io_service& io_service)
|
||||
: service_(&boost::asio::use_service<IoObjectService>(io_service))
|
||||
{
|
||||
service_->construct(implementation);
|
||||
}
|
||||
|
||||
basic_io_object(basic_io_object&& other)
|
||||
: service_(&other.get_service())
|
||||
{
|
||||
service_->move_construct(implementation, other.implementation);
|
||||
}
|
||||
|
||||
~basic_io_object()
|
||||
{
|
||||
service_->destroy(implementation);
|
||||
}
|
||||
|
||||
basic_io_object& operator=(basic_io_object&& other)
|
||||
{
|
||||
service_->move_assign(implementation,
|
||||
*other.service_, other.implementation);
|
||||
service_ = other.service_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
service_type& get_service()
|
||||
{
|
||||
return *service_;
|
||||
}
|
||||
|
||||
const service_type& get_service() const
|
||||
{
|
||||
return *service_;
|
||||
}
|
||||
|
||||
implementation_type& get_implementation()
|
||||
{
|
||||
return implementation;
|
||||
}
|
||||
|
||||
const implementation_type& get_implementation() const
|
||||
{
|
||||
return implementation;
|
||||
}
|
||||
|
||||
implementation_type implementation;
|
||||
|
||||
private:
|
||||
basic_io_object(const basic_io_object&);
|
||||
void operator=(const basic_io_object&);
|
||||
|
||||
IoObjectService* service_;
|
||||
};
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_raw_socket.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/raw_socket_service.hpp>
|
||||
@@ -42,8 +43,12 @@ class basic_raw_socket
|
||||
: public basic_socket<Protocol, RawSocketService>
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// socket.
|
||||
typedef typename RawSocketService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of a socket.
|
||||
typedef typename RawSocketService::native_type native_type;
|
||||
typedef typename RawSocketService::native_handle_type native_handle_type;
|
||||
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
@@ -121,12 +126,47 @@ public:
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_raw_socket(boost::asio::io_service& io_service,
|
||||
const protocol_type& protocol, const native_type& native_socket)
|
||||
const protocol_type& protocol, const native_handle_type& native_socket)
|
||||
: basic_socket<Protocol, RawSocketService>(
|
||||
io_service, protocol, native_socket)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_raw_socket from another.
|
||||
/**
|
||||
* This constructor moves a raw socket from one object to another.
|
||||
*
|
||||
* @param other The other basic_raw_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_raw_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_raw_socket(basic_raw_socket&& other)
|
||||
: basic_socket<Protocol, RawSocketService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_raw_socket from another.
|
||||
/**
|
||||
* This assignment operator moves a raw socket from one object to another.
|
||||
*
|
||||
* @param other The other basic_raw_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_raw_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_raw_socket& operator=(basic_raw_socket&& other)
|
||||
{
|
||||
basic_socket<Protocol, RawSocketService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Send some data on a connected socket.
|
||||
/**
|
||||
* This function is used to send data on the raw socket. The function call
|
||||
@@ -152,8 +192,9 @@ public:
|
||||
std::size_t send(const ConstBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send(this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -178,9 +219,9 @@ public:
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send(
|
||||
this->implementation, buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -204,7 +245,8 @@ public:
|
||||
std::size_t send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.send(this->implementation, buffers, flags, ec);
|
||||
return this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous send on a connected socket.
|
||||
@@ -243,9 +285,15 @@ public:
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
|
||||
void async_send(const ConstBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous send on a connected socket.
|
||||
@@ -278,9 +326,15 @@ public:
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, WriteHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send(this->implementation, buffers, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Send raw data to the specified endpoint.
|
||||
@@ -313,9 +367,9 @@ public:
|
||||
const endpoint_type& destination)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send_to(
|
||||
this->implementation, buffers, destination, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send_to(
|
||||
this->get_implementation(), buffers, destination, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "send_to");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -340,9 +394,9 @@ public:
|
||||
const endpoint_type& destination, socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send_to(
|
||||
this->implementation, buffers, destination, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send_to(
|
||||
this->get_implementation(), buffers, destination, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "send_to");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -367,7 +421,7 @@ public:
|
||||
const endpoint_type& destination, socket_base::message_flags flags,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.send_to(this->implementation,
|
||||
return this->get_service().send_to(this->get_implementation(),
|
||||
buffers, destination, flags, ec);
|
||||
}
|
||||
|
||||
@@ -410,10 +464,15 @@ public:
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send_to(const ConstBufferSequence& buffers,
|
||||
const endpoint_type& destination, WriteHandler handler)
|
||||
const endpoint_type& destination,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send_to(this->implementation, buffers, destination, 0,
|
||||
handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send_to(this->get_implementation(), buffers,
|
||||
destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous send.
|
||||
@@ -446,10 +505,14 @@ public:
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send_to(const ConstBufferSequence& buffers,
|
||||
const endpoint_type& destination, socket_base::message_flags flags,
|
||||
WriteHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send_to(this->implementation, buffers, destination,
|
||||
flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send_to(this->get_implementation(), buffers,
|
||||
destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive some data on a connected socket.
|
||||
@@ -480,9 +543,9 @@ public:
|
||||
std::size_t receive(const MutableBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive(
|
||||
this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -509,9 +572,9 @@ public:
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive(
|
||||
this->implementation, buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -537,7 +600,8 @@ public:
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.receive(this->implementation, buffers, flags, ec);
|
||||
return this->get_service().receive(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive on a connected socket.
|
||||
@@ -577,9 +641,15 @@ public:
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive on a connected socket.
|
||||
@@ -612,9 +682,15 @@ public:
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags flags, ReadHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive(this->implementation, buffers, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive raw data with the endpoint of the sender.
|
||||
@@ -648,9 +724,9 @@ public:
|
||||
endpoint_type& sender_endpoint)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive_from(
|
||||
this->implementation, buffers, sender_endpoint, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive_from(
|
||||
this->get_implementation(), buffers, sender_endpoint, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive_from");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -675,9 +751,9 @@ public:
|
||||
endpoint_type& sender_endpoint, socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive_from(
|
||||
this->implementation, buffers, sender_endpoint, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive_from(
|
||||
this->get_implementation(), buffers, sender_endpoint, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive_from");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -702,8 +778,8 @@ public:
|
||||
endpoint_type& sender_endpoint, socket_base::message_flags flags,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.receive_from(this->implementation, buffers,
|
||||
sender_endpoint, flags, ec);
|
||||
return this->get_service().receive_from(this->get_implementation(),
|
||||
buffers, sender_endpoint, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
@@ -744,10 +820,15 @@ public:
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive_from(const MutableBufferSequence& buffers,
|
||||
endpoint_type& sender_endpoint, ReadHandler handler)
|
||||
endpoint_type& sender_endpoint,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive_from(this->implementation, buffers,
|
||||
sender_endpoint, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive_from(this->get_implementation(), buffers,
|
||||
sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
@@ -782,10 +863,14 @@ public:
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive_from(const MutableBufferSequence& buffers,
|
||||
endpoint_type& sender_endpoint, socket_base::message_flags flags,
|
||||
ReadHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive_from(this->implementation, buffers,
|
||||
sender_endpoint, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive_from(this->get_implementation(), buffers,
|
||||
sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
514
project/jni/boost/include/boost/asio/basic_seq_packet_socket.hpp
Normal file
514
project/jni/boost/include/boost/asio/basic_seq_packet_socket.hpp
Normal file
@@ -0,0 +1,514 @@
|
||||
//
|
||||
// basic_seq_packet_socket.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
|
||||
#define BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/seq_packet_socket_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Provides sequenced packet socket functionality.
|
||||
/**
|
||||
* The basic_seq_packet_socket class template provides asynchronous and blocking
|
||||
* sequenced packet socket functionality.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*/
|
||||
template <typename Protocol,
|
||||
typename SeqPacketSocketService = seq_packet_socket_service<Protocol> >
|
||||
class basic_seq_packet_socket
|
||||
: public basic_socket<Protocol, SeqPacketSocketService>
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// socket.
|
||||
typedef typename SeqPacketSocketService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of a socket.
|
||||
typedef typename SeqPacketSocketService::native_handle_type
|
||||
native_handle_type;
|
||||
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// Construct a basic_seq_packet_socket without opening it.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket without opening it. The
|
||||
* socket needs to be opened and then connected or accepted before data can
|
||||
* be sent or received on it.
|
||||
*
|
||||
* @param io_service The io_service object that the sequenced packet socket
|
||||
* will use to dispatch handlers for any asynchronous operations performed on
|
||||
* the socket.
|
||||
*/
|
||||
explicit basic_seq_packet_socket(boost::asio::io_service& io_service)
|
||||
: basic_socket<Protocol, SeqPacketSocketService>(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct and open a basic_seq_packet_socket.
|
||||
/**
|
||||
* This constructor creates and opens a sequenced_packet socket. The socket
|
||||
* needs to be connected or accepted before data can be sent or received on
|
||||
* it.
|
||||
*
|
||||
* @param io_service The io_service object that the sequenced packet socket
|
||||
* will use to dispatch handlers for any asynchronous operations performed on
|
||||
* the socket.
|
||||
*
|
||||
* @param protocol An object specifying protocol parameters to be used.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_seq_packet_socket(boost::asio::io_service& io_service,
|
||||
const protocol_type& protocol)
|
||||
: basic_socket<Protocol, SeqPacketSocketService>(io_service, protocol)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_seq_packet_socket, opening it and binding it to the
|
||||
/// given local endpoint.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket and automatically opens
|
||||
* it bound to the specified endpoint on the local machine. The protocol used
|
||||
* is the protocol associated with the given endpoint.
|
||||
*
|
||||
* @param io_service The io_service object that the sequenced packet socket
|
||||
* will use to dispatch handlers for any asynchronous operations performed on
|
||||
* the socket.
|
||||
*
|
||||
* @param endpoint An endpoint on the local machine to which the sequenced
|
||||
* packet socket will be bound.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_seq_packet_socket(boost::asio::io_service& io_service,
|
||||
const endpoint_type& endpoint)
|
||||
: basic_socket<Protocol, SeqPacketSocketService>(io_service, endpoint)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a basic_seq_packet_socket on an existing native socket.
|
||||
/**
|
||||
* This constructor creates a sequenced packet socket object to hold an
|
||||
* existing native socket.
|
||||
*
|
||||
* @param io_service The io_service object that the sequenced packet socket
|
||||
* will use to dispatch handlers for any asynchronous operations performed on
|
||||
* the socket.
|
||||
*
|
||||
* @param protocol An object specifying protocol parameters to be used.
|
||||
*
|
||||
* @param native_socket The new underlying socket implementation.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_seq_packet_socket(boost::asio::io_service& io_service,
|
||||
const protocol_type& protocol, const native_handle_type& native_socket)
|
||||
: basic_socket<Protocol, SeqPacketSocketService>(
|
||||
io_service, protocol, native_socket)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_seq_packet_socket from another.
|
||||
/**
|
||||
* This constructor moves a sequenced packet socket from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_seq_packet_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_seq_packet_socket(basic_seq_packet_socket&& other)
|
||||
: basic_socket<Protocol, SeqPacketSocketService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_seq_packet_socket from another.
|
||||
/**
|
||||
* This assignment operator moves a sequenced packet socket from one object to
|
||||
* another.
|
||||
*
|
||||
* @param other The other basic_seq_packet_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_seq_packet_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_seq_packet_socket& operator=(basic_seq_packet_socket&& other)
|
||||
{
|
||||
basic_socket<Protocol, SeqPacketSocketService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Send some data on the socket.
|
||||
/**
|
||||
* This function is used to send data on the sequenced packet socket. The
|
||||
* function call will block until the data has been sent successfully, or an
|
||||
* until error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be sent on the socket.
|
||||
*
|
||||
* @param flags Flags specifying how the send call is to be made.
|
||||
*
|
||||
* @returns The number of bytes sent.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @par Example
|
||||
* To send a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* socket.send(boost::asio::buffer(data, size), 0);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on sending multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Send some data on the socket.
|
||||
/**
|
||||
* This function is used to send data on the sequenced packet socket. The
|
||||
* function call will block the data has been sent successfully, or an until
|
||||
* error occurs.
|
||||
*
|
||||
* @param buffers One or more data buffers to be sent on the socket.
|
||||
*
|
||||
* @param flags Flags specifying how the send call is to be made.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes sent. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The send operation may not transmit all of the data to the peer.
|
||||
* Consider using the @ref write function if you need to ensure that all data
|
||||
* is written before the blocking operation completes.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous send.
|
||||
/**
|
||||
* This function is used to asynchronously send data on the sequenced packet
|
||||
* socket. The function call always returns immediately.
|
||||
*
|
||||
* @param buffers One or more data buffers to be sent on the socket. Although
|
||||
* the buffers object may be copied as necessary, ownership of the underlying
|
||||
* memory blocks is retained by the caller, which must guarantee that they
|
||||
* remain valid until the handler is called.
|
||||
*
|
||||
* @param flags Flags specifying how the send call is to be made.
|
||||
*
|
||||
* @param handler The handler to be called when the send operation completes.
|
||||
* Copies will be made of the handler as required. The function signature of
|
||||
* the handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes sent.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*
|
||||
* @par Example
|
||||
* To send a single data buffer use the @ref buffer function as follows:
|
||||
* @code
|
||||
* socket.async_send(boost::asio::buffer(data, size), 0, handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on sending multiple
|
||||
* buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive some data on the socket.
|
||||
/**
|
||||
* This function is used to receive data on the sequenced packet socket. The
|
||||
* function call will block until data has been received successfully, or
|
||||
* until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
*
|
||||
* @param out_flags After the receive call completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record.
|
||||
*
|
||||
* @returns The number of bytes received.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. An error code of
|
||||
* boost::asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.receive(boost::asio::buffer(data, size), out_flags);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags& out_flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, 0, out_flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Receive some data on the socket.
|
||||
/**
|
||||
* This function is used to receive data on the sequenced packet socket. The
|
||||
* function call will block until data has been received successfully, or
|
||||
* until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
*
|
||||
* @param in_flags Flags specifying how the receive call is to be made.
|
||||
*
|
||||
* @param out_flags After the receive call completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record.
|
||||
*
|
||||
* @returns The number of bytes received.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. An error code of
|
||||
* boost::asio::error::eof indicates that the connection was closed by the
|
||||
* peer.
|
||||
*
|
||||
* @note The receive operation may not receive all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that the
|
||||
* requested amount of data is read before the blocking operation completes.
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.receive(boost::asio::buffer(data, size), 0, out_flags);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags in_flags,
|
||||
socket_base::message_flags& out_flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, in_flags, out_flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Receive some data on a connected socket.
|
||||
/**
|
||||
* This function is used to receive data on the sequenced packet socket. The
|
||||
* function call will block until data has been received successfully, or
|
||||
* until an error occurs.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
*
|
||||
* @param in_flags Flags specifying how the receive call is to be made.
|
||||
*
|
||||
* @param out_flags After the receive call completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @returns The number of bytes received. Returns 0 if an error occurred.
|
||||
*
|
||||
* @note The receive operation may not receive all of the requested number of
|
||||
* bytes. Consider using the @ref read function if you need to ensure that the
|
||||
* requested amount of data is read before the blocking operation completes.
|
||||
*/
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags in_flags,
|
||||
socket_base::message_flags& out_flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().receive(this->get_implementation(),
|
||||
buffers, in_flags, out_flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
/**
|
||||
* This function is used to asynchronously receive data from the sequenced
|
||||
* packet socket. The function call always returns immediately.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the handler is called.
|
||||
*
|
||||
* @param out_flags Once the asynchronous operation completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record. The caller must guarantee that the referenced
|
||||
* variable remains valid until the handler is called.
|
||||
*
|
||||
* @param handler The handler to be called when the receive operation
|
||||
* completes. Copies will be made of the handler as required. The function
|
||||
* signature of the handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes received.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.async_receive(boost::asio::buffer(data, size), out_flags, handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags& out_flags,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(), buffers,
|
||||
0, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
/**
|
||||
* This function is used to asynchronously receive data from the sequenced
|
||||
* data socket. The function call always returns immediately.
|
||||
*
|
||||
* @param buffers One or more buffers into which the data will be received.
|
||||
* Although the buffers object may be copied as necessary, ownership of the
|
||||
* underlying memory blocks is retained by the caller, which must guarantee
|
||||
* that they remain valid until the handler is called.
|
||||
*
|
||||
* @param in_flags Flags specifying how the receive call is to be made.
|
||||
*
|
||||
* @param out_flags Once the asynchronous operation completes, contains flags
|
||||
* associated with the received data. For example, if the
|
||||
* socket_base::message_end_of_record bit is set then the received data marks
|
||||
* the end of a record. The caller must guarantee that the referenced
|
||||
* variable remains valid until the handler is called.
|
||||
*
|
||||
* @param handler The handler to be called when the receive operation
|
||||
* completes. Copies will be made of the handler as required. The function
|
||||
* signature of the handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error, // Result of operation.
|
||||
* std::size_t bytes_transferred // Number of bytes received.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*
|
||||
* @par Example
|
||||
* To receive into a single data buffer use the @ref buffer function as
|
||||
* follows:
|
||||
* @code
|
||||
* socket.async_receive(
|
||||
* boost::asio::buffer(data, size),
|
||||
* 0, out_flags, handler);
|
||||
* @endcode
|
||||
* See the @ref buffer documentation for information on receiving into
|
||||
* multiple buffers in one go, and how to use it with arrays, boost::array or
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags in_flags,
|
||||
socket_base::message_flags& out_flags,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(), buffers,
|
||||
in_flags, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_serial_port.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/serial_port_base.hpp>
|
||||
@@ -48,8 +49,12 @@ class basic_serial_port
|
||||
public serial_port_base
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// serial port.
|
||||
typedef typename SerialPortService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of a serial port.
|
||||
typedef typename SerialPortService::native_type native_type;
|
||||
typedef typename SerialPortService::native_handle_type native_handle_type;
|
||||
|
||||
/// A basic_serial_port is always the lowest layer.
|
||||
typedef basic_serial_port<SerialPortService> lowest_layer_type;
|
||||
@@ -82,8 +87,8 @@ public:
|
||||
: basic_io_object<SerialPortService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, device, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(), device, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct and open a basic_serial_port.
|
||||
@@ -102,8 +107,8 @@ public:
|
||||
: basic_io_object<SerialPortService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, device, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(), device, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct a basic_serial_port on an existing native serial port.
|
||||
@@ -119,14 +124,50 @@ public:
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_serial_port(boost::asio::io_service& io_service,
|
||||
const native_type& native_serial_port)
|
||||
const native_handle_type& native_serial_port)
|
||||
: basic_io_object<SerialPortService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.assign(this->implementation, native_serial_port, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().assign(this->get_implementation(),
|
||||
native_serial_port, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_serial_port from another.
|
||||
/**
|
||||
* This constructor moves a serial port from one object to another.
|
||||
*
|
||||
* @param other The other basic_serial_port object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_serial_port(io_service&) constructor.
|
||||
*/
|
||||
basic_serial_port(basic_serial_port&& other)
|
||||
: basic_io_object<SerialPortService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_serial_port)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_serial_port from another.
|
||||
/**
|
||||
* This assignment operator moves a serial port from one object to another.
|
||||
*
|
||||
* @param other The other basic_serial_port object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_serial_port(io_service&) constructor.
|
||||
*/
|
||||
basic_serial_port& operator=(basic_serial_port&& other)
|
||||
{
|
||||
basic_io_object<SerialPortService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_serial_port)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
@@ -166,8 +207,8 @@ public:
|
||||
void open(const std::string& device)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, device, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(), device, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Open the serial port using the specified device name.
|
||||
@@ -182,7 +223,7 @@ public:
|
||||
boost::system::error_code open(const std::string& device,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.open(this->implementation, device, ec);
|
||||
return this->get_service().open(this->get_implementation(), device, ec);
|
||||
}
|
||||
|
||||
/// Assign an existing native serial port to the serial port.
|
||||
@@ -193,11 +234,12 @@ public:
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const native_type& native_serial_port)
|
||||
void assign(const native_handle_type& native_serial_port)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.assign(this->implementation, native_serial_port, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().assign(this->get_implementation(),
|
||||
native_serial_port, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native serial port to the serial port.
|
||||
@@ -208,16 +250,17 @@ public:
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
boost::system::error_code assign(const native_type& native_serial_port,
|
||||
boost::system::error_code assign(const native_handle_type& native_serial_port,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.assign(this->implementation, native_serial_port, ec);
|
||||
return this->get_service().assign(this->get_implementation(),
|
||||
native_serial_port, ec);
|
||||
}
|
||||
|
||||
/// Determine whether the serial port is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return this->service.is_open(this->implementation);
|
||||
return this->get_service().is_open(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Close the serial port.
|
||||
@@ -231,8 +274,8 @@ public:
|
||||
void close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.close(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().close(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the serial port.
|
||||
@@ -245,7 +288,19 @@ public:
|
||||
*/
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.close(this->implementation, ec);
|
||||
return this->get_service().close(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// (Deprecated: Use native_handle().) Get the native serial port
|
||||
/// representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* serial port. This is intended to allow access to native serial port
|
||||
* functionality that is not otherwise provided.
|
||||
*/
|
||||
native_type native()
|
||||
{
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Get the native serial port representation.
|
||||
@@ -254,9 +309,9 @@ public:
|
||||
* serial port. This is intended to allow access to native serial port
|
||||
* functionality that is not otherwise provided.
|
||||
*/
|
||||
native_type native()
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return this->service.native(this->implementation);
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the serial port.
|
||||
@@ -270,8 +325,8 @@ public:
|
||||
void cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().cancel(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the serial port.
|
||||
@@ -284,7 +339,7 @@ public:
|
||||
*/
|
||||
boost::system::error_code cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
return this->get_service().cancel(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Send a break sequence to the serial port.
|
||||
@@ -297,8 +352,8 @@ public:
|
||||
void send_break()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.send_break(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().send_break(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "send_break");
|
||||
}
|
||||
|
||||
/// Send a break sequence to the serial port.
|
||||
@@ -310,7 +365,7 @@ public:
|
||||
*/
|
||||
boost::system::error_code send_break(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.send_break(this->implementation, ec);
|
||||
return this->get_service().send_break(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Set an option on the serial port.
|
||||
@@ -332,8 +387,8 @@ public:
|
||||
void set_option(const SettableSerialPortOption& option)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.set_option(this->implementation, option, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().set_option(this->get_implementation(), option, ec);
|
||||
boost::asio::detail::throw_error(ec, "set_option");
|
||||
}
|
||||
|
||||
/// Set an option on the serial port.
|
||||
@@ -355,7 +410,8 @@ public:
|
||||
boost::system::error_code set_option(const SettableSerialPortOption& option,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.set_option(this->implementation, option, ec);
|
||||
return this->get_service().set_option(
|
||||
this->get_implementation(), option, ec);
|
||||
}
|
||||
|
||||
/// Get an option from the serial port.
|
||||
@@ -378,8 +434,8 @@ public:
|
||||
void get_option(GettableSerialPortOption& option)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.get_option(this->implementation, option, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().get_option(this->get_implementation(), option, ec);
|
||||
boost::asio::detail::throw_error(ec, "get_option");
|
||||
}
|
||||
|
||||
/// Get an option from the serial port.
|
||||
@@ -402,7 +458,8 @@ public:
|
||||
boost::system::error_code get_option(GettableSerialPortOption& option,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.get_option(this->implementation, option, ec);
|
||||
return this->get_service().get_option(
|
||||
this->get_implementation(), option, ec);
|
||||
}
|
||||
|
||||
/// Write some data to the serial port.
|
||||
@@ -436,8 +493,9 @@ public:
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.write_some(this->implementation, buffers, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().write_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
boost::asio::detail::throw_error(ec, "write_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -461,7 +519,8 @@ public:
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.write_some(this->implementation, buffers, ec);
|
||||
return this->get_service().write_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write.
|
||||
@@ -501,9 +560,14 @@ public:
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_write_some(this->implementation, buffers, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_write_some(this->get_implementation(),
|
||||
buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Read some data from the serial port.
|
||||
@@ -538,8 +602,9 @@ public:
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.read_some(this->implementation, buffers, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().read_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
boost::asio::detail::throw_error(ec, "read_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -564,7 +629,8 @@ public:
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.read_some(this->implementation, buffers, ec);
|
||||
return this->get_service().read_some(
|
||||
this->get_implementation(), buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read.
|
||||
@@ -605,9 +671,14 @@ public:
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_read_some(this->implementation, buffers, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_read_some(this->get_implementation(),
|
||||
buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
384
project/jni/boost/include/boost/asio/basic_signal_set.hpp
Normal file
384
project/jni/boost/include/boost/asio/basic_signal_set.hpp
Normal file
@@ -0,0 +1,384 @@
|
||||
//
|
||||
// basic_signal_set.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_SIGNAL_SET_HPP
|
||||
#define BOOST_ASIO_BASIC_SIGNAL_SET_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/signal_set_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Provides signal functionality.
|
||||
/**
|
||||
* The basic_signal_set class template provides the ability to perform an
|
||||
* asynchronous wait for one or more signals to occur.
|
||||
*
|
||||
* Most applications will use the boost::asio::signal_set typedef.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Example
|
||||
* Performing an asynchronous wait:
|
||||
* @code
|
||||
* void handler(
|
||||
* const boost::system::error_code& error,
|
||||
* int signal_number)
|
||||
* {
|
||||
* if (!error)
|
||||
* {
|
||||
* // A signal occurred.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Construct a signal set registered for process termination.
|
||||
* boost::asio::signal_set signals(io_service, SIGINT, SIGTERM);
|
||||
*
|
||||
* // Start an asynchronous wait for one of the signals to occur.
|
||||
* signals.async_wait(handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Queueing of signal notifications
|
||||
*
|
||||
* If a signal is registered with a signal_set, and the signal occurs when
|
||||
* there are no waiting handlers, then the signal notification is queued. The
|
||||
* next async_wait operation on that signal_set will dequeue the notification.
|
||||
* If multiple notifications are queued, subsequent async_wait operations
|
||||
* dequeue them one at a time. Signal notifications are dequeued in order of
|
||||
* ascending signal number.
|
||||
*
|
||||
* If a signal number is removed from a signal_set (using the @c remove or @c
|
||||
* erase member functions) then any queued notifications for that signal are
|
||||
* discarded.
|
||||
*
|
||||
* @par Multiple registration of signals
|
||||
*
|
||||
* The same signal number may be registered with different signal_set objects.
|
||||
* When the signal occurs, one handler is called for each signal_set object.
|
||||
*
|
||||
* Note that multiple registration only works for signals that are registered
|
||||
* using Asio. The application must not also register a signal handler using
|
||||
* functions such as @c signal() or @c sigaction().
|
||||
*
|
||||
* @par Signal masking on POSIX platforms
|
||||
*
|
||||
* POSIX allows signals to be blocked using functions such as @c sigprocmask()
|
||||
* and @c pthread_sigmask(). For signals to be delivered, programs must ensure
|
||||
* that any signals registered using signal_set objects are unblocked in at
|
||||
* least one thread.
|
||||
*/
|
||||
template <typename SignalSetService = signal_set_service>
|
||||
class basic_signal_set
|
||||
: public basic_io_object<SignalSetService>
|
||||
{
|
||||
public:
|
||||
/// Construct a signal set without adding any signals.
|
||||
/**
|
||||
* This constructor creates a signal set without registering for any signals.
|
||||
*
|
||||
* @param io_service The io_service object that the signal set will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the set.
|
||||
*/
|
||||
explicit basic_signal_set(boost::asio::io_service& io_service)
|
||||
: basic_io_object<SignalSetService>(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a signal set and add one signal.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for one signal.
|
||||
*
|
||||
* @param io_service The io_service object that the signal set will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the set.
|
||||
*
|
||||
* @param signal_number_1 The signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code boost::asio::signal_set signals(io_service);
|
||||
* signals.add(signal_number_1); @endcode
|
||||
*/
|
||||
basic_signal_set(boost::asio::io_service& io_service, int signal_number_1)
|
||||
: basic_io_object<SignalSetService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.add(this->implementation, signal_number_1, ec);
|
||||
boost::asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Construct a signal set and add two signals.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for two signals.
|
||||
*
|
||||
* @param io_service The io_service object that the signal set will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the set.
|
||||
*
|
||||
* @param signal_number_1 The first signal number to be added.
|
||||
*
|
||||
* @param signal_number_2 The second signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code boost::asio::signal_set signals(io_service);
|
||||
* signals.add(signal_number_1);
|
||||
* signals.add(signal_number_2); @endcode
|
||||
*/
|
||||
basic_signal_set(boost::asio::io_service& io_service, int signal_number_1,
|
||||
int signal_number_2)
|
||||
: basic_io_object<SignalSetService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.add(this->implementation, signal_number_1, ec);
|
||||
boost::asio::detail::throw_error(ec, "add");
|
||||
this->service.add(this->implementation, signal_number_2, ec);
|
||||
boost::asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Construct a signal set and add three signals.
|
||||
/**
|
||||
* This constructor creates a signal set and registers for three signals.
|
||||
*
|
||||
* @param io_service The io_service object that the signal set will use to
|
||||
* dispatch handlers for any asynchronous operations performed on the set.
|
||||
*
|
||||
* @param signal_number_1 The first signal number to be added.
|
||||
*
|
||||
* @param signal_number_2 The second signal number to be added.
|
||||
*
|
||||
* @param signal_number_3 The third signal number to be added.
|
||||
*
|
||||
* @note This constructor is equivalent to performing:
|
||||
* @code boost::asio::signal_set signals(io_service);
|
||||
* signals.add(signal_number_1);
|
||||
* signals.add(signal_number_2);
|
||||
* signals.add(signal_number_3); @endcode
|
||||
*/
|
||||
basic_signal_set(boost::asio::io_service& io_service, int signal_number_1,
|
||||
int signal_number_2, int signal_number_3)
|
||||
: basic_io_object<SignalSetService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.add(this->implementation, signal_number_1, ec);
|
||||
boost::asio::detail::throw_error(ec, "add");
|
||||
this->service.add(this->implementation, signal_number_2, ec);
|
||||
boost::asio::detail::throw_error(ec, "add");
|
||||
this->service.add(this->implementation, signal_number_3, ec);
|
||||
boost::asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Add a signal to a signal_set.
|
||||
/**
|
||||
* This function adds the specified signal to the set. It has no effect if the
|
||||
* signal is already in the set.
|
||||
*
|
||||
* @param signal_number The signal to be added to the set.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void add(int signal_number)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.add(this->implementation, signal_number, ec);
|
||||
boost::asio::detail::throw_error(ec, "add");
|
||||
}
|
||||
|
||||
/// Add a signal to a signal_set.
|
||||
/**
|
||||
* This function adds the specified signal to the set. It has no effect if the
|
||||
* signal is already in the set.
|
||||
*
|
||||
* @param signal_number The signal to be added to the set.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
boost::system::error_code add(int signal_number,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.add(this->implementation, signal_number, ec);
|
||||
}
|
||||
|
||||
/// Remove a signal from a signal_set.
|
||||
/**
|
||||
* This function removes the specified signal from the set. It has no effect
|
||||
* if the signal is not in the set.
|
||||
*
|
||||
* @param signal_number The signal to be removed from the set.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note Removes any notifications that have been queued for the specified
|
||||
* signal number.
|
||||
*/
|
||||
void remove(int signal_number)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.remove(this->implementation, signal_number, ec);
|
||||
boost::asio::detail::throw_error(ec, "remove");
|
||||
}
|
||||
|
||||
/// Remove a signal from a signal_set.
|
||||
/**
|
||||
* This function removes the specified signal from the set. It has no effect
|
||||
* if the signal is not in the set.
|
||||
*
|
||||
* @param signal_number The signal to be removed from the set.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note Removes any notifications that have been queued for the specified
|
||||
* signal number.
|
||||
*/
|
||||
boost::system::error_code remove(int signal_number,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.remove(this->implementation, signal_number, ec);
|
||||
}
|
||||
|
||||
/// Remove all signals from a signal_set.
|
||||
/**
|
||||
* This function removes all signals from the set. It has no effect if the set
|
||||
* is already empty.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note Removes all queued notifications.
|
||||
*/
|
||||
void clear()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.clear(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec, "clear");
|
||||
}
|
||||
|
||||
/// Remove all signals from a signal_set.
|
||||
/**
|
||||
* This function removes all signals from the set. It has no effect if the set
|
||||
* is already empty.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note Removes all queued notifications.
|
||||
*/
|
||||
boost::system::error_code clear(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.clear(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Cancel all operations associated with the signal set.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the signal set. The handler for each cancelled
|
||||
* operation will be invoked with the boost::asio::error::operation_aborted
|
||||
* error code.
|
||||
*
|
||||
* Cancellation does not alter the set of registered signals.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note If a registered signal occurred before cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
void cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all operations associated with the signal set.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the signal set. The handler for each cancelled
|
||||
* operation will be invoked with the boost::asio::error::operation_aborted
|
||||
* error code.
|
||||
*
|
||||
* Cancellation does not alter the set of registered signals.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note If a registered signal occurred before cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
boost::system::error_code cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous operation to wait for a signal to be delivered.
|
||||
/**
|
||||
* This function may be used to initiate an asynchronous wait against the
|
||||
* signal set. It always returns immediately.
|
||||
*
|
||||
* For each call to async_wait(), the supplied handler will be called exactly
|
||||
* once. The handler will be called when:
|
||||
*
|
||||
* @li One of the registered signals in the signal set occurs; or
|
||||
*
|
||||
* @li The signal set was cancelled, in which case the handler is passed the
|
||||
* error code boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param handler The handler to be called when the signal occurs. Copies
|
||||
* will be made of the handler as required. The function signature of the
|
||||
* handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error, // Result of operation.
|
||||
* int signal_number // Indicates which signal occurred.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*/
|
||||
template <typename SignalHandler>
|
||||
void async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a SignalHandler.
|
||||
BOOST_ASIO_SIGNAL_HANDLER_CHECK(SignalHandler, handler) type_check;
|
||||
|
||||
this->service.async_wait(this->implementation,
|
||||
BOOST_ASIO_MOVE_CAST(SignalHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_SIGNAL_SET_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_socket.hpp
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/socket_base.hpp>
|
||||
@@ -41,8 +42,12 @@ class basic_socket
|
||||
public socket_base
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// socket.
|
||||
typedef typename SocketService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of a socket.
|
||||
typedef typename SocketService::native_type native_type;
|
||||
typedef typename SocketService::native_handle_type native_handle_type;
|
||||
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
@@ -81,8 +86,8 @@ public:
|
||||
: basic_io_object<SocketService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, protocol, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct a basic_socket, opening it and binding it to the given local
|
||||
@@ -105,10 +110,11 @@ public:
|
||||
: basic_io_object<SocketService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, endpoint.protocol(), ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->service.bind(this->implementation, endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
const protocol_type protocol = endpoint.protocol();
|
||||
this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
this->get_service().bind(this->get_implementation(), endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec, "bind");
|
||||
}
|
||||
|
||||
/// Construct a basic_socket on an existing native socket.
|
||||
@@ -125,14 +131,50 @@ public:
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_socket(boost::asio::io_service& io_service,
|
||||
const protocol_type& protocol, const native_type& native_socket)
|
||||
const protocol_type& protocol, const native_handle_type& native_socket)
|
||||
: basic_io_object<SocketService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.assign(this->implementation, protocol, native_socket, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().assign(this->get_implementation(),
|
||||
protocol, native_socket, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_socket from another.
|
||||
/**
|
||||
* This constructor moves a socket from one object to another.
|
||||
*
|
||||
* @param other The other basic_socket object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_socket(basic_socket&& other)
|
||||
: basic_io_object<SocketService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_socket)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_socket from another.
|
||||
/**
|
||||
* This assignment operator moves a socket from one object to another.
|
||||
*
|
||||
* @param other The other basic_socket object from which the move will
|
||||
* occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_socket& operator=(basic_socket&& other)
|
||||
{
|
||||
basic_io_object<SocketService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_socket)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
/**
|
||||
* This function returns a reference to the lowest layer in a stack of
|
||||
@@ -178,8 +220,8 @@ public:
|
||||
void open(const protocol_type& protocol = protocol_type())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, protocol, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Open the socket using the specified protocol.
|
||||
@@ -204,7 +246,7 @@ public:
|
||||
boost::system::error_code open(const protocol_type& protocol,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.open(this->implementation, protocol, ec);
|
||||
return this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
}
|
||||
|
||||
/// Assign an existing native socket to the socket.
|
||||
@@ -217,11 +259,13 @@ public:
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const protocol_type& protocol, const native_type& native_socket)
|
||||
void assign(const protocol_type& protocol,
|
||||
const native_handle_type& native_socket)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.assign(this->implementation, protocol, native_socket, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().assign(this->get_implementation(),
|
||||
protocol, native_socket, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assign an existing native socket to the socket.
|
||||
@@ -235,16 +279,16 @@ public:
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
boost::system::error_code assign(const protocol_type& protocol,
|
||||
const native_type& native_socket, boost::system::error_code& ec)
|
||||
const native_handle_type& native_socket, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.assign(this->implementation,
|
||||
return this->get_service().assign(this->get_implementation(),
|
||||
protocol, native_socket, ec);
|
||||
}
|
||||
|
||||
/// Determine whether the socket is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return this->service.is_open(this->implementation);
|
||||
return this->get_service().is_open(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Close the socket.
|
||||
@@ -253,7 +297,8 @@ public:
|
||||
* or connect operations will be cancelled immediately, and will complete
|
||||
* with the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
* @throws boost::system::system_error Thrown on failure. Note that, even if
|
||||
* the function indicates an error, the underlying descriptor is closed.
|
||||
*
|
||||
* @note For portable behaviour with respect to graceful closure of a
|
||||
* connected socket, call shutdown() before closing the socket.
|
||||
@@ -261,8 +306,8 @@ public:
|
||||
void close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.close(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().close(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the socket.
|
||||
@@ -271,7 +316,8 @@ public:
|
||||
* or connect operations will be cancelled immediately, and will complete
|
||||
* with the boost::asio::error::operation_aborted error.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
* @param ec Set to indicate what error occurred, if any. Note that, even if
|
||||
* the function indicates an error, the underlying descriptor is closed.
|
||||
*
|
||||
* @par Example
|
||||
* @code
|
||||
@@ -290,7 +336,18 @@ public:
|
||||
*/
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.close(this->implementation, ec);
|
||||
return this->get_service().close(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// (Deprecated: Use native_handle().) Get the native socket representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* socket. This is intended to allow access to native socket functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_type native()
|
||||
{
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Get the native socket representation.
|
||||
@@ -299,9 +356,9 @@ public:
|
||||
* socket. This is intended to allow access to native socket functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_type native()
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return this->service.native(this->implementation);
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the socket.
|
||||
@@ -348,8 +405,8 @@ public:
|
||||
void cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().cancel(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the socket.
|
||||
@@ -395,7 +452,7 @@ public:
|
||||
#endif
|
||||
boost::system::error_code cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
return this->get_service().cancel(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Determine whether the socket is at the out-of-band data mark.
|
||||
@@ -411,8 +468,8 @@ public:
|
||||
bool at_mark() const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
bool b = this->service.at_mark(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
bool b = this->get_service().at_mark(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "at_mark");
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -428,7 +485,7 @@ public:
|
||||
*/
|
||||
bool at_mark(boost::system::error_code& ec) const
|
||||
{
|
||||
return this->service.at_mark(this->implementation, ec);
|
||||
return this->get_service().at_mark(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Determine the number of bytes available for reading.
|
||||
@@ -444,8 +501,9 @@ public:
|
||||
std::size_t available() const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.available(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().available(
|
||||
this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "available");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -461,7 +519,7 @@ public:
|
||||
*/
|
||||
std::size_t available(boost::system::error_code& ec) const
|
||||
{
|
||||
return this->service.available(this->implementation, ec);
|
||||
return this->get_service().available(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Bind the socket to the given local endpoint.
|
||||
@@ -485,8 +543,8 @@ public:
|
||||
void bind(const endpoint_type& endpoint)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.bind(this->implementation, endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().bind(this->get_implementation(), endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec, "bind");
|
||||
}
|
||||
|
||||
/// Bind the socket to the given local endpoint.
|
||||
@@ -515,7 +573,7 @@ public:
|
||||
boost::system::error_code bind(const endpoint_type& endpoint,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.bind(this->implementation, endpoint, ec);
|
||||
return this->get_service().bind(this->get_implementation(), endpoint, ec);
|
||||
}
|
||||
|
||||
/// Connect the socket to the specified endpoint.
|
||||
@@ -546,11 +604,12 @@ public:
|
||||
boost::system::error_code ec;
|
||||
if (!is_open())
|
||||
{
|
||||
this->service.open(this->implementation, peer_endpoint.protocol(), ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(),
|
||||
peer_endpoint.protocol(), ec);
|
||||
boost::asio::detail::throw_error(ec, "connect");
|
||||
}
|
||||
this->service.connect(this->implementation, peer_endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().connect(this->get_implementation(), peer_endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec, "connect");
|
||||
}
|
||||
|
||||
/// Connect the socket to the specified endpoint.
|
||||
@@ -586,14 +645,15 @@ public:
|
||||
{
|
||||
if (!is_open())
|
||||
{
|
||||
if (this->service.open(this->implementation,
|
||||
if (this->get_service().open(this->get_implementation(),
|
||||
peer_endpoint.protocol(), ec))
|
||||
{
|
||||
return ec;
|
||||
}
|
||||
}
|
||||
|
||||
return this->service.connect(this->implementation, peer_endpoint, ec);
|
||||
return this->get_service().connect(
|
||||
this->get_implementation(), peer_endpoint, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous connect.
|
||||
@@ -638,21 +698,28 @@ public:
|
||||
* @endcode
|
||||
*/
|
||||
template <typename ConnectHandler>
|
||||
void async_connect(const endpoint_type& peer_endpoint, ConnectHandler handler)
|
||||
void async_connect(const endpoint_type& peer_endpoint,
|
||||
BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ConnectHandler.
|
||||
BOOST_ASIO_CONNECT_HANDLER_CHECK(ConnectHandler, handler) type_check;
|
||||
|
||||
if (!is_open())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
if (this->service.open(this->implementation,
|
||||
peer_endpoint.protocol(), ec))
|
||||
const protocol_type protocol = peer_endpoint.protocol();
|
||||
if (this->get_service().open(this->get_implementation(), protocol, ec))
|
||||
{
|
||||
this->get_io_service().post(
|
||||
boost::asio::detail::bind_handler(handler, ec));
|
||||
boost::asio::detail::bind_handler(
|
||||
BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler), ec));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this->service.async_connect(this->implementation, peer_endpoint, handler);
|
||||
this->get_service().async_connect(this->get_implementation(),
|
||||
peer_endpoint, BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
|
||||
}
|
||||
|
||||
/// Set an option on the socket.
|
||||
@@ -693,8 +760,8 @@ public:
|
||||
void set_option(const SettableSocketOption& option)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.set_option(this->implementation, option, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().set_option(this->get_implementation(), option, ec);
|
||||
boost::asio::detail::throw_error(ec, "set_option");
|
||||
}
|
||||
|
||||
/// Set an option on the socket.
|
||||
@@ -740,7 +807,8 @@ public:
|
||||
boost::system::error_code set_option(const SettableSocketOption& option,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.set_option(this->implementation, option, ec);
|
||||
return this->get_service().set_option(
|
||||
this->get_implementation(), option, ec);
|
||||
}
|
||||
|
||||
/// Get an option from the socket.
|
||||
@@ -782,8 +850,8 @@ public:
|
||||
void get_option(GettableSocketOption& option) const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.get_option(this->implementation, option, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().get_option(this->get_implementation(), option, ec);
|
||||
boost::asio::detail::throw_error(ec, "get_option");
|
||||
}
|
||||
|
||||
/// Get an option from the socket.
|
||||
@@ -830,7 +898,8 @@ public:
|
||||
boost::system::error_code get_option(GettableSocketOption& option,
|
||||
boost::system::error_code& ec) const
|
||||
{
|
||||
return this->service.get_option(this->implementation, option, ec);
|
||||
return this->get_service().get_option(
|
||||
this->get_implementation(), option, ec);
|
||||
}
|
||||
|
||||
/// Perform an IO control command on the socket.
|
||||
@@ -859,8 +928,8 @@ public:
|
||||
void io_control(IoControlCommand& command)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.io_control(this->implementation, command, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().io_control(this->get_implementation(), command, ec);
|
||||
boost::asio::detail::throw_error(ec, "io_control");
|
||||
}
|
||||
|
||||
/// Perform an IO control command on the socket.
|
||||
@@ -894,7 +963,338 @@ public:
|
||||
boost::system::error_code io_control(IoControlCommand& command,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.io_control(this->implementation, command, ec);
|
||||
return this->get_service().io_control(
|
||||
this->get_implementation(), command, ec);
|
||||
}
|
||||
|
||||
/// Gets the non-blocking mode of the socket.
|
||||
/**
|
||||
* @returns @c true if the socket's synchronous operations will fail with
|
||||
* boost::asio::error::would_block if they are unable to perform the requested
|
||||
* operation immediately. If @c false, synchronous operations will block
|
||||
* until complete.
|
||||
*
|
||||
* @note The non-blocking mode has no effect on the behaviour of asynchronous
|
||||
* operations. Asynchronous operations will never fail with the error
|
||||
* boost::asio::error::would_block.
|
||||
*/
|
||||
bool non_blocking() const
|
||||
{
|
||||
return this->get_service().non_blocking(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the socket.
|
||||
/**
|
||||
* @param mode If @c true, the socket's synchronous operations will fail with
|
||||
* boost::asio::error::would_block if they are unable to perform the requested
|
||||
* operation immediately. If @c false, synchronous operations will block
|
||||
* until complete.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note The non-blocking mode has no effect on the behaviour of asynchronous
|
||||
* operations. Asynchronous operations will never fail with the error
|
||||
* boost::asio::error::would_block.
|
||||
*/
|
||||
void non_blocking(bool mode)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().non_blocking(this->get_implementation(), mode, ec);
|
||||
boost::asio::detail::throw_error(ec, "non_blocking");
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the socket.
|
||||
/**
|
||||
* @param mode If @c true, the socket's synchronous operations will fail with
|
||||
* boost::asio::error::would_block if they are unable to perform the requested
|
||||
* operation immediately. If @c false, synchronous operations will block
|
||||
* until complete.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note The non-blocking mode has no effect on the behaviour of asynchronous
|
||||
* operations. Asynchronous operations will never fail with the error
|
||||
* boost::asio::error::would_block.
|
||||
*/
|
||||
boost::system::error_code non_blocking(
|
||||
bool mode, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().non_blocking(
|
||||
this->get_implementation(), mode, ec);
|
||||
}
|
||||
|
||||
/// Gets the non-blocking mode of the native socket implementation.
|
||||
/**
|
||||
* This function is used to retrieve the non-blocking mode of the underlying
|
||||
* native socket. This mode has no effect on the behaviour of the socket
|
||||
* object's synchronous operations.
|
||||
*
|
||||
* @returns @c true if the underlying socket is in non-blocking mode and
|
||||
* direct system calls may fail with boost::asio::error::would_block (or the
|
||||
* equivalent system error).
|
||||
*
|
||||
* @note The current non-blocking mode is cached by the socket object.
|
||||
* Consequently, the return value may be incorrect if the non-blocking mode
|
||||
* was set directly on the native socket.
|
||||
*
|
||||
* @par Example
|
||||
* This function is intended to allow the encapsulation of arbitrary
|
||||
* non-blocking system calls as asynchronous operations, in a way that is
|
||||
* transparent to the user of the socket object. The following example
|
||||
* illustrates how Linux's @c sendfile system call might be encapsulated:
|
||||
* @code template <typename Handler>
|
||||
* struct sendfile_op
|
||||
* {
|
||||
* tcp::socket& sock_;
|
||||
* int fd_;
|
||||
* Handler handler_;
|
||||
* off_t offset_;
|
||||
* std::size_t total_bytes_transferred_;
|
||||
*
|
||||
* // Function call operator meeting WriteHandler requirements.
|
||||
* // Used as the handler for the async_write_some operation.
|
||||
* void operator()(boost::system::error_code ec, std::size_t)
|
||||
* {
|
||||
* // Put the underlying socket into non-blocking mode.
|
||||
* if (!ec)
|
||||
* if (!sock_.native_non_blocking())
|
||||
* sock_.native_non_blocking(true, ec);
|
||||
*
|
||||
* if (!ec)
|
||||
* {
|
||||
* for (;;)
|
||||
* {
|
||||
* // Try the system call.
|
||||
* errno = 0;
|
||||
* int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
|
||||
* ec = boost::system::error_code(n < 0 ? errno : 0,
|
||||
* boost::asio::error::get_system_category());
|
||||
* total_bytes_transferred_ += ec ? 0 : n;
|
||||
*
|
||||
* // Retry operation immediately if interrupted by signal.
|
||||
* if (ec == boost::asio::error::interrupted)
|
||||
* continue;
|
||||
*
|
||||
* // Check if we need to run the operation again.
|
||||
* if (ec == boost::asio::error::would_block
|
||||
* || ec == boost::asio::error::try_again)
|
||||
* {
|
||||
* // We have to wait for the socket to become ready again.
|
||||
* sock_.async_write_some(boost::asio::null_buffers(), *this);
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* if (ec || n == 0)
|
||||
* {
|
||||
* // An error occurred, or we have reached the end of the file.
|
||||
* // Either way we must exit the loop so we can call the handler.
|
||||
* break;
|
||||
* }
|
||||
*
|
||||
* // Loop around to try calling sendfile again.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Pass result back to user's handler.
|
||||
* handler_(ec, total_bytes_transferred_);
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* template <typename Handler>
|
||||
* void async_sendfile(tcp::socket& sock, int fd, Handler h)
|
||||
* {
|
||||
* sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
|
||||
* sock.async_write_some(boost::asio::null_buffers(), op);
|
||||
* } @endcode
|
||||
*/
|
||||
bool native_non_blocking() const
|
||||
{
|
||||
return this->get_service().native_non_blocking(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the native socket implementation.
|
||||
/**
|
||||
* This function is used to modify the non-blocking mode of the underlying
|
||||
* native socket. It has no effect on the behaviour of the socket object's
|
||||
* synchronous operations.
|
||||
*
|
||||
* @param mode If @c true, the underlying socket is put into non-blocking
|
||||
* mode and direct system calls may fail with boost::asio::error::would_block
|
||||
* (or the equivalent system error).
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. If the @c mode is
|
||||
* @c false, but the current value of @c non_blocking() is @c true, this
|
||||
* function fails with boost::asio::error::invalid_argument, as the
|
||||
* combination does not make sense.
|
||||
*
|
||||
* @par Example
|
||||
* This function is intended to allow the encapsulation of arbitrary
|
||||
* non-blocking system calls as asynchronous operations, in a way that is
|
||||
* transparent to the user of the socket object. The following example
|
||||
* illustrates how Linux's @c sendfile system call might be encapsulated:
|
||||
* @code template <typename Handler>
|
||||
* struct sendfile_op
|
||||
* {
|
||||
* tcp::socket& sock_;
|
||||
* int fd_;
|
||||
* Handler handler_;
|
||||
* off_t offset_;
|
||||
* std::size_t total_bytes_transferred_;
|
||||
*
|
||||
* // Function call operator meeting WriteHandler requirements.
|
||||
* // Used as the handler for the async_write_some operation.
|
||||
* void operator()(boost::system::error_code ec, std::size_t)
|
||||
* {
|
||||
* // Put the underlying socket into non-blocking mode.
|
||||
* if (!ec)
|
||||
* if (!sock_.native_non_blocking())
|
||||
* sock_.native_non_blocking(true, ec);
|
||||
*
|
||||
* if (!ec)
|
||||
* {
|
||||
* for (;;)
|
||||
* {
|
||||
* // Try the system call.
|
||||
* errno = 0;
|
||||
* int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
|
||||
* ec = boost::system::error_code(n < 0 ? errno : 0,
|
||||
* boost::asio::error::get_system_category());
|
||||
* total_bytes_transferred_ += ec ? 0 : n;
|
||||
*
|
||||
* // Retry operation immediately if interrupted by signal.
|
||||
* if (ec == boost::asio::error::interrupted)
|
||||
* continue;
|
||||
*
|
||||
* // Check if we need to run the operation again.
|
||||
* if (ec == boost::asio::error::would_block
|
||||
* || ec == boost::asio::error::try_again)
|
||||
* {
|
||||
* // We have to wait for the socket to become ready again.
|
||||
* sock_.async_write_some(boost::asio::null_buffers(), *this);
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* if (ec || n == 0)
|
||||
* {
|
||||
* // An error occurred, or we have reached the end of the file.
|
||||
* // Either way we must exit the loop so we can call the handler.
|
||||
* break;
|
||||
* }
|
||||
*
|
||||
* // Loop around to try calling sendfile again.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Pass result back to user's handler.
|
||||
* handler_(ec, total_bytes_transferred_);
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* template <typename Handler>
|
||||
* void async_sendfile(tcp::socket& sock, int fd, Handler h)
|
||||
* {
|
||||
* sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
|
||||
* sock.async_write_some(boost::asio::null_buffers(), op);
|
||||
* } @endcode
|
||||
*/
|
||||
void native_non_blocking(bool mode)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().native_non_blocking(
|
||||
this->get_implementation(), mode, ec);
|
||||
boost::asio::detail::throw_error(ec, "native_non_blocking");
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the native socket implementation.
|
||||
/**
|
||||
* This function is used to modify the non-blocking mode of the underlying
|
||||
* native socket. It has no effect on the behaviour of the socket object's
|
||||
* synchronous operations.
|
||||
*
|
||||
* @param mode If @c true, the underlying socket is put into non-blocking
|
||||
* mode and direct system calls may fail with boost::asio::error::would_block
|
||||
* (or the equivalent system error).
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any. If the @c mode is
|
||||
* @c false, but the current value of @c non_blocking() is @c true, this
|
||||
* function fails with boost::asio::error::invalid_argument, as the
|
||||
* combination does not make sense.
|
||||
*
|
||||
* @par Example
|
||||
* This function is intended to allow the encapsulation of arbitrary
|
||||
* non-blocking system calls as asynchronous operations, in a way that is
|
||||
* transparent to the user of the socket object. The following example
|
||||
* illustrates how Linux's @c sendfile system call might be encapsulated:
|
||||
* @code template <typename Handler>
|
||||
* struct sendfile_op
|
||||
* {
|
||||
* tcp::socket& sock_;
|
||||
* int fd_;
|
||||
* Handler handler_;
|
||||
* off_t offset_;
|
||||
* std::size_t total_bytes_transferred_;
|
||||
*
|
||||
* // Function call operator meeting WriteHandler requirements.
|
||||
* // Used as the handler for the async_write_some operation.
|
||||
* void operator()(boost::system::error_code ec, std::size_t)
|
||||
* {
|
||||
* // Put the underlying socket into non-blocking mode.
|
||||
* if (!ec)
|
||||
* if (!sock_.native_non_blocking())
|
||||
* sock_.native_non_blocking(true, ec);
|
||||
*
|
||||
* if (!ec)
|
||||
* {
|
||||
* for (;;)
|
||||
* {
|
||||
* // Try the system call.
|
||||
* errno = 0;
|
||||
* int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
|
||||
* ec = boost::system::error_code(n < 0 ? errno : 0,
|
||||
* boost::asio::error::get_system_category());
|
||||
* total_bytes_transferred_ += ec ? 0 : n;
|
||||
*
|
||||
* // Retry operation immediately if interrupted by signal.
|
||||
* if (ec == boost::asio::error::interrupted)
|
||||
* continue;
|
||||
*
|
||||
* // Check if we need to run the operation again.
|
||||
* if (ec == boost::asio::error::would_block
|
||||
* || ec == boost::asio::error::try_again)
|
||||
* {
|
||||
* // We have to wait for the socket to become ready again.
|
||||
* sock_.async_write_some(boost::asio::null_buffers(), *this);
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* if (ec || n == 0)
|
||||
* {
|
||||
* // An error occurred, or we have reached the end of the file.
|
||||
* // Either way we must exit the loop so we can call the handler.
|
||||
* break;
|
||||
* }
|
||||
*
|
||||
* // Loop around to try calling sendfile again.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Pass result back to user's handler.
|
||||
* handler_(ec, total_bytes_transferred_);
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* template <typename Handler>
|
||||
* void async_sendfile(tcp::socket& sock, int fd, Handler h)
|
||||
* {
|
||||
* sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
|
||||
* sock.async_write_some(boost::asio::null_buffers(), op);
|
||||
* } @endcode
|
||||
*/
|
||||
boost::system::error_code native_non_blocking(
|
||||
bool mode, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().native_non_blocking(
|
||||
this->get_implementation(), mode, ec);
|
||||
}
|
||||
|
||||
/// Get the local endpoint of the socket.
|
||||
@@ -915,8 +1315,9 @@ public:
|
||||
endpoint_type local_endpoint() const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
endpoint_type ep = this->service.local_endpoint(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
endpoint_type ep = this->get_service().local_endpoint(
|
||||
this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "local_endpoint");
|
||||
return ep;
|
||||
}
|
||||
|
||||
@@ -943,7 +1344,7 @@ public:
|
||||
*/
|
||||
endpoint_type local_endpoint(boost::system::error_code& ec) const
|
||||
{
|
||||
return this->service.local_endpoint(this->implementation, ec);
|
||||
return this->get_service().local_endpoint(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Get the remote endpoint of the socket.
|
||||
@@ -964,8 +1365,9 @@ public:
|
||||
endpoint_type remote_endpoint() const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
endpoint_type ep = this->service.remote_endpoint(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
endpoint_type ep = this->get_service().remote_endpoint(
|
||||
this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "remote_endpoint");
|
||||
return ep;
|
||||
}
|
||||
|
||||
@@ -992,7 +1394,7 @@ public:
|
||||
*/
|
||||
endpoint_type remote_endpoint(boost::system::error_code& ec) const
|
||||
{
|
||||
return this->service.remote_endpoint(this->implementation, ec);
|
||||
return this->get_service().remote_endpoint(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Disable sends or receives on the socket.
|
||||
@@ -1015,8 +1417,8 @@ public:
|
||||
void shutdown(shutdown_type what)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.shutdown(this->implementation, what, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().shutdown(this->get_implementation(), what, ec);
|
||||
boost::asio::detail::throw_error(ec, "shutdown");
|
||||
}
|
||||
|
||||
/// Disable sends or receives on the socket.
|
||||
@@ -1044,7 +1446,7 @@ public:
|
||||
boost::system::error_code shutdown(shutdown_type what,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.shutdown(this->implementation, what, ec);
|
||||
return this->get_service().shutdown(this->get_implementation(), what, ec);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_socket_acceptor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/socket_acceptor_service.hpp>
|
||||
@@ -55,8 +56,12 @@ class basic_socket_acceptor
|
||||
public socket_base
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of an
|
||||
/// acceptor.
|
||||
typedef typename SocketAcceptorService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of an acceptor.
|
||||
typedef typename SocketAcceptorService::native_type native_type;
|
||||
typedef typename SocketAcceptorService::native_handle_type native_handle_type;
|
||||
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
@@ -96,8 +101,8 @@ public:
|
||||
: basic_io_object<SocketAcceptorService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, protocol, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Construct an acceptor opened on the given endpoint.
|
||||
@@ -132,19 +137,20 @@ public:
|
||||
: basic_io_object<SocketAcceptorService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, endpoint.protocol(), ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
const protocol_type protocol = endpoint.protocol();
|
||||
this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
if (reuse_addr)
|
||||
{
|
||||
this->service.set_option(this->implementation,
|
||||
this->get_service().set_option(this->get_implementation(),
|
||||
socket_base::reuse_address(true), ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "set_option");
|
||||
}
|
||||
this->service.bind(this->implementation, endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->service.listen(this->implementation,
|
||||
this->get_service().bind(this->get_implementation(), endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec, "bind");
|
||||
this->get_service().listen(this->get_implementation(),
|
||||
socket_base::max_connections, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
boost::asio::detail::throw_error(ec, "listen");
|
||||
}
|
||||
|
||||
/// Construct a basic_socket_acceptor on an existing native acceptor.
|
||||
@@ -163,14 +169,50 @@ public:
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_socket_acceptor(boost::asio::io_service& io_service,
|
||||
const protocol_type& protocol, const native_type& native_acceptor)
|
||||
const protocol_type& protocol, const native_handle_type& native_acceptor)
|
||||
: basic_io_object<SocketAcceptorService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.assign(this->implementation, protocol, native_acceptor, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().assign(this->get_implementation(),
|
||||
protocol, native_acceptor, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_socket_acceptor from another.
|
||||
/**
|
||||
* This constructor moves an acceptor from one object to another.
|
||||
*
|
||||
* @param other The other basic_socket_acceptor object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_socket_acceptor(io_service&) constructor.
|
||||
*/
|
||||
basic_socket_acceptor(basic_socket_acceptor&& other)
|
||||
: basic_io_object<SocketAcceptorService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_socket_acceptor from another.
|
||||
/**
|
||||
* This assignment operator moves an acceptor from one object to another.
|
||||
*
|
||||
* @param other The other basic_socket_acceptor object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_socket_acceptor(io_service&) constructor.
|
||||
*/
|
||||
basic_socket_acceptor& operator=(basic_socket_acceptor&& other)
|
||||
{
|
||||
basic_io_object<SocketAcceptorService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Open the acceptor using the specified protocol.
|
||||
/**
|
||||
* This function opens the socket acceptor so that it will use the specified
|
||||
@@ -189,8 +231,8 @@ public:
|
||||
void open(const protocol_type& protocol = protocol_type())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.open(this->implementation, protocol, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
boost::asio::detail::throw_error(ec, "open");
|
||||
}
|
||||
|
||||
/// Open the acceptor using the specified protocol.
|
||||
@@ -216,7 +258,7 @@ public:
|
||||
boost::system::error_code open(const protocol_type& protocol,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.open(this->implementation, protocol, ec);
|
||||
return this->get_service().open(this->get_implementation(), protocol, ec);
|
||||
}
|
||||
|
||||
/// Assigns an existing native acceptor to the acceptor.
|
||||
@@ -229,11 +271,13 @@ public:
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void assign(const protocol_type& protocol, const native_type& native_acceptor)
|
||||
void assign(const protocol_type& protocol,
|
||||
const native_handle_type& native_acceptor)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.assign(this->implementation, protocol, native_acceptor, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().assign(this->get_implementation(),
|
||||
protocol, native_acceptor, ec);
|
||||
boost::asio::detail::throw_error(ec, "assign");
|
||||
}
|
||||
|
||||
/// Assigns an existing native acceptor to the acceptor.
|
||||
@@ -247,16 +291,16 @@ public:
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
boost::system::error_code assign(const protocol_type& protocol,
|
||||
const native_type& native_acceptor, boost::system::error_code& ec)
|
||||
const native_handle_type& native_acceptor, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.assign(this->implementation,
|
||||
return this->get_service().assign(this->get_implementation(),
|
||||
protocol, native_acceptor, ec);
|
||||
}
|
||||
|
||||
/// Determine whether the acceptor is open.
|
||||
bool is_open() const
|
||||
{
|
||||
return this->service.is_open(this->implementation);
|
||||
return this->get_service().is_open(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Bind the acceptor to the given local endpoint.
|
||||
@@ -279,8 +323,8 @@ public:
|
||||
void bind(const endpoint_type& endpoint)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.bind(this->implementation, endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().bind(this->get_implementation(), endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec, "bind");
|
||||
}
|
||||
|
||||
/// Bind the acceptor to the given local endpoint.
|
||||
@@ -308,7 +352,7 @@ public:
|
||||
boost::system::error_code bind(const endpoint_type& endpoint,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.bind(this->implementation, endpoint, ec);
|
||||
return this->get_service().bind(this->get_implementation(), endpoint, ec);
|
||||
}
|
||||
|
||||
/// Place the acceptor into the state where it will listen for new
|
||||
@@ -324,8 +368,8 @@ public:
|
||||
void listen(int backlog = socket_base::max_connections)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.listen(this->implementation, backlog, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().listen(this->get_implementation(), backlog, ec);
|
||||
boost::asio::detail::throw_error(ec, "listen");
|
||||
}
|
||||
|
||||
/// Place the acceptor into the state where it will listen for new
|
||||
@@ -352,7 +396,7 @@ public:
|
||||
*/
|
||||
boost::system::error_code listen(int backlog, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.listen(this->implementation, backlog, ec);
|
||||
return this->get_service().listen(this->get_implementation(), backlog, ec);
|
||||
}
|
||||
|
||||
/// Close the acceptor.
|
||||
@@ -368,8 +412,8 @@ public:
|
||||
void close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.close(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().close(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "close");
|
||||
}
|
||||
|
||||
/// Close the acceptor.
|
||||
@@ -396,7 +440,18 @@ public:
|
||||
*/
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.close(this->implementation, ec);
|
||||
return this->get_service().close(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// (Deprecated: Use native_handle().) Get the native acceptor representation.
|
||||
/**
|
||||
* This function may be used to obtain the underlying representation of the
|
||||
* acceptor. This is intended to allow access to native acceptor functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_type native()
|
||||
{
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Get the native acceptor representation.
|
||||
@@ -405,9 +460,9 @@ public:
|
||||
* acceptor. This is intended to allow access to native acceptor functionality
|
||||
* that is not otherwise provided.
|
||||
*/
|
||||
native_type native()
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
return this->service.native(this->implementation);
|
||||
return this->get_service().native_handle(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the acceptor.
|
||||
@@ -421,8 +476,8 @@ public:
|
||||
void cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().cancel(this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the acceptor.
|
||||
@@ -435,7 +490,7 @@ public:
|
||||
*/
|
||||
boost::system::error_code cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
return this->get_service().cancel(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Set an option on the acceptor.
|
||||
@@ -463,8 +518,8 @@ public:
|
||||
void set_option(const SettableSocketOption& option)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.set_option(this->implementation, option, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().set_option(this->get_implementation(), option, ec);
|
||||
boost::asio::detail::throw_error(ec, "set_option");
|
||||
}
|
||||
|
||||
/// Set an option on the acceptor.
|
||||
@@ -497,7 +552,8 @@ public:
|
||||
boost::system::error_code set_option(const SettableSocketOption& option,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.set_option(this->implementation, option, ec);
|
||||
return this->get_service().set_option(
|
||||
this->get_implementation(), option, ec);
|
||||
}
|
||||
|
||||
/// Get an option from the acceptor.
|
||||
@@ -526,8 +582,8 @@ public:
|
||||
void get_option(GettableSocketOption& option)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.get_option(this->implementation, option, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().get_option(this->get_implementation(), option, ec);
|
||||
boost::asio::detail::throw_error(ec, "get_option");
|
||||
}
|
||||
|
||||
/// Get an option from the acceptor.
|
||||
@@ -561,7 +617,189 @@ public:
|
||||
boost::system::error_code get_option(GettableSocketOption& option,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.get_option(this->implementation, option, ec);
|
||||
return this->get_service().get_option(
|
||||
this->get_implementation(), option, ec);
|
||||
}
|
||||
|
||||
/// Perform an IO control command on the acceptor.
|
||||
/**
|
||||
* This function is used to execute an IO control command on the acceptor.
|
||||
*
|
||||
* @param command The IO control command to be performed on the acceptor.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @sa IoControlCommand @n
|
||||
* boost::asio::socket_base::non_blocking_io
|
||||
*
|
||||
* @par Example
|
||||
* Getting the number of bytes ready to read:
|
||||
* @code
|
||||
* boost::asio::ip::tcp::acceptor acceptor(io_service);
|
||||
* ...
|
||||
* boost::asio::ip::tcp::acceptor::non_blocking_io command(true);
|
||||
* socket.io_control(command);
|
||||
* @endcode
|
||||
*/
|
||||
template <typename IoControlCommand>
|
||||
void io_control(IoControlCommand& command)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().io_control(this->get_implementation(), command, ec);
|
||||
boost::asio::detail::throw_error(ec, "io_control");
|
||||
}
|
||||
|
||||
/// Perform an IO control command on the acceptor.
|
||||
/**
|
||||
* This function is used to execute an IO control command on the acceptor.
|
||||
*
|
||||
* @param command The IO control command to be performed on the acceptor.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @sa IoControlCommand @n
|
||||
* boost::asio::socket_base::non_blocking_io
|
||||
*
|
||||
* @par Example
|
||||
* Getting the number of bytes ready to read:
|
||||
* @code
|
||||
* boost::asio::ip::tcp::acceptor acceptor(io_service);
|
||||
* ...
|
||||
* boost::asio::ip::tcp::acceptor::non_blocking_io command(true);
|
||||
* boost::system::error_code ec;
|
||||
* socket.io_control(command, ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
template <typename IoControlCommand>
|
||||
boost::system::error_code io_control(IoControlCommand& command,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().io_control(
|
||||
this->get_implementation(), command, ec);
|
||||
}
|
||||
|
||||
/// Gets the non-blocking mode of the acceptor.
|
||||
/**
|
||||
* @returns @c true if the acceptor's synchronous operations will fail with
|
||||
* boost::asio::error::would_block if they are unable to perform the requested
|
||||
* operation immediately. If @c false, synchronous operations will block
|
||||
* until complete.
|
||||
*
|
||||
* @note The non-blocking mode has no effect on the behaviour of asynchronous
|
||||
* operations. Asynchronous operations will never fail with the error
|
||||
* boost::asio::error::would_block.
|
||||
*/
|
||||
bool non_blocking() const
|
||||
{
|
||||
return this->get_service().non_blocking(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the acceptor.
|
||||
/**
|
||||
* @param mode If @c true, the acceptor's synchronous operations will fail
|
||||
* with boost::asio::error::would_block if they are unable to perform the
|
||||
* requested operation immediately. If @c false, synchronous operations will
|
||||
* block until complete.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note The non-blocking mode has no effect on the behaviour of asynchronous
|
||||
* operations. Asynchronous operations will never fail with the error
|
||||
* boost::asio::error::would_block.
|
||||
*/
|
||||
void non_blocking(bool mode)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().non_blocking(this->get_implementation(), mode, ec);
|
||||
boost::asio::detail::throw_error(ec, "non_blocking");
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the acceptor.
|
||||
/**
|
||||
* @param mode If @c true, the acceptor's synchronous operations will fail
|
||||
* with boost::asio::error::would_block if they are unable to perform the
|
||||
* requested operation immediately. If @c false, synchronous operations will
|
||||
* block until complete.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @note The non-blocking mode has no effect on the behaviour of asynchronous
|
||||
* operations. Asynchronous operations will never fail with the error
|
||||
* boost::asio::error::would_block.
|
||||
*/
|
||||
boost::system::error_code non_blocking(
|
||||
bool mode, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().non_blocking(
|
||||
this->get_implementation(), mode, ec);
|
||||
}
|
||||
|
||||
/// Gets the non-blocking mode of the native acceptor implementation.
|
||||
/**
|
||||
* This function is used to retrieve the non-blocking mode of the underlying
|
||||
* native acceptor. This mode has no effect on the behaviour of the acceptor
|
||||
* object's synchronous operations.
|
||||
*
|
||||
* @returns @c true if the underlying acceptor is in non-blocking mode and
|
||||
* direct system calls may fail with boost::asio::error::would_block (or the
|
||||
* equivalent system error).
|
||||
*
|
||||
* @note The current non-blocking mode is cached by the acceptor object.
|
||||
* Consequently, the return value may be incorrect if the non-blocking mode
|
||||
* was set directly on the native acceptor.
|
||||
*/
|
||||
bool native_non_blocking() const
|
||||
{
|
||||
return this->get_service().native_non_blocking(this->get_implementation());
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the native acceptor implementation.
|
||||
/**
|
||||
* This function is used to modify the non-blocking mode of the underlying
|
||||
* native acceptor. It has no effect on the behaviour of the acceptor object's
|
||||
* synchronous operations.
|
||||
*
|
||||
* @param mode If @c true, the underlying acceptor is put into non-blocking
|
||||
* mode and direct system calls may fail with boost::asio::error::would_block
|
||||
* (or the equivalent system error).
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. If the @c mode is
|
||||
* @c false, but the current value of @c non_blocking() is @c true, this
|
||||
* function fails with boost::asio::error::invalid_argument, as the
|
||||
* combination does not make sense.
|
||||
*/
|
||||
void native_non_blocking(bool mode)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->get_service().native_non_blocking(
|
||||
this->get_implementation(), mode, ec);
|
||||
boost::asio::detail::throw_error(ec, "native_non_blocking");
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the native acceptor implementation.
|
||||
/**
|
||||
* This function is used to modify the non-blocking mode of the underlying
|
||||
* native acceptor. It has no effect on the behaviour of the acceptor object's
|
||||
* synchronous operations.
|
||||
*
|
||||
* @param mode If @c true, the underlying acceptor is put into non-blocking
|
||||
* mode and direct system calls may fail with boost::asio::error::would_block
|
||||
* (or the equivalent system error).
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any. If the @c mode is
|
||||
* @c false, but the current value of @c non_blocking() is @c true, this
|
||||
* function fails with boost::asio::error::invalid_argument, as the
|
||||
* combination does not make sense.
|
||||
*/
|
||||
boost::system::error_code native_non_blocking(
|
||||
bool mode, boost::system::error_code& ec)
|
||||
{
|
||||
return this->get_service().native_non_blocking(
|
||||
this->get_implementation(), mode, ec);
|
||||
}
|
||||
|
||||
/// Get the local endpoint of the acceptor.
|
||||
@@ -582,8 +820,9 @@ public:
|
||||
endpoint_type local_endpoint() const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
endpoint_type ep = this->service.local_endpoint(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
endpoint_type ep = this->get_service().local_endpoint(
|
||||
this->get_implementation(), ec);
|
||||
boost::asio::detail::throw_error(ec, "local_endpoint");
|
||||
return ep;
|
||||
}
|
||||
|
||||
@@ -611,7 +850,7 @@ public:
|
||||
*/
|
||||
endpoint_type local_endpoint(boost::system::error_code& ec) const
|
||||
{
|
||||
return this->service.local_endpoint(this->implementation, ec);
|
||||
return this->get_service().local_endpoint(this->get_implementation(), ec);
|
||||
}
|
||||
|
||||
/// Accept a new connection.
|
||||
@@ -636,8 +875,8 @@ public:
|
||||
void accept(basic_socket<protocol_type, SocketService>& peer)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.accept(this->implementation, peer, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().accept(this->get_implementation(), peer, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "accept");
|
||||
}
|
||||
|
||||
/// Accept a new connection.
|
||||
@@ -668,7 +907,7 @@ public:
|
||||
basic_socket<protocol_type, SocketService>& peer,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.accept(this->implementation, peer, 0, ec);
|
||||
return this->get_service().accept(this->get_implementation(), peer, 0, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous accept.
|
||||
@@ -711,9 +950,14 @@ public:
|
||||
*/
|
||||
template <typename SocketService, typename AcceptHandler>
|
||||
void async_accept(basic_socket<protocol_type, SocketService>& peer,
|
||||
AcceptHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
|
||||
{
|
||||
this->service.async_accept(this->implementation, peer, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a AcceptHandler.
|
||||
BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_accept(this->get_implementation(),
|
||||
peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
|
||||
}
|
||||
|
||||
/// Accept a new connection and obtain the endpoint of the peer
|
||||
@@ -744,8 +988,9 @@ public:
|
||||
endpoint_type& peer_endpoint)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.accept(this->implementation, peer, &peer_endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
this->get_service().accept(this->get_implementation(),
|
||||
peer, &peer_endpoint, ec);
|
||||
boost::asio::detail::throw_error(ec, "accept");
|
||||
}
|
||||
|
||||
/// Accept a new connection and obtain the endpoint of the peer
|
||||
@@ -781,7 +1026,8 @@ public:
|
||||
basic_socket<protocol_type, SocketService>& peer,
|
||||
endpoint_type& peer_endpoint, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.accept(this->implementation, peer, &peer_endpoint, ec);
|
||||
return this->get_service().accept(
|
||||
this->get_implementation(), peer, &peer_endpoint, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous accept.
|
||||
@@ -812,10 +1058,14 @@ public:
|
||||
*/
|
||||
template <typename SocketService, typename AcceptHandler>
|
||||
void async_accept(basic_socket<protocol_type, SocketService>& peer,
|
||||
endpoint_type& peer_endpoint, AcceptHandler handler)
|
||||
endpoint_type& peer_endpoint, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
|
||||
{
|
||||
this->service.async_accept(this->implementation,
|
||||
peer, &peer_endpoint, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a AcceptHandler.
|
||||
BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_accept(this->get_implementation(), peer,
|
||||
&peer_endpoint, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_socket_iostream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -19,34 +19,39 @@
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/asio/basic_socket_streambuf.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
#define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5
|
||||
#endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
# include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
|
||||
# if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
# define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5
|
||||
# endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// explicit basic_socket_iostream(T1 x1, ..., Tn xn)
|
||||
// : basic_iostream<char>(&this->boost::base_from_member<
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService> >::member)
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
// Time, TimeTraits, TimerService> >::member)
|
||||
// {
|
||||
// if (rdbuf()->connect(x1, ..., xn) == 0)
|
||||
// this->setstate(std::ios_base::failbit);
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \
|
||||
# define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
: std::basic_iostream<char>(&this->boost::base_from_member< \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member) \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService, \
|
||||
Time, TimeTraits, TimerService> >::member) \
|
||||
{ \
|
||||
tie(this); \
|
||||
if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \
|
||||
@@ -63,7 +68,7 @@
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \
|
||||
# define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
void connect(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
{ \
|
||||
@@ -72,6 +77,8 @@
|
||||
} \
|
||||
/**/
|
||||
|
||||
#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -79,17 +86,31 @@ namespace asio {
|
||||
|
||||
/// Iostream interface for a socket.
|
||||
template <typename Protocol,
|
||||
typename StreamSocketService = stream_socket_service<Protocol> >
|
||||
typename StreamSocketService = stream_socket_service<Protocol>,
|
||||
typename Time = boost::posix_time::ptime,
|
||||
typename TimeTraits = boost::asio::time_traits<Time>,
|
||||
typename TimerService = deadline_timer_service<Time, TimeTraits> >
|
||||
class basic_socket_iostream
|
||||
: public boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >,
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService> >,
|
||||
public std::basic_iostream<char>
|
||||
{
|
||||
public:
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// The time type.
|
||||
typedef typename TimeTraits::time_type time_type;
|
||||
|
||||
/// The duration type.
|
||||
typedef typename TimeTraits::duration_type duration_type;
|
||||
|
||||
/// Construct a basic_socket_iostream without establishing a connection.
|
||||
basic_socket_iostream()
|
||||
: std::basic_iostream<char>(&this->boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member)
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService> >::member)
|
||||
{
|
||||
tie(this);
|
||||
}
|
||||
@@ -103,6 +124,17 @@ public:
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
explicit basic_socket_iostream(T1 t1, ..., TN tn);
|
||||
#elif defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
template <typename... T>
|
||||
explicit basic_socket_iostream(T... x)
|
||||
: std::basic_iostream<char>(&this->boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService> >::member)
|
||||
{
|
||||
tie(this);
|
||||
if (rdbuf()->connect(x...) == 0)
|
||||
this->setstate(std::ios_base::failbit);
|
||||
}
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY),
|
||||
@@ -118,6 +150,13 @@ public:
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
void connect(T1 t1, ..., TN tn);
|
||||
#elif defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
template <typename... T>
|
||||
void connect(T... x)
|
||||
{
|
||||
if (rdbuf()->connect(x...) == 0)
|
||||
this->setstate(std::ios_base::failbit);
|
||||
}
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY),
|
||||
@@ -132,11 +171,77 @@ public:
|
||||
}
|
||||
|
||||
/// Return a pointer to the underlying streambuf.
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* rdbuf() const
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService>* rdbuf() const
|
||||
{
|
||||
return const_cast<basic_socket_streambuf<Protocol, StreamSocketService>*>(
|
||||
return const_cast<basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService>*>(
|
||||
&this->boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member);
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService> >::member);
|
||||
}
|
||||
|
||||
/// Get the last error associated with the stream.
|
||||
/**
|
||||
* @return An \c error_code corresponding to the last error from the stream.
|
||||
*
|
||||
* @par Example
|
||||
* To print the error associated with a failure to establish a connection:
|
||||
* @code tcp::iostream s("www.boost.org", "http");
|
||||
* if (!s)
|
||||
* {
|
||||
* std::cout << "Error: " << s.error().message() << std::endl;
|
||||
* } @endcode
|
||||
*/
|
||||
const boost::system::error_code& error() const
|
||||
{
|
||||
return rdbuf()->puberror();
|
||||
}
|
||||
|
||||
/// Get the stream's expiry time as an absolute time.
|
||||
/**
|
||||
* @return An absolute time value representing the stream's expiry time.
|
||||
*/
|
||||
time_type expires_at() const
|
||||
{
|
||||
return rdbuf()->expires_at();
|
||||
}
|
||||
|
||||
/// Set the stream's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the stream.
|
||||
*/
|
||||
void expires_at(const time_type& expiry_time)
|
||||
{
|
||||
rdbuf()->expires_at(expiry_time);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time relative to now.
|
||||
/**
|
||||
* @return A relative time value representing the stream's expiry time.
|
||||
*/
|
||||
duration_type expires_from_now() const
|
||||
{
|
||||
return rdbuf()->expires_from_now();
|
||||
}
|
||||
|
||||
/// Set the stream's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*/
|
||||
void expires_from_now(const duration_type& expiry_time)
|
||||
{
|
||||
rdbuf()->expires_from_now(expiry_time);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -145,8 +250,10 @@ public:
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#undef BOOST_ASIO_PRIVATE_CTR_DEF
|
||||
#undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
# undef BOOST_ASIO_PRIVATE_CTR_DEF
|
||||
# undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
#endif // defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_socket_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -20,53 +20,64 @@
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#include <streambuf>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/deadline_timer_service.hpp>
|
||||
#include <boost/asio/detail/array.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
#include <boost/asio/time_traits.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
#define BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY 5
|
||||
#endif // !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
# include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
|
||||
# if !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
# define BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY 5
|
||||
# endif // !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
// Time, TimeTraits, TimerService>* connect(
|
||||
// T1 x1, ..., Tn xn)
|
||||
// {
|
||||
// init_buffers();
|
||||
// boost::system::error_code ec;
|
||||
// this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
// this->basic_socket<Protocol, StreamSocketService>::close(ec_);
|
||||
// typedef typename Protocol::resolver resolver_type;
|
||||
// typedef typename resolver_type::query resolver_query;
|
||||
// resolver_query query(x1, ..., xn);
|
||||
// resolve_and_connect(query, ec);
|
||||
// return !ec ? this : 0;
|
||||
// resolve_and_connect(query);
|
||||
// return !ec_ ? this : 0;
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CONNECT_DEF( z, n, data ) \
|
||||
# define BOOST_ASIO_PRIVATE_CONNECT_DEF( z, n, data ) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect( \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService, \
|
||||
Time, TimeTraits, TimerService>* connect( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
{ \
|
||||
init_buffers(); \
|
||||
boost::system::error_code ec; \
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec); \
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec_); \
|
||||
typedef typename Protocol::resolver resolver_type; \
|
||||
typedef typename resolver_type::query resolver_query; \
|
||||
resolver_query query(BOOST_PP_ENUM_PARAMS(n, x)); \
|
||||
resolve_and_connect(query, ec); \
|
||||
return !ec ? this : 0; \
|
||||
resolve_and_connect(query); \
|
||||
return !ec_ ? this : 0; \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -74,7 +85,10 @@ namespace asio {
|
||||
|
||||
/// Iostream streambuf for a socket.
|
||||
template <typename Protocol,
|
||||
typename StreamSocketService = stream_socket_service<Protocol> >
|
||||
typename StreamSocketService = stream_socket_service<Protocol>,
|
||||
typename Time = boost::posix_time::ptime,
|
||||
typename TimeTraits = boost::asio::time_traits<Time>,
|
||||
typename TimerService = deadline_timer_service<Time, TimeTraits> >
|
||||
class basic_socket_streambuf
|
||||
: public std::streambuf,
|
||||
private boost::base_from_member<io_service>,
|
||||
@@ -84,11 +98,19 @@ public:
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// The time type.
|
||||
typedef typename TimeTraits::time_type time_type;
|
||||
|
||||
/// The duration type.
|
||||
typedef typename TimeTraits::duration_type duration_type;
|
||||
|
||||
/// Construct a basic_socket_streambuf without establishing a connection.
|
||||
basic_socket_streambuf()
|
||||
: basic_socket<Protocol, StreamSocketService>(
|
||||
boost::base_from_member<boost::asio::io_service>::member),
|
||||
unbuffered_(false)
|
||||
unbuffered_(false),
|
||||
timer_service_(0),
|
||||
timer_state_(no_timer)
|
||||
{
|
||||
init_buffers();
|
||||
}
|
||||
@@ -98,6 +120,8 @@ public:
|
||||
{
|
||||
if (pptr() != pbase())
|
||||
overflow(traits_type::eof());
|
||||
|
||||
destroy_timer();
|
||||
}
|
||||
|
||||
/// Establish a connection.
|
||||
@@ -107,14 +131,30 @@ public:
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService>* connect(
|
||||
const endpoint_type& endpoint)
|
||||
{
|
||||
init_buffers();
|
||||
boost::system::error_code ec;
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
this->basic_socket<Protocol, StreamSocketService>::connect(endpoint, ec);
|
||||
return !ec ? this : 0;
|
||||
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec_);
|
||||
|
||||
if (timer_state_ == timer_has_expired)
|
||||
{
|
||||
ec_ = boost::asio::error::operation_aborted;
|
||||
return 0;
|
||||
}
|
||||
|
||||
io_handler handler = { this };
|
||||
this->basic_socket<Protocol, StreamSocketService>::async_connect(
|
||||
endpoint, handler);
|
||||
|
||||
ec_ = boost::asio::error::would_block;
|
||||
this->get_service().get_io_service().reset();
|
||||
do this->get_service().get_io_service().run_one();
|
||||
while (ec_ == boost::asio::error::would_block);
|
||||
|
||||
return !ec_ ? this : 0;
|
||||
}
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
@@ -130,6 +170,19 @@ public:
|
||||
template <typename T1, ..., typename TN>
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
T1 t1, ..., TN tn);
|
||||
#elif defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
template <typename... T>
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService>* connect(T... x)
|
||||
{
|
||||
init_buffers();
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec_);
|
||||
typedef typename Protocol::resolver resolver_type;
|
||||
typedef typename resolver_type::query resolver_query;
|
||||
resolver_query query(x...);
|
||||
resolve_and_connect(query);
|
||||
return !ec_ ? this : 0;
|
||||
}
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY),
|
||||
@@ -141,14 +194,85 @@ public:
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* close()
|
||||
basic_socket_streambuf<Protocol, StreamSocketService,
|
||||
Time, TimeTraits, TimerService>* close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
sync();
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
if (!ec)
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec_);
|
||||
if (!ec_)
|
||||
init_buffers();
|
||||
return !ec ? this : 0;
|
||||
return !ec_ ? this : 0;
|
||||
}
|
||||
|
||||
/// Get the last error associated with the stream buffer.
|
||||
/**
|
||||
* @return An \c error_code corresponding to the last error from the stream
|
||||
* buffer.
|
||||
*/
|
||||
const boost::system::error_code& puberror() const
|
||||
{
|
||||
return error();
|
||||
}
|
||||
|
||||
/// Get the stream buffer's expiry time as an absolute time.
|
||||
/**
|
||||
* @return An absolute time value representing the stream buffer's expiry
|
||||
* time.
|
||||
*/
|
||||
time_type expires_at() const
|
||||
{
|
||||
return timer_service_
|
||||
? timer_service_->expires_at(timer_implementation_)
|
||||
: time_type();
|
||||
}
|
||||
|
||||
/// Set the stream buffer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the stream.
|
||||
*/
|
||||
void expires_at(const time_type& expiry_time)
|
||||
{
|
||||
construct_timer();
|
||||
|
||||
boost::system::error_code ec;
|
||||
timer_service_->expires_at(timer_implementation_, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_at");
|
||||
|
||||
start_timer();
|
||||
}
|
||||
|
||||
/// Get the stream buffer's expiry time relative to now.
|
||||
/**
|
||||
* @return A relative time value representing the stream buffer's expiry time.
|
||||
*/
|
||||
duration_type expires_from_now() const
|
||||
{
|
||||
return TimeTraits::subtract(expires_at(), TimeTraits::now());
|
||||
}
|
||||
|
||||
/// Set the stream buffer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time associated with the stream. Stream
|
||||
* operations performed after this time (where the operations cannot be
|
||||
* completed using the internal buffers) will fail with the error
|
||||
* boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*/
|
||||
void expires_from_now(const duration_type& expiry_time)
|
||||
{
|
||||
construct_timer();
|
||||
|
||||
boost::system::error_code ec;
|
||||
timer_service_->expires_from_now(timer_implementation_, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_from_now");
|
||||
|
||||
start_timer();
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -156,15 +280,26 @@ protected:
|
||||
{
|
||||
if (gptr() == egptr())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = this->service.receive(
|
||||
this->implementation,
|
||||
boost::asio::buffer(boost::asio::buffer(get_buffer_) + putback_max),
|
||||
0, ec);
|
||||
if (ec)
|
||||
if (timer_state_ == timer_has_expired)
|
||||
{
|
||||
ec_ = boost::asio::error::operation_aborted;
|
||||
return traits_type::eof();
|
||||
setg(get_buffer_.begin(), get_buffer_.begin() + putback_max,
|
||||
get_buffer_.begin() + putback_max + bytes_transferred);
|
||||
}
|
||||
|
||||
io_handler handler = { this };
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
boost::asio::buffer(boost::asio::buffer(get_buffer_) + putback_max),
|
||||
0, handler);
|
||||
|
||||
ec_ = boost::asio::error::would_block;
|
||||
this->get_service().get_io_service().reset();
|
||||
do this->get_service().get_io_service().run_one();
|
||||
while (ec_ == boost::asio::error::would_block);
|
||||
if (ec_)
|
||||
return traits_type::eof();
|
||||
|
||||
setg(&get_buffer_[0], &get_buffer_[0] + putback_max,
|
||||
&get_buffer_[0] + putback_max + bytes_transferred_);
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
else
|
||||
@@ -184,13 +319,25 @@ protected:
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send the single character immediately.
|
||||
boost::system::error_code ec;
|
||||
char_type ch = traits_type::to_char_type(c);
|
||||
this->service.send(this->implementation,
|
||||
boost::asio::buffer(&ch, sizeof(char_type)), 0, ec);
|
||||
if (ec)
|
||||
if (timer_state_ == timer_has_expired)
|
||||
{
|
||||
ec_ = boost::asio::error::operation_aborted;
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Send the single character immediately.
|
||||
char_type ch = traits_type::to_char_type(c);
|
||||
io_handler handler = { this };
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
boost::asio::buffer(&ch, sizeof(char_type)), 0, handler);
|
||||
|
||||
ec_ = boost::asio::error::would_block;
|
||||
this->get_service().get_io_service().reset();
|
||||
do this->get_service().get_io_service().run_one();
|
||||
while (ec_ == boost::asio::error::would_block);
|
||||
if (ec_)
|
||||
return traits_type::eof();
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
@@ -201,15 +348,26 @@ protected:
|
||||
boost::asio::buffer(pbase(), pptr() - pbase());
|
||||
while (boost::asio::buffer_size(buffer) > 0)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = this->service.send(
|
||||
this->implementation, boost::asio::buffer(buffer),
|
||||
0, ec);
|
||||
if (ec)
|
||||
if (timer_state_ == timer_has_expired)
|
||||
{
|
||||
ec_ = boost::asio::error::operation_aborted;
|
||||
return traits_type::eof();
|
||||
buffer = buffer + bytes_transferred;
|
||||
}
|
||||
|
||||
io_handler handler = { this };
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
boost::asio::buffer(buffer), 0, handler);
|
||||
|
||||
ec_ = boost::asio::error::would_block;
|
||||
this->get_service().get_io_service().reset();
|
||||
do this->get_service().get_io_service().run_one();
|
||||
while (ec_ == boost::asio::error::would_block);
|
||||
if (ec_)
|
||||
return traits_type::eof();
|
||||
|
||||
buffer = buffer + bytes_transferred_;
|
||||
}
|
||||
setp(put_buffer_.begin(), put_buffer_.end());
|
||||
setp(&put_buffer_[0], &put_buffer_[0] + put_buffer_.size());
|
||||
|
||||
// If the new character is eof then our work here is done.
|
||||
if (traits_type::eq_int_type(c, traits_type::eof()))
|
||||
@@ -239,45 +397,141 @@ protected:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Get the last error associated with the stream buffer.
|
||||
/**
|
||||
* @return An \c error_code corresponding to the last error from the stream
|
||||
* buffer.
|
||||
*/
|
||||
virtual const boost::system::error_code& error() const
|
||||
{
|
||||
return ec_;
|
||||
}
|
||||
|
||||
private:
|
||||
void init_buffers()
|
||||
{
|
||||
setg(get_buffer_.begin(),
|
||||
get_buffer_.begin() + putback_max,
|
||||
get_buffer_.begin() + putback_max);
|
||||
setg(&get_buffer_[0],
|
||||
&get_buffer_[0] + putback_max,
|
||||
&get_buffer_[0] + putback_max);
|
||||
if (unbuffered_)
|
||||
setp(0, 0);
|
||||
else
|
||||
setp(put_buffer_.begin(), put_buffer_.end());
|
||||
setp(&put_buffer_[0], &put_buffer_[0] + put_buffer_.size());
|
||||
}
|
||||
|
||||
template <typename ResolverQuery>
|
||||
void resolve_and_connect(const ResolverQuery& query,
|
||||
boost::system::error_code& ec)
|
||||
void resolve_and_connect(const ResolverQuery& query)
|
||||
{
|
||||
typedef typename Protocol::resolver resolver_type;
|
||||
typedef typename resolver_type::iterator iterator_type;
|
||||
resolver_type resolver(
|
||||
boost::base_from_member<boost::asio::io_service>::member);
|
||||
iterator_type i = resolver.resolve(query, ec);
|
||||
if (!ec)
|
||||
iterator_type i = resolver.resolve(query, ec_);
|
||||
if (!ec_)
|
||||
{
|
||||
iterator_type end;
|
||||
ec = boost::asio::error::host_not_found;
|
||||
while (ec && i != end)
|
||||
ec_ = boost::asio::error::host_not_found;
|
||||
while (ec_ && i != end)
|
||||
{
|
||||
this->basic_socket<Protocol, StreamSocketService>::close();
|
||||
this->basic_socket<Protocol, StreamSocketService>::connect(*i, ec);
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec_);
|
||||
|
||||
if (timer_state_ == timer_has_expired)
|
||||
{
|
||||
ec_ = boost::asio::error::operation_aborted;
|
||||
return;
|
||||
}
|
||||
|
||||
io_handler handler = { this };
|
||||
this->basic_socket<Protocol, StreamSocketService>::async_connect(
|
||||
*i, handler);
|
||||
|
||||
ec_ = boost::asio::error::would_block;
|
||||
this->get_service().get_io_service().reset();
|
||||
do this->get_service().get_io_service().run_one();
|
||||
while (ec_ == boost::asio::error::would_block);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct io_handler;
|
||||
friend struct io_handler;
|
||||
struct io_handler
|
||||
{
|
||||
basic_socket_streambuf* this_;
|
||||
|
||||
void operator()(const boost::system::error_code& ec,
|
||||
std::size_t bytes_transferred = 0)
|
||||
{
|
||||
this_->ec_ = ec;
|
||||
this_->bytes_transferred_ = bytes_transferred;
|
||||
}
|
||||
};
|
||||
|
||||
struct timer_handler;
|
||||
friend struct timer_handler;
|
||||
struct timer_handler
|
||||
{
|
||||
basic_socket_streambuf* this_;
|
||||
|
||||
void operator()(const boost::system::error_code&)
|
||||
{
|
||||
time_type now = TimeTraits::now();
|
||||
|
||||
time_type expiry_time = this_->timer_service_->expires_at(
|
||||
this_->timer_implementation_);
|
||||
|
||||
if (TimeTraits::less_than(now, expiry_time))
|
||||
{
|
||||
this_->timer_state_ = timer_is_pending;
|
||||
this_->timer_service_->async_wait(this_->timer_implementation_, *this);
|
||||
}
|
||||
else
|
||||
{
|
||||
this_->timer_state_ = timer_has_expired;
|
||||
boost::system::error_code ec;
|
||||
this_->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void construct_timer()
|
||||
{
|
||||
if (timer_service_ == 0)
|
||||
{
|
||||
TimerService& timer_service = use_service<TimerService>(
|
||||
boost::base_from_member<boost::asio::io_service>::member);
|
||||
timer_service.construct(timer_implementation_);
|
||||
timer_service_ = &timer_service;
|
||||
}
|
||||
}
|
||||
|
||||
void destroy_timer()
|
||||
{
|
||||
if (timer_service_)
|
||||
timer_service_->destroy(timer_implementation_);
|
||||
}
|
||||
|
||||
void start_timer()
|
||||
{
|
||||
if (timer_state_ != timer_is_pending)
|
||||
{
|
||||
timer_handler handler = { this };
|
||||
handler(boost::system::error_code());
|
||||
}
|
||||
}
|
||||
|
||||
enum { putback_max = 8 };
|
||||
enum { buffer_size = 512 };
|
||||
boost::array<char, buffer_size> get_buffer_;
|
||||
boost::array<char, buffer_size> put_buffer_;
|
||||
boost::asio::detail::array<char, buffer_size> get_buffer_;
|
||||
boost::asio::detail::array<char, buffer_size> put_buffer_;
|
||||
bool unbuffered_;
|
||||
boost::system::error_code ec_;
|
||||
std::size_t bytes_transferred_;
|
||||
TimerService* timer_service_;
|
||||
typename TimerService::implementation_type timer_implementation_;
|
||||
enum state { no_timer, timer_is_pending, timer_has_expired } timer_state_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
@@ -285,7 +539,9 @@ private:
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
# undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
#endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
#endif // !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_stream_socket.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
@@ -45,8 +46,12 @@ class basic_stream_socket
|
||||
: public basic_socket<Protocol, StreamSocketService>
|
||||
{
|
||||
public:
|
||||
/// (Deprecated: Use native_handle_type.) The native representation of a
|
||||
/// socket.
|
||||
typedef typename StreamSocketService::native_handle_type native_type;
|
||||
|
||||
/// The native representation of a socket.
|
||||
typedef typename StreamSocketService::native_type native_type;
|
||||
typedef typename StreamSocketService::native_handle_type native_handle_type;
|
||||
|
||||
/// The protocol type.
|
||||
typedef Protocol protocol_type;
|
||||
@@ -122,12 +127,47 @@ public:
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
basic_stream_socket(boost::asio::io_service& io_service,
|
||||
const protocol_type& protocol, const native_type& native_socket)
|
||||
const protocol_type& protocol, const native_handle_type& native_socket)
|
||||
: basic_socket<Protocol, StreamSocketService>(
|
||||
io_service, protocol, native_socket)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a basic_stream_socket from another.
|
||||
/**
|
||||
* This constructor moves a stream socket from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_stream_socket(basic_stream_socket&& other)
|
||||
: basic_socket<Protocol, StreamSocketService>(
|
||||
BOOST_ASIO_MOVE_CAST(basic_stream_socket)(other))
|
||||
{
|
||||
}
|
||||
|
||||
/// Move-assign a basic_stream_socket from another.
|
||||
/**
|
||||
* This assignment operator moves a stream socket from one object to another.
|
||||
*
|
||||
* @param other The other basic_stream_socket object from which the move
|
||||
* will occur.
|
||||
*
|
||||
* @note Following the move, the moved-from object is in the same state as if
|
||||
* constructed using the @c basic_stream_socket(io_service&) constructor.
|
||||
*/
|
||||
basic_stream_socket& operator=(basic_stream_socket&& other)
|
||||
{
|
||||
basic_socket<Protocol, StreamSocketService>::operator=(
|
||||
BOOST_ASIO_MOVE_CAST(basic_stream_socket)(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Send some data on the socket.
|
||||
/**
|
||||
* This function is used to send data on the stream socket. The function
|
||||
@@ -157,9 +197,9 @@ public:
|
||||
std::size_t send(const ConstBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send(
|
||||
this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -195,9 +235,9 @@ public:
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send(
|
||||
this->implementation, buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "send");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -223,7 +263,8 @@ public:
|
||||
std::size_t send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.send(this->implementation, buffers, flags, ec);
|
||||
return this->get_service().send(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous send.
|
||||
@@ -262,9 +303,15 @@ public:
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
|
||||
void async_send(const ConstBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(), buffers, 0,
|
||||
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous send.
|
||||
@@ -306,9 +353,15 @@ public:
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, WriteHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send(this->implementation, buffers, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(), buffers, flags,
|
||||
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive some data on the socket.
|
||||
@@ -343,8 +396,9 @@ public:
|
||||
std::size_t receive(const MutableBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive(this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -383,9 +437,9 @@ public:
|
||||
socket_base::message_flags flags)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive(
|
||||
this->implementation, buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
boost::asio::detail::throw_error(ec, "receive");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -411,7 +465,8 @@ public:
|
||||
std::size_t receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags flags, boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.receive(this->implementation, buffers, flags, ec);
|
||||
return this->get_service().receive(
|
||||
this->get_implementation(), buffers, flags, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
@@ -452,9 +507,15 @@ public:
|
||||
* std::vector.
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Start an asynchronous receive.
|
||||
@@ -498,9 +559,15 @@ public:
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags flags, ReadHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive(this->implementation, buffers, flags, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Write some data to the socket.
|
||||
@@ -534,8 +601,9 @@ public:
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.send(this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().send(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "write_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -559,7 +627,7 @@ public:
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.send(this->implementation, buffers, 0, ec);
|
||||
return this->get_service().send(this->get_implementation(), buffers, 0, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write.
|
||||
@@ -599,9 +667,14 @@ public:
|
||||
*/
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
this->service.async_send(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WriteHandler.
|
||||
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_send(this->get_implementation(),
|
||||
buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Read some data from the socket.
|
||||
@@ -636,8 +709,9 @@ public:
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.receive(this->implementation, buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
std::size_t s = this->get_service().receive(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
boost::asio::detail::throw_error(ec, "read_some");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -662,7 +736,8 @@ public:
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.receive(this->implementation, buffers, 0, ec);
|
||||
return this->get_service().receive(
|
||||
this->get_implementation(), buffers, 0, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read.
|
||||
@@ -703,9 +778,14 @@ public:
|
||||
*/
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
this->service.async_receive(this->implementation, buffers, 0, handler);
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a ReadHandler.
|
||||
BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
|
||||
|
||||
this->get_service().async_receive(this->get_implementation(),
|
||||
buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -130,9 +130,9 @@ public:
|
||||
* of the streambuf's input sequence is 0.
|
||||
*/
|
||||
explicit basic_streambuf(
|
||||
std::size_t max_size = (std::numeric_limits<std::size_t>::max)(),
|
||||
std::size_t maximum_size = (std::numeric_limits<std::size_t>::max)(),
|
||||
const Allocator& allocator = Allocator())
|
||||
: max_size_(max_size),
|
||||
: max_size_(maximum_size),
|
||||
buffer_(allocator)
|
||||
{
|
||||
std::size_t pend = (std::min<std::size_t>)(max_size_, buffer_delta);
|
||||
@@ -237,6 +237,8 @@ public:
|
||||
*/
|
||||
void consume(std::size_t n)
|
||||
{
|
||||
if (egptr() < pptr())
|
||||
setg(&buffer_[0], gptr(), pptr());
|
||||
if (gptr() + n > pptr())
|
||||
n = pptr() - gptr();
|
||||
gbump(static_cast<int>(n));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// basic_streambuf_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
518
project/jni/boost/include/boost/asio/basic_waitable_timer.hpp
Normal file
518
project/jni/boost/include/boost/asio/basic_waitable_timer.hpp
Normal file
@@ -0,0 +1,518 @@
|
||||
//
|
||||
// basic_waitable_timer.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_WAITABLE_TIMER_HPP
|
||||
#define BOOST_ASIO_BASIC_WAITABLE_TIMER_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/detail/handler_type_requirements.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/wait_traits.hpp>
|
||||
#include <boost/asio/waitable_timer_service.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Provides waitable timer functionality.
|
||||
/**
|
||||
* The basic_waitable_timer class template provides the ability to perform a
|
||||
* blocking or asynchronous wait for a timer to expire.
|
||||
*
|
||||
* A waitable timer is always in one of two states: "expired" or "not expired".
|
||||
* If the wait() or async_wait() function is called on an expired timer, the
|
||||
* wait operation will complete immediately.
|
||||
*
|
||||
* Most applications will use the boost::asio::waitable_timer typedef.
|
||||
*
|
||||
* @note This waitable timer functionality is for use with the C++11 standard
|
||||
* library's @c <chrono> facility, or with the Boost.Chrono library.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Examples
|
||||
* Performing a blocking wait:
|
||||
* @code
|
||||
* // Construct a timer without setting an expiry time.
|
||||
* boost::asio::waitable_timer timer(io_service);
|
||||
*
|
||||
* // Set an expiry time relative to now.
|
||||
* timer.expires_from_now(boost::posix_time::seconds(5));
|
||||
*
|
||||
* // Wait for the timer to expire.
|
||||
* timer.wait();
|
||||
* @endcode
|
||||
*
|
||||
* @par
|
||||
* Performing an asynchronous wait:
|
||||
* @code
|
||||
* void handler(const boost::system::error_code& error)
|
||||
* {
|
||||
* if (!error)
|
||||
* {
|
||||
* // Timer expired.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Construct a timer with an absolute expiry time.
|
||||
* boost::asio::waitable_timer timer(io_service,
|
||||
* boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
|
||||
*
|
||||
* // Start an asynchronous wait.
|
||||
* timer.async_wait(handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Changing an active waitable_timer's expiry time
|
||||
*
|
||||
* Changing the expiry time of a timer while there are pending asynchronous
|
||||
* waits causes those wait operations to be cancelled. To ensure that the action
|
||||
* associated with the timer is performed only once, use something like this:
|
||||
* used:
|
||||
*
|
||||
* @code
|
||||
* void on_some_event()
|
||||
* {
|
||||
* if (my_timer.expires_from_now(seconds(5)) > 0)
|
||||
* {
|
||||
* // We managed to cancel the timer. Start new asynchronous wait.
|
||||
* my_timer.async_wait(on_timeout);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Too late, timer has already expired!
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void on_timeout(const boost::system::error_code& e)
|
||||
* {
|
||||
* if (e != boost::asio::error::operation_aborted)
|
||||
* {
|
||||
* // Timer was not cancelled, take necessary action.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @li The boost::asio::basic_waitable_timer::expires_from_now() function
|
||||
* cancels any pending asynchronous waits, and returns the number of
|
||||
* asynchronous waits that were cancelled. If it returns 0 then you were too
|
||||
* late and the wait handler has already been executed, or will soon be
|
||||
* executed. If it returns 1 then the wait handler was successfully cancelled.
|
||||
*
|
||||
* @li If a wait handler is cancelled, the boost::system::error_code passed to
|
||||
* it contains the value boost::asio::error::operation_aborted.
|
||||
*/
|
||||
template <typename Clock,
|
||||
typename WaitTraits = boost::asio::wait_traits<Clock>,
|
||||
typename WaitableTimerService = waitable_timer_service<Clock, WaitTraits> >
|
||||
class basic_waitable_timer
|
||||
: public basic_io_object<WaitableTimerService>
|
||||
{
|
||||
public:
|
||||
/// The clock type.
|
||||
typedef Clock clock_type;
|
||||
|
||||
/// The duration type of the clock.
|
||||
typedef typename clock_type::duration duration;
|
||||
|
||||
/// The time point type of the clock.
|
||||
typedef typename clock_type::time_point time_point;
|
||||
|
||||
/// The wait traits type.
|
||||
typedef WaitTraits traits_type;
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* This constructor creates a timer without setting an expiry time. The
|
||||
* expires_at() or expires_from_now() functions must be called to set an
|
||||
* expiry time before the timer can be waited on.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*/
|
||||
explicit basic_waitable_timer(boost::asio::io_service& io_service)
|
||||
: basic_io_object<WaitableTimerService>(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time as an absolute time.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, expressed
|
||||
* as an absolute time.
|
||||
*/
|
||||
basic_waitable_timer(boost::asio::io_service& io_service,
|
||||
const time_point& expiry_time)
|
||||
: basic_io_object<WaitableTimerService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_at(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_at");
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, relative to
|
||||
* now.
|
||||
*/
|
||||
basic_waitable_timer(boost::asio::io_service& io_service,
|
||||
const duration& expiry_time)
|
||||
: basic_io_object<WaitableTimerService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_from_now(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_from_now");
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when cancel() is called, then the
|
||||
* handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Cancels one asynchronous operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.cancel_one(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec, "cancel_one");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Cancels one asynchronous operation that is waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of one pending asynchronous wait
|
||||
* operation against the timer. Handlers are cancelled in FIFO order. The
|
||||
* handler for the cancelled operation will be invoked with the
|
||||
* boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled. That is,
|
||||
* either 0 or 1.
|
||||
*
|
||||
* @note If the timer has already expired when cancel_one() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t cancel_one(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel_one(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
time_point expires_at() const
|
||||
{
|
||||
return this->service.expires_at(this->implementation);
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when expires_at() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_at(const time_point& expiry_time)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_at(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_at");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when expires_at() is called, then
|
||||
* the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_at(const time_point& expiry_time,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.expires_at(this->implementation, expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
duration expires_from_now() const
|
||||
{
|
||||
return this->service.expires_from_now(this->implementation);
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*
|
||||
* @note If the timer has already expired when expires_from_now() is called,
|
||||
* then the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration& expiry_time)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_from_now(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec, "expires_from_now");
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @note If the timer has already expired when expires_from_now() is called,
|
||||
* then the handlers for asynchronous wait operations will:
|
||||
*
|
||||
* @li have already been invoked; or
|
||||
*
|
||||
* @li have been queued for invocation in the near future.
|
||||
*
|
||||
* These handlers can no longer be cancelled, and therefore are passed an
|
||||
* error code that indicates the successful completion of the wait operation.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration& expiry_time,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.expires_from_now(
|
||||
this->implementation, expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void wait()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.wait(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec, "wait");
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
void wait(boost::system::error_code& ec)
|
||||
{
|
||||
this->service.wait(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous wait on the timer.
|
||||
/**
|
||||
* This function may be used to initiate an asynchronous wait against the
|
||||
* timer. It always returns immediately.
|
||||
*
|
||||
* For each call to async_wait(), the supplied handler will be called exactly
|
||||
* once. The handler will be called when:
|
||||
*
|
||||
* @li The timer has expired.
|
||||
*
|
||||
* @li The timer was cancelled, in which case the handler is passed the error
|
||||
* code boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param handler The handler to be called when the timer expires. Copies
|
||||
* will be made of the handler as required. The function signature of the
|
||||
* handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error // Result of operation.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*/
|
||||
template <typename WaitHandler>
|
||||
void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
|
||||
{
|
||||
// If you get an error on the following line it means that your handler does
|
||||
// not meet the documented type requirements for a WaitHandler.
|
||||
BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
|
||||
|
||||
this->service.async_wait(this->implementation,
|
||||
BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_WAITABLE_TIMER_HPP
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
// buffered_read_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/asio/buffered_read_stream_fwd.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@@ -97,13 +96,6 @@ public:
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
@@ -227,16 +219,7 @@ public:
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
size_t total_buffer_size = 0;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
boost::asio::mutable_buffer buffer(*iter);
|
||||
total_buffer_size += boost::asio::buffer_size(buffer);
|
||||
}
|
||||
|
||||
if (total_buffer_size == 0)
|
||||
if (boost::asio::buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.empty())
|
||||
@@ -253,16 +236,7 @@ public:
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
size_t total_buffer_size = 0;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
boost::asio::mutable_buffer buffer(*iter);
|
||||
total_buffer_size += boost::asio::buffer_size(buffer);
|
||||
}
|
||||
|
||||
if (total_buffer_size == 0)
|
||||
if (boost::asio::buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.empty() && !fill(ec))
|
||||
@@ -294,24 +268,8 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers_.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers_.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter),
|
||||
storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
std::size_t bytes_copied = boost::asio::buffer_copy(
|
||||
buffers_, storage_.data(), storage_.size());
|
||||
storage_.consume(bytes_copied);
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
|
||||
}
|
||||
@@ -330,16 +288,7 @@ public:
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
{
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
size_t total_buffer_size = 0;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
boost::asio::mutable_buffer buffer(*iter);
|
||||
total_buffer_size += boost::asio::buffer_size(buffer);
|
||||
}
|
||||
|
||||
if (total_buffer_size == 0)
|
||||
if (boost::asio::buffer_size(buffers) == 0)
|
||||
{
|
||||
get_io_service().post(detail::bind_handler(
|
||||
handler, boost::system::error_code(), 0));
|
||||
@@ -398,23 +347,8 @@ private:
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t copy(const MutableBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
std::size_t bytes_copied = boost::asio::buffer_copy(
|
||||
buffers, storage_.data(), storage_.size());
|
||||
storage_.consume(bytes_copied);
|
||||
return bytes_copied;
|
||||
}
|
||||
@@ -425,24 +359,7 @@ private:
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek_copy(const MutableBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
return bytes_copied;
|
||||
return boost::asio::buffer_copy(buffers, storage_.data(), storage_.size());
|
||||
}
|
||||
|
||||
/// The next layer.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// buffered_read_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// buffered_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -87,13 +87,6 @@ public:
|
||||
return stream_impl_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return stream_impl_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// buffered_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// buffered_write_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/asio/buffered_write_stream_fwd.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@@ -98,13 +97,6 @@ public:
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
@@ -184,16 +176,7 @@ public:
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
typename ConstBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers.end();
|
||||
size_t total_buffer_size = 0;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
boost::asio::const_buffer buffer(*iter);
|
||||
total_buffer_size += boost::asio::buffer_size(buffer);
|
||||
}
|
||||
|
||||
if (total_buffer_size == 0)
|
||||
if (boost::asio::buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.size() == storage_.capacity())
|
||||
@@ -210,16 +193,7 @@ public:
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
|
||||
typename ConstBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers.end();
|
||||
size_t total_buffer_size = 0;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
boost::asio::const_buffer buffer(*iter);
|
||||
total_buffer_size += boost::asio::buffer_size(buffer);
|
||||
}
|
||||
|
||||
if (total_buffer_size == 0)
|
||||
if (boost::asio::buffer_size(buffers) == 0)
|
||||
return 0;
|
||||
|
||||
if (storage_.size() == storage_.capacity() && !flush(ec))
|
||||
@@ -251,25 +225,14 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename ConstBufferSequence::const_iterator iter = buffers_.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers_.end();
|
||||
for (; iter != end && space_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t bytes_avail = buffer_size(*iter);
|
||||
std::size_t length = (bytes_avail < space_avail)
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + bytes_copied + length);
|
||||
memcpy(storage_.data() + orig_size + bytes_copied,
|
||||
buffer_cast<const void*>(*iter), length);
|
||||
bytes_copied += length;
|
||||
space_avail -= length;
|
||||
}
|
||||
std::size_t bytes_avail = boost::asio::buffer_size(buffers_);
|
||||
std::size_t length = bytes_avail < space_avail
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + length);
|
||||
std::size_t bytes_copied = boost::asio::buffer_copy(
|
||||
storage_.data(), buffers_, length);
|
||||
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
|
||||
}
|
||||
@@ -288,16 +251,7 @@ public:
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
{
|
||||
typename ConstBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers.end();
|
||||
size_t total_buffer_size = 0;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
boost::asio::const_buffer buffer(*iter);
|
||||
total_buffer_size += boost::asio::buffer_size(buffer);
|
||||
}
|
||||
|
||||
if (total_buffer_size == 0)
|
||||
if (boost::asio::buffer_size(buffers) == 0)
|
||||
{
|
||||
get_io_service().post(detail::bind_handler(
|
||||
handler, boost::system::error_code(), 0));
|
||||
@@ -376,27 +330,13 @@ private:
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t copy(const ConstBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename ConstBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && space_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t bytes_avail = buffer_size(*iter);
|
||||
std::size_t length = (bytes_avail < space_avail)
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + bytes_copied + length);
|
||||
memcpy(storage_.data() + orig_size + bytes_copied,
|
||||
buffer_cast<const void*>(*iter), length);
|
||||
bytes_copied += length;
|
||||
space_avail -= length;
|
||||
}
|
||||
|
||||
return bytes_copied;
|
||||
std::size_t bytes_avail = boost::asio::buffer_size(buffers);
|
||||
std::size_t length = bytes_avail < space_avail ? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + length);
|
||||
return boost::asio::buffer_copy(
|
||||
storage_.data() + orig_size, buffers, length);
|
||||
}
|
||||
|
||||
/// The next layer.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// buffered_write_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// buffers_iterator.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@@ -73,18 +73,47 @@ namespace detail
|
||||
/// A random access iterator over the bytes in a buffer sequence.
|
||||
template <typename BufferSequence, typename ByteType = char>
|
||||
class buffers_iterator
|
||||
: public boost::iterator<
|
||||
std::random_access_iterator_tag,
|
||||
typename detail::buffers_iterator_types<
|
||||
BufferSequence, ByteType>::byte_type>
|
||||
{
|
||||
private:
|
||||
typedef typename detail::buffers_iterator_types<
|
||||
BufferSequence, ByteType>::buffer_type buffer_type;
|
||||
typedef typename detail::buffers_iterator_types<
|
||||
BufferSequence, ByteType>::byte_type byte_type;
|
||||
|
||||
public:
|
||||
/// The type used for the distance between two iterators.
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
/// The type of the value pointed to by the iterator.
|
||||
typedef ByteType value_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The type of the result of applying operator->() to the iterator.
|
||||
/**
|
||||
* If the buffer sequence stores buffer objects that are convertible to
|
||||
* mutable_buffer, this is a pointer to a non-const ByteType. Otherwise, a
|
||||
* pointer to a const ByteType.
|
||||
*/
|
||||
typedef const_or_non_const_ByteType* pointer;
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
typedef typename detail::buffers_iterator_types<
|
||||
BufferSequence, ByteType>::byte_type* pointer;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The type of the result of applying operator*() to the iterator.
|
||||
/**
|
||||
* If the buffer sequence stores buffer objects that are convertible to
|
||||
* mutable_buffer, this is a reference to a non-const ByteType. Otherwise, a
|
||||
* reference to a const ByteType.
|
||||
*/
|
||||
typedef const_or_non_const_ByteType& reference;
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
typedef typename detail::buffers_iterator_types<
|
||||
BufferSequence, ByteType>::byte_type& reference;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// The iterator category.
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
|
||||
/// Default constructor. Creates an iterator in an undefined state.
|
||||
buffers_iterator()
|
||||
: current_buffer_(),
|
||||
@@ -136,19 +165,19 @@ public:
|
||||
}
|
||||
|
||||
/// Dereference an iterator.
|
||||
byte_type& operator*() const
|
||||
reference operator*() const
|
||||
{
|
||||
return dereference();
|
||||
}
|
||||
|
||||
/// Dereference an iterator.
|
||||
byte_type* operator->() const
|
||||
pointer operator->() const
|
||||
{
|
||||
return &dereference();
|
||||
}
|
||||
|
||||
/// Access an individual element.
|
||||
byte_type& operator[](std::ptrdiff_t difference) const
|
||||
reference operator[](std::ptrdiff_t difference) const
|
||||
{
|
||||
buffers_iterator tmp(*this);
|
||||
tmp.advance(difference);
|
||||
@@ -271,9 +300,9 @@ public:
|
||||
|
||||
private:
|
||||
// Dereference the iterator.
|
||||
byte_type& dereference() const
|
||||
reference dereference() const
|
||||
{
|
||||
return buffer_cast<byte_type*>(current_buffer_)[current_buffer_position_];
|
||||
return buffer_cast<pointer>(current_buffer_)[current_buffer_position_];
|
||||
}
|
||||
|
||||
// Compare two iterators for equality.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// completion_condition.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -76,6 +76,28 @@ private:
|
||||
std::size_t minimum_;
|
||||
};
|
||||
|
||||
class transfer_exactly_t
|
||||
{
|
||||
public:
|
||||
typedef std::size_t result_type;
|
||||
|
||||
explicit transfer_exactly_t(std::size_t size)
|
||||
: size_(size)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Error>
|
||||
std::size_t operator()(const Error& err, std::size_t bytes_transferred)
|
||||
{
|
||||
return (!!err || bytes_transferred >= size_) ? 0 :
|
||||
(size_ - bytes_transferred < default_max_transfer_size
|
||||
? size_ - bytes_transferred : std::size_t(default_max_transfer_size));
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t size_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
@@ -154,6 +176,40 @@ inline detail::transfer_at_least_t transfer_at_least(std::size_t minimum)
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Return a completion condition function object that indicates that a read or
|
||||
/// write operation should continue until an exact number of bytes has been
|
||||
/// transferred, or until an error occurs.
|
||||
/**
|
||||
* This function is used to create an object, of unspecified type, that meets
|
||||
* CompletionCondition requirements.
|
||||
*
|
||||
* @par Example
|
||||
* Reading until a buffer is full or contains exactly 64 bytes:
|
||||
* @code
|
||||
* boost::array<char, 128> buf;
|
||||
* boost::system::error_code ec;
|
||||
* std::size_t n = boost::asio::read(
|
||||
* sock, boost::asio::buffer(buf),
|
||||
* boost::asio::transfer_exactly(64), ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // n == 64
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
unspecified transfer_exactly(std::size_t size);
|
||||
#else
|
||||
inline detail::transfer_exactly_t transfer_exactly(std::size_t size)
|
||||
{
|
||||
return detail::transfer_exactly_t(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
|
||||
} // namespace asio
|
||||
|
||||
816
project/jni/boost/include/boost/asio/connect.hpp
Normal file
816
project/jni/boost/include/boost/asio/connect.hpp
Normal file
@@ -0,0 +1,816 @@
|
||||
//
|
||||
// connect.hpp
|
||||
// ~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_CONNECT_HPP
|
||||
#define BOOST_ASIO_CONNECT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/**
|
||||
* @defgroup connect boost::asio::connect
|
||||
*
|
||||
* @brief Establishes a socket connection by trying each endpoint in a sequence.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. If the sequence is
|
||||
* empty, the associated @c error_code is boost::asio::error::not_found.
|
||||
* Otherwise, contains the error from the last connection attempt.
|
||||
*
|
||||
* @note This overload assumes that a default constructed object of type @c
|
||||
* Iterator represents the end of the sequence. This is a valid assumption for
|
||||
* iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
|
||||
*
|
||||
* @par Example
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
* boost::asio::connect(s, r.resolve(q)); @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService, typename Iterator>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin);
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any. If the sequence is
|
||||
* empty, set to boost::asio::error::not_found. Otherwise, contains the error
|
||||
* from the last connection attempt.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @note This overload assumes that a default constructed object of type @c
|
||||
* Iterator represents the end of the sequence. This is a valid assumption for
|
||||
* iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
|
||||
*
|
||||
* @par Example
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
* boost::system::error_code ec;
|
||||
* boost::asio::connect(s, r.resolve(q), ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService, typename Iterator>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, boost::system::error_code& ec);
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param end An iterator pointing to the end of a sequence of endpoints.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. If the sequence is
|
||||
* empty, the associated @c error_code is boost::asio::error::not_found.
|
||||
* Otherwise, contains the error from the last connection attempt.
|
||||
*
|
||||
* @par Example
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::resolver::iterator i = r.resolve(q), end;
|
||||
* tcp::socket s(io_service);
|
||||
* boost::asio::connect(s, i, end); @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService, typename Iterator>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, Iterator end);
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param end An iterator pointing to the end of a sequence of endpoints.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any. If the sequence is
|
||||
* empty, set to boost::asio::error::not_found. Otherwise, contains the error
|
||||
* from the last connection attempt.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @par Example
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::resolver::iterator i = r.resolve(q), end;
|
||||
* tcp::socket s(io_service);
|
||||
* boost::system::error_code ec;
|
||||
* boost::asio::connect(s, i, end, ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService, typename Iterator>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, Iterator end, boost::system::error_code& ec);
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param connect_condition A function object that is called prior to each
|
||||
* connection attempt. The signature of the function object must be:
|
||||
* @code Iterator connect_condition(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next); @endcode
|
||||
* The @c ec parameter contains the result from the most recent connect
|
||||
* operation. Before the first connection attempt, @c ec is always set to
|
||||
* indicate success. The @c next parameter is an iterator pointing to the next
|
||||
* endpoint to be tried. The function object should return the next iterator,
|
||||
* but is permitted to return a different iterator so that endpoints may be
|
||||
* skipped. The implementation guarantees that the function object will never
|
||||
* be called with the end iterator.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. If the sequence is
|
||||
* empty, the associated @c error_code is boost::asio::error::not_found.
|
||||
* Otherwise, contains the error from the last connection attempt.
|
||||
*
|
||||
* @note This overload assumes that a default constructed object of type @c
|
||||
* Iterator represents the end of the sequence. This is a valid assumption for
|
||||
* iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
|
||||
*
|
||||
* @par Example
|
||||
* The following connect condition function object can be used to output
|
||||
* information about the individual connection attempts:
|
||||
* @code struct my_connect_condition
|
||||
* {
|
||||
* template <typename Iterator>
|
||||
* Iterator operator()(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next)
|
||||
* {
|
||||
* if (ec) std::cout << "Error: " << ec.message() << std::endl;
|
||||
* std::cout << "Trying: " << next->endpoint() << std::endl;
|
||||
* return next;
|
||||
* }
|
||||
* }; @endcode
|
||||
* It would be used with the boost::asio::connect function as follows:
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
* tcp::resolver::iterator i = boost::asio::connect(
|
||||
* s, r.resolve(q), my_connect_condition());
|
||||
* std::cout << "Connected to: " << i->endpoint() << std::endl; @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, ConnectCondition connect_condition);
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param connect_condition A function object that is called prior to each
|
||||
* connection attempt. The signature of the function object must be:
|
||||
* @code Iterator connect_condition(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next); @endcode
|
||||
* The @c ec parameter contains the result from the most recent connect
|
||||
* operation. Before the first connection attempt, @c ec is always set to
|
||||
* indicate success. The @c next parameter is an iterator pointing to the next
|
||||
* endpoint to be tried. The function object should return the next iterator,
|
||||
* but is permitted to return a different iterator so that endpoints may be
|
||||
* skipped. The implementation guarantees that the function object will never
|
||||
* be called with the end iterator.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any. If the sequence is
|
||||
* empty, set to boost::asio::error::not_found. Otherwise, contains the error
|
||||
* from the last connection attempt.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @note This overload assumes that a default constructed object of type @c
|
||||
* Iterator represents the end of the sequence. This is a valid assumption for
|
||||
* iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
|
||||
*
|
||||
* @par Example
|
||||
* The following connect condition function object can be used to output
|
||||
* information about the individual connection attempts:
|
||||
* @code struct my_connect_condition
|
||||
* {
|
||||
* template <typename Iterator>
|
||||
* Iterator operator()(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next)
|
||||
* {
|
||||
* if (ec) std::cout << "Error: " << ec.message() << std::endl;
|
||||
* std::cout << "Trying: " << next->endpoint() << std::endl;
|
||||
* return next;
|
||||
* }
|
||||
* }; @endcode
|
||||
* It would be used with the boost::asio::connect function as follows:
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
* boost::system::error_code ec;
|
||||
* tcp::resolver::iterator i = boost::asio::connect(
|
||||
* s, r.resolve(q), my_connect_condition(), ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* std::cout << "Connected to: " << i->endpoint() << std::endl;
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
|
||||
ConnectCondition connect_condition, boost::system::error_code& ec);
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param end An iterator pointing to the end of a sequence of endpoints.
|
||||
*
|
||||
* @param connect_condition A function object that is called prior to each
|
||||
* connection attempt. The signature of the function object must be:
|
||||
* @code Iterator connect_condition(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next); @endcode
|
||||
* The @c ec parameter contains the result from the most recent connect
|
||||
* operation. Before the first connection attempt, @c ec is always set to
|
||||
* indicate success. The @c next parameter is an iterator pointing to the next
|
||||
* endpoint to be tried. The function object should return the next iterator,
|
||||
* but is permitted to return a different iterator so that endpoints may be
|
||||
* skipped. The implementation guarantees that the function object will never
|
||||
* be called with the end iterator.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure. If the sequence is
|
||||
* empty, the associated @c error_code is boost::asio::error::not_found.
|
||||
* Otherwise, contains the error from the last connection attempt.
|
||||
*
|
||||
* @par Example
|
||||
* The following connect condition function object can be used to output
|
||||
* information about the individual connection attempts:
|
||||
* @code struct my_connect_condition
|
||||
* {
|
||||
* template <typename Iterator>
|
||||
* Iterator operator()(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next)
|
||||
* {
|
||||
* if (ec) std::cout << "Error: " << ec.message() << std::endl;
|
||||
* std::cout << "Trying: " << next->endpoint() << std::endl;
|
||||
* return next;
|
||||
* }
|
||||
* }; @endcode
|
||||
* It would be used with the boost::asio::connect function as follows:
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::resolver::iterator i = r.resolve(q), end;
|
||||
* tcp::socket s(io_service);
|
||||
* i = boost::asio::connect(s, i, end, my_connect_condition());
|
||||
* std::cout << "Connected to: " << i->endpoint() << std::endl; @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
|
||||
Iterator end, ConnectCondition connect_condition);
|
||||
|
||||
/// Establishes a socket connection by trying each endpoint in a sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c connect member
|
||||
* function, once for each endpoint in the sequence, until a connection is
|
||||
* successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param end An iterator pointing to the end of a sequence of endpoints.
|
||||
*
|
||||
* @param connect_condition A function object that is called prior to each
|
||||
* connection attempt. The signature of the function object must be:
|
||||
* @code Iterator connect_condition(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next); @endcode
|
||||
* The @c ec parameter contains the result from the most recent connect
|
||||
* operation. Before the first connection attempt, @c ec is always set to
|
||||
* indicate success. The @c next parameter is an iterator pointing to the next
|
||||
* endpoint to be tried. The function object should return the next iterator,
|
||||
* but is permitted to return a different iterator so that endpoints may be
|
||||
* skipped. The implementation guarantees that the function object will never
|
||||
* be called with the end iterator.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any. If the sequence is
|
||||
* empty, set to boost::asio::error::not_found. Otherwise, contains the error
|
||||
* from the last connection attempt.
|
||||
*
|
||||
* @returns On success, an iterator denoting the successfully connected
|
||||
* endpoint. Otherwise, the end iterator.
|
||||
*
|
||||
* @par Example
|
||||
* The following connect condition function object can be used to output
|
||||
* information about the individual connection attempts:
|
||||
* @code struct my_connect_condition
|
||||
* {
|
||||
* template <typename Iterator>
|
||||
* Iterator operator()(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next)
|
||||
* {
|
||||
* if (ec) std::cout << "Error: " << ec.message() << std::endl;
|
||||
* std::cout << "Trying: " << next->endpoint() << std::endl;
|
||||
* return next;
|
||||
* }
|
||||
* }; @endcode
|
||||
* It would be used with the boost::asio::connect function as follows:
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::resolver::iterator i = r.resolve(q), end;
|
||||
* tcp::socket s(io_service);
|
||||
* boost::system::error_code ec;
|
||||
* i = boost::asio::connect(s, i, end, my_connect_condition(), ec);
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* std::cout << "Connected to: " << i->endpoint() << std::endl;
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService,
|
||||
typename Iterator, typename ConnectCondition>
|
||||
Iterator connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, Iterator end, ConnectCondition connect_condition,
|
||||
boost::system::error_code& ec);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @defgroup async_connect boost::asio::async_connect
|
||||
*
|
||||
* @brief Asynchronously establishes a socket connection by trying each
|
||||
* endpoint in a sequence.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/// Asynchronously establishes a socket connection by trying each endpoint in a
|
||||
/// sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c async_connect
|
||||
* member function, once for each endpoint in the sequence, until a connection
|
||||
* is successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param handler The handler to be called when the connect operation
|
||||
* completes. Copies will be made of the handler as required. The function
|
||||
* signature of the handler must be:
|
||||
* @code void handler(
|
||||
* // Result of operation. if the sequence is empty, set to
|
||||
* // boost::asio::error::not_found. Otherwise, contains the
|
||||
* // error from the last connection attempt.
|
||||
* const boost::system::error_code& error,
|
||||
*
|
||||
* // On success, an iterator denoting the successfully
|
||||
* // connected endpoint. Otherwise, the end iterator.
|
||||
* Iterator iterator
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*
|
||||
* @note This overload assumes that a default constructed object of type @c
|
||||
* Iterator represents the end of the sequence. This is a valid assumption for
|
||||
* iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
|
||||
*
|
||||
* @par Example
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* r.async_resolve(q, resolve_handler);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void resolve_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* if (!ec)
|
||||
* {
|
||||
* boost::asio::async_connect(s, i, connect_handler);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void connect_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* // ...
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService,
|
||||
typename Iterator, typename ComposedConnectHandler>
|
||||
void async_connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
|
||||
|
||||
/// Asynchronously establishes a socket connection by trying each endpoint in a
|
||||
/// sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c async_connect
|
||||
* member function, once for each endpoint in the sequence, until a connection
|
||||
* is successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param end An iterator pointing to the end of a sequence of endpoints.
|
||||
*
|
||||
* @param handler The handler to be called when the connect operation
|
||||
* completes. Copies will be made of the handler as required. The function
|
||||
* signature of the handler must be:
|
||||
* @code void handler(
|
||||
* // Result of operation. if the sequence is empty, set to
|
||||
* // boost::asio::error::not_found. Otherwise, contains the
|
||||
* // error from the last connection attempt.
|
||||
* const boost::system::error_code& error,
|
||||
*
|
||||
* // On success, an iterator denoting the successfully
|
||||
* // connected endpoint. Otherwise, the end iterator.
|
||||
* Iterator iterator
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*
|
||||
* @par Example
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* r.async_resolve(q, resolve_handler);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void resolve_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* if (!ec)
|
||||
* {
|
||||
* tcp::resolver::iterator end;
|
||||
* boost::asio::async_connect(s, i, end, connect_handler);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void connect_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* // ...
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService,
|
||||
typename Iterator, typename ComposedConnectHandler>
|
||||
void async_connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, Iterator end,
|
||||
BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
|
||||
|
||||
/// Asynchronously establishes a socket connection by trying each endpoint in a
|
||||
/// sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c async_connect
|
||||
* member function, once for each endpoint in the sequence, until a connection
|
||||
* is successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param connect_condition A function object that is called prior to each
|
||||
* connection attempt. The signature of the function object must be:
|
||||
* @code Iterator connect_condition(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next); @endcode
|
||||
* The @c ec parameter contains the result from the most recent connect
|
||||
* operation. Before the first connection attempt, @c ec is always set to
|
||||
* indicate success. The @c next parameter is an iterator pointing to the next
|
||||
* endpoint to be tried. The function object should return the next iterator,
|
||||
* but is permitted to return a different iterator so that endpoints may be
|
||||
* skipped. The implementation guarantees that the function object will never
|
||||
* be called with the end iterator.
|
||||
*
|
||||
* @param handler The handler to be called when the connect operation
|
||||
* completes. Copies will be made of the handler as required. The function
|
||||
* signature of the handler must be:
|
||||
* @code void handler(
|
||||
* // Result of operation. if the sequence is empty, set to
|
||||
* // boost::asio::error::not_found. Otherwise, contains the
|
||||
* // error from the last connection attempt.
|
||||
* const boost::system::error_code& error,
|
||||
*
|
||||
* // On success, an iterator denoting the successfully
|
||||
* // connected endpoint. Otherwise, the end iterator.
|
||||
* Iterator iterator
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*
|
||||
* @note This overload assumes that a default constructed object of type @c
|
||||
* Iterator represents the end of the sequence. This is a valid assumption for
|
||||
* iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
|
||||
*
|
||||
* @par Example
|
||||
* The following connect condition function object can be used to output
|
||||
* information about the individual connection attempts:
|
||||
* @code struct my_connect_condition
|
||||
* {
|
||||
* template <typename Iterator>
|
||||
* Iterator operator()(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next)
|
||||
* {
|
||||
* if (ec) std::cout << "Error: " << ec.message() << std::endl;
|
||||
* std::cout << "Trying: " << next->endpoint() << std::endl;
|
||||
* return next;
|
||||
* }
|
||||
* }; @endcode
|
||||
* It would be used with the boost::asio::connect function as follows:
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* r.async_resolve(q, resolve_handler);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void resolve_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* if (!ec)
|
||||
* {
|
||||
* boost::asio::async_connect(s, i,
|
||||
* my_connect_condition(),
|
||||
* connect_handler);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void connect_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* std::cout << "Connected to: " << i->endpoint() << std::endl;
|
||||
* }
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService, typename Iterator,
|
||||
typename ConnectCondition, typename ComposedConnectHandler>
|
||||
void async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
|
||||
ConnectCondition connect_condition,
|
||||
BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
|
||||
|
||||
/// Asynchronously establishes a socket connection by trying each endpoint in a
|
||||
/// sequence.
|
||||
/**
|
||||
* This function attempts to connect a socket to one of a sequence of
|
||||
* endpoints. It does this by repeated calls to the socket's @c async_connect
|
||||
* member function, once for each endpoint in the sequence, until a connection
|
||||
* is successfully established.
|
||||
*
|
||||
* @param s The socket to be connected. If the socket is already open, it will
|
||||
* be closed.
|
||||
*
|
||||
* @param begin An iterator pointing to the start of a sequence of endpoints.
|
||||
*
|
||||
* @param end An iterator pointing to the end of a sequence of endpoints.
|
||||
*
|
||||
* @param connect_condition A function object that is called prior to each
|
||||
* connection attempt. The signature of the function object must be:
|
||||
* @code Iterator connect_condition(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next); @endcode
|
||||
* The @c ec parameter contains the result from the most recent connect
|
||||
* operation. Before the first connection attempt, @c ec is always set to
|
||||
* indicate success. The @c next parameter is an iterator pointing to the next
|
||||
* endpoint to be tried. The function object should return the next iterator,
|
||||
* but is permitted to return a different iterator so that endpoints may be
|
||||
* skipped. The implementation guarantees that the function object will never
|
||||
* be called with the end iterator.
|
||||
*
|
||||
* @param handler The handler to be called when the connect operation
|
||||
* completes. Copies will be made of the handler as required. The function
|
||||
* signature of the handler must be:
|
||||
* @code void handler(
|
||||
* // Result of operation. if the sequence is empty, set to
|
||||
* // boost::asio::error::not_found. Otherwise, contains the
|
||||
* // error from the last connection attempt.
|
||||
* const boost::system::error_code& error,
|
||||
*
|
||||
* // On success, an iterator denoting the successfully
|
||||
* // connected endpoint. Otherwise, the end iterator.
|
||||
* Iterator iterator
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*
|
||||
* @par Example
|
||||
* The following connect condition function object can be used to output
|
||||
* information about the individual connection attempts:
|
||||
* @code struct my_connect_condition
|
||||
* {
|
||||
* template <typename Iterator>
|
||||
* Iterator operator()(
|
||||
* const boost::system::error_code& ec,
|
||||
* Iterator next)
|
||||
* {
|
||||
* if (ec) std::cout << "Error: " << ec.message() << std::endl;
|
||||
* std::cout << "Trying: " << next->endpoint() << std::endl;
|
||||
* return next;
|
||||
* }
|
||||
* }; @endcode
|
||||
* It would be used with the boost::asio::connect function as follows:
|
||||
* @code tcp::resolver r(io_service);
|
||||
* tcp::resolver::query q("host", "service");
|
||||
* tcp::socket s(io_service);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* r.async_resolve(q, resolve_handler);
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void resolve_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* if (!ec)
|
||||
* {
|
||||
* tcp::resolver::iterator end;
|
||||
* boost::asio::async_connect(s, i, end,
|
||||
* my_connect_condition(),
|
||||
* connect_handler);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // ...
|
||||
*
|
||||
* void connect_handler(
|
||||
* const boost::system::error_code& ec,
|
||||
* tcp::resolver::iterator i)
|
||||
* {
|
||||
* if (ec)
|
||||
* {
|
||||
* // An error occurred.
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* std::cout << "Connected to: " << i->endpoint() << std::endl;
|
||||
* }
|
||||
* } @endcode
|
||||
*/
|
||||
template <typename Protocol, typename SocketService, typename Iterator,
|
||||
typename ConnectCondition, typename ComposedConnectHandler>
|
||||
void async_connect(basic_socket<Protocol, SocketService>& s,
|
||||
Iterator begin, Iterator end, ConnectCondition connect_condition,
|
||||
BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
|
||||
|
||||
/*@}*/
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/impl/connect.hpp>
|
||||
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
// datagram_socket_service.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -68,11 +68,18 @@ public:
|
||||
typedef typename service_impl_type::implementation_type implementation_type;
|
||||
#endif
|
||||
|
||||
/// The native socket type.
|
||||
/// (Deprecated: Use native_handle_type.) The native socket type.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_type;
|
||||
#else
|
||||
typedef typename service_impl_type::native_type native_type;
|
||||
typedef typename service_impl_type::native_handle_type native_type;
|
||||
#endif
|
||||
|
||||
/// The native socket type.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef implementation_defined native_handle_type;
|
||||
#else
|
||||
typedef typename service_impl_type::native_handle_type native_handle_type;
|
||||
#endif
|
||||
|
||||
/// Construct a new datagram socket service for the specified io_service.
|
||||
@@ -83,18 +90,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/// Destroy all user-defined handler objects owned by the service.
|
||||
void shutdown_service()
|
||||
{
|
||||
service_impl_.shutdown_service();
|
||||
}
|
||||
|
||||
/// Construct a new datagram socket implementation.
|
||||
void construct(implementation_type& impl)
|
||||
{
|
||||
service_impl_.construct(impl);
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Move-construct a new datagram socket implementation.
|
||||
void move_construct(implementation_type& impl,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_construct(impl, other_impl);
|
||||
}
|
||||
|
||||
/// Move-assign from another datagram socket implementation.
|
||||
void move_assign(implementation_type& impl,
|
||||
datagram_socket_service& other_service,
|
||||
implementation_type& other_impl)
|
||||
{
|
||||
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Destroy a datagram socket implementation.
|
||||
void destroy(implementation_type& impl)
|
||||
{
|
||||
@@ -114,7 +132,7 @@ public:
|
||||
|
||||
/// Assign an existing native socket to a datagram socket.
|
||||
boost::system::error_code assign(implementation_type& impl,
|
||||
const protocol_type& protocol, const native_type& native_socket,
|
||||
const protocol_type& protocol, const native_handle_type& native_socket,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.assign(impl, protocol, native_socket, ec);
|
||||
@@ -133,10 +151,16 @@ public:
|
||||
return service_impl_.close(impl, ec);
|
||||
}
|
||||
|
||||
/// Get the native socket implementation.
|
||||
/// (Deprecated: Use native_handle().) Get the native socket implementation.
|
||||
native_type native(implementation_type& impl)
|
||||
{
|
||||
return service_impl_.native(impl);
|
||||
return service_impl_.native_handle(impl);
|
||||
}
|
||||
|
||||
/// Get the native socket implementation.
|
||||
native_handle_type native_handle(implementation_type& impl)
|
||||
{
|
||||
return service_impl_.native_handle(impl);
|
||||
}
|
||||
|
||||
/// Cancel all asynchronous operations associated with the socket.
|
||||
@@ -177,9 +201,11 @@ public:
|
||||
/// Start an asynchronous connect.
|
||||
template <typename ConnectHandler>
|
||||
void async_connect(implementation_type& impl,
|
||||
const endpoint_type& peer_endpoint, ConnectHandler handler)
|
||||
const endpoint_type& peer_endpoint,
|
||||
BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
|
||||
{
|
||||
service_impl_.async_connect(impl, peer_endpoint, handler);
|
||||
service_impl_.async_connect(impl, peer_endpoint,
|
||||
BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
|
||||
}
|
||||
|
||||
/// Set a socket option.
|
||||
@@ -206,6 +232,32 @@ public:
|
||||
return service_impl_.io_control(impl, command, ec);
|
||||
}
|
||||
|
||||
/// Gets the non-blocking mode of the socket.
|
||||
bool non_blocking(const implementation_type& impl) const
|
||||
{
|
||||
return service_impl_.non_blocking(impl);
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the socket.
|
||||
boost::system::error_code non_blocking(implementation_type& impl,
|
||||
bool mode, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.non_blocking(impl, mode, ec);
|
||||
}
|
||||
|
||||
/// Gets the non-blocking mode of the native socket implementation.
|
||||
bool native_non_blocking(const implementation_type& impl) const
|
||||
{
|
||||
return service_impl_.native_non_blocking(impl);
|
||||
}
|
||||
|
||||
/// Sets the non-blocking mode of the native socket implementation.
|
||||
boost::system::error_code native_non_blocking(implementation_type& impl,
|
||||
bool mode, boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.native_non_blocking(impl, mode, ec);
|
||||
}
|
||||
|
||||
/// Get the local endpoint.
|
||||
endpoint_type local_endpoint(const implementation_type& impl,
|
||||
boost::system::error_code& ec) const
|
||||
@@ -239,9 +291,11 @@ public:
|
||||
/// Start an asynchronous send.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send(implementation_type& impl, const ConstBufferSequence& buffers,
|
||||
socket_base::message_flags flags, WriteHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
service_impl_.async_send(impl, buffers, flags, handler);
|
||||
service_impl_.async_send(impl, buffers, flags,
|
||||
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Send a datagram to the specified endpoint.
|
||||
@@ -257,9 +311,11 @@ public:
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_send_to(implementation_type& impl,
|
||||
const ConstBufferSequence& buffers, const endpoint_type& destination,
|
||||
socket_base::message_flags flags, WriteHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
|
||||
{
|
||||
service_impl_.async_send_to(impl, buffers, destination, flags, handler);
|
||||
service_impl_.async_send_to(impl, buffers, destination, flags,
|
||||
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive some data from the peer.
|
||||
@@ -275,9 +331,11 @@ public:
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive(implementation_type& impl,
|
||||
const MutableBufferSequence& buffers,
|
||||
socket_base::message_flags flags, ReadHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
service_impl_.async_receive(impl, buffers, flags, handler);
|
||||
service_impl_.async_receive(impl, buffers, flags,
|
||||
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
/// Receive a datagram with the endpoint of the sender.
|
||||
@@ -294,13 +352,20 @@ public:
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_receive_from(implementation_type& impl,
|
||||
const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
|
||||
socket_base::message_flags flags, ReadHandler handler)
|
||||
socket_base::message_flags flags,
|
||||
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
|
||||
{
|
||||
service_impl_.async_receive_from(impl, buffers, sender_endpoint, flags,
|
||||
handler);
|
||||
BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
|
||||
}
|
||||
|
||||
private:
|
||||
// Destroy all user-defined handler objects owned by the service.
|
||||
void shutdown_service()
|
||||
{
|
||||
service_impl_.shutdown_service();
|
||||
}
|
||||
|
||||
// The platform-specific implementation.
|
||||
service_impl_type service_impl_;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// deadline_timer.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// deadline_timer_service.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <boost/asio/detail/deadline_timer_service.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/time_traits.hpp>
|
||||
#include <boost/asio/detail/timer_queue_ptime.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -72,12 +73,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/// Destroy all user-defined handler objects owned by the service.
|
||||
void shutdown_service()
|
||||
{
|
||||
service_impl_.shutdown_service();
|
||||
}
|
||||
|
||||
/// Construct a new timer implementation.
|
||||
void construct(implementation_type& impl)
|
||||
{
|
||||
@@ -96,6 +91,13 @@ public:
|
||||
return service_impl_.cancel(impl, ec);
|
||||
}
|
||||
|
||||
/// Cancels one asynchronous wait operation associated with the timer.
|
||||
std::size_t cancel_one(implementation_type& impl,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return service_impl_.cancel_one(impl, ec);
|
||||
}
|
||||
|
||||
/// Get the expiry time for the timer as an absolute time.
|
||||
time_type expires_at(const implementation_type& impl) const
|
||||
{
|
||||
@@ -130,12 +132,19 @@ public:
|
||||
|
||||
// Start an asynchronous wait on the timer.
|
||||
template <typename WaitHandler>
|
||||
void async_wait(implementation_type& impl, WaitHandler handler)
|
||||
void async_wait(implementation_type& impl,
|
||||
BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
|
||||
{
|
||||
service_impl_.async_wait(impl, handler);
|
||||
service_impl_.async_wait(impl, BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
|
||||
}
|
||||
|
||||
private:
|
||||
// Destroy all user-defined handler objects owned by the service.
|
||||
void shutdown_service()
|
||||
{
|
||||
service_impl_.shutdown_service();
|
||||
}
|
||||
|
||||
// The platform-specific implementation.
|
||||
service_impl_type service_impl_;
|
||||
};
|
||||
|
||||
40
project/jni/boost/include/boost/asio/detail/array.hpp
Normal file
40
project/jni/boost/include/boost/asio/detail/array.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// detail/array.hpp
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_DETAIL_ARRAY_HPP
|
||||
#define BOOST_ASIO_DETAIL_ARRAY_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
# include <array>
|
||||
#else // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
# include <boost/array.hpp>
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
using std::array;
|
||||
#else // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
using boost::array;
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_ARRAY_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/array_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -15,6 +15,8 @@
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T, std::size_t N>
|
||||
@@ -22,4 +24,11 @@ class array;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
// Standard library components can't be forward declared, so we'll have to
|
||||
// include the array header. Fortunately, it's fairly lightweight and doesn't
|
||||
// add significantly to the compile time.
|
||||
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
# include <array>
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_ARRAY_FWD_HPP
|
||||
|
||||
44
project/jni/boost/include/boost/asio/detail/atomic_count.hpp
Normal file
44
project/jni/boost/include/boost/asio/detail/atomic_count.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// detail/atomic_count.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_DETAIL_ATOMIC_COUNT_HPP
|
||||
#define BOOST_ASIO_DETAIL_ATOMIC_COUNT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS)
|
||||
// Nothing to include.
|
||||
#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
# include <atomic>
|
||||
#else // defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
# include <boost/detail/atomic_count.hpp>
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_HAS_THREADS) || defined(BOOST_ASIO_DISABLE_THREADS)
|
||||
typedef long atomic_count;
|
||||
#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
typedef std::atomic<long> atomic_count;
|
||||
#else // defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
typedef boost::detail::atomic_count atomic_count;
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_ATOMIC_COUNT_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/base_from_completion_cond.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/bind_handler.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -35,6 +35,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
binder1(Handler& handler, const Arg1& arg1)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_));
|
||||
@@ -66,6 +72,14 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
binder1<Handler, Arg1>* this_handler)
|
||||
@@ -75,7 +89,7 @@ inline void asio_handler_invoke(const Function& function,
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline binder1<Handler, Arg1> bind_handler(const Handler& handler,
|
||||
inline binder1<Handler, Arg1> bind_handler(Handler handler,
|
||||
const Arg1& arg1)
|
||||
{
|
||||
return binder1<Handler, Arg1>(handler, arg1);
|
||||
@@ -92,6 +106,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
binder2(Handler& handler, const Arg1& arg1, const Arg2& arg2)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
@@ -125,6 +146,14 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
@@ -134,7 +163,7 @@ inline void asio_handler_invoke(const Function& function,
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline binder2<Handler, Arg1, Arg2> bind_handler(const Handler& handler,
|
||||
inline binder2<Handler, Arg1, Arg2> bind_handler(Handler handler,
|
||||
const Arg1& arg1, const Arg2& arg2)
|
||||
{
|
||||
return binder2<Handler, Arg1, Arg2>(handler, arg1, arg2);
|
||||
@@ -153,6 +182,15 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
binder3(Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
@@ -188,6 +226,15 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
@@ -198,7 +245,7 @@ inline void asio_handler_invoke(const Function& function,
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline binder3<Handler, Arg1, Arg2, Arg3> bind_handler(const Handler& handler,
|
||||
inline binder3<Handler, Arg1, Arg2, Arg3> bind_handler(Handler handler,
|
||||
const Arg1& arg1, const Arg2& arg2, const Arg3& arg3)
|
||||
{
|
||||
return binder3<Handler, Arg1, Arg2, Arg3>(handler, arg1, arg2, arg3);
|
||||
@@ -219,6 +266,16 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
binder4(Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
@@ -258,6 +315,15 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
@@ -270,7 +336,7 @@ inline void asio_handler_invoke(const Function& function,
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4>
|
||||
inline binder4<Handler, Arg1, Arg2, Arg3, Arg4> bind_handler(
|
||||
const Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
Handler handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4)
|
||||
{
|
||||
return binder4<Handler, Arg1, Arg2, Arg3, Arg4>(handler, arg1, arg2, arg3,
|
||||
@@ -293,6 +359,17 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
binder5(Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4),
|
||||
arg5_(arg5)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
@@ -334,6 +411,15 @@ inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline void asio_handler_invoke(Function& function,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline void asio_handler_invoke(const Function& function,
|
||||
@@ -346,7 +432,7 @@ inline void asio_handler_invoke(const Function& function,
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
|
||||
typename Arg4, typename Arg5>
|
||||
inline binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5> bind_handler(
|
||||
const Handler& handler, const Arg1& arg1, const Arg2& arg2,
|
||||
Handler handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
|
||||
{
|
||||
return binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>(handler, arg1, arg2,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/buffer_resize_guard.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/buffer_sequence_adapter.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/detail/array_fwd.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
@@ -81,11 +82,11 @@ class buffer_sequence_adapter
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(const Buffers& buffers)
|
||||
explicit buffer_sequence_adapter(const Buffers& buffer_sequence)
|
||||
: count_(0), total_buffer_size_(0)
|
||||
{
|
||||
typename Buffers::const_iterator iter = buffers.begin();
|
||||
typename Buffers::const_iterator end = buffers.end();
|
||||
typename Buffers::const_iterator iter = buffer_sequence.begin();
|
||||
typename Buffers::const_iterator end = buffer_sequence.end();
|
||||
for (; iter != end && count_ < max_buffers; ++iter, ++count_)
|
||||
{
|
||||
Buffer buffer(*iter);
|
||||
@@ -109,10 +110,10 @@ public:
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const Buffers& buffers)
|
||||
static bool all_empty(const Buffers& buffer_sequence)
|
||||
{
|
||||
typename Buffers::const_iterator iter = buffers.begin();
|
||||
typename Buffers::const_iterator end = buffers.end();
|
||||
typename Buffers::const_iterator iter = buffer_sequence.begin();
|
||||
typename Buffers::const_iterator end = buffer_sequence.end();
|
||||
std::size_t i = 0;
|
||||
for (; iter != end && i < max_buffers; ++iter, ++i)
|
||||
if (boost::asio::buffer_size(Buffer(*iter)) > 0)
|
||||
@@ -120,10 +121,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static void validate(const Buffers& buffers)
|
||||
static void validate(const Buffers& buffer_sequence)
|
||||
{
|
||||
typename Buffers::const_iterator iter = buffers.begin();
|
||||
typename Buffers::const_iterator end = buffers.end();
|
||||
typename Buffers::const_iterator iter = buffer_sequence.begin();
|
||||
typename Buffers::const_iterator end = buffer_sequence.end();
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
Buffer buffer(*iter);
|
||||
@@ -131,10 +132,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static Buffer first(const Buffers& buffers)
|
||||
static Buffer first(const Buffers& buffer_sequence)
|
||||
{
|
||||
typename Buffers::const_iterator iter = buffers.begin();
|
||||
typename Buffers::const_iterator end = buffers.end();
|
||||
typename Buffers::const_iterator iter = buffer_sequence.begin();
|
||||
typename Buffers::const_iterator end = buffer_sequence.end();
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
Buffer buffer(*iter);
|
||||
@@ -159,10 +160,10 @@ class buffer_sequence_adapter<Buffer, boost::asio::mutable_buffers_1>
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const boost::asio::mutable_buffers_1& buffers)
|
||||
const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffer_, Buffer(buffers));
|
||||
total_buffer_size_ = boost::asio::buffer_size(buffers);
|
||||
init_native_buffer(buffer_, Buffer(buffer_sequence));
|
||||
total_buffer_size_ = boost::asio::buffer_size(buffer_sequence);
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
@@ -180,19 +181,19 @@ public:
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::asio::mutable_buffers_1& buffers)
|
||||
static bool all_empty(const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
return boost::asio::buffer_size(buffers) == 0;
|
||||
return boost::asio::buffer_size(buffer_sequence) == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::asio::mutable_buffers_1& buffers)
|
||||
static void validate(const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
boost::asio::buffer_cast<const void*>(buffers);
|
||||
boost::asio::buffer_cast<const void*>(buffer_sequence);
|
||||
}
|
||||
|
||||
static Buffer first(const boost::asio::mutable_buffers_1& buffers)
|
||||
static Buffer first(const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffers);
|
||||
return Buffer(buffer_sequence);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -206,10 +207,10 @@ class buffer_sequence_adapter<Buffer, boost::asio::const_buffers_1>
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const boost::asio::const_buffers_1& buffers)
|
||||
const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffer_, Buffer(buffers));
|
||||
total_buffer_size_ = boost::asio::buffer_size(buffers);
|
||||
init_native_buffer(buffer_, Buffer(buffer_sequence));
|
||||
total_buffer_size_ = boost::asio::buffer_size(buffer_sequence);
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
@@ -227,19 +228,19 @@ public:
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::asio::const_buffers_1& buffers)
|
||||
static bool all_empty(const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
return boost::asio::buffer_size(buffers) == 0;
|
||||
return boost::asio::buffer_size(buffer_sequence) == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::asio::const_buffers_1& buffers)
|
||||
static void validate(const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
boost::asio::buffer_cast<const void*>(buffers);
|
||||
boost::asio::buffer_cast<const void*>(buffer_sequence);
|
||||
}
|
||||
|
||||
static Buffer first(const boost::asio::const_buffers_1& buffers)
|
||||
static Buffer first(const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffers);
|
||||
return Buffer(buffer_sequence);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -247,6 +248,114 @@ private:
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
template <typename Buffer, typename Elem>
|
||||
class buffer_sequence_adapter<Buffer, boost::array<Elem, 2> >
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const boost::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffers_[0], Buffer(buffer_sequence[0]));
|
||||
init_native_buffer(buffers_[1], Buffer(buffer_sequence[1]));
|
||||
total_buffer_size_ = boost::asio::buffer_size(buffer_sequence[0])
|
||||
+ boost::asio::buffer_size(buffer_sequence[1]);
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return buffers_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return boost::asio::buffer_size(buffer_sequence[0]) == 0
|
||||
&& boost::asio::buffer_size(buffer_sequence[1]) == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
boost::asio::buffer_cast<const void*>(buffer_sequence[0]);
|
||||
boost::asio::buffer_cast<const void*>(buffer_sequence[1]);
|
||||
}
|
||||
|
||||
static Buffer first(const boost::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return Buffer(boost::asio::buffer_size(buffer_sequence[0]) != 0
|
||||
? buffer_sequence[0] : buffer_sequence[1]);
|
||||
}
|
||||
|
||||
private:
|
||||
native_buffer_type buffers_[2];
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
|
||||
template <typename Buffer, typename Elem>
|
||||
class buffer_sequence_adapter<Buffer, std::array<Elem, 2> >
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const std::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffers_[0], Buffer(buffer_sequence[0]));
|
||||
init_native_buffer(buffers_[1], Buffer(buffer_sequence[1]));
|
||||
total_buffer_size_ = boost::asio::buffer_size(buffer_sequence[0])
|
||||
+ boost::asio::buffer_size(buffer_sequence[1]);
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return buffers_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const std::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return boost::asio::buffer_size(buffer_sequence[0]) == 0
|
||||
&& boost::asio::buffer_size(buffer_sequence[1]) == 0;
|
||||
}
|
||||
|
||||
static void validate(const std::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
boost::asio::buffer_cast<const void*>(buffer_sequence[0]);
|
||||
boost::asio::buffer_cast<const void*>(buffer_sequence[1]);
|
||||
}
|
||||
|
||||
static Buffer first(const std::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return Buffer(boost::asio::buffer_size(buffer_sequence[0]) != 0
|
||||
? buffer_sequence[0] : buffer_sequence[1]);
|
||||
}
|
||||
|
||||
private:
|
||||
native_buffer_type buffers_[2];
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/buffered_stream_storage.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -16,7 +16,8 @@
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
@@ -37,10 +38,10 @@ public:
|
||||
typedef std::size_t size_type;
|
||||
|
||||
// Constructor.
|
||||
explicit buffered_stream_storage(std::size_t capacity)
|
||||
explicit buffered_stream_storage(std::size_t buffer_capacity)
|
||||
: begin_offset_(0),
|
||||
end_offset_(0),
|
||||
buffer_(capacity)
|
||||
buffer_(buffer_capacity)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -52,15 +53,15 @@ public:
|
||||
}
|
||||
|
||||
// Return a pointer to the beginning of the unread data.
|
||||
byte_type* data()
|
||||
mutable_buffer data()
|
||||
{
|
||||
return &buffer_[0] + begin_offset_;
|
||||
return boost::asio::buffer(buffer_) + begin_offset_;
|
||||
}
|
||||
|
||||
// Return a pointer to the beginning of the unread data.
|
||||
const byte_type* data() const
|
||||
const_buffer data() const
|
||||
{
|
||||
return &buffer_[0] + begin_offset_;
|
||||
return boost::asio::buffer(buffer_) + begin_offset_;
|
||||
}
|
||||
|
||||
// Is there no unread data in the buffer.
|
||||
@@ -78,7 +79,7 @@ public:
|
||||
// Resize the buffer to the specified length.
|
||||
void resize(size_type length)
|
||||
{
|
||||
assert(length <= capacity());
|
||||
BOOST_ASSERT(length <= capacity());
|
||||
if (begin_offset_ + length <= capacity())
|
||||
{
|
||||
end_offset_ = begin_offset_ + length;
|
||||
@@ -101,7 +102,7 @@ public:
|
||||
// Consume multiple bytes from the beginning of the buffer.
|
||||
void consume(size_type count)
|
||||
{
|
||||
assert(begin_offset_ + count <= end_offset_);
|
||||
BOOST_ASSERT(begin_offset_ + count <= end_offset_);
|
||||
begin_offset_ += count;
|
||||
if (empty())
|
||||
clear();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/call_stack.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -27,34 +27,60 @@ namespace detail {
|
||||
|
||||
// Helper class to determine whether or not the current thread is inside an
|
||||
// invocation of io_service::run() for a specified io_service object.
|
||||
template <typename Owner>
|
||||
template <typename Key, typename Value = unsigned char>
|
||||
class call_stack
|
||||
{
|
||||
public:
|
||||
// Context class automatically pushes an owner on to the stack.
|
||||
// Context class automatically pushes the key/value pair on to the stack.
|
||||
class context
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
// Push the owner on to the stack.
|
||||
explicit context(Owner* d)
|
||||
: owner_(d),
|
||||
next_(call_stack<Owner>::top_)
|
||||
// Push the key on to the stack.
|
||||
explicit context(Key* k)
|
||||
: key_(k),
|
||||
next_(call_stack<Key, Value>::top_)
|
||||
{
|
||||
call_stack<Owner>::top_ = this;
|
||||
value_ = reinterpret_cast<unsigned char*>(this);
|
||||
call_stack<Key, Value>::top_ = this;
|
||||
}
|
||||
|
||||
// Pop the owner from the stack.
|
||||
// Push the key/value pair on to the stack.
|
||||
context(Key* k, Value& v)
|
||||
: key_(k),
|
||||
value_(&v),
|
||||
next_(call_stack<Key, Value>::top_)
|
||||
{
|
||||
call_stack<Key, Value>::top_ = this;
|
||||
}
|
||||
|
||||
// Pop the key/value pair from the stack.
|
||||
~context()
|
||||
{
|
||||
call_stack<Owner>::top_ = next_;
|
||||
call_stack<Key, Value>::top_ = next_;
|
||||
}
|
||||
|
||||
// Find the next context with the same key.
|
||||
Value* next_by_key() const
|
||||
{
|
||||
context* elem = next_;
|
||||
while (elem)
|
||||
{
|
||||
if (elem->key_ == key_)
|
||||
return elem->value_;
|
||||
elem = elem->next_;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class call_stack<Owner>;
|
||||
friend class call_stack<Key, Value>;
|
||||
|
||||
// The owner associated with the context.
|
||||
Owner* owner_;
|
||||
// The key associated with the context.
|
||||
Key* key_;
|
||||
|
||||
// The value associated with the context.
|
||||
Value* value_;
|
||||
|
||||
// The next element in the stack.
|
||||
context* next_;
|
||||
@@ -62,17 +88,18 @@ public:
|
||||
|
||||
friend class context;
|
||||
|
||||
// Determine whether the specified owner is on the stack.
|
||||
static bool contains(Owner* d)
|
||||
// Determine whether the specified owner is on the stack. Returns address of
|
||||
// key if present, 0 otherwise.
|
||||
static Value* contains(Key* k)
|
||||
{
|
||||
context* elem = top_;
|
||||
while (elem)
|
||||
{
|
||||
if (elem->owner_ == d)
|
||||
return true;
|
||||
if (elem->key_ == k)
|
||||
return elem->value_;
|
||||
elem = elem->next_;
|
||||
}
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -80,9 +107,9 @@ private:
|
||||
static tss_ptr<context> top_;
|
||||
};
|
||||
|
||||
template <typename Owner>
|
||||
tss_ptr<typename call_stack<Owner>::context>
|
||||
call_stack<Owner>::top_;
|
||||
template <typename Key, typename Value>
|
||||
tss_ptr<typename call_stack<Key, Value>::context>
|
||||
call_stack<Key, Value>::top_;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
//
|
||||
// detail/chrono_time_traits.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_DETAIL_CHRONO_TIME_TRAITS_HPP
|
||||
#define BOOST_ASIO_DETAIL_CHRONO_TIME_TRAITS_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Adapts std::chrono clocks for use with a deadline timer.
|
||||
template <typename Clock, typename WaitTraits>
|
||||
struct chrono_time_traits
|
||||
{
|
||||
// The clock type.
|
||||
typedef Clock clock_type;
|
||||
|
||||
// The duration type of the clock.
|
||||
typedef typename clock_type::duration duration_type;
|
||||
|
||||
// The time point type of the clock.
|
||||
typedef typename clock_type::time_point time_type;
|
||||
|
||||
// The period of the clock.
|
||||
typedef typename duration_type::period period_type;
|
||||
|
||||
// Get the current time.
|
||||
static time_type now()
|
||||
{
|
||||
return clock_type::now();
|
||||
}
|
||||
|
||||
// Add a duration to a time.
|
||||
static time_type add(const time_type& t, const duration_type& d)
|
||||
{
|
||||
return t + d;
|
||||
}
|
||||
|
||||
// Subtract one time from another.
|
||||
static duration_type subtract(const time_type& t1, const time_type& t2)
|
||||
{
|
||||
return t1 - t2;
|
||||
}
|
||||
|
||||
// Test whether one time is less than another.
|
||||
static bool less_than(const time_type& t1, const time_type& t2)
|
||||
{
|
||||
return t1 < t2;
|
||||
}
|
||||
|
||||
// Implement just enough of the posix_time::time_duration interface to supply
|
||||
// what the timer_queue requires.
|
||||
class posix_time_duration
|
||||
{
|
||||
public:
|
||||
explicit posix_time_duration(const duration_type& d)
|
||||
: d_(d)
|
||||
{
|
||||
}
|
||||
|
||||
boost::int64_t ticks() const
|
||||
{
|
||||
return d_.count();
|
||||
}
|
||||
|
||||
boost::int64_t total_seconds() const
|
||||
{
|
||||
return duration_cast<1, 1>();
|
||||
}
|
||||
|
||||
boost::int64_t total_milliseconds() const
|
||||
{
|
||||
return duration_cast<1, 1000>();
|
||||
}
|
||||
|
||||
boost::int64_t total_microseconds() const
|
||||
{
|
||||
return duration_cast<1, 1000000>();
|
||||
}
|
||||
|
||||
private:
|
||||
template <boost::int64_t Num, boost::int64_t Den>
|
||||
boost::int64_t duration_cast() const
|
||||
{
|
||||
const boost::int64_t num = period_type::num * Den;
|
||||
const boost::int64_t den = period_type::den * Num;
|
||||
|
||||
if (num == 1 && den == 1)
|
||||
return ticks();
|
||||
else if (num != 1 && den == 1)
|
||||
return ticks() * num;
|
||||
else if (num == 1 && period_type::den != 1)
|
||||
return ticks() / den;
|
||||
else
|
||||
return ticks() * num / den;
|
||||
}
|
||||
|
||||
duration_type d_;
|
||||
};
|
||||
|
||||
// Convert to POSIX duration type.
|
||||
static posix_time_duration to_posix_duration(const duration_type& d)
|
||||
{
|
||||
return posix_time_duration(WaitTraits::to_wait_duration(d));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CHRONO_TIME_TRAITS_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/completion_handler.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -33,34 +33,39 @@ class completion_handler : public operation
|
||||
public:
|
||||
BOOST_ASIO_DEFINE_HANDLER_PTR(completion_handler);
|
||||
|
||||
completion_handler(Handler h)
|
||||
completion_handler(Handler& h)
|
||||
: operation(&completion_handler::do_complete),
|
||||
handler_(h)
|
||||
handler_(BOOST_ASIO_MOVE_CAST(Handler)(h))
|
||||
{
|
||||
}
|
||||
|
||||
static void do_complete(io_service_impl* owner, operation* base,
|
||||
boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/)
|
||||
const boost::system::error_code& /*ec*/,
|
||||
std::size_t /*bytes_transferred*/)
|
||||
{
|
||||
// Take ownership of the handler object.
|
||||
completion_handler* h(static_cast<completion_handler*>(base));
|
||||
ptr p = { boost::addressof(h->handler_), h, h };
|
||||
|
||||
BOOST_ASIO_HANDLER_COMPLETION((h));
|
||||
|
||||
// Make a copy of the handler so that the memory can be deallocated before
|
||||
// the upcall is made. Even if we're not about to make an upcall, a
|
||||
// sub-object of the handler may be the true owner of the memory associated
|
||||
// with the handler. Consequently, a local copy of the handler is required
|
||||
// to ensure that any owning sub-object remains valid until after we have
|
||||
// deallocated the memory here.
|
||||
Handler handler(h->handler_);
|
||||
Handler handler(BOOST_ASIO_MOVE_CAST(Handler)(h->handler_));
|
||||
p.h = boost::addressof(handler);
|
||||
p.reset();
|
||||
|
||||
// Make the upcall if required.
|
||||
if (owner)
|
||||
{
|
||||
boost::asio::detail::fenced_block b;
|
||||
fenced_block b(fenced_block::half);
|
||||
BOOST_ASIO_HANDLER_INVOCATION_BEGIN(());
|
||||
boost_asio_handler_invoke_helpers::invoke(handler, handler);
|
||||
BOOST_ASIO_HANDLER_INVOCATION_END;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/config.hpp
|
||||
// ~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -12,6 +12,7 @@
|
||||
#define BOOST_ASIO_DETAIL_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
// Default to a header-only implementation. The user must specifically request
|
||||
// separate compilation by defining either BOOST_ASIO_SEPARATE_COMPILATION or
|
||||
@@ -46,6 +47,135 @@
|
||||
# define BOOST_ASIO_DECL
|
||||
#endif // !defined(BOOST_ASIO_DECL)
|
||||
|
||||
// Support move construction and assignment on compilers known to allow it.
|
||||
#if !defined(BOOST_ASIO_DISABLE_MOVE)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define BOOST_ASIO_HAS_MOVE
|
||||
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
|
||||
# endif // defined(__GNUC__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_MOVE)
|
||||
|
||||
// If BOOST_ASIO_MOVE_CAST isn't defined, and move support is available, define
|
||||
// BOOST_ASIO_MOVE_ARG and BOOST_ASIO_MOVE_CAST to take advantage of rvalue
|
||||
// references and perfect forwarding.
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
|
||||
# define BOOST_ASIO_MOVE_ARG(type) type&&
|
||||
# define BOOST_ASIO_MOVE_CAST(type) static_cast<type&&>
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
|
||||
|
||||
// If BOOST_ASIO_MOVE_CAST still isn't defined, default to a C++03-compatible
|
||||
// implementation. Note that older g++ and MSVC versions don't like it when you
|
||||
// pass a non-member function through a const reference, so for most compilers
|
||||
// we'll play it safe and stick with the old approach of passing the handler by
|
||||
// value.
|
||||
#if !defined(BOOST_ASIO_MOVE_CAST)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
|
||||
# define BOOST_ASIO_MOVE_ARG(type) const type&
|
||||
# else // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
|
||||
# define BOOST_ASIO_MOVE_ARG(type) type
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
|
||||
# elif defined(BOOST_MSVC)
|
||||
# if (_MSC_VER >= 1400)
|
||||
# define BOOST_ASIO_MOVE_ARG(type) const type&
|
||||
# else // (_MSC_VER >= 1400)
|
||||
# define BOOST_ASIO_MOVE_ARG(type) type
|
||||
# endif // (_MSC_VER >= 1400)
|
||||
# else
|
||||
# define BOOST_ASIO_MOVE_ARG(type) type
|
||||
# endif
|
||||
# define BOOST_ASIO_MOVE_CAST(type) static_cast<const type&>
|
||||
#endif // !defined_BOOST_ASIO_MOVE_CAST
|
||||
|
||||
// Support variadic templates on compilers known to allow it.
|
||||
#if !defined(BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define BOOST_ASIO_HAS_VARIADIC_TEMPLATES
|
||||
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
|
||||
# endif // defined(__GNUC__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES)
|
||||
|
||||
// Standard library support for system errors.
|
||||
#if !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define BOOST_ASIO_HAS_STD_SYSTEM_ERROR
|
||||
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
|
||||
# endif // defined(__GNUC__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
|
||||
|
||||
// Standard library support for arrays.
|
||||
#if !defined(BOOST_ASIO_DISABLE_STD_ARRAY)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define BOOST_ASIO_HAS_STD_ARRAY
|
||||
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
|
||||
# endif // defined(__GNUC__)
|
||||
# if defined(BOOST_MSVC)
|
||||
# if (_MSC_VER >= 1600)
|
||||
# define BOOST_ASIO_HAS_STD_ARRAY
|
||||
# endif // (_MSC_VER >= 1600)
|
||||
# endif // defined(BOOST_MSVC)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_STD_ARRAY)
|
||||
|
||||
// Standard library support for shared_ptr and weak_ptr.
|
||||
#if !defined(BOOST_ASIO_DISABLE_STD_SHARED_PTR)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define BOOST_ASIO_HAS_STD_SHARED_PTR
|
||||
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
|
||||
# endif // defined(__GNUC__)
|
||||
# if defined(BOOST_MSVC)
|
||||
# if (_MSC_VER >= 1600)
|
||||
# define BOOST_ASIO_HAS_STD_SHARED_PTR
|
||||
# endif // (_MSC_VER >= 1600)
|
||||
# endif // defined(BOOST_MSVC)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_STD_SHARED_PTR)
|
||||
|
||||
// Standard library support for atomic operations.
|
||||
#if !defined(BOOST_ASIO_DISABLE_STD_ATOMIC)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define BOOST_ASIO_HAS_STD_ATOMIC
|
||||
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
|
||||
# endif // defined(__GNUC__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_STD_ATOMIC)
|
||||
|
||||
// Standard library support for chrono. Some standard libraries (such as the
|
||||
// libstdc++ shipped with gcc 4.6) provide monotonic_clock as per early C++0x
|
||||
// drafts, rather than the eventually standardised name of steady_clock.
|
||||
#if !defined(BOOST_ASIO_DISABLE_STD_CHRONO)
|
||||
# if defined(__GNUC__)
|
||||
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define BOOST_ASIO_HAS_STD_CHRONO
|
||||
# define BOOST_ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK
|
||||
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4)
|
||||
# endif // defined(__GNUC__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_STD_CHRONO)
|
||||
|
||||
// Boost support for chrono.
|
||||
#if !defined(BOOST_ASIO_DISABLE_BOOST_CHRONO)
|
||||
# if (BOOST_VERSION >= 104700)
|
||||
# define BOOST_ASIO_HAS_BOOST_CHRONO
|
||||
# endif // (BOOST_VERSION >= 104700)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_BOOST_CHRONO)
|
||||
|
||||
// Windows: target OS version.
|
||||
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
|
||||
# if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)
|
||||
@@ -181,6 +311,15 @@
|
||||
# endif // defined(BOOST_ASIO_HAS_IOCP)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
|
||||
|
||||
// Windows: object handles.
|
||||
#if !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
|
||||
# if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
|
||||
# if !defined(UNDER_CE)
|
||||
# define BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE 1
|
||||
# endif // !defined(UNDER_CE)
|
||||
# endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
|
||||
|
||||
// Windows: OVERLAPPED wrapper.
|
||||
#if !defined(BOOST_ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
|
||||
# if defined(BOOST_ASIO_HAS_IOCP)
|
||||
@@ -202,4 +341,18 @@
|
||||
# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_LOCAL_SOCKETS)
|
||||
|
||||
// Can use sigaction() instead of signal().
|
||||
#if !defined(BOOST_ASIO_DISABLE_SIGACTION)
|
||||
# if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
# define BOOST_ASIO_HAS_SIGACTION 1
|
||||
# endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_SIGACTION)
|
||||
|
||||
// Can use signal().
|
||||
#if !defined(BOOST_ASIO_DISABLE_SIGNAL)
|
||||
# if !defined(UNDER_CE)
|
||||
# define BOOST_ASIO_HAS_SIGNAL 1
|
||||
# endif // !defined(UNDER_CE)
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_SIGNAL)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CONFIG_HPP
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// detail/consuming_buffers.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user