mirror of
https://github.com/Vita3K/ext-boost.git
synced 2024-11-23 05:29:39 +00:00
Update to Boost 1.71.0
This commit is contained in:
parent
6b780f14b6
commit
509da24bc9
8
INSTALL
Normal file
8
INSTALL
Normal file
@ -0,0 +1,8 @@
|
||||
See ./index.html for information about this release. The "Getting Started"
|
||||
section is a useful starting place.
|
||||
|
||||
---------------------------
|
||||
Copyright Beman Dawes, 2008
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
See ./LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
|
61
Jamroot
61
Jamroot
@ -19,23 +19,28 @@
|
||||
# ======= configured locations (below).
|
||||
#
|
||||
# --prefix=<PREFIX> Install architecture independent files here.
|
||||
# Default; C:\Boost on Win32
|
||||
# Default; /usr/local on Unix. Linux, etc.
|
||||
# Default: C:\Boost on Windows
|
||||
# Default: /usr/local on Unix, Linux, etc.
|
||||
#
|
||||
# --exec-prefix=<EPREFIX> Install architecture dependent files here.
|
||||
# Default; <PREFIX>
|
||||
# Default: <PREFIX>
|
||||
#
|
||||
# --libdir=<DIR> Install library files here.
|
||||
# Default; <EPREFIX>/lib
|
||||
# --libdir=<LIBDIR> Install library files here.
|
||||
# Default: <EPREFIX>/lib
|
||||
#
|
||||
# --includedir=<HDRDIR> Install header files here.
|
||||
# Default; <PREFIX>/include
|
||||
# Default: <PREFIX>/include
|
||||
#
|
||||
# --cmakedir=<CMAKEDIR> Install CMake configuration files here.
|
||||
# Default: <LIBDIR>/cmake
|
||||
#
|
||||
# --no-cmake-config Do not install CMake configuration files.
|
||||
#
|
||||
# stage Build and install only compiled library files to the
|
||||
# ===== stage directory.
|
||||
#
|
||||
# --stagedir=<STAGEDIR> Install library files here
|
||||
# Default; ./stage
|
||||
# Default: ./stage
|
||||
#
|
||||
# Other Options:
|
||||
#
|
||||
@ -135,9 +140,11 @@ import "class" : new ;
|
||||
import property-set ;
|
||||
import threadapi-feature ;
|
||||
import option ;
|
||||
# Backslash because of `bcp --namespace`
|
||||
import tools/boost\_install/boost-install ;
|
||||
|
||||
path-constant BOOST_ROOT : . ;
|
||||
constant BOOST_VERSION : 1.67.0 ;
|
||||
constant BOOST_VERSION : 1.71.0 ;
|
||||
constant BOOST_JAMROOT_MODULE : $(__name__) ;
|
||||
|
||||
boostcpp.set-version $(BOOST_VERSION) ;
|
||||
@ -177,6 +184,9 @@ project boost
|
||||
<xsl:param>boost.defaults=Boost
|
||||
<conditional>@threadapi-feature.detect
|
||||
: usage-requirements <include>.
|
||||
: default-build
|
||||
<visibility>hidden
|
||||
<threading>multi
|
||||
: build-dir bin.v2
|
||||
;
|
||||
|
||||
@ -242,7 +252,7 @@ explicit-alias serialization : libs/serialization/build//boost_serialization ;
|
||||
explicit-alias wserialization : libs/serialization/build//boost_wserialization ;
|
||||
for local l in $(all-libraries)
|
||||
{
|
||||
if ! $(l) in test graph serialization
|
||||
if ! $(l) in test graph serialization headers
|
||||
{
|
||||
explicit-alias $(l) : libs/$(l)/build//boost_$(l) ;
|
||||
}
|
||||
@ -284,39 +294,26 @@ if [ path.exists $(BOOST_ROOT)/libs/wave/tool/build ]
|
||||
use-project /boost/libs/wave/tool : libs/wave/tool/build ;
|
||||
}
|
||||
|
||||
# Make the boost-install rule visible in subprojects
|
||||
|
||||
# This rule should be called from libraries' Jamfiles and will create two
|
||||
# targets, "install" and "stage", that will install or stage that library. The
|
||||
# --prefix option is respected, but --with and --without options, naturally, are
|
||||
# ignored.
|
||||
#
|
||||
# - libraries -- list of library targets to install.
|
||||
#
|
||||
|
||||
rule boost-install ( libraries * )
|
||||
{
|
||||
package.install install
|
||||
: <dependency>/boost//install-proper-headers $(install-requirements)
|
||||
: # No binaries
|
||||
: $(libraries)
|
||||
: # No headers, it is handled by the dependency.
|
||||
;
|
||||
|
||||
local stage-locate = [ option.get stagedir : $(BOOST_ROOT)/stage ] ;
|
||||
|
||||
install stage : $(libraries) : <location>$(stage-locate)/lib ;
|
||||
|
||||
module [ CALLER_MODULE ]
|
||||
{
|
||||
explicit stage ;
|
||||
explicit install ;
|
||||
}
|
||||
boost-install.boost-install $(libraries) ;
|
||||
}
|
||||
|
||||
# Creates a library target, adding autolink support and also creates
|
||||
# stage and install targets via boost-install, above.
|
||||
rule boost-lib ( name : sources * : requirements * : default-build * : usage-requirements * )
|
||||
{
|
||||
autolink = <link>shared:<define>BOOST_$(name:U)_DYN_LINK=1 ;
|
||||
name = boost_$(name) ;
|
||||
autolink = <link>shared:<define>$(name:U)_DYN_LINK=1 ;
|
||||
lib $(name)
|
||||
: $(sources)
|
||||
: $(requirements) $(autolink)
|
||||
@ -327,14 +324,6 @@ rule boost-lib ( name : sources * : requirements * : default-build * : usage-req
|
||||
}
|
||||
|
||||
|
||||
headers =
|
||||
# The .SUNWCCh files are present in tr1 include directory and have to be
|
||||
# installed (see http://lists.boost.org/Archives/boost/2007/05/121430.php).
|
||||
[ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ]
|
||||
[ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ]
|
||||
[ path.glob $(BOOST_ROOT)/boost/tr1/tr1 : * : bcc32 sun CVS .svn ]
|
||||
;
|
||||
|
||||
# Declare special top-level targets that build and install the desired variants
|
||||
# of the libraries.
|
||||
boostcpp.declare-targets $(all-libraries) : $(headers) : $(all-headers) ;
|
||||
boostcpp.declare-targets $(all-libraries) ;
|
||||
|
@ -27,7 +27,7 @@ namespace boost { namespace algorithm {
|
||||
///
|
||||
/// \note This function is part of the C++2011 standard library.
|
||||
template<typename InputIterator, typename Predicate>
|
||||
bool all_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( !p(*first))
|
||||
@ -43,7 +43,7 @@ bool all_of ( InputIterator first, InputIterator last, Predicate p )
|
||||
/// \param p A predicate for testing the elements of the range
|
||||
///
|
||||
template<typename Range, typename Predicate>
|
||||
bool all_of ( const Range &r, Predicate p )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of ( const Range &r, Predicate p )
|
||||
{
|
||||
return boost::algorithm::all_of ( boost::begin (r), boost::end (r), p );
|
||||
}
|
||||
@ -57,7 +57,7 @@ bool all_of ( const Range &r, Predicate p )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename InputIterator, typename T>
|
||||
bool all_of_equal ( InputIterator first, InputIterator last, const T &val )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of_equal ( InputIterator first, InputIterator last, const T &val )
|
||||
{
|
||||
for ( ; first != last; ++first )
|
||||
if ( val != *first )
|
||||
@ -73,7 +73,7 @@ bool all_of_equal ( InputIterator first, InputIterator last, const T &val )
|
||||
/// \param val A value to compare against
|
||||
///
|
||||
template<typename Range, typename T>
|
||||
bool all_of_equal ( const Range &r, const T &val )
|
||||
BOOST_CXX14_CONSTEXPR bool all_of_equal ( const Range &r, const T &val )
|
||||
{
|
||||
return boost::algorithm::all_of_equal ( boost::begin (r), boost::end (r), val );
|
||||
}
|
||||
|
31
boost/algorithm/string.hpp
Normal file
31
boost/algorithm/string.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Boost string_algo library string_algo.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2004.
|
||||
//
|
||||
// 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_ALGO_HPP
|
||||
#define BOOST_STRING_ALGO_HPP
|
||||
|
||||
/*! \file
|
||||
Cumulative include for string_algo library
|
||||
*/
|
||||
|
||||
#include <boost/algorithm/string/std_containers_traits.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/erase.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/find_iterator.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_STRING_ALGO_HPP
|
176
boost/algorithm/string/case_conv.hpp
Normal file
176
boost/algorithm/string/case_conv.hpp
Normal file
@ -0,0 +1,176 @@
|
||||
// Boost string_algo library case_conv.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_CASE_CONV_HPP
|
||||
#define BOOST_STRING_CASE_CONV_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/case_conv.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines sequence case-conversion algorithms.
|
||||
Algorithms convert each element in the input sequence to the
|
||||
desired case using provided locales.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// to_lower -----------------------------------------------//
|
||||
|
||||
//! Convert to lower case
|
||||
/*!
|
||||
Each element of the input sequence is converted to lower
|
||||
case. The result is a copy of the input converted to lower case.
|
||||
It is returned as a sequence or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input range
|
||||
\param Loc A locale used for conversion
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
a copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT
|
||||
to_lower_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy(
|
||||
Output,
|
||||
::boost::as_literal(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to lower case
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT to_lower_copy(
|
||||
const SequenceT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||
Input,
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<SequenceT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to lower case
|
||||
/*!
|
||||
Each element of the input sequence is converted to lower
|
||||
case. The input sequence is modified in-place.
|
||||
|
||||
\param Input A range
|
||||
\param Loc a locale used for conversion
|
||||
*/
|
||||
template<typename WritableRangeT>
|
||||
inline void to_lower(
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
::boost::algorithm::detail::transform_range(
|
||||
::boost::as_literal(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
// to_upper -----------------------------------------------//
|
||||
|
||||
//! Convert to upper case
|
||||
/*!
|
||||
Each element of the input sequence is converted to upper
|
||||
case. The result is a copy of the input converted to upper case.
|
||||
It is returned as a sequence or copied to the output iterator
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input range
|
||||
\param Loc A locale used for conversion
|
||||
\return
|
||||
An output iterator pointing just after the last inserted character or
|
||||
a copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT
|
||||
to_upper_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy(
|
||||
Output,
|
||||
::boost::as_literal(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to upper case
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT to_upper_copy(
|
||||
const SequenceT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||
Input,
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<SequenceT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to upper case
|
||||
/*!
|
||||
Each element of the input sequence is converted to upper
|
||||
case. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input range
|
||||
\param Loc a locale used for conversion
|
||||
*/
|
||||
template<typename WritableRangeT>
|
||||
inline void to_upper(
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
::boost::algorithm::detail::transform_range(
|
||||
::boost::as_literal(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::to_lower;
|
||||
using algorithm::to_lower_copy;
|
||||
using algorithm::to_upper;
|
||||
using algorithm::to_upper_copy;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_CASE_CONV_HPP
|
127
boost/algorithm/string/detail/case_conv.hpp
Normal file
127
boost/algorithm/string/detail/case_conv.hpp
Normal file
@ -0,0 +1,127 @@
|
||||
// Boost string_algo library string_funct.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_CASE_CONV_DETAIL_HPP
|
||||
#define BOOST_STRING_CASE_CONV_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <locale>
|
||||
#include <functional>
|
||||
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// case conversion functors -----------------------------------------------//
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4512) //assignment operator could not be generated
|
||||
#endif
|
||||
|
||||
// a tolower functor
|
||||
template<typename CharT>
|
||||
struct to_lowerF
|
||||
{
|
||||
typedef CharT argument_type;
|
||||
typedef CharT result_type;
|
||||
// Constructor
|
||||
to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {}
|
||||
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::tolower( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
|
||||
#else
|
||||
return std::tolower<CharT>( Ch, *m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale* m_Loc;
|
||||
};
|
||||
|
||||
// a toupper functor
|
||||
template<typename CharT>
|
||||
struct to_upperF
|
||||
{
|
||||
typedef CharT argument_type;
|
||||
typedef CharT result_type;
|
||||
// Constructor
|
||||
to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {}
|
||||
|
||||
// Operation
|
||||
CharT operator ()( CharT Ch ) const
|
||||
{
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
|
||||
return std::toupper( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
|
||||
#else
|
||||
return std::toupper<CharT>( Ch, *m_Loc );
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
const std::locale* m_Loc;
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// algorithm implementation -------------------------------------------------------------------------
|
||||
|
||||
// Transform a range
|
||||
template<typename OutputIteratorT, typename RangeT, typename FunctorT>
|
||||
OutputIteratorT transform_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
return std::transform(
|
||||
::boost::begin(Input),
|
||||
::boost::end(Input),
|
||||
Output,
|
||||
Functor);
|
||||
}
|
||||
|
||||
// Transform a range (in-place)
|
||||
template<typename RangeT, typename FunctorT>
|
||||
void transform_range(
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
std::transform(
|
||||
::boost::begin(Input),
|
||||
::boost::end(Input),
|
||||
::boost::begin(Input),
|
||||
Functor);
|
||||
}
|
||||
|
||||
template<typename SequenceT, typename RangeT, typename FunctorT>
|
||||
inline SequenceT transform_range_copy(
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
return SequenceT(
|
||||
::boost::make_transform_iterator(
|
||||
::boost::begin(Input),
|
||||
Functor),
|
||||
::boost::make_transform_iterator(
|
||||
::boost::end(Input),
|
||||
Functor));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_CASE_CONV_DETAIL_HPP
|
204
boost/algorithm/string/detail/find_format.hpp
Normal file
204
boost/algorithm/string/detail/find_format.hpp
Normal file
@ -0,0 +1,204 @@
|
||||
// Boost string_algo library find_format.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_FIND_FORMAT_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_store.hpp>
|
||||
#include <boost/algorithm/string/detail/replace_storage.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// find_format_copy (iterator variant) implementation -------------------------------//
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline OutputIteratorT find_format_copy_impl2(
|
||||
OutputIteratorT Output,
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult )
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Match not found - return original sequence
|
||||
Output = std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
return Output;
|
||||
}
|
||||
|
||||
// Copy the beginning of the sequence
|
||||
Output = std::copy( ::boost::begin(Input), ::boost::begin(M), Output );
|
||||
// Format find result
|
||||
// Copy formatted result
|
||||
Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
|
||||
// Copy the rest of the sequence
|
||||
Output = std::copy( M.end(), ::boost::end(Input), Output );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline OutputIteratorT find_format_copy_impl(
|
||||
OutputIteratorT Output,
|
||||
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) );
|
||||
} else {
|
||||
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// find_format_copy implementation --------------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline InputT find_format_copy_impl2(
|
||||
const InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Match not found - return original sequence
|
||||
return InputT( Input );
|
||||
}
|
||||
|
||||
InputT Output;
|
||||
// Copy the beginning of the sequence
|
||||
boost::algorithm::detail::insert( Output, ::boost::end(Output), ::boost::begin(Input), M.begin() );
|
||||
// Copy formatted result
|
||||
boost::algorithm::detail::insert( Output, ::boost::end(Output), M.format_result() );
|
||||
// Copy the rest of the sequence
|
||||
boost::algorithm::detail::insert( Output, ::boost::end(Output), M.end(), ::boost::end(Input) );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline InputT find_format_copy_impl(
|
||||
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(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return Input;
|
||||
}
|
||||
}
|
||||
|
||||
// replace implementation ----------------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline void find_format_impl2(
|
||||
InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef find_format_store<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_iterator<InputT>::type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
if ( !M )
|
||||
{
|
||||
// Search not found - return original sequence
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace match
|
||||
::boost::algorithm::detail::replace( Input, M.begin(), M.end(), M.format_result() );
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline void find_format_impl(
|
||||
InputT& Input,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
::boost::algorithm::detail::find_format_impl2(
|
||||
Input,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_DETAIL_HPP
|
273
boost/algorithm/string/detail/find_format_all.hpp
Normal file
273
boost/algorithm/string/detail/find_format_all.hpp
Normal file
@ -0,0 +1,273 @@
|
||||
// Boost string_algo library find_format_all.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_FIND_FORMAT_ALL_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_store.hpp>
|
||||
#include <boost/algorithm/string/detail/replace_storage.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// find_format_all_copy (iterator variant) implementation ---------------------------//
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline OutputIteratorT find_format_all_copy_impl2(
|
||||
OutputIteratorT Output,
|
||||
const InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult )
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
// Initialize last match
|
||||
input_iterator_type LastMatch=::boost::begin(Input);
|
||||
|
||||
// Iterate through all matches
|
||||
while( M )
|
||||
{
|
||||
// Copy the beginning of the sequence
|
||||
Output = std::copy( LastMatch, M.begin(), Output );
|
||||
// Copy formatted result
|
||||
Output = std::copy( ::boost::begin(M.format_result()), ::boost::end(M.format_result()), Output );
|
||||
|
||||
// Proceed to the next match
|
||||
LastMatch=M.end();
|
||||
M=Finder( LastMatch, ::boost::end(Input) );
|
||||
}
|
||||
|
||||
// Copy the rest of the sequence
|
||||
Output = std::copy( LastMatch, ::boost::end(Input), Output );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline OutputIteratorT find_format_all_copy_impl(
|
||||
OutputIteratorT Output,
|
||||
const InputT& Input,
|
||||
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) );
|
||||
} else {
|
||||
return std::copy( ::boost::begin(Input), ::boost::end(Input), Output );
|
||||
}
|
||||
}
|
||||
|
||||
// find_format_all_copy implementation ----------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline InputT find_format_all_copy_impl2(
|
||||
const InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
const FindResultT& FindResult,
|
||||
const FormatResultT& FormatResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
// Initialize last match
|
||||
input_iterator_type LastMatch=::boost::begin(Input);
|
||||
|
||||
// Output temporary
|
||||
InputT Output;
|
||||
|
||||
// Iterate through all matches
|
||||
while( M )
|
||||
{
|
||||
// Copy the beginning of the sequence
|
||||
boost::algorithm::detail::insert( Output, ::boost::end(Output), LastMatch, M.begin() );
|
||||
// Copy formatted result
|
||||
boost::algorithm::detail::insert( Output, ::boost::end(Output), M.format_result() );
|
||||
|
||||
// Proceed to the next match
|
||||
LastMatch=M.end();
|
||||
M=Finder( LastMatch, ::boost::end(Input) );
|
||||
}
|
||||
|
||||
// Copy the rest of the sequence
|
||||
::boost::algorithm::detail::insert( Output, ::boost::end(Output), LastMatch, ::boost::end(Input) );
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline InputT find_format_all_copy_impl(
|
||||
const InputT& Input,
|
||||
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(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
} else {
|
||||
return Input;
|
||||
}
|
||||
}
|
||||
|
||||
// find_format_all implementation ------------------------------------------------//
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT,
|
||||
typename FormatResultT >
|
||||
inline void find_format_all_impl2(
|
||||
InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
FindResultT FindResult,
|
||||
FormatResultT FormatResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_iterator<InputT>::type input_iterator_type;
|
||||
typedef find_format_store<
|
||||
input_iterator_type,
|
||||
FormatterT,
|
||||
FormatResultT > store_type;
|
||||
|
||||
// Create store for the find result
|
||||
store_type M( FindResult, FormatResult, Formatter );
|
||||
|
||||
// Instantiate replacement storage
|
||||
std::deque<
|
||||
BOOST_STRING_TYPENAME range_value<InputT>::type> Storage;
|
||||
|
||||
// Initialize replacement iterators
|
||||
input_iterator_type InsertIt=::boost::begin(Input);
|
||||
input_iterator_type SearchIt=::boost::begin(Input);
|
||||
|
||||
while( M )
|
||||
{
|
||||
// process the segment
|
||||
InsertIt=process_segment(
|
||||
Storage,
|
||||
Input,
|
||||
InsertIt,
|
||||
SearchIt,
|
||||
M.begin() );
|
||||
|
||||
// Adjust search iterator
|
||||
SearchIt=M.end();
|
||||
|
||||
// Copy formatted replace to the storage
|
||||
::boost::algorithm::detail::copy_to_storage( Storage, M.format_result() );
|
||||
|
||||
// Find range for a next match
|
||||
M=Finder( SearchIt, ::boost::end(Input) );
|
||||
}
|
||||
|
||||
// process the last segment
|
||||
InsertIt=::boost::algorithm::detail::process_segment(
|
||||
Storage,
|
||||
Input,
|
||||
InsertIt,
|
||||
SearchIt,
|
||||
::boost::end(Input) );
|
||||
|
||||
if ( Storage.empty() )
|
||||
{
|
||||
// Truncate input
|
||||
::boost::algorithm::detail::erase( Input, InsertIt, ::boost::end(Input) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy remaining data to the end of input
|
||||
::boost::algorithm::detail::insert( Input, ::boost::end(Input), Storage.begin(), Storage.end() );
|
||||
}
|
||||
}
|
||||
|
||||
template<
|
||||
typename InputT,
|
||||
typename FinderT,
|
||||
typename FormatterT,
|
||||
typename FindResultT >
|
||||
inline void find_format_all_impl(
|
||||
InputT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter,
|
||||
FindResultT FindResult)
|
||||
{
|
||||
if( ::boost::algorithm::detail::check_find_result(Input, FindResult) ) {
|
||||
::boost::algorithm::detail::find_format_all_impl2(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
FindResult,
|
||||
Formatter(FindResult) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
|
89
boost/algorithm/string/detail/find_format_store.hpp
Normal file
89
boost/algorithm/string/detail/find_format_store.hpp
Normal file
@ -0,0 +1,89 @@
|
||||
// Boost string_algo library find_format_store.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_FIND_FORMAT_STORE_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// temporary format and find result storage --------------------------------//
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4512) //assignment operator could not be generated
|
||||
#endif
|
||||
template<
|
||||
typename ForwardIteratorT,
|
||||
typename FormatterT,
|
||||
typename FormatResultT >
|
||||
class find_format_store :
|
||||
public iterator_range<ForwardIteratorT>
|
||||
{
|
||||
public:
|
||||
// typedefs
|
||||
typedef iterator_range<ForwardIteratorT> base_type;
|
||||
typedef FormatterT formatter_type;
|
||||
typedef FormatResultT format_result_type;
|
||||
|
||||
public:
|
||||
// Construction
|
||||
find_format_store(
|
||||
const base_type& FindResult,
|
||||
const format_result_type& FormatResult,
|
||||
const formatter_type& Formatter ) :
|
||||
base_type(FindResult),
|
||||
m_FormatResult(FormatResult),
|
||||
m_Formatter(Formatter) {}
|
||||
|
||||
// Assignment
|
||||
template< typename FindResultT >
|
||||
find_format_store& operator=( FindResultT FindResult )
|
||||
{
|
||||
iterator_range<ForwardIteratorT>::operator=(FindResult);
|
||||
if( !this->empty() ) {
|
||||
m_FormatResult=m_Formatter(FindResult);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Retrieve format result
|
||||
const format_result_type& format_result()
|
||||
{
|
||||
return m_FormatResult;
|
||||
}
|
||||
|
||||
private:
|
||||
format_result_type m_FormatResult;
|
||||
const formatter_type& m_Formatter;
|
||||
};
|
||||
|
||||
template<typename InputT, typename FindResultT>
|
||||
bool check_find_result(InputT&, FindResultT& FindResult)
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<InputT>::type input_iterator_type;
|
||||
iterator_range<input_iterator_type> ResultRange(FindResult);
|
||||
return !ResultRange.empty();
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
|
119
boost/algorithm/string/detail/formatter.hpp
Normal file
119
boost/algorithm/string/detail/formatter.hpp
Normal file
@ -0,0 +1,119 @@
|
||||
// Boost string_algo library formatter.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_FORMATTER_DETAIL_HPP
|
||||
#define BOOST_STRING_FORMATTER_DETAIL_HPP
|
||||
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/util.hpp>
|
||||
|
||||
// generic replace functors -----------------------------------------------//
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// const format functor ----------------------------------------------------//
|
||||
|
||||
// constant format functor
|
||||
template<typename RangeT>
|
||||
struct const_formatF
|
||||
{
|
||||
private:
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type format_iterator;
|
||||
typedef iterator_range<format_iterator> result_type;
|
||||
|
||||
public:
|
||||
// Construction
|
||||
const_formatF(const RangeT& Format) :
|
||||
m_Format(::boost::begin(Format), ::boost::end(Format)) {}
|
||||
|
||||
// Operation
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
template<typename Range2T>
|
||||
result_type& operator()(const Range2T&)
|
||||
{
|
||||
return m_Format;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename Range2T>
|
||||
const result_type& operator()(const Range2T&) const
|
||||
{
|
||||
return m_Format;
|
||||
}
|
||||
|
||||
private:
|
||||
result_type m_Format;
|
||||
};
|
||||
|
||||
// identity format functor ----------------------------------------------------//
|
||||
|
||||
// identity format functor
|
||||
template<typename RangeT>
|
||||
struct identity_formatF
|
||||
{
|
||||
// Operation
|
||||
template< typename Range2T >
|
||||
const RangeT& operator()(const Range2T& Replace) const
|
||||
{
|
||||
return RangeT(::boost::begin(Replace), ::boost::end(Replace));
|
||||
}
|
||||
};
|
||||
|
||||
// empty format functor ( used by erase ) ------------------------------------//
|
||||
|
||||
// empty format functor
|
||||
template< typename CharT >
|
||||
struct empty_formatF
|
||||
{
|
||||
template< typename ReplaceT >
|
||||
empty_container<CharT> operator()(const ReplaceT&) const
|
||||
{
|
||||
return empty_container<CharT>();
|
||||
}
|
||||
};
|
||||
|
||||
// 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
|
||||
|
||||
#endif // BOOST_STRING_FORMATTER_DETAIL_HPP
|
77
boost/algorithm/string/detail/predicate.hpp
Normal file
77
boost/algorithm/string/detail/predicate.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
// Boost string_algo library predicate.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_PREDICATE_DETAIL_HPP
|
||||
#define BOOST_STRING_PREDICATE_DETAIL_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// ends_with predicate implementation ----------------------------------//
|
||||
|
||||
template<
|
||||
typename ForwardIterator1T,
|
||||
typename ForwardIterator2T,
|
||||
typename PredicateT>
|
||||
inline bool ends_with_iter_select(
|
||||
ForwardIterator1T Begin,
|
||||
ForwardIterator1T End,
|
||||
ForwardIterator2T SubBegin,
|
||||
ForwardIterator2T SubEnd,
|
||||
PredicateT Comp,
|
||||
std::bidirectional_iterator_tag)
|
||||
{
|
||||
ForwardIterator1T it=End;
|
||||
ForwardIterator2T pit=SubEnd;
|
||||
for(;it!=Begin && pit!=SubBegin;)
|
||||
{
|
||||
if( !(Comp(*(--it),*(--pit))) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return pit==SubBegin;
|
||||
}
|
||||
|
||||
template<
|
||||
typename ForwardIterator1T,
|
||||
typename ForwardIterator2T,
|
||||
typename PredicateT>
|
||||
inline bool ends_with_iter_select(
|
||||
ForwardIterator1T Begin,
|
||||
ForwardIterator1T End,
|
||||
ForwardIterator2T SubBegin,
|
||||
ForwardIterator2T SubEnd,
|
||||
PredicateT Comp,
|
||||
std::forward_iterator_tag)
|
||||
{
|
||||
if ( SubBegin==SubEnd )
|
||||
{
|
||||
// empty subsequence check
|
||||
return true;
|
||||
}
|
||||
|
||||
iterator_range<ForwardIterator1T> Result
|
||||
=last_finder(
|
||||
::boost::make_iterator_range(SubBegin, SubEnd),
|
||||
Comp)(Begin, End);
|
||||
|
||||
return !Result.empty() && Result.end()==End;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_PREDICATE_DETAIL_HPP
|
159
boost/algorithm/string/detail/replace_storage.hpp
Normal file
159
boost/algorithm/string/detail/replace_storage.hpp
Normal file
@ -0,0 +1,159 @@
|
||||
// Boost string_algo library replace_storage.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_REPLACE_STORAGE_DETAIL_HPP
|
||||
#define BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
#include <boost/algorithm/string/detail/sequence.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// storage handling routines -----------------------------------------------//
|
||||
|
||||
template< typename StorageT, typename OutputIteratorT >
|
||||
inline OutputIteratorT move_from_storage(
|
||||
StorageT& Storage,
|
||||
OutputIteratorT DestBegin,
|
||||
OutputIteratorT DestEnd )
|
||||
{
|
||||
OutputIteratorT OutputIt=DestBegin;
|
||||
|
||||
while( !Storage.empty() && OutputIt!=DestEnd )
|
||||
{
|
||||
*OutputIt=Storage.front();
|
||||
Storage.pop_front();
|
||||
++OutputIt;
|
||||
}
|
||||
|
||||
return OutputIt;
|
||||
}
|
||||
|
||||
template< typename StorageT, typename WhatT >
|
||||
inline void copy_to_storage(
|
||||
StorageT& Storage,
|
||||
const WhatT& What )
|
||||
{
|
||||
Storage.insert( Storage.end(), ::boost::begin(What), ::boost::end(What) );
|
||||
}
|
||||
|
||||
|
||||
// process segment routine -----------------------------------------------//
|
||||
|
||||
template< bool HasStableIterators >
|
||||
struct process_segment_helper
|
||||
{
|
||||
// Optimized version of process_segment for generic sequence
|
||||
template<
|
||||
typename StorageT,
|
||||
typename InputT,
|
||||
typename ForwardIteratorT >
|
||||
ForwardIteratorT operator()(
|
||||
StorageT& Storage,
|
||||
InputT& /*Input*/,
|
||||
ForwardIteratorT InsertIt,
|
||||
ForwardIteratorT SegmentBegin,
|
||||
ForwardIteratorT SegmentEnd )
|
||||
{
|
||||
// Copy data from the storage until the beginning of the segment
|
||||
ForwardIteratorT It=::boost::algorithm::detail::move_from_storage( Storage, InsertIt, SegmentBegin );
|
||||
|
||||
// 3 cases are possible :
|
||||
// a) Storage is empty, It==SegmentBegin
|
||||
// b) Storage is empty, It!=SegmentBegin
|
||||
// c) Storage is not empty
|
||||
|
||||
if( Storage.empty() )
|
||||
{
|
||||
if( It==SegmentBegin )
|
||||
{
|
||||
// Case a) everything is grand, just return end of segment
|
||||
return SegmentEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case b) move the segment backwards
|
||||
return std::copy( SegmentBegin, SegmentEnd, It );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case c) -> shift the segment to the left and keep the overlap in the storage
|
||||
while( It!=SegmentEnd )
|
||||
{
|
||||
// Store value into storage
|
||||
Storage.push_back( *It );
|
||||
// Get the top from the storage and put it here
|
||||
*It=Storage.front();
|
||||
Storage.pop_front();
|
||||
|
||||
// Advance
|
||||
++It;
|
||||
}
|
||||
|
||||
return It;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct process_segment_helper< true >
|
||||
{
|
||||
// Optimized version of process_segment for list-like sequence
|
||||
template<
|
||||
typename StorageT,
|
||||
typename InputT,
|
||||
typename ForwardIteratorT >
|
||||
ForwardIteratorT operator()(
|
||||
StorageT& Storage,
|
||||
InputT& Input,
|
||||
ForwardIteratorT InsertIt,
|
||||
ForwardIteratorT SegmentBegin,
|
||||
ForwardIteratorT SegmentEnd )
|
||||
|
||||
{
|
||||
// Call replace to do the job
|
||||
::boost::algorithm::detail::replace( Input, InsertIt, SegmentBegin, Storage );
|
||||
// Empty the storage
|
||||
Storage.clear();
|
||||
// Iterators were not changed, simply return the end of segment
|
||||
return SegmentEnd;
|
||||
}
|
||||
};
|
||||
|
||||
// Process one segment in the replace_all algorithm
|
||||
template<
|
||||
typename StorageT,
|
||||
typename InputT,
|
||||
typename ForwardIteratorT >
|
||||
inline ForwardIteratorT process_segment(
|
||||
StorageT& Storage,
|
||||
InputT& Input,
|
||||
ForwardIteratorT InsertIt,
|
||||
ForwardIteratorT SegmentBegin,
|
||||
ForwardIteratorT SegmentEnd )
|
||||
{
|
||||
return
|
||||
process_segment_helper<
|
||||
has_stable_iterators<InputT>::value>()(
|
||||
Storage, Input, InsertIt, SegmentBegin, SegmentEnd );
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
|
200
boost/algorithm/string/detail/sequence.hpp
Normal file
200
boost/algorithm/string/detail/sequence.hpp
Normal file
@ -0,0 +1,200 @@
|
||||
// Boost string_algo library sequence.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_DETAIL_SEQUENCE_HPP
|
||||
#define BOOST_STRING_DETAIL_SEQUENCE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/logical.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// insert helpers -------------------------------------------------//
|
||||
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
inline void insert(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator At,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
Input.insert( At, Begin, End );
|
||||
}
|
||||
|
||||
template< typename InputT, typename InsertT >
|
||||
inline void insert(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator At,
|
||||
const InsertT& Insert )
|
||||
{
|
||||
::boost::algorithm::detail::insert( Input, At, ::boost::begin(Insert), ::boost::end(Insert) );
|
||||
}
|
||||
|
||||
// erase helper ---------------------------------------------------//
|
||||
|
||||
// Erase a range in the sequence
|
||||
/*
|
||||
Returns the iterator pointing just after the erase subrange
|
||||
*/
|
||||
template< typename InputT >
|
||||
inline typename InputT::iterator erase(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To )
|
||||
{
|
||||
return Input.erase( From, To );
|
||||
}
|
||||
|
||||
// replace helper implementation ----------------------------------//
|
||||
|
||||
// Optimized version of replace for generic sequence containers
|
||||
// Assumption: insert and erase are expensive
|
||||
template< bool HasConstTimeOperations >
|
||||
struct replace_const_time_helper
|
||||
{
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
// Copy data to the container ( as much as possible )
|
||||
ForwardIteratorT InsertIt=Begin;
|
||||
BOOST_STRING_TYPENAME InputT::iterator InputIt=From;
|
||||
for(; InsertIt!=End && InputIt!=To; InsertIt++, InputIt++ )
|
||||
{
|
||||
*InputIt=*InsertIt;
|
||||
}
|
||||
|
||||
if ( InsertIt!=End )
|
||||
{
|
||||
// Replace sequence is longer, insert it
|
||||
Input.insert( InputIt, InsertIt, End );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( InputIt!=To )
|
||||
{
|
||||
// Replace sequence is shorter, erase the rest
|
||||
Input.erase( InputIt, To );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct replace_const_time_helper< true >
|
||||
{
|
||||
// Const-time erase and insert methods -> use them
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
BOOST_STRING_TYPENAME InputT::iterator At=Input.erase( From, To );
|
||||
if ( Begin!=End )
|
||||
{
|
||||
if(!Input.empty())
|
||||
{
|
||||
Input.insert( At, Begin, End );
|
||||
}
|
||||
else
|
||||
{
|
||||
Input.insert( Input.begin(), Begin, End );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// No native replace method
|
||||
template< bool HasNative >
|
||||
struct replace_native_helper
|
||||
{
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
replace_const_time_helper<
|
||||
boost::mpl::and_<
|
||||
has_const_time_insert<InputT>,
|
||||
has_const_time_erase<InputT> >::value >()(
|
||||
Input, From, To, Begin, End );
|
||||
}
|
||||
};
|
||||
|
||||
// Container has native replace method
|
||||
template<>
|
||||
struct replace_native_helper< true >
|
||||
{
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
void operator()(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
Input.replace( From, To, Begin, End );
|
||||
}
|
||||
};
|
||||
|
||||
// replace helper -------------------------------------------------//
|
||||
|
||||
template< typename InputT, typename ForwardIteratorT >
|
||||
inline void replace(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
ForwardIteratorT Begin,
|
||||
ForwardIteratorT End )
|
||||
{
|
||||
replace_native_helper< has_native_replace<InputT>::value >()(
|
||||
Input, From, To, Begin, End );
|
||||
}
|
||||
|
||||
template< typename InputT, typename InsertT >
|
||||
inline void replace(
|
||||
InputT& Input,
|
||||
BOOST_STRING_TYPENAME InputT::iterator From,
|
||||
BOOST_STRING_TYPENAME InputT::iterator To,
|
||||
const InsertT& Insert )
|
||||
{
|
||||
if(From!=To)
|
||||
{
|
||||
::boost::algorithm::detail::replace( Input, From, To, ::boost::begin(Insert), ::boost::end(Insert) );
|
||||
}
|
||||
else
|
||||
{
|
||||
::boost::algorithm::detail::insert( Input, From, ::boost::begin(Insert), ::boost::end(Insert) );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_DETAIL_SEQUENCE_HPP
|
844
boost/algorithm/string/erase.hpp
Normal file
844
boost/algorithm/string/erase.hpp
Normal file
@ -0,0 +1,844 @@
|
||||
// Boost string_algo library erase.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// 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_ERASE_HPP
|
||||
#define BOOST_STRING_ERASE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines various erase algorithms. Each algorithm removes
|
||||
part(s) of the input according to a searching criteria.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// erase_range -------------------------------------------------------//
|
||||
|
||||
//! Erase range algorithm
|
||||
/*!
|
||||
Remove the given range from the input. The result is a modified copy of
|
||||
the input. It is returned as a sequence or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param SearchRange A range in the input to be removed
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename OutputIteratorT, typename RangeT>
|
||||
inline OutputIteratorT erase_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type>& SearchRange )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::range_finder(SearchRange),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase range algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT erase_range_copy(
|
||||
const SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<SequenceT>::type>& SearchRange )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::range_finder(SearchRange),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase range algorithm
|
||||
/*!
|
||||
Remove the given range from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param SearchRange A range in the input to be removed
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void erase_range(
|
||||
SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_iterator<SequenceT>::type>& SearchRange )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::range_finder(SearchRange),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_first --------------------------------------------------------//
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_first_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_first(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_first ( case insensitive ) ------------------------------------//
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_first_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase first algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the first occurrence of the substring from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_first(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_last --------------------------------------------------------//
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_last_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_last(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_last ( case insensitive ) ------------------------------------//
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_last_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase last algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the last occurrence of the substring from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_last(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_nth --------------------------------------------------------------------//
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_nth(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_nth ( case insensitive ) ---------------------------------------------//
|
||||
|
||||
//! Erase nth algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase nth algorithm
|
||||
/*!
|
||||
Remove the Nth occurrence of the substring in the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_nth(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
|
||||
// erase_all --------------------------------------------------------//
|
||||
|
||||
//! Erase all algorithm
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param Search A substring to be searched for.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT erase_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT erase_all_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void erase_all(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search )
|
||||
{
|
||||
::boost::algorithm::find_format_all(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_all ( case insensitive ) ------------------------------------//
|
||||
|
||||
//! Erase all algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT ierase_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT ierase_all_copy(
|
||||
const SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
//! Erase all algorithm ( case insensitive )
|
||||
/*!
|
||||
Remove all the occurrences of the string from the input.
|
||||
The input sequence is modified in-place. Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void ierase_all(
|
||||
SequenceT& Input,
|
||||
const RangeT& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format_all(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::empty_formatter(Input) );
|
||||
}
|
||||
|
||||
// erase_head --------------------------------------------------------------------//
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
Remove the head from the input. The head is a prefix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The result is a modified copy of the input.
|
||||
It is returned as a sequence or copied to the output iterator.
|
||||
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT>
|
||||
inline OutputIteratorT erase_head_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
int N )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::head_finder(N),
|
||||
::boost::algorithm::empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT erase_head_copy(
|
||||
const SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::head_finder(N),
|
||||
::boost::algorithm::empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase head algorithm
|
||||
/*!
|
||||
Remove the head from the input. The head is a prefix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the head
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void erase_head(
|
||||
SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::head_finder(N),
|
||||
::boost::algorithm::empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
// erase_tail --------------------------------------------------------------------//
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
Remove the tail from the input. The tail is a suffix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT>
|
||||
inline OutputIteratorT erase_tail_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
int N )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::tail_finder(N),
|
||||
::boost::algorithm::empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline SequenceT erase_tail_copy(
|
||||
const SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::tail_finder(N),
|
||||
::boost::algorithm::empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
//! Erase tail algorithm
|
||||
/*!
|
||||
Remove the tail from the input. The tail is a suffix of a sequence of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the tail
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
*/
|
||||
template<typename SequenceT>
|
||||
inline void erase_tail(
|
||||
SequenceT& Input,
|
||||
int N )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::tail_finder(N),
|
||||
::boost::algorithm::empty_formatter( Input ) );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names into the boost namespace
|
||||
using algorithm::erase_range_copy;
|
||||
using algorithm::erase_range;
|
||||
using algorithm::erase_first_copy;
|
||||
using algorithm::erase_first;
|
||||
using algorithm::ierase_first_copy;
|
||||
using algorithm::ierase_first;
|
||||
using algorithm::erase_last_copy;
|
||||
using algorithm::erase_last;
|
||||
using algorithm::ierase_last_copy;
|
||||
using algorithm::ierase_last;
|
||||
using algorithm::erase_nth_copy;
|
||||
using algorithm::erase_nth;
|
||||
using algorithm::ierase_nth_copy;
|
||||
using algorithm::ierase_nth;
|
||||
using algorithm::erase_all_copy;
|
||||
using algorithm::erase_all;
|
||||
using algorithm::ierase_all_copy;
|
||||
using algorithm::ierase_all;
|
||||
using algorithm::erase_head_copy;
|
||||
using algorithm::erase_head;
|
||||
using algorithm::erase_tail_copy;
|
||||
using algorithm::erase_tail;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_ERASE_HPP
|
334
boost/algorithm/string/find.hpp
Normal file
334
boost/algorithm/string/find.hpp
Normal file
@ -0,0 +1,334 @@
|
||||
// Boost string_algo library find.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_FIND_HPP
|
||||
#define BOOST_STRING_FIND_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
#include <boost/algorithm/string/constants.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines a set of find algorithms. The algorithms are searching
|
||||
for a substring of the input. The result is given as an \c iterator_range
|
||||
delimiting the substring.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// Generic find -----------------------------------------------//
|
||||
|
||||
//! Generic find algorithm
|
||||
/*!
|
||||
Search the input using the given finder.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Finder Finder object used for searching.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
*/
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find(
|
||||
RangeT& Input,
|
||||
const FinderT& Finder)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(::boost::as_literal(Input));
|
||||
|
||||
return Finder(::boost::begin(lit_input),::boost::end(lit_input));
|
||||
}
|
||||
|
||||
// find_first -----------------------------------------------//
|
||||
|
||||
//! Find first algorithm
|
||||
/*!
|
||||
Search for the first occurrence of the substring in the input.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_first(
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::first_finder(Search));
|
||||
}
|
||||
|
||||
//! Find first algorithm ( case insensitive )
|
||||
/*!
|
||||
Search for the first occurrence of the substring in the input.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_first(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::first_finder(Search,is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_last -----------------------------------------------//
|
||||
|
||||
//! Find last algorithm
|
||||
/*!
|
||||
Search for the last occurrence of the substring in the input.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_last(
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::last_finder(Search));
|
||||
}
|
||||
|
||||
//! Find last algorithm ( case insensitive )
|
||||
/*!
|
||||
Search for the last match a string in the input.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_last(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::last_finder(Search, is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_nth ----------------------------------------------------------------------//
|
||||
|
||||
//! Find n-th algorithm
|
||||
/*!
|
||||
Search for the n-th (zero-indexed) occurrence of the substring in the
|
||||
input.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index (zero-indexed) of the match to be found.
|
||||
For negative N, the matches are counted from the end of string.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_nth(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth)
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::nth_finder(Search,Nth));
|
||||
}
|
||||
|
||||
//! Find n-th algorithm ( case insensitive ).
|
||||
/*!
|
||||
Search for the n-th (zero-indexed) occurrence of the substring in the
|
||||
input. Searching is case insensitive.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index (zero-indexed) of the match to be found.
|
||||
For negative N, the matches are counted from the end of string.
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_nth(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::nth_finder(Search,Nth,is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_head ----------------------------------------------------------------------//
|
||||
|
||||
//! Find head algorithm
|
||||
/*!
|
||||
Get the head of the input. Head is a prefix of the string of the
|
||||
given size. If the input is shorter then required, whole input is considered
|
||||
to be the head.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the head
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, at most size(Input)-|N| characters are extracted.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c Range1T::iterator or
|
||||
\c Range1T::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_head(
|
||||
RangeT& Input,
|
||||
int N)
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::head_finder(N));
|
||||
}
|
||||
|
||||
// find_tail ----------------------------------------------------------------------//
|
||||
|
||||
//! Find tail algorithm
|
||||
/*!
|
||||
Get the tail of the input. Tail is a suffix of the string of the
|
||||
given size. If the input is shorter then required, whole input is considered
|
||||
to be the tail.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, at most size(Input)-|N| characters are extracted.
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_tail(
|
||||
RangeT& Input,
|
||||
int N)
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::tail_finder(N));
|
||||
}
|
||||
|
||||
// find_token --------------------------------------------------------------------//
|
||||
|
||||
//! Find token algorithm
|
||||
/*!
|
||||
Look for a given token in the string. Token is a character that matches the
|
||||
given predicate.
|
||||
If the "token compress mode" is enabled, adjacent tokens are considered to be one match.
|
||||
|
||||
\param Input A input string.
|
||||
\param Pred A unary predicate to identify a token
|
||||
\param eCompress Enable/Disable compressing of adjacent tokens
|
||||
\return
|
||||
An \c iterator_range delimiting the match.
|
||||
Returned iterator is either \c RangeT::iterator or
|
||||
\c RangeT::const_iterator, depending on the constness of
|
||||
the input parameter.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_token(
|
||||
RangeT& Input,
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off)
|
||||
{
|
||||
return ::boost::algorithm::find(Input, ::boost::algorithm::token_finder(Pred, eCompress));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::find;
|
||||
using algorithm::find_first;
|
||||
using algorithm::ifind_first;
|
||||
using algorithm::find_last;
|
||||
using algorithm::ifind_last;
|
||||
using algorithm::find_nth;
|
||||
using algorithm::ifind_nth;
|
||||
using algorithm::find_head;
|
||||
using algorithm::find_tail;
|
||||
using algorithm::find_token;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_FIND_HPP
|
287
boost/algorithm/string/find_format.hpp
Normal file
287
boost/algorithm/string/find_format.hpp
Normal file
@ -0,0 +1,287 @@
|
||||
// Boost string_algo library find_format.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_FIND_FORMAT_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_HPP
|
||||
|
||||
#include <deque>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/concept.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format.hpp>
|
||||
#include <boost/algorithm/string/detail/find_format_all.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines generic replace algorithms. Each algorithm replaces
|
||||
part(s) of the input. The part to be replaced is looked up using a Finder object.
|
||||
Result of finding is then used by a Formatter object to generate the replacement.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// generic replace -----------------------------------------------------------------//
|
||||
|
||||
//! Generic replace algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline OutputIteratorT find_format_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FinderConcept<
|
||||
FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
|
||||
));
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
|
||||
));
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input));
|
||||
|
||||
return detail::find_format_copy_impl(
|
||||
Output,
|
||||
lit_input,
|
||||
Formatter,
|
||||
Finder( ::boost::begin(lit_input), ::boost::end(lit_input) ) );
|
||||
}
|
||||
|
||||
//! Generic replace algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline SequenceT find_format_copy(
|
||||
const SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FinderConcept<
|
||||
FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
|
||||
return detail::find_format_copy_impl(
|
||||
Input,
|
||||
Formatter,
|
||||
Finder(::boost::begin(Input), ::boost::end(Input)));
|
||||
}
|
||||
|
||||
//! Generic replace algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input. The input is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline void find_format(
|
||||
SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter)
|
||||
{
|
||||
// Concept check
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FinderConcept<
|
||||
FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
|
||||
detail::find_format_impl(
|
||||
Input,
|
||||
Formatter,
|
||||
Finder(::boost::begin(Input), ::boost::end(Input)));
|
||||
}
|
||||
|
||||
|
||||
// find_format_all generic ----------------------------------------------------------------//
|
||||
|
||||
//! Generic replace all algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input. Repeat this for all matching
|
||||
substrings.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename RangeT,
|
||||
typename FinderT,
|
||||
typename FormatterT>
|
||||
inline OutputIteratorT find_format_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const RangeT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter)
|
||||
{
|
||||
// Concept check
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FinderConcept<
|
||||
FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
|
||||
));
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
|
||||
));
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input));
|
||||
|
||||
return detail::find_format_all_copy_impl(
|
||||
Output,
|
||||
lit_input,
|
||||
Finder,
|
||||
Formatter,
|
||||
Finder(::boost::begin(lit_input), ::boost::end(lit_input)));
|
||||
}
|
||||
|
||||
//! Generic replace all algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT >
|
||||
inline SequenceT find_format_all_copy(
|
||||
const SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FinderConcept<
|
||||
FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
|
||||
return detail::find_format_all_copy_impl(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
Finder( ::boost::begin(Input), ::boost::end(Input) ) );
|
||||
}
|
||||
|
||||
//! Generic replace all algorithm
|
||||
/*!
|
||||
Use the Finder to search for a substring. Use the Formatter to format
|
||||
this substring and replace it in the input. Repeat this for all matching
|
||||
substrings.The input is modified in-place.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Finder A Finder object used to search for a match to be replaced
|
||||
\param Formatter A Formatter object used to format a match
|
||||
*/
|
||||
template<
|
||||
typename SequenceT,
|
||||
typename FinderT,
|
||||
typename FormatterT >
|
||||
inline void find_format_all(
|
||||
SequenceT& Input,
|
||||
FinderT Finder,
|
||||
FormatterT Formatter )
|
||||
{
|
||||
// Concept check
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FinderConcept<
|
||||
FinderT,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
FormatterConcept<
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
|
||||
));
|
||||
|
||||
detail::find_format_all_impl(
|
||||
Input,
|
||||
Finder,
|
||||
Formatter,
|
||||
Finder(::boost::begin(Input), ::boost::end(Input)));
|
||||
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::find_format_copy;
|
||||
using algorithm::find_format;
|
||||
using algorithm::find_format_all_copy;
|
||||
using algorithm::find_format_all;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_FIND_FORMAT_HPP
|
@ -43,7 +43,6 @@ namespace boost {
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param Search A substring to be searched for.
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c first_finder object
|
||||
*/
|
||||
template<typename RangeT>
|
||||
@ -84,7 +83,6 @@ namespace boost {
|
||||
The result is given as an \c iterator_range delimiting the match.
|
||||
|
||||
\param Search A substring to be searched for.
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c last_finder object
|
||||
*/
|
||||
template<typename RangeT>
|
||||
@ -124,7 +122,6 @@ namespace boost {
|
||||
|
||||
\param Search A substring to be searched for.
|
||||
\param Nth An index of the match to be find
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c nth_finder object
|
||||
*/
|
||||
template<typename RangeT>
|
||||
@ -230,7 +227,6 @@ namespace boost {
|
||||
|
||||
\param Begin Beginning of the range
|
||||
\param End End of the range
|
||||
\param Range The range.
|
||||
\return An instance of the \c range_finger object
|
||||
*/
|
||||
template< typename ForwardIteratorT >
|
||||
|
120
boost/algorithm/string/formatter.hpp
Normal file
120
boost/algorithm/string/formatter.hpp
Normal file
@ -0,0 +1,120 @@
|
||||
// Boost string_algo library formatter.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_FORMATTER_HPP
|
||||
#define BOOST_STRING_FORMATTER_HPP
|
||||
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/formatter.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines Formatter generators. Formatter is a functor which formats
|
||||
a string according to given parameters. A Formatter works
|
||||
in conjunction with a Finder. A Finder can provide additional information
|
||||
for a specific Formatter. An example of such a cooperation is regex_finder
|
||||
and regex_formatter.
|
||||
|
||||
Formatters are used as pluggable components for replace facilities.
|
||||
This header contains generator functions for the Formatters provided in this library.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// generic formatters ---------------------------------------------------------------//
|
||||
|
||||
//! Constant formatter
|
||||
/*!
|
||||
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 formatting
|
||||
\return An instance of the \c const_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::const_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
|
||||
const_formatter(const RangeT& Format)
|
||||
{
|
||||
return detail::const_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >(::boost::as_literal(Format));
|
||||
}
|
||||
|
||||
//! Identity formatter
|
||||
/*!
|
||||
Constructs an \c identity_formatter. Identity formatter always returns
|
||||
the parameter.
|
||||
|
||||
\return An instance of the \c identity_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::identity_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
|
||||
identity_formatter()
|
||||
{
|
||||
return detail::identity_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
}
|
||||
|
||||
//! Empty formatter
|
||||
/*!
|
||||
Constructs an \c empty_formatter. Empty formatter always returns an empty
|
||||
sequence.
|
||||
|
||||
\param Input container used to select a correct value_type for the
|
||||
resulting empty_container<>.
|
||||
\return An instance of the \c empty_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::empty_formatF<
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>
|
||||
empty_formatter(const RangeT&)
|
||||
{
|
||||
return detail::empty_formatF<
|
||||
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 formatted 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
|
||||
|
||||
// pull the names to the boost namespace
|
||||
using algorithm::const_formatter;
|
||||
using algorithm::identity_formatter;
|
||||
using algorithm::empty_formatter;
|
||||
using algorithm::dissect_formatter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_FORMATTER_HPP
|
@ -71,7 +71,11 @@ namespace boost {
|
||||
inline SequenceSequenceT&
|
||||
iter_find(
|
||||
SequenceSequenceT& Result,
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
RangeT&& Input,
|
||||
#else
|
||||
RangeT& Input,
|
||||
#endif
|
||||
FinderT Finder )
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
@ -142,7 +146,11 @@ namespace boost {
|
||||
inline SequenceSequenceT&
|
||||
iter_split(
|
||||
SequenceSequenceT& Result,
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
RangeT&& Input,
|
||||
#else
|
||||
RangeT& Input,
|
||||
#endif
|
||||
FinderT Finder )
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT((
|
||||
|
145
boost/algorithm/string/join.hpp
Normal file
145
boost/algorithm/string/join.hpp
Normal file
@ -0,0 +1,145 @@
|
||||
// Boost string_algo library join.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// 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_JOIN_HPP
|
||||
#define BOOST_STRING_JOIN_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/detail/sequence.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines join algorithm.
|
||||
|
||||
Join algorithm is a counterpart to split algorithms.
|
||||
It joins strings from a 'list' by adding user defined separator.
|
||||
Additionally there is a version that allows simple filtering
|
||||
by providing a predicate.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// join --------------------------------------------------------------//
|
||||
|
||||
//! Join algorithm
|
||||
/*!
|
||||
This algorithm joins all strings in a 'list' into one long string.
|
||||
Segments are concatenated by given separator.
|
||||
|
||||
\param Input A container that holds the input strings. It must be a container-of-containers.
|
||||
\param Separator A string that will separate the joined segments.
|
||||
\return Concatenated string.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Range1T>
|
||||
inline typename range_value<SequenceSequenceT>::type
|
||||
join(
|
||||
const SequenceSequenceT& Input,
|
||||
const Range1T& Separator)
|
||||
{
|
||||
// Define working types
|
||||
typedef typename range_value<SequenceSequenceT>::type ResultT;
|
||||
typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
|
||||
|
||||
// Parse input
|
||||
InputIteratorT itBegin=::boost::begin(Input);
|
||||
InputIteratorT itEnd=::boost::end(Input);
|
||||
|
||||
// Construct container to hold the result
|
||||
ResultT Result;
|
||||
|
||||
// Append first element
|
||||
if(itBegin!=itEnd)
|
||||
{
|
||||
detail::insert(Result, ::boost::end(Result), *itBegin);
|
||||
++itBegin;
|
||||
}
|
||||
|
||||
for(;itBegin!=itEnd; ++itBegin)
|
||||
{
|
||||
// Add separator
|
||||
detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator));
|
||||
// Add element
|
||||
detail::insert(Result, ::boost::end(Result), *itBegin);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
// join_if ----------------------------------------------------------//
|
||||
|
||||
//! Conditional join algorithm
|
||||
/*!
|
||||
This algorithm joins all strings in a 'list' into one long string.
|
||||
Segments are concatenated by given separator. Only segments that
|
||||
satisfy the predicate will be added to the result.
|
||||
|
||||
\param Input A container that holds the input strings. It must be a container-of-containers.
|
||||
\param Separator A string that will separate the joined segments.
|
||||
\param Pred A segment selection predicate
|
||||
\return Concatenated string.
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template< typename SequenceSequenceT, typename Range1T, typename PredicateT>
|
||||
inline typename range_value<SequenceSequenceT>::type
|
||||
join_if(
|
||||
const SequenceSequenceT& Input,
|
||||
const Range1T& Separator,
|
||||
PredicateT Pred)
|
||||
{
|
||||
// Define working types
|
||||
typedef typename range_value<SequenceSequenceT>::type ResultT;
|
||||
typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
|
||||
|
||||
// Parse input
|
||||
InputIteratorT itBegin=::boost::begin(Input);
|
||||
InputIteratorT itEnd=::boost::end(Input);
|
||||
|
||||
// Construct container to hold the result
|
||||
ResultT Result;
|
||||
|
||||
// Roll to the first element that will be added
|
||||
while(itBegin!=itEnd && !Pred(*itBegin)) ++itBegin;
|
||||
// Add this element
|
||||
if(itBegin!=itEnd)
|
||||
{
|
||||
detail::insert(Result, ::boost::end(Result), *itBegin);
|
||||
++itBegin;
|
||||
}
|
||||
|
||||
for(;itBegin!=itEnd; ++itBegin)
|
||||
{
|
||||
if(Pred(*itBegin))
|
||||
{
|
||||
// Add separator
|
||||
detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator));
|
||||
// Add element
|
||||
detail::insert(Result, ::boost::end(Result), *itBegin);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::join;
|
||||
using algorithm::join_if;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_JOIN_HPP
|
||||
|
475
boost/algorithm/string/predicate.hpp
Normal file
475
boost/algorithm/string/predicate.hpp
Normal file
@ -0,0 +1,475 @@
|
||||
// Boost string_algo library predicate.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_PREDICATE_HPP
|
||||
#define BOOST_STRING_PREDICATE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
#include <boost/algorithm/string/detail/predicate.hpp>
|
||||
|
||||
/*! \file boost/algorithm/string/predicate.hpp
|
||||
Defines string-related predicates.
|
||||
The predicates determine whether a substring is contained in the input string
|
||||
under various conditions: a string starts with the substring, ends with the
|
||||
substring, simply contains the substring or if both strings are equal.
|
||||
Additionaly the algorithm \c all() checks all elements of a container to satisfy a
|
||||
condition.
|
||||
|
||||
All predicates provide the strong exception guarantee.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// starts_with predicate -----------------------------------------------//
|
||||
|
||||
//! 'Starts with' predicate
|
||||
/*!
|
||||
This predicate holds when the test string is a prefix of the Input.
|
||||
In other words, if the input starts with the test.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool starts_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range2T>::type Iterator2T;
|
||||
|
||||
Iterator1T InputEnd=::boost::end(lit_input);
|
||||
Iterator2T TestEnd=::boost::end(lit_test);
|
||||
|
||||
Iterator1T it=::boost::begin(lit_input);
|
||||
Iterator2T pit=::boost::begin(lit_test);
|
||||
for(;
|
||||
it!=InputEnd && pit!=TestEnd;
|
||||
++it,++pit)
|
||||
{
|
||||
if( !(Comp(*it,*pit)) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return pit==TestEnd;
|
||||
}
|
||||
|
||||
//! 'Starts with' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool starts_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return ::boost::algorithm::starts_with(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Starts with' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test string is a prefix of the Input.
|
||||
In other words, if the input starts with the test.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool istarts_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::starts_with(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
|
||||
// ends_with predicate -----------------------------------------------//
|
||||
|
||||
//! 'Ends with' predicate
|
||||
/*!
|
||||
This predicate holds when the test string is a suffix of the Input.
|
||||
In other words, if the input ends with the test.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool ends_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
iterator_traits<Iterator1T>::iterator_category category;
|
||||
|
||||
return detail::
|
||||
ends_with_iter_select(
|
||||
::boost::begin(lit_input),
|
||||
::boost::end(lit_input),
|
||||
::boost::begin(lit_test),
|
||||
::boost::end(lit_test),
|
||||
Comp,
|
||||
category());
|
||||
}
|
||||
|
||||
|
||||
//! 'Ends with' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool ends_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return ::boost::algorithm::ends_with(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Ends with' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test container is a suffix of the Input.
|
||||
In other words, if the input ends with the test.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool iends_with(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::ends_with(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
// contains predicate -----------------------------------------------//
|
||||
|
||||
//! 'Contains' predicate
|
||||
/*!
|
||||
This predicate holds when the test container is contained in the Input.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool contains(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
||||
|
||||
if (::boost::empty(lit_test))
|
||||
{
|
||||
// Empty range is contained always
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use the temporary variable to make VACPP happy
|
||||
bool bResult=(::boost::algorithm::first_finder(lit_test,Comp)(::boost::begin(lit_input), ::boost::end(lit_input)));
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//! 'Contains' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool contains(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return ::boost::algorithm::contains(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Contains' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test container is contained in the Input.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool icontains(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::contains(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
// equals predicate -----------------------------------------------//
|
||||
|
||||
//! 'Equals' predicate
|
||||
/*!
|
||||
This predicate holds when the test container is equal to the
|
||||
input container i.e. all elements in both containers are same.
|
||||
When the optional predicate is specified, it is used for character-wise
|
||||
comparison.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Comp An element comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This is a two-way version of \c std::equal algorithm
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool equals(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(::boost::as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(::boost::as_literal(Test));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range2T>::type Iterator2T;
|
||||
|
||||
Iterator1T InputEnd=::boost::end(lit_input);
|
||||
Iterator2T TestEnd=::boost::end(lit_test);
|
||||
|
||||
Iterator1T it=::boost::begin(lit_input);
|
||||
Iterator2T pit=::boost::begin(lit_test);
|
||||
for(;
|
||||
it!=InputEnd && pit!=TestEnd;
|
||||
++it,++pit)
|
||||
{
|
||||
if( !(Comp(*it,*pit)) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return (pit==TestEnd) && (it==InputEnd);
|
||||
}
|
||||
|
||||
//! 'Equals' predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool equals(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test)
|
||||
{
|
||||
return ::boost::algorithm::equals(Input, Test, is_equal());
|
||||
}
|
||||
|
||||
//! 'Equals' predicate ( case insensitive )
|
||||
/*!
|
||||
This predicate holds when the test container is equal to the
|
||||
input container i.e. all elements in both containers are same.
|
||||
Elements are compared case insensitively.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Test A test sequence
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This is a two-way version of \c std::equal algorithm
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool iequals(
|
||||
const Range1T& Input,
|
||||
const Range2T& Test,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::equals(Input, Test, is_iequal(Loc));
|
||||
}
|
||||
|
||||
// lexicographical_compare predicate -----------------------------//
|
||||
|
||||
//! Lexicographical compare predicate
|
||||
/*!
|
||||
This predicate is an overload of std::lexicographical_compare
|
||||
for range arguments
|
||||
|
||||
It check whether the first argument is lexicographically less
|
||||
then the second one.
|
||||
|
||||
If the optional predicate is specified, it is used for character-wise
|
||||
comparison
|
||||
|
||||
\param Arg1 First argument
|
||||
\param Arg2 Second argument
|
||||
\param Pred Comparison predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T, typename PredicateT>
|
||||
inline bool lexicographical_compare(
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2,
|
||||
PredicateT Pred)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_arg1(::boost::as_literal(Arg1));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_arg2(::boost::as_literal(Arg2));
|
||||
|
||||
return std::lexicographical_compare(
|
||||
::boost::begin(lit_arg1),
|
||||
::boost::end(lit_arg1),
|
||||
::boost::begin(lit_arg2),
|
||||
::boost::end(lit_arg2),
|
||||
Pred);
|
||||
}
|
||||
|
||||
//! Lexicographical compare predicate
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool lexicographical_compare(
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2)
|
||||
{
|
||||
return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_less());
|
||||
}
|
||||
|
||||
//! Lexicographical compare predicate (case-insensitive)
|
||||
/*!
|
||||
This predicate is an overload of std::lexicographical_compare
|
||||
for range arguments.
|
||||
It check whether the first argument is lexicographically less
|
||||
then the second one.
|
||||
Elements are compared case insensitively
|
||||
|
||||
|
||||
\param Arg1 First argument
|
||||
\param Arg2 Second argument
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool ilexicographical_compare(
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return ::boost::algorithm::lexicographical_compare(Arg1, Arg2, is_iless(Loc));
|
||||
}
|
||||
|
||||
|
||||
// all predicate -----------------------------------------------//
|
||||
|
||||
//! 'All' predicate
|
||||
/*!
|
||||
This predicate holds it all its elements satisfy a given
|
||||
condition, represented by the predicate.
|
||||
|
||||
\param Input An input sequence
|
||||
\param Pred A predicate
|
||||
\return The result of the test
|
||||
|
||||
\note This function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline bool all(
|
||||
const RangeT& Input,
|
||||
PredicateT Pred)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::boost::as_literal(Input));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type Iterator1T;
|
||||
|
||||
Iterator1T InputEnd=::boost::end(lit_input);
|
||||
for( Iterator1T It=::boost::begin(lit_input); It!=InputEnd; ++It)
|
||||
{
|
||||
if (!Pred(*It))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::starts_with;
|
||||
using algorithm::istarts_with;
|
||||
using algorithm::ends_with;
|
||||
using algorithm::iends_with;
|
||||
using algorithm::contains;
|
||||
using algorithm::icontains;
|
||||
using algorithm::equals;
|
||||
using algorithm::iequals;
|
||||
using algorithm::all;
|
||||
using algorithm::lexicographical_compare;
|
||||
using algorithm::ilexicographical_compare;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_PREDICATE_HPP
|
926
boost/algorithm/string/replace.hpp
Normal file
926
boost/algorithm/string/replace.hpp
Normal file
@ -0,0 +1,926 @@
|
||||
// Boost string_algo library replace.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006.
|
||||
//
|
||||
// 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_REPLACE_HPP
|
||||
#define BOOST_STRING_REPLACE_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
#include <boost/algorithm/string/find_format.hpp>
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/formatter.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines various replace algorithms. Each algorithm replaces
|
||||
part(s) of the input according to set of searching and replace criteria.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// replace_range --------------------------------------------------------------------//
|
||||
|
||||
//! Replace range algorithm
|
||||
/*!
|
||||
Replace the given range in the input string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param SearchRange A range in the input to be substituted
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_range_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type>& SearchRange,
|
||||
const Range2T& Format)
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::range_finder(SearchRange),
|
||||
::boost::algorithm::const_formatter(Format));
|
||||
}
|
||||
|
||||
//! Replace range algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_range_copy(
|
||||
const SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<SequenceT>::type>& SearchRange,
|
||||
const RangeT& Format)
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::range_finder(SearchRange),
|
||||
::boost::algorithm::const_formatter(Format));
|
||||
}
|
||||
|
||||
//! Replace range algorithm
|
||||
/*!
|
||||
Replace the given range in the input string.
|
||||
The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param SearchRange A range in the input to be substituted
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_range(
|
||||
SequenceT& Input,
|
||||
const iterator_range<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_iterator<SequenceT>::type>& SearchRange,
|
||||
const RangeT& Format)
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::range_finder(SearchRange),
|
||||
::boost::algorithm::const_formatter(Format));
|
||||
}
|
||||
|
||||
// replace_first --------------------------------------------------------------------//
|
||||
|
||||
//! Replace first algorithm
|
||||
/*!
|
||||
Replace the first match of the search substring in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format)
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_first_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm
|
||||
/*!
|
||||
replace the first match of the search substring in the input
|
||||
with the format string. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_first(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_first ( case insensitive ) ---------------------------------------------//
|
||||
|
||||
//! Replace first algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the first match of the search substring in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_first_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range2T, typename Range1T>
|
||||
inline SequenceT ireplace_first_copy(
|
||||
const SequenceT& Input,
|
||||
const Range2T& Search,
|
||||
const Range1T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace first algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the first match of the search substring in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_first(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_last --------------------------------------------------------------------//
|
||||
|
||||
//! Replace last algorithm
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_last_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_last(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_last ( case insensitive ) -----------------------------------------------//
|
||||
|
||||
//! Replace last algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_last_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_last_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace last algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace the last match of the search string in the input
|
||||
with the format string.The input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_last(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::last_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_nth --------------------------------------------------------------------//
|
||||
|
||||
//! Replace nth algorithm
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_nth(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_nth ( case insensitive ) -----------------------------------------------//
|
||||
|
||||
//! Replace nth algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_nth_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc) ),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_nth_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace nth algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace an Nth (zero-indexed) match of the search string in the input
|
||||
with the format string. Input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Nth An index of the match to be replaced. The index is 0-based.
|
||||
For negative N, matches are counted from the end of string.
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_nth(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
int Nth,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_all --------------------------------------------------------------------//
|
||||
|
||||
//! Replace all algorithm
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT replace_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT replace_all_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void replace_all(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format )
|
||||
{
|
||||
::boost::algorithm::find_format_all(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_all ( case insensitive ) -----------------------------------------------//
|
||||
|
||||
//! Replace all algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T,
|
||||
typename Range3T>
|
||||
inline OutputIteratorT ireplace_all_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const Range3T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm ( case insensitive )
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline SequenceT ireplace_all_copy(
|
||||
const SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
return ::boost::algorithm::find_format_all_copy(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace all algorithm ( case insensitive )
|
||||
/*!
|
||||
Replace all occurrences of the search string in the input
|
||||
with the format string.The input sequence is modified in-place.
|
||||
Searching is case insensitive.
|
||||
|
||||
\param Input An input string
|
||||
\param Search A substring to be searched for
|
||||
\param Format A substitute string
|
||||
\param Loc A locale used for case insensitive comparison
|
||||
*/
|
||||
template<typename SequenceT, typename Range1T, typename Range2T>
|
||||
inline void ireplace_all(
|
||||
SequenceT& Input,
|
||||
const Range1T& Search,
|
||||
const Range2T& Format,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
::boost::algorithm::find_format_all(
|
||||
Input,
|
||||
::boost::algorithm::first_finder(Search, is_iequal(Loc)),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_head --------------------------------------------------------------------//
|
||||
|
||||
//! Replace head algorithm
|
||||
/*!
|
||||
Replace the head of the input with the given format string.
|
||||
The head is a prefix of a string of given size.
|
||||
If the sequence is shorter then required, whole string if
|
||||
considered to be the head.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_head_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
int N,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::head_finder(N),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace head algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_head_copy(
|
||||
const SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::head_finder(N),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace head algorithm
|
||||
/*!
|
||||
Replace the head of the input with the given format string.
|
||||
The head is a prefix of a string of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the head. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the head.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_head(
|
||||
SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::head_finder(N),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
// replace_tail --------------------------------------------------------------------//
|
||||
|
||||
//! Replace tail algorithm
|
||||
/*!
|
||||
Replace the tail of the input with the given format string.
|
||||
The tail is a suffix of a string of given size.
|
||||
If the sequence is shorter then required, whole string is
|
||||
considered to be the tail.
|
||||
The result is a modified copy of the input. It is returned as a sequence
|
||||
or copied to the output iterator.
|
||||
|
||||
\param Output An output iterator to which the result will be copied
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
\return An output iterator pointing just after the last inserted character or
|
||||
a modified copy of the input
|
||||
|
||||
\note The second variant of this function provides the strong exception-safety guarantee
|
||||
*/
|
||||
template<
|
||||
typename OutputIteratorT,
|
||||
typename Range1T,
|
||||
typename Range2T>
|
||||
inline OutputIteratorT replace_tail_copy(
|
||||
OutputIteratorT Output,
|
||||
const Range1T& Input,
|
||||
int N,
|
||||
const Range2T& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Output,
|
||||
Input,
|
||||
::boost::algorithm::tail_finder(N),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace tail algorithm
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline SequenceT replace_tail_copy(
|
||||
const SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
return ::boost::algorithm::find_format_copy(
|
||||
Input,
|
||||
::boost::algorithm::tail_finder(N),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
//! Replace tail algorithm
|
||||
/*!
|
||||
Replace the tail of the input with the given format sequence.
|
||||
The tail is a suffix of a string of given size.
|
||||
If the sequence is shorter then required, the whole string is
|
||||
considered to be the tail. The input sequence is modified in-place.
|
||||
|
||||
\param Input An input string
|
||||
\param N Length of the tail.
|
||||
For N>=0, at most N characters are extracted.
|
||||
For N<0, size(Input)-|N| characters are extracted.
|
||||
\param Format A substitute string
|
||||
*/
|
||||
template<typename SequenceT, typename RangeT>
|
||||
inline void replace_tail(
|
||||
SequenceT& Input,
|
||||
int N,
|
||||
const RangeT& Format )
|
||||
{
|
||||
::boost::algorithm::find_format(
|
||||
Input,
|
||||
::boost::algorithm::tail_finder(N),
|
||||
::boost::algorithm::const_formatter(Format) );
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
||||
// pull names to the boost namespace
|
||||
using algorithm::replace_range_copy;
|
||||
using algorithm::replace_range;
|
||||
using algorithm::replace_first_copy;
|
||||
using algorithm::replace_first;
|
||||
using algorithm::ireplace_first_copy;
|
||||
using algorithm::ireplace_first;
|
||||
using algorithm::replace_last_copy;
|
||||
using algorithm::replace_last;
|
||||
using algorithm::ireplace_last_copy;
|
||||
using algorithm::ireplace_last;
|
||||
using algorithm::replace_nth_copy;
|
||||
using algorithm::replace_nth;
|
||||
using algorithm::ireplace_nth_copy;
|
||||
using algorithm::ireplace_nth;
|
||||
using algorithm::replace_all_copy;
|
||||
using algorithm::replace_all;
|
||||
using algorithm::ireplace_all_copy;
|
||||
using algorithm::ireplace_all;
|
||||
using algorithm::replace_head_copy;
|
||||
using algorithm::replace_head;
|
||||
using algorithm::replace_tail_copy;
|
||||
using algorithm::replace_tail;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_REPLACE_HPP
|
120
boost/algorithm/string/sequence_traits.hpp
Normal file
120
boost/algorithm/string/sequence_traits.hpp
Normal file
@ -0,0 +1,120 @@
|
||||
// Boost string_algo library sequence_traits.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_SEQUENCE_TRAITS_HPP
|
||||
#define BOOST_STRING_SEQUENCE_TRAITS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
|
||||
/*! \file
|
||||
Traits defined in this header are used by various algorithms to achieve
|
||||
better performance for specific containers.
|
||||
Traits provide fail-safe defaults. If a container supports some of these
|
||||
features, it is possible to specialize the specific trait for this container.
|
||||
For lacking compilers, it is possible of define an override for a specific tester
|
||||
function.
|
||||
|
||||
Due to a language restriction, it is not currently possible to define specializations for
|
||||
stl containers without including the corresponding header. To decrease the overhead
|
||||
needed by this inclusion, user can selectively include a specialization
|
||||
header for a specific container. They are located in boost/algorithm/string/stl
|
||||
directory. Alternatively she can include boost/algorithm/string/std_collection_traits.hpp
|
||||
header which contains specializations for all stl containers.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// sequence traits -----------------------------------------------//
|
||||
|
||||
|
||||
//! Native replace trait
|
||||
/*!
|
||||
This trait specifies that the sequence has \c std::string like replace method
|
||||
*/
|
||||
template< typename T >
|
||||
class has_native_replace
|
||||
{
|
||||
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
|
||||
|
||||
typedef mpl::bool_<has_native_replace<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Stable iterators trait
|
||||
/*!
|
||||
This trait specifies that the sequence has stable iterators. It means
|
||||
that operations like insert/erase/replace do not invalidate iterators.
|
||||
*/
|
||||
template< typename T >
|
||||
class has_stable_iterators
|
||||
{
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Const time insert trait
|
||||
/*!
|
||||
This trait specifies that the sequence's insert method has
|
||||
constant time complexity.
|
||||
*/
|
||||
template< typename T >
|
||||
class has_const_time_insert
|
||||
{
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
//! Const time erase trait
|
||||
/*!
|
||||
This trait specifies that the sequence's erase method has
|
||||
constant time complexity.
|
||||
*/
|
||||
template< typename T >
|
||||
class has_const_time_erase
|
||||
{
|
||||
public:
|
||||
# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = false };
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value=false);
|
||||
# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_SEQUENCE_TRAITS_HPP
|
@ -61,7 +61,11 @@ namespace boost {
|
||||
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
|
||||
inline SequenceSequenceT& find_all(
|
||||
SequenceSequenceT& Result,
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
Range1T&& Input,
|
||||
#else
|
||||
Range1T& Input,
|
||||
#endif
|
||||
const Range2T& Search)
|
||||
{
|
||||
return ::boost::algorithm::iter_find(
|
||||
@ -96,7 +100,11 @@ namespace boost {
|
||||
template< typename SequenceSequenceT, typename Range1T, typename Range2T >
|
||||
inline SequenceSequenceT& ifind_all(
|
||||
SequenceSequenceT& Result,
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
Range1T&& Input,
|
||||
#else
|
||||
Range1T& Input,
|
||||
#endif
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale() )
|
||||
{
|
||||
@ -139,7 +147,11 @@ namespace boost {
|
||||
template< typename SequenceSequenceT, typename RangeT, typename PredicateT >
|
||||
inline SequenceSequenceT& split(
|
||||
SequenceSequenceT& Result,
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
RangeT&& Input,
|
||||
#else
|
||||
RangeT& Input,
|
||||
#endif
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off )
|
||||
{
|
||||
|
68
boost/algorithm/string/std/list_traits.hpp
Normal file
68
boost/algorithm/string/std/list_traits.hpp
Normal file
@ -0,0 +1,68 @@
|
||||
// Boost string_algo library list_traits.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_STD_LIST_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_LIST_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include <list>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// std::list<> traits -----------------------------------------------//
|
||||
|
||||
|
||||
// stable iterators trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_stable_iterators< ::std::list<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
// const time insert trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_insert< ::std::list<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
// const time erase trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_erase< ::std::list<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_STD_LIST_TRAITS_HPP
|
69
boost/algorithm/string/std/slist_traits.hpp
Normal file
69
boost/algorithm/string/std/slist_traits.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
// Boost string_algo library slist_traits.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_STD_SLIST_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_SLIST_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include BOOST_SLIST_HEADER
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// SGI's std::slist<> traits -----------------------------------------------//
|
||||
|
||||
|
||||
// stable iterators trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_stable_iterators< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_stable_iterators<T>::value> type;
|
||||
};
|
||||
|
||||
// const time insert trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_insert< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_insert<T>::value> type;
|
||||
};
|
||||
|
||||
// const time erase trait
|
||||
template<typename T, typename AllocT>
|
||||
class has_const_time_erase< BOOST_STD_EXTENSION_NAMESPACE::slist<T,AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true };
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
typedef mpl::bool_<has_const_time_erase<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_STD_LIST_TRAITS_HPP
|
44
boost/algorithm/string/std/string_traits.hpp
Normal file
44
boost/algorithm/string/std/string_traits.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
// Boost string_algo library string_traits.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_STD_STRING_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_STRING_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
#include <string>
|
||||
#include <boost/algorithm/string/sequence_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// std::basic_string<> traits -----------------------------------------------//
|
||||
|
||||
|
||||
// native replace trait
|
||||
template<typename T, typename TraitsT, typename AllocT>
|
||||
class has_native_replace< std::basic_string<T, TraitsT, AllocT> >
|
||||
{
|
||||
public:
|
||||
#if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
enum { value = true } ;
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value=true);
|
||||
#endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
|
||||
|
||||
typedef mpl::bool_<has_native_replace<T>::value> type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_LIST_TRAITS_HPP
|
26
boost/algorithm/string/std_containers_traits.hpp
Normal file
26
boost/algorithm/string/std_containers_traits.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
// Boost string_algo library std_containers_traits.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_STD_CONTAINERS_TRAITS_HPP
|
||||
#define BOOST_STRING_STD_CONTAINERS_TRAITS_HPP
|
||||
|
||||
/*!\file
|
||||
This file includes sequence traits for stl containers.
|
||||
*/
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/algorithm/string/std/string_traits.hpp>
|
||||
#include <boost/algorithm/string/std/list_traits.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_SLIST
|
||||
# include <boost/algorithm/string/std/slist_traits.hpp>
|
||||
#endif
|
||||
|
||||
#endif // BOOST_STRING_STD_CONTAINERS_TRAITS_HPP
|
33
boost/algorithm/string/yes_no_type.hpp
Normal file
33
boost/algorithm/string/yes_no_type.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
// Boost string_algo library yes_no_type.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_YES_NO_TYPE_DETAIL_HPP
|
||||
#define BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// taken from boost mailing-list
|
||||
// when yes_no_type will become officially
|
||||
// a part of boost distribution, this header
|
||||
// will be deprecated
|
||||
template<int I> struct size_descriptor
|
||||
{
|
||||
typedef char (& type)[I];
|
||||
};
|
||||
|
||||
typedef size_descriptor<1>::type yes_type;
|
||||
typedef size_descriptor<2>::type no_type;
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
|
19
boost/align/align.hpp
Normal file
19
boost/align/align.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
Copyright 2014-2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_ALIGN_HPP
|
||||
#define BOOST_ALIGN_ALIGN_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_STD_ALIGN)
|
||||
#include <boost/align/detail/align_cxx11.hpp>
|
||||
#else
|
||||
#include <boost/align/detail/align.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
27
boost/align/align_up.hpp
Normal file
27
boost/align/align_up.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_ALIGN_UP_HPP
|
||||
#define BOOST_ALIGN_ALIGN_UP_HPP
|
||||
|
||||
#include <boost/align/detail/align_up.hpp>
|
||||
#include <boost/align/detail/not_pointer.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR inline typename detail::not_pointer<T, T>::type
|
||||
align_up(T value, std::size_t alignment) BOOST_NOEXCEPT
|
||||
{
|
||||
return T((value + (T(alignment) - 1)) & ~T(alignment - 1));
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
43
boost/align/aligned_alloc.hpp
Normal file
43
boost/align/aligned_alloc.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2014-2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_ALIGNED_ALLOC_HPP
|
||||
#define BOOST_ALIGN_ALIGNED_ALLOC_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__APPLE_CC__) || defined(macintosh)
|
||||
#include <AvailabilityMacros.h>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_ALIGN_USE_ALLOCATE)
|
||||
#include <boost/align/detail/aligned_alloc.hpp>
|
||||
#elif defined(_MSC_VER) && !defined(UNDER_CE)
|
||||
#include <boost/align/detail/aligned_alloc_msvc.hpp>
|
||||
#elif defined(__MINGW32__) && (__MSVCRT_VERSION__ >= 0x0700)
|
||||
#include <boost/align/detail/aligned_alloc_msvc.hpp>
|
||||
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
|
||||
#include <boost/align/detail/aligned_alloc_posix.hpp>
|
||||
#elif MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
|
||||
#include <boost/align/detail/aligned_alloc_macos.hpp>
|
||||
#elif defined(__ANDROID__)
|
||||
#include <boost/align/detail/aligned_alloc_android.hpp>
|
||||
#elif defined(__SunOS_5_11) || defined(__SunOS_5_12)
|
||||
#include <boost/align/detail/aligned_alloc_posix.hpp>
|
||||
#elif defined(sun) || defined(__sun)
|
||||
#include <boost/align/detail/aligned_alloc_sunos.hpp>
|
||||
#elif (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600)
|
||||
#include <boost/align/detail/aligned_alloc_posix.hpp>
|
||||
#else
|
||||
#include <boost/align/detail/aligned_alloc.hpp>
|
||||
#endif
|
||||
|
||||
#endif
|
54
boost/align/alignment_of.hpp
Normal file
54
boost/align/alignment_of.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2014-2016 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_ALIGNMENT_OF_HPP
|
||||
#define BOOST_ALIGN_ALIGNMENT_OF_HPP
|
||||
|
||||
#include <boost/align/detail/element_type.hpp>
|
||||
#include <boost/align/alignment_of_forward.hpp>
|
||||
|
||||
#if defined(_MSC_VER) && defined(__clang__)
|
||||
#include <boost/align/detail/alignment_of_cxx11.hpp>
|
||||
#elif defined(BOOST_MSVC)
|
||||
#include <boost/align/detail/alignment_of_msvc.hpp>
|
||||
#elif defined(__GNUC__) && defined(__unix__) && !defined(__LP64__)
|
||||
#include <boost/align/detail/alignment_of.hpp>
|
||||
#elif defined(BOOST_CLANG) && !defined(__x86_64__)
|
||||
#include <boost/align/detail/alignment_of.hpp>
|
||||
#elif !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#include <boost/align/detail/alignment_of_cxx11.hpp>
|
||||
#elif defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600)
|
||||
#include <boost/align/detail/alignment_of_gcc.hpp>
|
||||
#elif defined(__CODEGEARC__)
|
||||
#include <boost/align/detail/alignment_of_codegear.hpp>
|
||||
#elif defined(BOOST_CLANG)
|
||||
#include <boost/align/detail/alignment_of_clang.hpp>
|
||||
#elif __GNUC__ > 4
|
||||
#include <boost/align/detail/alignment_of_gcc.hpp>
|
||||
#elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)
|
||||
#include <boost/align/detail/alignment_of_gcc.hpp>
|
||||
#else
|
||||
#include <boost/align/detail/alignment_of.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
template<class T>
|
||||
struct alignment_of
|
||||
: detail::alignment_of<typename
|
||||
detail::element_type<T>::type>::type { };
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
template<class T>
|
||||
constexpr std::size_t alignment_of_v = alignment_of<T>::value;
|
||||
#endif
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
20
boost/align/alignment_of_forward.hpp
Normal file
20
boost/align/alignment_of_forward.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
|
||||
#define BOOST_ALIGN_ALIGNMENT_OF_FORWARD_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
template<class T>
|
||||
struct alignment_of;
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
38
boost/align/detail/align.hpp
Normal file
38
boost/align/detail/align.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2014-2016 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGN_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
align(std::size_t alignment, std::size_t size, void*& ptr,
|
||||
std::size_t& space)
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
if (size <= space) {
|
||||
char* p = reinterpret_cast<char*>(~(alignment - 1) &
|
||||
(reinterpret_cast<std::size_t>(ptr) + alignment - 1));
|
||||
std::size_t n = space - (p - static_cast<char*>(ptr));
|
||||
if (size <= n) {
|
||||
ptr = p;
|
||||
space = n;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
21
boost/align/detail/align_cxx11.hpp
Normal file
21
boost/align/detail/align_cxx11.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
using std::align;
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
28
boost/align/detail/align_up.hpp
Normal file
28
boost/align/detail/align_up.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGN_UP_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGN_UP_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
align_up(void* ptr, std::size_t alignment) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
return reinterpret_cast<void*>(~(alignment - 1) &
|
||||
(reinterpret_cast<std::size_t>(ptr) + alignment - 1));
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
52
boost/align/detail/aligned_alloc.hpp
Normal file
52
boost/align/detail/aligned_alloc.hpp
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2014-2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/align/align.hpp>
|
||||
#include <boost/align/alignment_of.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
enum {
|
||||
N = alignment_of<void*>::value
|
||||
};
|
||||
if (alignment < N) {
|
||||
alignment = N;
|
||||
}
|
||||
std::size_t n = size + alignment - N;
|
||||
void* p = std::malloc(sizeof(void*) + n);
|
||||
if (p) {
|
||||
void* r = static_cast<char*>(p) + sizeof(void*);
|
||||
(void)boost::alignment::align(alignment, size, r, n);
|
||||
*(static_cast<void**>(r) - 1) = p;
|
||||
p = r;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
inline void
|
||||
aligned_free(void* ptr) BOOST_NOEXCEPT
|
||||
{
|
||||
if (ptr) {
|
||||
std::free(*(static_cast<void**>(ptr) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
34
boost/align/detail/aligned_alloc_android.hpp
Normal file
34
boost/align/detail/aligned_alloc_android.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <malloc.h>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
return ::memalign(alignment, size);
|
||||
}
|
||||
|
||||
inline void
|
||||
aligned_free(void* ptr) BOOST_NOEXCEPT
|
||||
{
|
||||
::free(ptr);
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
44
boost/align/detail/aligned_alloc_macos.hpp
Normal file
44
boost/align/detail/aligned_alloc_macos.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (alignment < sizeof(void*)) {
|
||||
alignment = sizeof(void*);
|
||||
}
|
||||
void* p;
|
||||
if (::posix_memalign(&p, alignment, size) != 0) {
|
||||
p = 0;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
inline void
|
||||
aligned_free(void* ptr) BOOST_NOEXCEPT
|
||||
{
|
||||
::free(ptr);
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
34
boost/align/detail/aligned_alloc_msvc.hpp
Normal file
34
boost/align/detail/aligned_alloc_msvc.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <malloc.h>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
return ::_aligned_malloc(size, alignment);
|
||||
}
|
||||
|
||||
inline void
|
||||
aligned_free(void* ptr) BOOST_NOEXCEPT
|
||||
{
|
||||
::_aligned_free(ptr);
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
41
boost/align/detail/aligned_alloc_posix.hpp
Normal file
41
boost/align/detail/aligned_alloc_posix.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
if (alignment < sizeof(void*)) {
|
||||
alignment = sizeof(void*);
|
||||
}
|
||||
void* p;
|
||||
if (::posix_memalign(&p, alignment, size) != 0) {
|
||||
p = 0;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
inline void
|
||||
aligned_free(void* ptr) BOOST_NOEXCEPT
|
||||
{
|
||||
::free(ptr);
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
34
boost/align/detail/aligned_alloc_sunos.hpp
Normal file
34
boost/align/detail/aligned_alloc_sunos.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP
|
||||
|
||||
#include <boost/align/detail/is_alignment.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
|
||||
inline void*
|
||||
aligned_alloc(std::size_t alignment, std::size_t size) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_ASSERT(detail::is_alignment(alignment));
|
||||
return ::memalign(alignment, size);
|
||||
}
|
||||
|
||||
inline void
|
||||
aligned_free(void* ptr) BOOST_NOEXCEPT
|
||||
{
|
||||
::free(ptr);
|
||||
}
|
||||
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
31
boost/align/detail/alignment_of.hpp
Normal file
31
boost/align/detail/alignment_of.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2014-2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP
|
||||
|
||||
#include <boost/align/detail/min_size.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct offset_value {
|
||||
char value;
|
||||
T object;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct alignment_of
|
||||
: min_size<sizeof(T), sizeof(offset_value<T>) - sizeof(T)> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
26
boost/align/detail/alignment_of_clang.hpp
Normal file
26
boost/align/detail/alignment_of_clang.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP
|
||||
|
||||
#include <boost/align/detail/integral_constant.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct alignment_of
|
||||
: integral_constant<std::size_t, __alignof(T)> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
26
boost/align/detail/alignment_of_codegear.hpp
Normal file
26
boost/align/detail/alignment_of_codegear.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP
|
||||
|
||||
#include <boost/align/detail/integral_constant.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct alignment_of
|
||||
: integral_constant<std::size_t, alignof(T)> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
23
boost/align/detail/alignment_of_cxx11.hpp
Normal file
23
boost/align/detail/alignment_of_cxx11.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
using std::alignment_of;
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
26
boost/align/detail/alignment_of_gcc.hpp
Normal file
26
boost/align/detail/alignment_of_gcc.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP
|
||||
|
||||
#include <boost/align/detail/integral_constant.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct alignment_of
|
||||
: integral_constant<std::size_t, __alignof__(T)> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
32
boost/align/detail/alignment_of_msvc.hpp
Normal file
32
boost/align/detail/alignment_of_msvc.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2014-2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_MSVC_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_MSVC_HPP
|
||||
|
||||
#include <boost/align/detail/min_size.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct offset_value {
|
||||
T first;
|
||||
char value;
|
||||
T second;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct alignment_of
|
||||
: min_size<sizeof(T), sizeof(offset_value<T>) - (sizeof(T) << 1)> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
91
boost/align/detail/element_type.hpp
Normal file
91
boost/align/detail/element_type.hpp
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright 2015 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_ELEMENT_TYPE_HPP
|
||||
#define BOOST_ALIGN_DETAIL_ELEMENT_TYPE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#include <type_traits>
|
||||
#else
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
using std::remove_reference;
|
||||
using std::remove_all_extents;
|
||||
using std::remove_cv;
|
||||
#else
|
||||
template<class T>
|
||||
struct remove_reference {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_reference<T&> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
template<class T>
|
||||
struct remove_reference<T&&> {
|
||||
typedef T type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
struct remove_all_extents {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_all_extents<T[]> {
|
||||
typedef typename remove_all_extents<T>::type type;
|
||||
};
|
||||
|
||||
template<class T, std::size_t N>
|
||||
struct remove_all_extents<T[N]> {
|
||||
typedef typename remove_all_extents<T>::type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_cv {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_cv<const T> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_cv<volatile T> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_cv<const volatile T> {
|
||||
typedef T type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
struct element_type {
|
||||
typedef typename remove_cv<typename remove_all_extents<typename
|
||||
remove_reference<T>::type>::type>::type type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
53
boost/align/detail/integral_constant.hpp
Normal file
53
boost/align/detail/integral_constant.hpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright 2014-2016 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP
|
||||
#define BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
using std::integral_constant;
|
||||
using std::true_type;
|
||||
using std::false_type;
|
||||
#else
|
||||
template<class T, T Value>
|
||||
struct integral_constant {
|
||||
typedef T value_type;
|
||||
typedef integral_constant type;
|
||||
|
||||
BOOST_CONSTEXPR operator value_type() const BOOST_NOEXCEPT {
|
||||
return Value;
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR value_type operator()() const BOOST_NOEXCEPT {
|
||||
return Value;
|
||||
}
|
||||
|
||||
BOOST_STATIC_CONSTEXPR T value = Value;
|
||||
};
|
||||
|
||||
template<class T, T Value>
|
||||
BOOST_CONSTEXPR_OR_CONST T integral_constant<T, Value>::value;
|
||||
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
typedef integral_constant<bool, false> false_type;
|
||||
#endif
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
28
boost/align/detail/is_alignment.hpp
Normal file
28
boost/align/detail/is_alignment.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP
|
||||
#define BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
BOOST_CONSTEXPR inline bool
|
||||
is_alignment(std::size_t value) BOOST_NOEXCEPT
|
||||
{
|
||||
return (value > 0) && ((value & (value - 1)) == 0);
|
||||
}
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
26
boost/align/detail/min_size.hpp
Normal file
26
boost/align/detail/min_size.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2014 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_MIN_SIZE_HPP
|
||||
#define BOOST_ALIGN_DETAIL_MIN_SIZE_HPP
|
||||
|
||||
#include <boost/align/detail/integral_constant.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
template<std::size_t A, std::size_t B>
|
||||
struct min_size
|
||||
: integral_constant<std::size_t, (A < B) ? A : B> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
27
boost/align/detail/not_pointer.hpp
Normal file
27
boost/align/detail/not_pointer.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_ALIGN_DETAIL_NOT_POINTER_HPP
|
||||
#define BOOST_ALIGN_DETAIL_NOT_POINTER_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace alignment {
|
||||
namespace detail {
|
||||
|
||||
template<class T, class U>
|
||||
struct not_pointer {
|
||||
typedef U type;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct not_pointer<T*, U> { };
|
||||
|
||||
} /* detail */
|
||||
} /* alignment */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
@ -12,7 +12,7 @@
|
||||
// with features contributed and bugs found by
|
||||
// Antony Polukhin, Ed Brey, Mark Rodgers,
|
||||
// Peter Dimov, and James Curran
|
||||
// when: July 2001, April 2013 - May 2013
|
||||
// when: July 2001, April 2013 - 2019
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -38,7 +38,7 @@ namespace boost
|
||||
{
|
||||
public: // structors
|
||||
|
||||
any() BOOST_NOEXCEPT
|
||||
BOOST_CONSTEXPR any() BOOST_NOEXCEPT
|
||||
: content(0)
|
||||
{
|
||||
}
|
||||
@ -98,7 +98,7 @@ namespace boost
|
||||
|
||||
any & operator=(any rhs)
|
||||
{
|
||||
any(rhs).swap(*this);
|
||||
rhs.swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ namespace boost
|
||||
return *this;
|
||||
}
|
||||
|
||||
// move assignement
|
||||
// move assignment
|
||||
any & operator=(any&& rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
rhs.swap(*this);
|
||||
@ -149,7 +149,7 @@ namespace boost
|
||||
public: // types (public so any_cast can be non-friend)
|
||||
#endif
|
||||
|
||||
class placeholder
|
||||
class BOOST_SYMBOL_VISIBLE placeholder
|
||||
{
|
||||
public: // structors
|
||||
|
||||
@ -166,7 +166,11 @@ namespace boost
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
class holder : public placeholder
|
||||
class holder
|
||||
#ifndef BOOST_NO_CXX11_FINAL
|
||||
final
|
||||
#endif
|
||||
: public placeholder
|
||||
{
|
||||
public: // structors
|
||||
|
||||
@ -271,8 +275,8 @@ namespace boost
|
||||
// `ValueType` is not a reference. Example:
|
||||
// `static_cast<std::string>(*result);`
|
||||
// which is equal to `std::string(*result);`
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
|
||||
boost::is_reference<ValueType>,
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::conditional<
|
||||
boost::is_reference<ValueType>::value,
|
||||
ValueType,
|
||||
BOOST_DEDUCED_TYPENAME boost::add_reference<ValueType>::type
|
||||
>::type ref_type;
|
||||
@ -329,6 +333,7 @@ namespace boost
|
||||
}
|
||||
|
||||
// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
|
||||
// Copyright Antony Polukhin, 2013-2019.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
|
100
boost/archive/archive_exception.hpp
Normal file
100
boost/archive/archive_exception.hpp
Normal file
@ -0,0 +1,100 @@
|
||||
#ifndef BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
|
||||
#define BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// archive/archive_exception.hpp:
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to 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.
|
||||
|
||||
#include <exception>
|
||||
#include <boost/assert.hpp>
|
||||
#include <string>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/detail/decl.hpp>
|
||||
|
||||
// note: the only reason this is in here is that windows header
|
||||
// includes #define exception_code _exception_code (arrrgghhhh!).
|
||||
// the most expedient way to address this is be sure that this
|
||||
// header is always included whenever this header file is included.
|
||||
#if defined(BOOST_WINDOWS)
|
||||
#include <excpt.h>
|
||||
#endif
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// exceptions thrown by archives
|
||||
//
|
||||
class BOOST_SYMBOL_VISIBLE archive_exception :
|
||||
public virtual std::exception
|
||||
{
|
||||
private:
|
||||
char m_buffer[128];
|
||||
protected:
|
||||
BOOST_ARCHIVE_DECL unsigned int
|
||||
append(unsigned int l, const char * a);
|
||||
BOOST_ARCHIVE_DECL
|
||||
archive_exception() BOOST_NOEXCEPT;
|
||||
public:
|
||||
typedef enum {
|
||||
no_exception, // initialized without code
|
||||
other_exception, // any excepton not listed below
|
||||
unregistered_class, // attempt to serialize a pointer of
|
||||
// an unregistered class
|
||||
invalid_signature, // first line of archive does not contain
|
||||
// expected string
|
||||
unsupported_version,// archive created with library version
|
||||
// subsequent to this one
|
||||
pointer_conflict, // an attempt has been made to directly
|
||||
// serialize an object which has
|
||||
// already been serialized through a pointer.
|
||||
// Were this permitted, the archive load would result
|
||||
// in the creation of an extra copy of the obect.
|
||||
incompatible_native_format, // attempt to read native binary format
|
||||
// on incompatible platform
|
||||
array_size_too_short,// array being loaded doesn't fit in array allocated
|
||||
input_stream_error, // error on input stream
|
||||
invalid_class_name, // class name greater than the maximum permitted.
|
||||
// most likely a corrupted archive or an attempt
|
||||
// to insert virus via buffer overrun method.
|
||||
unregistered_cast, // base - derived relationship not registered with
|
||||
// void_cast_register
|
||||
unsupported_class_version, // type saved with a version # greater than the
|
||||
// one used by the program. This indicates that the program
|
||||
// needs to be rebuilt.
|
||||
multiple_code_instantiation, // code for implementing serialization for some
|
||||
// type has been instantiated in more than one module.
|
||||
output_stream_error // error on input stream
|
||||
} exception_code;
|
||||
exception_code code;
|
||||
|
||||
BOOST_ARCHIVE_DECL archive_exception(
|
||||
exception_code c,
|
||||
const char * e1 = NULL,
|
||||
const char * e2 = NULL
|
||||
) BOOST_NOEXCEPT;
|
||||
BOOST_ARCHIVE_DECL archive_exception(archive_exception const &) BOOST_NOEXCEPT ;
|
||||
virtual BOOST_ARCHIVE_DECL ~archive_exception() BOOST_NOEXCEPT_OR_NOTHROW ;
|
||||
virtual BOOST_ARCHIVE_DECL const char * what() const BOOST_NOEXCEPT_OR_NOTHROW ;
|
||||
};
|
||||
|
||||
}// namespace archive
|
||||
}// namespace boost
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#endif //BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
|
16
boost/archive/detail/abi_prefix.hpp
Normal file
16
boost/archive/detail/abi_prefix.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// abi_prefix.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to 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.
|
||||
|
||||
#include <boost/config/abi_prefix.hpp> // must be the last header
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4251 4231 4660 4275)
|
||||
#endif
|
||||
|
15
boost/archive/detail/abi_suffix.hpp
Normal file
15
boost/archive/detail/abi_suffix.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// abi_suffix.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// Use, modification and distribution is subject to 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.
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
57
boost/archive/detail/decl.hpp
Normal file
57
boost/archive/detail/decl.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_DECL_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_DECL_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2///////// 3/////////4/////////5/////////6/////////7/////////8
|
||||
// decl.hpp
|
||||
//
|
||||
// (c) Copyright Robert Ramey 2004
|
||||
// Use, modification, and distribution is subject to 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 library home page at http://www.boost.org/libs/serialization
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_SERIALIZATION_DYN_LINK))
|
||||
#if defined(BOOST_ARCHIVE_SOURCE)
|
||||
#define BOOST_ARCHIVE_DECL BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
#define BOOST_ARCHIVE_DECL BOOST_SYMBOL_IMPORT
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_WARCHIVE_SOURCE)
|
||||
#define BOOST_WARCHIVE_DECL BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
#define BOOST_WARCHIVE_DECL BOOST_SYMBOL_IMPORT
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_WARCHIVE_SOURCE) || defined(BOOST_ARCHIVE_SOURCE)
|
||||
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL BOOST_SYMBOL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if ! defined(BOOST_ARCHIVE_DECL)
|
||||
#define BOOST_ARCHIVE_DECL
|
||||
#endif
|
||||
#if ! defined(BOOST_WARCHIVE_DECL)
|
||||
#define BOOST_WARCHIVE_DECL
|
||||
#endif
|
||||
#if ! defined(BOOST_ARCHIVE_OR_WARCHIVE_DECL)
|
||||
#define BOOST_ARCHIVE_OR_WARCHIVE_DECL
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ARCHIVE_DETAIL_DECL_HPP
|
@ -183,7 +183,7 @@ namespace boost {
|
||||
|
||||
// check range (may be private because it is static)
|
||||
static BOOST_CONSTEXPR bool rangecheck (size_type i) {
|
||||
return i > size() ? boost::throw_exception(std::out_of_range ("array<>: index out of range")), true : true;
|
||||
return i >= size() ? boost::throw_exception(std::out_of_range ("array<>: index out of range")), true : true;
|
||||
}
|
||||
|
||||
};
|
||||
|
133
boost/asio/associated_allocator.hpp
Normal file
133
boost/asio/associated_allocator.hpp
Normal file
@ -0,0 +1,133 @@
|
||||
//
|
||||
// associated_allocator.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_ASSOCIATED_ALLOCATOR_HPP
|
||||
#define BOOST_ASIO_ASSOCIATED_ALLOCATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <memory>
|
||||
#include <boost/asio/detail/type_traits.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename>
|
||||
struct associated_allocator_check
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <typename T, typename E, typename = void>
|
||||
struct associated_allocator_impl
|
||||
{
|
||||
typedef E type;
|
||||
|
||||
static type get(const T&, const E& e) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_allocator_impl<T, E,
|
||||
typename associated_allocator_check<typename T::allocator_type>::type>
|
||||
{
|
||||
typedef typename T::allocator_type type;
|
||||
|
||||
static type get(const T& t, const E&) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return t.get_allocator();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Traits type used to obtain the allocator associated with an object.
|
||||
/**
|
||||
* A program may specialise this traits type if the @c T template parameter in
|
||||
* the specialisation is a user-defined type. The template parameter @c
|
||||
* Allocator shall be a type meeting the Allocator requirements.
|
||||
*
|
||||
* Specialisations shall meet the following requirements, where @c t is a const
|
||||
* reference to an object of type @c T, and @c a is an object of type @c
|
||||
* Allocator.
|
||||
*
|
||||
* @li Provide a nested typedef @c type that identifies a type meeting the
|
||||
* Allocator requirements.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t) and with return type @c type.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t,a) and with return type @c type.
|
||||
*/
|
||||
template <typename T, typename Allocator = std::allocator<void> >
|
||||
struct associated_allocator
|
||||
{
|
||||
/// If @c T has a nested type @c allocator_type, <tt>T::allocator_type</tt>.
|
||||
/// Otherwise @c Allocator.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef see_below type;
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
typedef typename detail::associated_allocator_impl<T, Allocator>::type type;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// If @c T has a nested type @c allocator_type, returns
|
||||
/// <tt>t.get_allocator()</tt>. Otherwise returns @c a.
|
||||
static type get(const T& t,
|
||||
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return detail::associated_allocator_impl<T, Allocator>::get(t, a);
|
||||
}
|
||||
};
|
||||
|
||||
/// Helper function to obtain an object's associated allocator.
|
||||
/**
|
||||
* @returns <tt>associated_allocator<T>::get(t)</tt>
|
||||
*/
|
||||
template <typename T>
|
||||
inline typename associated_allocator<T>::type
|
||||
get_associated_allocator(const T& t) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<T>::get(t);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated allocator.
|
||||
/**
|
||||
* @returns <tt>associated_allocator<T, Allocator>::get(t, a)</tt>
|
||||
*/
|
||||
template <typename T, typename Allocator>
|
||||
inline typename associated_allocator<T, Allocator>::type
|
||||
get_associated_allocator(const T& t, const Allocator& a) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<T, Allocator>::get(t, a);
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
|
||||
|
||||
template <typename T, typename Allocator = std::allocator<void> >
|
||||
using associated_allocator_t
|
||||
= typename associated_allocator<T, Allocator>::type;
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_ASSOCIATED_ALLOCATOR_HPP
|
151
boost/asio/associated_executor.hpp
Normal file
151
boost/asio/associated_executor.hpp
Normal file
@ -0,0 +1,151 @@
|
||||
//
|
||||
// associated_executor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_ASSOCIATED_EXECUTOR_HPP
|
||||
#define BOOST_ASIO_ASSOCIATED_EXECUTOR_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/detail/type_traits.hpp>
|
||||
#include <boost/asio/is_executor.hpp>
|
||||
#include <boost/asio/system_executor.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename>
|
||||
struct associated_executor_check
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template <typename T, typename E, typename = void>
|
||||
struct associated_executor_impl
|
||||
{
|
||||
typedef E type;
|
||||
|
||||
static type get(const T&, const E& e) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename E>
|
||||
struct associated_executor_impl<T, E,
|
||||
typename associated_executor_check<typename T::executor_type>::type>
|
||||
{
|
||||
typedef typename T::executor_type type;
|
||||
|
||||
static type get(const T& t, const E&) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return t.get_executor();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Traits type used to obtain the executor associated with an object.
|
||||
/**
|
||||
* A program may specialise this traits type if the @c T template parameter in
|
||||
* the specialisation is a user-defined type. The template parameter @c
|
||||
* Executor shall be a type meeting the Executor requirements.
|
||||
*
|
||||
* Specialisations shall meet the following requirements, where @c t is a const
|
||||
* reference to an object of type @c T, and @c e is an object of type @c
|
||||
* Executor.
|
||||
*
|
||||
* @li Provide a nested typedef @c type that identifies a type meeting the
|
||||
* Executor requirements.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t) and with return type @c type.
|
||||
*
|
||||
* @li Provide a noexcept static member function named @c get, callable as @c
|
||||
* get(t,e) and with return type @c type.
|
||||
*/
|
||||
template <typename T, typename Executor = system_executor>
|
||||
struct associated_executor
|
||||
{
|
||||
/// If @c T has a nested type @c executor_type, <tt>T::executor_type</tt>.
|
||||
/// Otherwise @c Executor.
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
typedef see_below type;
|
||||
#else // defined(GENERATING_DOCUMENTATION)
|
||||
typedef typename detail::associated_executor_impl<T, Executor>::type type;
|
||||
#endif // defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// If @c T has a nested type @c executor_type, returns
|
||||
/// <tt>t.get_executor()</tt>. Otherwise returns @c ex.
|
||||
static type get(const T& t,
|
||||
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return detail::associated_executor_impl<T, Executor>::get(t, ex);
|
||||
}
|
||||
};
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_executor<T>::get(t)</tt>
|
||||
*/
|
||||
template <typename T>
|
||||
inline typename associated_executor<T>::type
|
||||
get_associated_executor(const T& t) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<T>::get(t);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_executor<T, Executor>::get(t, ex)</tt>
|
||||
*/
|
||||
template <typename T, typename Executor>
|
||||
inline typename associated_executor<T, Executor>::type
|
||||
get_associated_executor(const T& t, const Executor& ex,
|
||||
typename enable_if<is_executor<
|
||||
Executor>::value>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<T, Executor>::get(t, ex);
|
||||
}
|
||||
|
||||
/// Helper function to obtain an object's associated executor.
|
||||
/**
|
||||
* @returns <tt>associated_executor<T, typename
|
||||
* ExecutionContext::executor_type>::get(t, ctx.get_executor())</tt>
|
||||
*/
|
||||
template <typename T, typename ExecutionContext>
|
||||
inline typename associated_executor<T,
|
||||
typename ExecutionContext::executor_type>::type
|
||||
get_associated_executor(const T& t, ExecutionContext& ctx,
|
||||
typename enable_if<is_convertible<ExecutionContext&,
|
||||
execution_context&>::value>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<T,
|
||||
typename ExecutionContext::executor_type>::get(t, ctx.get_executor());
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
|
||||
|
||||
template <typename T, typename Executor = system_executor>
|
||||
using associated_executor_t = typename associated_executor<T, Executor>::type;
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_ALIAS_TEMPLATES)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_ASSOCIATED_EXECUTOR_HPP
|
358
boost/asio/async_result.hpp
Normal file
358
boost/asio/async_result.hpp
Normal file
@ -0,0 +1,358 @@
|
||||
//
|
||||
// async_result.hpp
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_ASYNC_RESULT_HPP
|
||||
#define BOOST_ASIO_ASYNC_RESULT_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/detail/type_traits.hpp>
|
||||
#include <boost/asio/detail/variadic_templates.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// An interface for customising the behaviour of an initiating function.
|
||||
/**
|
||||
* The async_result traits class is used for determining:
|
||||
*
|
||||
* @li the concrete completion handler type to be called at the end of the
|
||||
* asynchronous operation;
|
||||
*
|
||||
* @li the initiating function return type; and
|
||||
*
|
||||
* @li how the return value of the initiating function is obtained.
|
||||
*
|
||||
* The trait allows the handler and return types to be determined at the point
|
||||
* where the specific completion handler signature is known.
|
||||
*
|
||||
* This template may be specialised for user-defined completion token types.
|
||||
* The primary template assumes that the CompletionToken is the completion
|
||||
* handler.
|
||||
*/
|
||||
template <typename CompletionToken, typename Signature>
|
||||
class async_result
|
||||
{
|
||||
public:
|
||||
/// The concrete completion handler type for the specific signature.
|
||||
typedef CompletionToken completion_handler_type;
|
||||
|
||||
/// The return type of the initiating function.
|
||||
typedef void return_type;
|
||||
|
||||
/// Construct an async result from a given handler.
|
||||
/**
|
||||
* When using a specalised async_result, the constructor has an opportunity
|
||||
* to initialise some state associated with the completion handler, which is
|
||||
* then returned from the initiating function.
|
||||
*/
|
||||
explicit async_result(completion_handler_type& h)
|
||||
{
|
||||
(void)h;
|
||||
}
|
||||
|
||||
/// Obtain the value to be returned from the initiating function.
|
||||
return_type get()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Initiate the asynchronous operation that will produce the result, and
|
||||
/// obtain the value to be returned from the initiating function.
|
||||
template <typename Initiation, typename RawCompletionToken, typename... Args>
|
||||
static return_type initiate(
|
||||
BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
BOOST_ASIO_MOVE_ARG(RawCompletionToken) token,
|
||||
BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
|
||||
BOOST_ASIO_MOVE_CAST(RawCompletionToken)(token),
|
||||
BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename Initiation, typename RawCompletionToken>
|
||||
static return_type initiate(
|
||||
BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
BOOST_ASIO_MOVE_ARG(RawCompletionToken) token)
|
||||
{
|
||||
BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
|
||||
BOOST_ASIO_MOVE_CAST(RawCompletionToken)(token));
|
||||
}
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \
|
||||
template <typename Initiation, typename RawCompletionToken, \
|
||||
BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
static return_type initiate( \
|
||||
BOOST_ASIO_MOVE_ARG(Initiation) initiation, \
|
||||
BOOST_ASIO_MOVE_ARG(RawCompletionToken) token, \
|
||||
BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \
|
||||
BOOST_ASIO_MOVE_CAST(RawCompletionToken)(token), \
|
||||
BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
} \
|
||||
/**/
|
||||
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF)
|
||||
#undef BOOST_ASIO_PRIVATE_INITIATE_DEF
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
private:
|
||||
async_result(const async_result&) BOOST_ASIO_DELETED;
|
||||
async_result& operator=(const async_result&) BOOST_ASIO_DELETED;
|
||||
};
|
||||
|
||||
/// Helper template to deduce the handler type from a CompletionToken, capture
|
||||
/// a local copy of the handler, and then create an async_result for the
|
||||
/// handler.
|
||||
template <typename CompletionToken, typename Signature>
|
||||
struct async_completion
|
||||
{
|
||||
/// The real handler type to be used for the asynchronous operation.
|
||||
typedef typename boost::asio::async_result<
|
||||
typename decay<CompletionToken>::type,
|
||||
Signature>::completion_handler_type completion_handler_type;
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
/// Constructor.
|
||||
/**
|
||||
* The constructor creates the concrete completion handler and makes the link
|
||||
* between the handler and the asynchronous result.
|
||||
*/
|
||||
explicit async_completion(CompletionToken& token)
|
||||
: completion_handler(static_cast<typename conditional<
|
||||
is_same<CompletionToken, completion_handler_type>::value,
|
||||
completion_handler_type&, CompletionToken&&>::type>(token)),
|
||||
result(completion_handler)
|
||||
{
|
||||
}
|
||||
#else // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
explicit async_completion(typename decay<CompletionToken>::type& token)
|
||||
: completion_handler(token),
|
||||
result(completion_handler)
|
||||
{
|
||||
}
|
||||
|
||||
explicit async_completion(const typename decay<CompletionToken>::type& token)
|
||||
: completion_handler(token),
|
||||
result(completion_handler)
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// A copy of, or reference to, a real handler object.
|
||||
#if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
typename conditional<
|
||||
is_same<CompletionToken, completion_handler_type>::value,
|
||||
completion_handler_type&, completion_handler_type>::type completion_handler;
|
||||
#else // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
completion_handler_type completion_handler;
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// The result of the asynchronous operation's initiating function.
|
||||
async_result<typename decay<CompletionToken>::type, Signature> result;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename CompletionToken, typename Signature>
|
||||
struct async_result_helper
|
||||
: async_result<typename decay<CompletionToken>::type, Signature>
|
||||
{
|
||||
};
|
||||
|
||||
struct async_result_memfns_base
|
||||
{
|
||||
void initiate();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct async_result_memfns_derived
|
||||
: T, async_result_memfns_base
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, T>
|
||||
struct async_result_memfns_check
|
||||
{
|
||||
};
|
||||
|
||||
template <typename>
|
||||
char (&async_result_initiate_memfn_helper(...))[2];
|
||||
|
||||
template <typename T>
|
||||
char async_result_initiate_memfn_helper(
|
||||
async_result_memfns_check<
|
||||
void (async_result_memfns_base::*)(),
|
||||
&async_result_memfns_derived<T>::initiate>*);
|
||||
|
||||
template <typename CompletionToken, typename Signature>
|
||||
struct async_result_has_initiate_memfn
|
||||
: integral_constant<bool, sizeof(async_result_initiate_memfn_helper<
|
||||
async_result<typename decay<CompletionToken>::type, Signature>
|
||||
>(0)) != 1>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
# define BOOST_ASIO_INITFN_RESULT_TYPE(ct, sig) \
|
||||
void_or_deduced
|
||||
#elif defined(_MSC_VER) && (_MSC_VER < 1500)
|
||||
# define BOOST_ASIO_INITFN_RESULT_TYPE(ct, sig) \
|
||||
typename ::boost::asio::detail::async_result_helper< \
|
||||
ct, sig>::return_type
|
||||
#define BOOST_ASIO_HANDLER_TYPE(ct, sig) \
|
||||
typename ::boost::asio::detail::async_result_helper< \
|
||||
ct, sig>::completion_handler_type
|
||||
#else
|
||||
# define BOOST_ASIO_INITFN_RESULT_TYPE(ct, sig) \
|
||||
typename ::boost::asio::async_result< \
|
||||
typename ::boost::asio::decay<ct>::type, sig>::return_type
|
||||
#define BOOST_ASIO_HANDLER_TYPE(ct, sig) \
|
||||
typename ::boost::asio::async_result< \
|
||||
typename ::boost::asio::decay<ct>::type, sig>::completion_handler_type
|
||||
#endif
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
template <typename CompletionToken, typename Signature,
|
||||
typename Initiation, typename... Args>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signature)
|
||||
async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken),
|
||||
BOOST_ASIO_MOVE_ARG(Args)... args);
|
||||
|
||||
#elif defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename CompletionToken, typename Signature,
|
||||
typename Initiation, typename... Args>
|
||||
inline typename enable_if<
|
||||
detail::async_result_has_initiate_memfn<CompletionToken, Signature>::value,
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signature)>::type
|
||||
async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token,
|
||||
BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
return async_result<typename decay<CompletionToken>::type,
|
||||
Signature>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
|
||||
BOOST_ASIO_MOVE_CAST(CompletionToken)(token),
|
||||
BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
}
|
||||
|
||||
template <typename CompletionToken, typename Signature,
|
||||
typename Initiation, typename... Args>
|
||||
inline typename enable_if<
|
||||
!detail::async_result_has_initiate_memfn<CompletionToken, Signature>::value,
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signature)>::type
|
||||
async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token,
|
||||
BOOST_ASIO_MOVE_ARG(Args)... args)
|
||||
{
|
||||
async_completion<CompletionToken, Signature> completion(token);
|
||||
|
||||
BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
|
||||
BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(CompletionToken,
|
||||
Signature))(completion.completion_handler),
|
||||
BOOST_ASIO_MOVE_CAST(Args)(args)...);
|
||||
|
||||
return completion.result.get();
|
||||
}
|
||||
|
||||
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename CompletionToken, typename Signature, typename Initiation>
|
||||
inline typename enable_if<
|
||||
detail::async_result_has_initiate_memfn<CompletionToken, Signature>::value,
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signature)>::type
|
||||
async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token)
|
||||
{
|
||||
return async_result<typename decay<CompletionToken>::type,
|
||||
Signature>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
|
||||
BOOST_ASIO_MOVE_CAST(CompletionToken)(token));
|
||||
}
|
||||
|
||||
template <typename CompletionToken, typename Signature, typename Initiation>
|
||||
inline typename enable_if<
|
||||
!detail::async_result_has_initiate_memfn<CompletionToken, Signature>::value,
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signature)>::type
|
||||
async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation,
|
||||
BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token)
|
||||
{
|
||||
async_completion<CompletionToken, Signature> completion(token);
|
||||
|
||||
BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
|
||||
BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(CompletionToken,
|
||||
Signature))(completion.completion_handler));
|
||||
|
||||
return completion.result.get();
|
||||
}
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \
|
||||
template <typename CompletionToken, typename Signature, \
|
||||
typename Initiation, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
inline typename enable_if< \
|
||||
detail::async_result_has_initiate_memfn< \
|
||||
CompletionToken, Signature>::value, \
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signature)>::type \
|
||||
async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \
|
||||
BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \
|
||||
BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
return async_result<typename decay<CompletionToken>::type, \
|
||||
Signature>::initiate(BOOST_ASIO_MOVE_CAST(Initiation)(initiation), \
|
||||
BOOST_ASIO_MOVE_CAST(CompletionToken)(token), \
|
||||
BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
} \
|
||||
\
|
||||
template <typename CompletionToken, typename Signature, \
|
||||
typename Initiation, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
|
||||
inline typename enable_if< \
|
||||
!detail::async_result_has_initiate_memfn< \
|
||||
CompletionToken, Signature>::value, \
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, Signature)>::type \
|
||||
async_initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation, \
|
||||
BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \
|
||||
BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
|
||||
{ \
|
||||
async_completion<CompletionToken, Signature> completion(token); \
|
||||
\
|
||||
BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \
|
||||
BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(CompletionToken, \
|
||||
Signature))(completion.completion_handler), \
|
||||
BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
|
||||
\
|
||||
return completion.result.get(); \
|
||||
} \
|
||||
/**/
|
||||
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF)
|
||||
#undef BOOST_ASIO_PRIVATE_INITIATE_DEF
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_ASYNC_RESULT_HPP
|
1117
boost/asio/basic_datagram_socket.hpp
Normal file
1117
boost/asio/basic_datagram_socket.hpp
Normal file
File diff suppressed because it is too large
Load Diff
1858
boost/asio/basic_socket.hpp
Normal file
1858
boost/asio/basic_socket.hpp
Normal file
File diff suppressed because it is too large
Load Diff
2498
boost/asio/buffer.hpp
Normal file
2498
boost/asio/buffer.hpp
Normal file
File diff suppressed because it is too large
Load Diff
40
boost/asio/detail/array.hpp
Normal file
40
boost/asio/detail/array.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// detail/array.hpp
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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
|
34
boost/asio/detail/array_fwd.hpp
Normal file
34
boost/asio/detail/array_fwd.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
//
|
||||
// detail/array_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_FWD_HPP
|
||||
#define BOOST_ASIO_DETAIL_ARRAY_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T, std::size_t N>
|
||||
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
|
32
boost/asio/detail/assert.hpp
Normal file
32
boost/asio/detail/assert.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// detail/assert.hpp
|
||||
// ~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_ASSERT_HPP
|
||||
#define BOOST_ASIO_DETAIL_ASSERT_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_BOOST_ASSERT)
|
||||
# include <boost/assert.hpp>
|
||||
#else // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
|
||||
# include <cassert>
|
||||
#endif // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_BOOST_ASSERT)
|
||||
# define BOOST_ASIO_ASSERT(expr) BOOST_ASSERT(expr)
|
||||
#else // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
|
||||
# define BOOST_ASIO_ASSERT(expr) assert(expr)
|
||||
#endif // defined(BOOST_ASIO_HAS_BOOST_ASSERT)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_ASSERT_HPP
|
47
boost/asio/detail/atomic_count.hpp
Normal file
47
boost/asio/detail/atomic_count.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// detail/atomic_count.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_ASIO_HAS_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_ASIO_HAS_THREADS)
|
||||
typedef long atomic_count;
|
||||
inline void increment(atomic_count& a, long b) { a += b; }
|
||||
#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
typedef std::atomic<long> atomic_count;
|
||||
inline void increment(atomic_count& a, long b) { a += b; }
|
||||
#else // defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
typedef boost::detail::atomic_count atomic_count;
|
||||
inline void increment(atomic_count& a, long b) { while (b > 0) ++a, --b; }
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_ATOMIC_COUNT_HPP
|
818
boost/asio/detail/bind_handler.hpp
Normal file
818
boost/asio/detail/bind_handler.hpp
Normal file
@ -0,0 +1,818 @@
|
||||
//
|
||||
// detail/bind_handler.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_BIND_HANDLER_HPP
|
||||
#define BOOST_ASIO_DETAIL_BIND_HANDLER_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/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_cont_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <boost/asio/detail/type_traits.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
class binder1
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
binder1(int, BOOST_ASIO_MOVE_ARG(T) handler, const Arg1& arg1)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(T)(handler)),
|
||||
arg1_(arg1)
|
||||
{
|
||||
}
|
||||
|
||||
binder1(Handler& handler, const Arg1& arg1)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
binder1(const binder1& other)
|
||||
: handler_(other.handler_),
|
||||
arg1_(other.arg1_)
|
||||
{
|
||||
}
|
||||
|
||||
binder1(binder1&& other)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(other.arg1_))
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
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)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline binder1<typename decay<Handler>::type, Arg1> bind_handler(
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1)
|
||||
{
|
||||
return binder1<typename decay<Handler>::type, Arg1>(0,
|
||||
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
class binder2
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
binder2(int, BOOST_ASIO_MOVE_ARG(T) handler,
|
||||
const Arg1& arg1, const Arg2& arg2)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(T)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2)
|
||||
{
|
||||
}
|
||||
|
||||
binder2(Handler& handler, const Arg1& arg1, const Arg2& arg2)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
binder2(const binder2& other)
|
||||
: handler_(other.handler_),
|
||||
arg1_(other.arg1_),
|
||||
arg2_(other.arg2_)
|
||||
{
|
||||
}
|
||||
|
||||
binder2(binder2&& other)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(other.arg1_)),
|
||||
arg2_(BOOST_ASIO_MOVE_CAST(Arg2)(other.arg2_))
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
static_cast<const Arg2&>(arg2_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_, arg2_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
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)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline binder2<typename decay<Handler>::type, Arg1, Arg2> bind_handler(
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1, const Arg2& arg2)
|
||||
{
|
||||
return binder2<typename decay<Handler>::type, Arg1, Arg2>(0,
|
||||
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, arg2);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
class binder3
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
binder3(int, BOOST_ASIO_MOVE_ARG(T) handler, const Arg1& arg1,
|
||||
const Arg2& arg2, const Arg3& arg3)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(T)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
binder3(const binder3& other)
|
||||
: handler_(other.handler_),
|
||||
arg1_(other.arg1_),
|
||||
arg2_(other.arg2_),
|
||||
arg3_(other.arg3_)
|
||||
{
|
||||
}
|
||||
|
||||
binder3(binder3&& other)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(other.arg1_)),
|
||||
arg2_(BOOST_ASIO_MOVE_CAST(Arg2)(other.arg2_)),
|
||||
arg3_(BOOST_ASIO_MOVE_CAST(Arg3)(other.arg3_))
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
static_cast<const Arg2&>(arg2_), static_cast<const Arg3&>(arg3_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_, arg2_, arg3_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
Arg3 arg3_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
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,
|
||||
binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
|
||||
inline binder3<typename decay<Handler>::type, Arg1, Arg2, Arg3> bind_handler(
|
||||
BOOST_ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1, const Arg2& arg2,
|
||||
const Arg3& arg3)
|
||||
{
|
||||
return binder3<typename decay<Handler>::type, Arg1, Arg2, Arg3>(0,
|
||||
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1,
|
||||
typename Arg2, typename Arg3, typename Arg4>
|
||||
class binder4
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
binder4(int, BOOST_ASIO_MOVE_ARG(T) handler, const Arg1& arg1,
|
||||
const Arg2& arg2, const Arg3& arg3, const Arg4& arg4)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(T)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
binder4(const binder4& other)
|
||||
: handler_(other.handler_),
|
||||
arg1_(other.arg1_),
|
||||
arg2_(other.arg2_),
|
||||
arg3_(other.arg3_),
|
||||
arg4_(other.arg4_)
|
||||
{
|
||||
}
|
||||
|
||||
binder4(binder4&& other)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(other.arg1_)),
|
||||
arg2_(BOOST_ASIO_MOVE_CAST(Arg2)(other.arg2_)),
|
||||
arg3_(BOOST_ASIO_MOVE_CAST(Arg3)(other.arg3_)),
|
||||
arg4_(BOOST_ASIO_MOVE_CAST(Arg4)(other.arg4_))
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
static_cast<const Arg2&>(arg2_), static_cast<const Arg3&>(arg3_),
|
||||
static_cast<const Arg4&>(arg4_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_, arg2_, arg3_, arg4_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
Arg3 arg3_;
|
||||
Arg4 arg4_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1,
|
||||
typename Arg2, typename Arg3, typename Arg4>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1,
|
||||
typename Arg2, typename Arg3, typename Arg4>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1,
|
||||
typename Arg2, typename Arg3, typename Arg4>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
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,
|
||||
binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1,
|
||||
typename Arg2, typename Arg3, typename Arg4>
|
||||
inline binder4<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4>
|
||||
bind_handler(BOOST_ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1,
|
||||
const Arg2& arg2, const Arg3& arg3, const Arg4& arg4)
|
||||
{
|
||||
return binder4<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4>(0,
|
||||
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
class binder5
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
binder5(int, BOOST_ASIO_MOVE_ARG(T) handler, const Arg1& arg1,
|
||||
const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(T)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(arg2),
|
||||
arg3_(arg3),
|
||||
arg4_(arg4),
|
||||
arg5_(arg5)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
binder5(const binder5& other)
|
||||
: handler_(other.handler_),
|
||||
arg1_(other.arg1_),
|
||||
arg2_(other.arg2_),
|
||||
arg3_(other.arg3_),
|
||||
arg4_(other.arg4_),
|
||||
arg5_(other.arg5_)
|
||||
{
|
||||
}
|
||||
|
||||
binder5(binder5&& other)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(other.arg1_)),
|
||||
arg2_(BOOST_ASIO_MOVE_CAST(Arg2)(other.arg2_)),
|
||||
arg3_(BOOST_ASIO_MOVE_CAST(Arg3)(other.arg3_)),
|
||||
arg4_(BOOST_ASIO_MOVE_CAST(Arg4)(other.arg4_)),
|
||||
arg5_(BOOST_ASIO_MOVE_CAST(Arg5)(other.arg5_))
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
static_cast<const Arg2&>(arg2_), static_cast<const Arg3&>(arg3_),
|
||||
static_cast<const Arg4&>(arg4_), static_cast<const Arg5&>(arg5_));
|
||||
}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
handler_(arg1_, arg2_, arg3_, arg4_, arg5_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
Arg3 arg3_;
|
||||
Arg4 arg4_;
|
||||
Arg5 arg5_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline bool asio_handler_is_continuation(
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
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,
|
||||
binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2,
|
||||
typename Arg3, typename Arg4, typename Arg5>
|
||||
inline binder5<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4, Arg5>
|
||||
bind_handler(BOOST_ASIO_MOVE_ARG(Handler) handler, const Arg1& arg1,
|
||||
const Arg2& arg2, const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
|
||||
{
|
||||
return binder5<typename decay<Handler>::type, Arg1, Arg2, Arg3, Arg4, Arg5>(0,
|
||||
BOOST_ASIO_MOVE_CAST(Handler)(handler), arg1, arg2, arg3, arg4, arg5);
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
class move_binder1
|
||||
{
|
||||
public:
|
||||
move_binder1(int, BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
BOOST_ASIO_MOVE_ARG(Arg1) arg1)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(arg1))
|
||||
{
|
||||
}
|
||||
|
||||
move_binder1(move_binder1&& other)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(other.arg1_))
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(BOOST_ASIO_MOVE_CAST(Arg1)(arg1_));
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
move_binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
move_binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1>
|
||||
inline bool asio_handler_is_continuation(
|
||||
move_binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1>
|
||||
inline void asio_handler_invoke(BOOST_ASIO_MOVE_ARG(Function) function,
|
||||
move_binder1<Handler, Arg1>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
BOOST_ASIO_MOVE_CAST(Function)(function), this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
class move_binder2
|
||||
{
|
||||
public:
|
||||
move_binder2(int, BOOST_ASIO_MOVE_ARG(Handler) handler,
|
||||
const Arg1& arg1, BOOST_ASIO_MOVE_ARG(Arg2) arg2)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
|
||||
arg1_(arg1),
|
||||
arg2_(BOOST_ASIO_MOVE_CAST(Arg2)(arg2))
|
||||
{
|
||||
}
|
||||
|
||||
move_binder2(move_binder2&& other)
|
||||
: handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
|
||||
arg1_(BOOST_ASIO_MOVE_CAST(Arg1)(other.arg1_)),
|
||||
arg2_(BOOST_ASIO_MOVE_CAST(Arg2)(other.arg2_))
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
handler_(static_cast<const Arg1&>(arg1_),
|
||||
BOOST_ASIO_MOVE_CAST(Arg2)(arg2_));
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler handler_;
|
||||
Arg1 arg1_;
|
||||
Arg2 arg2_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
move_binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline void asio_handler_deallocate(void* pointer, std::size_t size,
|
||||
move_binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2>
|
||||
inline bool asio_handler_is_continuation(
|
||||
move_binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler_);
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Arg1, typename Arg2>
|
||||
inline void asio_handler_invoke(BOOST_ASIO_MOVE_ARG(Function) function,
|
||||
move_binder2<Handler, Arg1, Arg2>* this_handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
BOOST_ASIO_MOVE_CAST(Function)(function), this_handler->handler_);
|
||||
}
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename Handler, typename Arg1, typename Allocator>
|
||||
struct associated_allocator<detail::binder1<Handler, Arg1>, Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(const detail::binder1<Handler, Arg1>& h,
|
||||
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Allocator>
|
||||
struct associated_allocator<detail::binder2<Handler, Arg1, Arg2>, Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(const detail::binder2<Handler, Arg1, Arg2>& h,
|
||||
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Executor>
|
||||
struct associated_executor<detail::binder1<Handler, Arg1>, Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(const detail::binder1<Handler, Arg1>& h,
|
||||
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Executor>
|
||||
struct associated_executor<detail::binder2<Handler, Arg1, Arg2>, Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(const detail::binder2<Handler, Arg1, Arg2>& h,
|
||||
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
template <typename Handler, typename Arg1, typename Allocator>
|
||||
struct associated_allocator<detail::move_binder1<Handler, Arg1>, Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(const detail::move_binder1<Handler, Arg1>& h,
|
||||
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Allocator>
|
||||
struct associated_allocator<
|
||||
detail::move_binder2<Handler, Arg1, Arg2>, Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(const detail::move_binder2<Handler, Arg1, Arg2>& h,
|
||||
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Executor>
|
||||
struct associated_executor<detail::move_binder1<Handler, Arg1>, Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(const detail::move_binder1<Handler, Arg1>& h,
|
||||
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename Arg1, typename Arg2, typename Executor>
|
||||
struct associated_executor<detail::move_binder2<Handler, Arg1, Arg2>, Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(const detail::move_binder2<Handler, Arg1, Arg2>& h,
|
||||
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_BIND_HANDLER_HPP
|
546
boost/asio/detail/buffer_sequence_adapter.hpp
Normal file
546
boost/asio/detail/buffer_sequence_adapter.hpp
Normal file
@ -0,0 +1,546 @@
|
||||
//
|
||||
// detail/buffer_sequence_adapter.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_BUFFER_SEQUENCE_ADAPTER_HPP
|
||||
#define BOOST_ASIO_DETAIL_BUFFER_SEQUENCE_ADAPTER_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/buffer.hpp>
|
||||
#include <boost/asio/detail/array_fwd.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class buffer_sequence_adapter_base
|
||||
{
|
||||
#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
||||
public:
|
||||
// The maximum number of buffers to support in a single operation.
|
||||
enum { max_buffers = 1 };
|
||||
|
||||
protected:
|
||||
typedef Windows::Storage::Streams::IBuffer^ native_buffer_type;
|
||||
|
||||
BOOST_ASIO_DECL static void init_native_buffer(
|
||||
native_buffer_type& buf,
|
||||
const boost::asio::mutable_buffer& buffer);
|
||||
|
||||
BOOST_ASIO_DECL static void init_native_buffer(
|
||||
native_buffer_type& buf,
|
||||
const boost::asio::const_buffer& buffer);
|
||||
#elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
public:
|
||||
// The maximum number of buffers to support in a single operation.
|
||||
enum { max_buffers = 64 < max_iov_len ? 64 : max_iov_len };
|
||||
|
||||
protected:
|
||||
typedef WSABUF native_buffer_type;
|
||||
|
||||
static void init_native_buffer(WSABUF& buf,
|
||||
const boost::asio::mutable_buffer& buffer)
|
||||
{
|
||||
buf.buf = static_cast<char*>(buffer.data());
|
||||
buf.len = static_cast<ULONG>(buffer.size());
|
||||
}
|
||||
|
||||
static void init_native_buffer(WSABUF& buf,
|
||||
const boost::asio::const_buffer& buffer)
|
||||
{
|
||||
buf.buf = const_cast<char*>(static_cast<const char*>(buffer.data()));
|
||||
buf.len = static_cast<ULONG>(buffer.size());
|
||||
}
|
||||
#else // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
public:
|
||||
// The maximum number of buffers to support in a single operation.
|
||||
enum { max_buffers = 64 < max_iov_len ? 64 : max_iov_len };
|
||||
|
||||
protected:
|
||||
typedef iovec native_buffer_type;
|
||||
|
||||
static void init_iov_base(void*& base, void* addr)
|
||||
{
|
||||
base = addr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void init_iov_base(T& base, void* addr)
|
||||
{
|
||||
base = static_cast<T>(addr);
|
||||
}
|
||||
|
||||
static void init_native_buffer(iovec& iov,
|
||||
const boost::asio::mutable_buffer& buffer)
|
||||
{
|
||||
init_iov_base(iov.iov_base, buffer.data());
|
||||
iov.iov_len = buffer.size();
|
||||
}
|
||||
|
||||
static void init_native_buffer(iovec& iov,
|
||||
const boost::asio::const_buffer& buffer)
|
||||
{
|
||||
init_iov_base(iov.iov_base, const_cast<void*>(buffer.data()));
|
||||
iov.iov_len = buffer.size();
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
};
|
||||
|
||||
// Helper class to translate buffers into the native buffer representation.
|
||||
template <typename Buffer, typename Buffers>
|
||||
class buffer_sequence_adapter
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(const Buffers& buffer_sequence)
|
||||
: count_(0), total_buffer_size_(0)
|
||||
{
|
||||
buffer_sequence_adapter::init(
|
||||
boost::asio::buffer_sequence_begin(buffer_sequence),
|
||||
boost::asio::buffer_sequence_end(buffer_sequence));
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return buffers_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return count_;
|
||||
}
|
||||
|
||||
std::size_t total_size() const
|
||||
{
|
||||
return total_buffer_size_;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const Buffers& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence_adapter::all_empty(
|
||||
boost::asio::buffer_sequence_begin(buffer_sequence),
|
||||
boost::asio::buffer_sequence_end(buffer_sequence));
|
||||
}
|
||||
|
||||
static void validate(const Buffers& buffer_sequence)
|
||||
{
|
||||
buffer_sequence_adapter::validate(
|
||||
boost::asio::buffer_sequence_begin(buffer_sequence),
|
||||
boost::asio::buffer_sequence_end(buffer_sequence));
|
||||
}
|
||||
|
||||
static Buffer first(const Buffers& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence_adapter::first(
|
||||
boost::asio::buffer_sequence_begin(buffer_sequence),
|
||||
boost::asio::buffer_sequence_end(buffer_sequence));
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Iterator>
|
||||
void init(Iterator begin, Iterator end)
|
||||
{
|
||||
Iterator iter = begin;
|
||||
for (; iter != end && count_ < max_buffers; ++iter, ++count_)
|
||||
{
|
||||
Buffer buffer(*iter);
|
||||
init_native_buffer(buffers_[count_], buffer);
|
||||
total_buffer_size_ += buffer.size();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
static bool all_empty(Iterator begin, Iterator end)
|
||||
{
|
||||
Iterator iter = begin;
|
||||
std::size_t i = 0;
|
||||
for (; iter != end && i < max_buffers; ++iter, ++i)
|
||||
if (Buffer(*iter).size() > 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
static void validate(Iterator begin, Iterator end)
|
||||
{
|
||||
Iterator iter = begin;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
Buffer buffer(*iter);
|
||||
buffer.data();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Iterator>
|
||||
static Buffer first(Iterator begin, Iterator end)
|
||||
{
|
||||
Iterator iter = begin;
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
Buffer buffer(*iter);
|
||||
if (buffer.size() != 0)
|
||||
return buffer;
|
||||
}
|
||||
return Buffer();
|
||||
}
|
||||
|
||||
native_buffer_type buffers_[max_buffers];
|
||||
std::size_t count_;
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
template <typename Buffer>
|
||||
class buffer_sequence_adapter<Buffer, boost::asio::mutable_buffer>
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const boost::asio::mutable_buffer& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffer_, Buffer(buffer_sequence));
|
||||
total_buffer_size_ = buffer_sequence.size();
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return &buffer_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::size_t total_size() const
|
||||
{
|
||||
return total_buffer_size_;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::asio::mutable_buffer& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence.size() == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::asio::mutable_buffer& buffer_sequence)
|
||||
{
|
||||
buffer_sequence.data();
|
||||
}
|
||||
|
||||
static Buffer first(const boost::asio::mutable_buffer& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffer_sequence);
|
||||
}
|
||||
|
||||
private:
|
||||
native_buffer_type buffer_;
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
template <typename Buffer>
|
||||
class buffer_sequence_adapter<Buffer, boost::asio::const_buffer>
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const boost::asio::const_buffer& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffer_, Buffer(buffer_sequence));
|
||||
total_buffer_size_ = buffer_sequence.size();
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return &buffer_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::size_t total_size() const
|
||||
{
|
||||
return total_buffer_size_;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::asio::const_buffer& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence.size() == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::asio::const_buffer& buffer_sequence)
|
||||
{
|
||||
buffer_sequence.data();
|
||||
}
|
||||
|
||||
static Buffer first(const boost::asio::const_buffer& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffer_sequence);
|
||||
}
|
||||
|
||||
private:
|
||||
native_buffer_type buffer_;
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
#if !defined(BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
template <typename Buffer>
|
||||
class buffer_sequence_adapter<Buffer, boost::asio::mutable_buffers_1>
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffer_, Buffer(buffer_sequence));
|
||||
total_buffer_size_ = buffer_sequence.size();
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return &buffer_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::size_t total_size() const
|
||||
{
|
||||
return total_buffer_size_;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence.size() == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
buffer_sequence.data();
|
||||
}
|
||||
|
||||
static Buffer first(const boost::asio::mutable_buffers_1& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffer_sequence);
|
||||
}
|
||||
|
||||
private:
|
||||
native_buffer_type buffer_;
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
template <typename Buffer>
|
||||
class buffer_sequence_adapter<Buffer, boost::asio::const_buffers_1>
|
||||
: buffer_sequence_adapter_base
|
||||
{
|
||||
public:
|
||||
explicit buffer_sequence_adapter(
|
||||
const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
init_native_buffer(buffer_, Buffer(buffer_sequence));
|
||||
total_buffer_size_ = buffer_sequence.size();
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return &buffer_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::size_t total_size() const
|
||||
{
|
||||
return total_buffer_size_;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence.size() == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
buffer_sequence.data();
|
||||
}
|
||||
|
||||
static Buffer first(const boost::asio::const_buffers_1& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffer_sequence);
|
||||
}
|
||||
|
||||
private:
|
||||
native_buffer_type buffer_;
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
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_ = buffer_sequence[0].size() + buffer_sequence[1].size();
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return buffers_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
std::size_t total_size() const
|
||||
{
|
||||
return total_buffer_size_;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const boost::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence[0].size() == 0 && buffer_sequence[1].size() == 0;
|
||||
}
|
||||
|
||||
static void validate(const boost::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
buffer_sequence[0].data();
|
||||
buffer_sequence[1].data();
|
||||
}
|
||||
|
||||
static Buffer first(const boost::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffer_sequence[0].size() != 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_ = buffer_sequence[0].size() + buffer_sequence[1].size();
|
||||
}
|
||||
|
||||
native_buffer_type* buffers()
|
||||
{
|
||||
return buffers_;
|
||||
}
|
||||
|
||||
std::size_t count() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
std::size_t total_size() const
|
||||
{
|
||||
return total_buffer_size_;
|
||||
}
|
||||
|
||||
bool all_empty() const
|
||||
{
|
||||
return total_buffer_size_ == 0;
|
||||
}
|
||||
|
||||
static bool all_empty(const std::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return buffer_sequence[0].size() == 0 && buffer_sequence[1].size() == 0;
|
||||
}
|
||||
|
||||
static void validate(const std::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
buffer_sequence[0].data();
|
||||
buffer_sequence[1].data();
|
||||
}
|
||||
|
||||
static Buffer first(const std::array<Elem, 2>& buffer_sequence)
|
||||
{
|
||||
return Buffer(buffer_sequence[0].size() != 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
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HEADER_ONLY)
|
||||
# include <boost/asio/detail/impl/buffer_sequence_adapter.ipp>
|
||||
#endif // defined(BOOST_ASIO_HEADER_ONLY)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_BUFFER_SEQUENCE_ADAPTER_HPP
|
127
boost/asio/detail/call_stack.hpp
Normal file
127
boost/asio/detail/call_stack.hpp
Normal file
@ -0,0 +1,127 @@
|
||||
//
|
||||
// detail/call_stack.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_CALL_STACK_HPP
|
||||
#define BOOST_ASIO_DETAIL_CALL_STACK_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/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/tss_ptr.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Helper class to determine whether or not the current thread is inside an
|
||||
// invocation of io_context::run() for a specified io_context object.
|
||||
template <typename Key, typename Value = unsigned char>
|
||||
class call_stack
|
||||
{
|
||||
public:
|
||||
// Context class automatically pushes the key/value pair on to the stack.
|
||||
class context
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
// Push the key on to the stack.
|
||||
explicit context(Key* k)
|
||||
: key_(k),
|
||||
next_(call_stack<Key, Value>::top_)
|
||||
{
|
||||
value_ = reinterpret_cast<unsigned char*>(this);
|
||||
call_stack<Key, Value>::top_ = this;
|
||||
}
|
||||
|
||||
// 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<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<Key, Value>;
|
||||
|
||||
// The key associated with the context.
|
||||
Key* key_;
|
||||
|
||||
// The value associated with the context.
|
||||
Value* value_;
|
||||
|
||||
// The next element in the stack.
|
||||
context* next_;
|
||||
};
|
||||
|
||||
friend class context;
|
||||
|
||||
// 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->key_ == k)
|
||||
return elem->value_;
|
||||
elem = elem->next_;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Obtain the value at the top of the stack.
|
||||
static Value* top()
|
||||
{
|
||||
context* elem = top_;
|
||||
return elem ? elem->value_ : 0;
|
||||
}
|
||||
|
||||
private:
|
||||
// The top of the stack of calls for the current thread.
|
||||
static tss_ptr<context> top_;
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
tss_ptr<typename call_stack<Key, Value>::context>
|
||||
call_stack<Key, Value>::top_;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CALL_STACK_HPP
|
68
boost/asio/detail/chrono.hpp
Normal file
68
boost/asio/detail/chrono.hpp
Normal file
@ -0,0 +1,68 @@
|
||||
//
|
||||
// detail/chrono.hpp
|
||||
// ~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_HPP
|
||||
#define BOOST_ASIO_DETAIL_CHRONO_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_CHRONO)
|
||||
# include <chrono>
|
||||
#elif defined(BOOST_ASIO_HAS_BOOST_CHRONO)
|
||||
# include <boost/chrono/system_clocks.hpp>
|
||||
#endif // defined(BOOST_ASIO_HAS_BOOST_CHRONO)
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace chrono {
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_STD_CHRONO)
|
||||
using std::chrono::duration;
|
||||
using std::chrono::time_point;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::nanoseconds;
|
||||
using std::chrono::microseconds;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::time_point_cast;
|
||||
#if defined(BOOST_ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK)
|
||||
typedef std::chrono::monotonic_clock steady_clock;
|
||||
#else // defined(BOOST_ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK)
|
||||
using std::chrono::steady_clock;
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_CHRONO_MONOTONIC_CLOCK)
|
||||
using std::chrono::system_clock;
|
||||
using std::chrono::high_resolution_clock;
|
||||
#elif defined(BOOST_ASIO_HAS_BOOST_CHRONO)
|
||||
using boost::chrono::duration;
|
||||
using boost::chrono::time_point;
|
||||
using boost::chrono::duration_cast;
|
||||
using boost::chrono::nanoseconds;
|
||||
using boost::chrono::microseconds;
|
||||
using boost::chrono::milliseconds;
|
||||
using boost::chrono::seconds;
|
||||
using boost::chrono::minutes;
|
||||
using boost::chrono::hours;
|
||||
using boost::chrono::time_point_cast;
|
||||
using boost::chrono::system_clock;
|
||||
using boost::chrono::steady_clock;
|
||||
using boost::chrono::high_resolution_clock;
|
||||
#endif // defined(BOOST_ASIO_HAS_BOOST_CHRONO)
|
||||
|
||||
} // namespace chrono
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CHRONO_HPP
|
192
boost/asio/detail/chrono_time_traits.hpp
Normal file
192
boost/asio/detail/chrono_time_traits.hpp
Normal file
@ -0,0 +1,192 @@
|
||||
//
|
||||
// detail/chrono_time_traits.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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/asio/detail/cstdint.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Helper template to compute the greatest common divisor.
|
||||
template <int64_t v1, int64_t v2>
|
||||
struct gcd { enum { value = gcd<v2, v1 % v2>::value }; };
|
||||
|
||||
template <int64_t v1>
|
||||
struct gcd<v1, 0> { enum { value = v1 }; };
|
||||
|
||||
// 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)
|
||||
{
|
||||
const time_type epoch;
|
||||
if (t >= epoch)
|
||||
{
|
||||
if ((time_type::max)() - t < d)
|
||||
return (time_type::max)();
|
||||
}
|
||||
else // t < epoch
|
||||
{
|
||||
if (-(t - (time_type::min)()) > d)
|
||||
return (time_type::min)();
|
||||
}
|
||||
|
||||
return t + d;
|
||||
}
|
||||
|
||||
// Subtract one time from another.
|
||||
static duration_type subtract(const time_type& t1, const time_type& t2)
|
||||
{
|
||||
const time_type epoch;
|
||||
if (t1 >= epoch)
|
||||
{
|
||||
if (t2 >= epoch)
|
||||
{
|
||||
return t1 - t2;
|
||||
}
|
||||
else if (t2 == (time_type::min)())
|
||||
{
|
||||
return (duration_type::max)();
|
||||
}
|
||||
else if ((time_type::max)() - t1 < epoch - t2)
|
||||
{
|
||||
return (duration_type::max)();
|
||||
}
|
||||
else
|
||||
{
|
||||
return t1 - t2;
|
||||
}
|
||||
}
|
||||
else // t1 < epoch
|
||||
{
|
||||
if (t2 < epoch)
|
||||
{
|
||||
return t1 - t2;
|
||||
}
|
||||
else if (t1 == (time_type::min)())
|
||||
{
|
||||
return (duration_type::min)();
|
||||
}
|
||||
else if ((time_type::max)() - t2 < epoch - t1)
|
||||
{
|
||||
return (duration_type::min)();
|
||||
}
|
||||
else
|
||||
{
|
||||
return -(t2 - t1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
int64_t ticks() const
|
||||
{
|
||||
return d_.count();
|
||||
}
|
||||
|
||||
int64_t total_seconds() const
|
||||
{
|
||||
return duration_cast<1, 1>();
|
||||
}
|
||||
|
||||
int64_t total_milliseconds() const
|
||||
{
|
||||
return duration_cast<1, 1000>();
|
||||
}
|
||||
|
||||
int64_t total_microseconds() const
|
||||
{
|
||||
return duration_cast<1, 1000000>();
|
||||
}
|
||||
|
||||
private:
|
||||
template <int64_t Num, int64_t Den>
|
||||
int64_t duration_cast() const
|
||||
{
|
||||
const int64_t num1 = period_type::num / gcd<period_type::num, Num>::value;
|
||||
const int64_t num2 = Num / gcd<period_type::num, Num>::value;
|
||||
|
||||
const int64_t den1 = period_type::den / gcd<period_type::den, Den>::value;
|
||||
const int64_t den2 = Den / gcd<period_type::den, Den>::value;
|
||||
|
||||
const int64_t num = num1 * den2;
|
||||
const int64_t den = num2 * den1;
|
||||
|
||||
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
|
85
boost/asio/detail/completion_handler.hpp
Normal file
85
boost/asio/detail/completion_handler.hpp
Normal file
@ -0,0 +1,85 @@
|
||||
//
|
||||
// detail/completion_handler.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_COMPLETION_HANDLER_HPP
|
||||
#define BOOST_ASIO_DETAIL_COMPLETION_HANDLER_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/detail/fenced_block.hpp>
|
||||
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_work.hpp>
|
||||
#include <boost/asio/detail/memory.hpp>
|
||||
#include <boost/asio/detail/operation.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename Handler>
|
||||
class completion_handler : public operation
|
||||
{
|
||||
public:
|
||||
BOOST_ASIO_DEFINE_HANDLER_PTR(completion_handler);
|
||||
|
||||
completion_handler(Handler& h)
|
||||
: operation(&completion_handler::do_complete),
|
||||
handler_(BOOST_ASIO_MOVE_CAST(Handler)(h))
|
||||
{
|
||||
handler_work<Handler>::start(handler_);
|
||||
}
|
||||
|
||||
static void do_complete(void* owner, operation* base,
|
||||
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::asio::detail::addressof(h->handler_), h, h };
|
||||
handler_work<Handler> w(h->handler_);
|
||||
|
||||
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(BOOST_ASIO_MOVE_CAST(Handler)(h->handler_));
|
||||
p.h = boost::asio::detail::addressof(handler);
|
||||
p.reset();
|
||||
|
||||
// Make the upcall if required.
|
||||
if (owner)
|
||||
{
|
||||
fenced_block b(fenced_block::half);
|
||||
BOOST_ASIO_HANDLER_INVOCATION_BEGIN(());
|
||||
w.complete(handler, handler);
|
||||
BOOST_ASIO_HANDLER_INVOCATION_END;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Handler handler_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_COMPLETION_HANDLER_HPP
|
94
boost/asio/detail/concurrency_hint.hpp
Normal file
94
boost/asio/detail/concurrency_hint.hpp
Normal file
@ -0,0 +1,94 @@
|
||||
//
|
||||
// detail/concurrency_hint.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_CONCURRENCY_HINT_HPP
|
||||
#define BOOST_ASIO_DETAIL_CONCURRENCY_HINT_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/detail/noncopyable.hpp>
|
||||
|
||||
// The concurrency hint ID and mask are used to identify when a "well-known"
|
||||
// concurrency hint value has been passed to the io_context.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_ID 0xA5100000u
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_ID_MASK 0xFFFF0000u
|
||||
|
||||
// If set, this bit indicates that the scheduler should perform locking.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_LOCKING_SCHEDULER 0x1u
|
||||
|
||||
// If set, this bit indicates that the reactor should perform locking when
|
||||
// managing descriptor registrations.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_REGISTRATION 0x2u
|
||||
|
||||
// If set, this bit indicates that the reactor should perform locking for I/O.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_IO 0x4u
|
||||
|
||||
// Helper macro to determine if we have a special concurrency hint.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_IS_SPECIAL(hint) \
|
||||
((static_cast<unsigned>(hint) \
|
||||
& BOOST_ASIO_CONCURRENCY_HINT_ID_MASK) \
|
||||
== BOOST_ASIO_CONCURRENCY_HINT_ID)
|
||||
|
||||
// Helper macro to determine if locking is enabled for a given facility.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_IS_LOCKING(facility, hint) \
|
||||
(((static_cast<unsigned>(hint) \
|
||||
& (BOOST_ASIO_CONCURRENCY_HINT_ID_MASK \
|
||||
| BOOST_ASIO_CONCURRENCY_HINT_LOCKING_ ## facility)) \
|
||||
^ BOOST_ASIO_CONCURRENCY_HINT_ID) != 0)
|
||||
|
||||
// This special concurrency hint disables locking in both the scheduler and
|
||||
// reactor I/O. This hint has the following restrictions:
|
||||
//
|
||||
// - Care must be taken to ensure that all operations on the io_context and any
|
||||
// of its associated I/O objects (such as sockets and timers) occur in only
|
||||
// one thread at a time.
|
||||
//
|
||||
// - Asynchronous resolve operations fail with operation_not_supported.
|
||||
//
|
||||
// - If a signal_set is used with the io_context, signal_set objects cannot be
|
||||
// used with any other io_context in the program.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_UNSAFE \
|
||||
static_cast<int>(BOOST_ASIO_CONCURRENCY_HINT_ID)
|
||||
|
||||
// This special concurrency hint disables locking in the reactor I/O. This hint
|
||||
// has the following restrictions:
|
||||
//
|
||||
// - Care must be taken to ensure that run functions on the io_context, and all
|
||||
// operations on the io_context's associated I/O objects (such as sockets and
|
||||
// timers), occur in only one thread at a time.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_UNSAFE_IO \
|
||||
static_cast<int>(BOOST_ASIO_CONCURRENCY_HINT_ID \
|
||||
| BOOST_ASIO_CONCURRENCY_HINT_LOCKING_SCHEDULER \
|
||||
| BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_REGISTRATION)
|
||||
|
||||
// The special concurrency hint provides full thread safety.
|
||||
#define BOOST_ASIO_CONCURRENCY_HINT_SAFE \
|
||||
static_cast<int>(BOOST_ASIO_CONCURRENCY_HINT_ID \
|
||||
| BOOST_ASIO_CONCURRENCY_HINT_LOCKING_SCHEDULER \
|
||||
| BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_REGISTRATION \
|
||||
| BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_IO)
|
||||
|
||||
// This #define may be overridden at compile time to specify a program-wide
|
||||
// default concurrency hint, used by the zero-argument io_context constructor.
|
||||
#if !defined(BOOST_ASIO_CONCURRENCY_HINT_DEFAULT)
|
||||
# define BOOST_ASIO_CONCURRENCY_HINT_DEFAULT -1
|
||||
#endif // !defined(BOOST_ASIO_CONCURRENCY_HINT_DEFAULT)
|
||||
|
||||
// This #define may be overridden at compile time to specify a program-wide
|
||||
// concurrency hint, used by the one-argument io_context constructor when
|
||||
// passed a value of 1.
|
||||
#if !defined(BOOST_ASIO_CONCURRENCY_HINT_1)
|
||||
# define BOOST_ASIO_CONCURRENCY_HINT_1 1
|
||||
#endif // !defined(BOOST_ASIO_CONCURRENCY_HINT_DEFAULT)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CONCURRENCY_HINT_HPP
|
114
boost/asio/detail/conditionally_enabled_event.hpp
Normal file
114
boost/asio/detail/conditionally_enabled_event.hpp
Normal file
@ -0,0 +1,114 @@
|
||||
//
|
||||
// detail/conditionally_enabled_event.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_CONDITIONALLY_ENABLED_EVENT_HPP
|
||||
#define BOOST_ASIO_DETAIL_CONDITIONALLY_ENABLED_EVENT_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/detail/conditionally_enabled_mutex.hpp>
|
||||
#include <boost/asio/detail/event.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/null_event.hpp>
|
||||
#include <boost/asio/detail/scoped_lock.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Mutex adapter used to conditionally enable or disable locking.
|
||||
class conditionally_enabled_event
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
// Constructor.
|
||||
conditionally_enabled_event()
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor.
|
||||
~conditionally_enabled_event()
|
||||
{
|
||||
}
|
||||
|
||||
// Signal the event. (Retained for backward compatibility.)
|
||||
void signal(conditionally_enabled_mutex::scoped_lock& lock)
|
||||
{
|
||||
if (lock.mutex_.enabled_)
|
||||
event_.signal(lock);
|
||||
}
|
||||
|
||||
// Signal all waiters.
|
||||
void signal_all(conditionally_enabled_mutex::scoped_lock& lock)
|
||||
{
|
||||
if (lock.mutex_.enabled_)
|
||||
event_.signal_all(lock);
|
||||
}
|
||||
|
||||
// Unlock the mutex and signal one waiter.
|
||||
void unlock_and_signal_one(
|
||||
conditionally_enabled_mutex::scoped_lock& lock)
|
||||
{
|
||||
if (lock.mutex_.enabled_)
|
||||
event_.unlock_and_signal_one(lock);
|
||||
}
|
||||
|
||||
// If there's a waiter, unlock the mutex and signal it.
|
||||
bool maybe_unlock_and_signal_one(
|
||||
conditionally_enabled_mutex::scoped_lock& lock)
|
||||
{
|
||||
if (lock.mutex_.enabled_)
|
||||
return event_.maybe_unlock_and_signal_one(lock);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the event.
|
||||
void clear(conditionally_enabled_mutex::scoped_lock& lock)
|
||||
{
|
||||
if (lock.mutex_.enabled_)
|
||||
event_.clear(lock);
|
||||
}
|
||||
|
||||
// Wait for the event to become signalled.
|
||||
void wait(conditionally_enabled_mutex::scoped_lock& lock)
|
||||
{
|
||||
if (lock.mutex_.enabled_)
|
||||
event_.wait(lock);
|
||||
else
|
||||
null_event().wait(lock);
|
||||
}
|
||||
|
||||
// Timed wait for the event to become signalled.
|
||||
bool wait_for_usec(
|
||||
conditionally_enabled_mutex::scoped_lock& lock, long usec)
|
||||
{
|
||||
if (lock.mutex_.enabled_)
|
||||
return event_.wait_for_usec(lock, usec);
|
||||
else
|
||||
return null_event().wait_for_usec(lock, usec);
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::detail::event event_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CONDITIONALLY_ENABLED_EVENT_HPP
|
151
boost/asio/detail/conditionally_enabled_mutex.hpp
Normal file
151
boost/asio/detail/conditionally_enabled_mutex.hpp
Normal file
@ -0,0 +1,151 @@
|
||||
//
|
||||
// detail/conditionally_enabled_mutex.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_CONDITIONALLY_ENABLED_MUTEX_HPP
|
||||
#define BOOST_ASIO_DETAIL_CONDITIONALLY_ENABLED_MUTEX_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/detail/mutex.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/scoped_lock.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
// Mutex adapter used to conditionally enable or disable locking.
|
||||
class conditionally_enabled_mutex
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
// Helper class to lock and unlock a mutex automatically.
|
||||
class scoped_lock
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
// Tag type used to distinguish constructors.
|
||||
enum adopt_lock_t { adopt_lock };
|
||||
|
||||
// Constructor adopts a lock that is already held.
|
||||
scoped_lock(conditionally_enabled_mutex& m, adopt_lock_t)
|
||||
: mutex_(m),
|
||||
locked_(m.enabled_)
|
||||
{
|
||||
}
|
||||
|
||||
// Constructor acquires the lock.
|
||||
explicit scoped_lock(conditionally_enabled_mutex& m)
|
||||
: mutex_(m)
|
||||
{
|
||||
if (m.enabled_)
|
||||
{
|
||||
mutex_.mutex_.lock();
|
||||
locked_ = true;
|
||||
}
|
||||
else
|
||||
locked_ = false;
|
||||
}
|
||||
|
||||
// Destructor releases the lock.
|
||||
~scoped_lock()
|
||||
{
|
||||
if (locked_)
|
||||
mutex_.mutex_.unlock();
|
||||
}
|
||||
|
||||
// Explicitly acquire the lock.
|
||||
void lock()
|
||||
{
|
||||
if (mutex_.enabled_ && !locked_)
|
||||
{
|
||||
mutex_.mutex_.lock();
|
||||
locked_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Explicitly release the lock.
|
||||
void unlock()
|
||||
{
|
||||
if (locked_)
|
||||
{
|
||||
mutex_.unlock();
|
||||
locked_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Test whether the lock is held.
|
||||
bool locked() const
|
||||
{
|
||||
return locked_;
|
||||
}
|
||||
|
||||
// Get the underlying mutex.
|
||||
boost::asio::detail::mutex& mutex()
|
||||
{
|
||||
return mutex_.mutex_;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class conditionally_enabled_event;
|
||||
conditionally_enabled_mutex& mutex_;
|
||||
bool locked_;
|
||||
};
|
||||
|
||||
// Constructor.
|
||||
explicit conditionally_enabled_mutex(bool enabled)
|
||||
: enabled_(enabled)
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor.
|
||||
~conditionally_enabled_mutex()
|
||||
{
|
||||
}
|
||||
|
||||
// Determine whether locking is enabled.
|
||||
bool enabled() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
// Lock the mutex.
|
||||
void lock()
|
||||
{
|
||||
if (enabled_)
|
||||
mutex_.lock();
|
||||
}
|
||||
|
||||
// Unlock the mutex.
|
||||
void unlock()
|
||||
{
|
||||
if (enabled_)
|
||||
mutex_.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
friend class scoped_lock;
|
||||
friend class conditionally_enabled_event;
|
||||
boost::asio::detail::mutex mutex_;
|
||||
const bool enabled_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CONDITIONALLY_ENABLED_MUTEX_HPP
|
1442
boost/asio/detail/config.hpp
Normal file
1442
boost/asio/detail/config.hpp
Normal file
File diff suppressed because it is too large
Load Diff
33
boost/asio/detail/cstddef.hpp
Normal file
33
boost/asio/detail/cstddef.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// detail/cstddef.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_CSTDDEF_HPP
|
||||
#define BOOST_ASIO_DETAIL_CSTDDEF_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>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_NULLPTR)
|
||||
using std::nullptr_t;
|
||||
#else // defined(BOOST_ASIO_HAS_NULLPTR)
|
||||
struct nullptr_t {};
|
||||
#endif // defined(BOOST_ASIO_HAS_NULLPTR)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CSTDDEF_HPP
|
62
boost/asio/detail/cstdint.hpp
Normal file
62
boost/asio/detail/cstdint.hpp
Normal file
@ -0,0 +1,62 @@
|
||||
//
|
||||
// detail/cstdint.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_CSTDINT_HPP
|
||||
#define BOOST_ASIO_DETAIL_CSTDINT_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_CSTDINT)
|
||||
# include <cstdint>
|
||||
#else // defined(BOOST_ASIO_HAS_CSTDINT)
|
||||
# include <boost/cstdint.hpp>
|
||||
#endif // defined(BOOST_ASIO_HAS_CSTDINT)
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_CSTDINT)
|
||||
using std::int16_t;
|
||||
using std::int_least16_t;
|
||||
using std::uint16_t;
|
||||
using std::uint_least16_t;
|
||||
using std::int32_t;
|
||||
using std::int_least32_t;
|
||||
using std::uint32_t;
|
||||
using std::uint_least32_t;
|
||||
using std::int64_t;
|
||||
using std::int_least64_t;
|
||||
using std::uint64_t;
|
||||
using std::uint_least64_t;
|
||||
using std::uintmax_t;
|
||||
#else // defined(BOOST_ASIO_HAS_CSTDINT)
|
||||
using boost::int16_t;
|
||||
using boost::int_least16_t;
|
||||
using boost::uint16_t;
|
||||
using boost::uint_least16_t;
|
||||
using boost::int32_t;
|
||||
using boost::int_least32_t;
|
||||
using boost::uint32_t;
|
||||
using boost::uint_least32_t;
|
||||
using boost::int64_t;
|
||||
using boost::int_least64_t;
|
||||
using boost::uint64_t;
|
||||
using boost::uint_least64_t;
|
||||
using boost::uintmax_t;
|
||||
#endif // defined(BOOST_ASIO_HAS_CSTDINT)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CSTDINT_HPP
|
220
boost/asio/detail/dev_poll_reactor.hpp
Normal file
220
boost/asio/detail/dev_poll_reactor.hpp
Normal file
@ -0,0 +1,220 @@
|
||||
//
|
||||
// detail/dev_poll_reactor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_DEV_POLL_REACTOR_HPP
|
||||
#define BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_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_DEV_POLL)
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <sys/devpoll.h>
|
||||
#include <boost/asio/detail/hash_map.hpp>
|
||||
#include <boost/asio/detail/limits.hpp>
|
||||
#include <boost/asio/detail/mutex.hpp>
|
||||
#include <boost/asio/detail/op_queue.hpp>
|
||||
#include <boost/asio/detail/reactor_op.hpp>
|
||||
#include <boost/asio/detail/reactor_op_queue.hpp>
|
||||
#include <boost/asio/detail/select_interrupter.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
#include <boost/asio/detail/timer_queue_base.hpp>
|
||||
#include <boost/asio/detail/timer_queue_set.hpp>
|
||||
#include <boost/asio/detail/wait_op.hpp>
|
||||
#include <boost/asio/execution_context.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class dev_poll_reactor
|
||||
: public execution_context_service_base<dev_poll_reactor>
|
||||
{
|
||||
public:
|
||||
enum op_types { read_op = 0, write_op = 1,
|
||||
connect_op = 1, except_op = 2, max_ops = 3 };
|
||||
|
||||
// Per-descriptor data.
|
||||
struct per_descriptor_data
|
||||
{
|
||||
};
|
||||
|
||||
// Constructor.
|
||||
BOOST_ASIO_DECL dev_poll_reactor(boost::asio::execution_context& ctx);
|
||||
|
||||
// Destructor.
|
||||
BOOST_ASIO_DECL ~dev_poll_reactor();
|
||||
|
||||
// Destroy all user-defined handler objects owned by the service.
|
||||
BOOST_ASIO_DECL void shutdown();
|
||||
|
||||
// Recreate internal descriptors following a fork.
|
||||
BOOST_ASIO_DECL void notify_fork(
|
||||
boost::asio::execution_context::fork_event fork_ev);
|
||||
|
||||
// Initialise the task.
|
||||
BOOST_ASIO_DECL void init_task();
|
||||
|
||||
// Register a socket with the reactor. Returns 0 on success, system error
|
||||
// code on failure.
|
||||
BOOST_ASIO_DECL int register_descriptor(socket_type, per_descriptor_data&);
|
||||
|
||||
// Register a descriptor with an associated single operation. Returns 0 on
|
||||
// success, system error code on failure.
|
||||
BOOST_ASIO_DECL int register_internal_descriptor(
|
||||
int op_type, socket_type descriptor,
|
||||
per_descriptor_data& descriptor_data, reactor_op* op);
|
||||
|
||||
// Move descriptor registration from one descriptor_data object to another.
|
||||
BOOST_ASIO_DECL void move_descriptor(socket_type descriptor,
|
||||
per_descriptor_data& target_descriptor_data,
|
||||
per_descriptor_data& source_descriptor_data);
|
||||
|
||||
// Post a reactor operation for immediate completion.
|
||||
void post_immediate_completion(reactor_op* op, bool is_continuation)
|
||||
{
|
||||
scheduler_.post_immediate_completion(op, is_continuation);
|
||||
}
|
||||
|
||||
// Start a new operation. The reactor operation will be performed when the
|
||||
// given descriptor is flagged as ready, or an error has occurred.
|
||||
BOOST_ASIO_DECL void start_op(int op_type, socket_type descriptor,
|
||||
per_descriptor_data&, reactor_op* op,
|
||||
bool is_continuation, bool allow_speculative);
|
||||
|
||||
// Cancel all operations associated with the given descriptor. The
|
||||
// handlers associated with the descriptor will be invoked with the
|
||||
// operation_aborted error.
|
||||
BOOST_ASIO_DECL void cancel_ops(socket_type descriptor, per_descriptor_data&);
|
||||
|
||||
// Cancel any operations that are running against the descriptor and remove
|
||||
// its registration from the reactor. The reactor resources associated with
|
||||
// the descriptor must be released by calling cleanup_descriptor_data.
|
||||
BOOST_ASIO_DECL void deregister_descriptor(socket_type descriptor,
|
||||
per_descriptor_data&, bool closing);
|
||||
|
||||
// Remove the descriptor's registration from the reactor. The reactor
|
||||
// resources associated with the descriptor must be released by calling
|
||||
// cleanup_descriptor_data.
|
||||
BOOST_ASIO_DECL void deregister_internal_descriptor(
|
||||
socket_type descriptor, per_descriptor_data&);
|
||||
|
||||
// Perform any post-deregistration cleanup tasks associated with the
|
||||
// descriptor data.
|
||||
BOOST_ASIO_DECL void cleanup_descriptor_data(per_descriptor_data&);
|
||||
|
||||
// Add a new timer queue to the reactor.
|
||||
template <typename Time_Traits>
|
||||
void add_timer_queue(timer_queue<Time_Traits>& queue);
|
||||
|
||||
// Remove a timer queue from the reactor.
|
||||
template <typename Time_Traits>
|
||||
void remove_timer_queue(timer_queue<Time_Traits>& queue);
|
||||
|
||||
// Schedule a new operation in the given timer queue to expire at the
|
||||
// specified absolute time.
|
||||
template <typename Time_Traits>
|
||||
void schedule_timer(timer_queue<Time_Traits>& queue,
|
||||
const typename Time_Traits::time_type& time,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op);
|
||||
|
||||
// Cancel the timer operations associated with the given token. Returns the
|
||||
// number of operations that have been posted or dispatched.
|
||||
template <typename Time_Traits>
|
||||
std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& timer,
|
||||
std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
|
||||
|
||||
// Move the timer operations associated with the given timer.
|
||||
template <typename Time_Traits>
|
||||
void move_timer(timer_queue<Time_Traits>& queue,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& target,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& source);
|
||||
|
||||
// Run /dev/poll once until interrupted or events are ready to be dispatched.
|
||||
BOOST_ASIO_DECL void run(long usec, op_queue<operation>& ops);
|
||||
|
||||
// Interrupt the select loop.
|
||||
BOOST_ASIO_DECL void interrupt();
|
||||
|
||||
private:
|
||||
// Create the /dev/poll file descriptor. Throws an exception if the descriptor
|
||||
// cannot be created.
|
||||
BOOST_ASIO_DECL static int do_dev_poll_create();
|
||||
|
||||
// Helper function to add a new timer queue.
|
||||
BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue);
|
||||
|
||||
// Helper function to remove a timer queue.
|
||||
BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue);
|
||||
|
||||
// Get the timeout value for the /dev/poll DP_POLL operation. The timeout
|
||||
// value is returned as a number of milliseconds. A return value of -1
|
||||
// indicates that the poll should block indefinitely.
|
||||
BOOST_ASIO_DECL int get_timeout(int msec);
|
||||
|
||||
// Cancel all operations associated with the given descriptor. The do_cancel
|
||||
// function of the handler objects will be invoked. This function does not
|
||||
// acquire the dev_poll_reactor's mutex.
|
||||
BOOST_ASIO_DECL void cancel_ops_unlocked(socket_type descriptor,
|
||||
const boost::system::error_code& ec);
|
||||
|
||||
// Add a pending event entry for the given descriptor.
|
||||
BOOST_ASIO_DECL ::pollfd& add_pending_event_change(int descriptor);
|
||||
|
||||
// The scheduler implementation used to post completions.
|
||||
scheduler& scheduler_;
|
||||
|
||||
// Mutex to protect access to internal data.
|
||||
boost::asio::detail::mutex mutex_;
|
||||
|
||||
// The /dev/poll file descriptor.
|
||||
int dev_poll_fd_;
|
||||
|
||||
// Vector of /dev/poll events waiting to be written to the descriptor.
|
||||
std::vector< ::pollfd> pending_event_changes_;
|
||||
|
||||
// Hash map to associate a descriptor with a pending event change index.
|
||||
hash_map<int, std::size_t> pending_event_change_index_;
|
||||
|
||||
// The interrupter is used to break a blocking DP_POLL operation.
|
||||
select_interrupter interrupter_;
|
||||
|
||||
// The queues of read, write and except operations.
|
||||
reactor_op_queue<socket_type> op_queue_[max_ops];
|
||||
|
||||
// The timer queues.
|
||||
timer_queue_set timer_queues_;
|
||||
|
||||
// Whether the service has been shut down.
|
||||
bool shutdown_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/impl/dev_poll_reactor.hpp>
|
||||
#if defined(BOOST_ASIO_HEADER_ONLY)
|
||||
# include <boost/asio/detail/impl/dev_poll_reactor.ipp>
|
||||
#endif // defined(BOOST_ASIO_HEADER_ONLY)
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_DEV_POLL)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_DEV_POLL_REACTOR_HPP
|
268
boost/asio/detail/epoll_reactor.hpp
Normal file
268
boost/asio/detail/epoll_reactor.hpp
Normal file
@ -0,0 +1,268 @@
|
||||
//
|
||||
// detail/epoll_reactor.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_EPOLL_REACTOR_HPP
|
||||
#define BOOST_ASIO_DETAIL_EPOLL_REACTOR_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_EPOLL)
|
||||
|
||||
#include <boost/asio/detail/atomic_count.hpp>
|
||||
#include <boost/asio/detail/conditionally_enabled_mutex.hpp>
|
||||
#include <boost/asio/detail/limits.hpp>
|
||||
#include <boost/asio/detail/object_pool.hpp>
|
||||
#include <boost/asio/detail/op_queue.hpp>
|
||||
#include <boost/asio/detail/reactor_op.hpp>
|
||||
#include <boost/asio/detail/select_interrupter.hpp>
|
||||
#include <boost/asio/detail/socket_types.hpp>
|
||||
#include <boost/asio/detail/timer_queue_base.hpp>
|
||||
#include <boost/asio/detail/timer_queue_set.hpp>
|
||||
#include <boost/asio/detail/wait_op.hpp>
|
||||
#include <boost/asio/execution_context.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_TIMERFD)
|
||||
# include <sys/timerfd.h>
|
||||
#endif // defined(BOOST_ASIO_HAS_TIMERFD)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class epoll_reactor
|
||||
: public execution_context_service_base<epoll_reactor>
|
||||
{
|
||||
private:
|
||||
// The mutex type used by this reactor.
|
||||
typedef conditionally_enabled_mutex mutex;
|
||||
|
||||
public:
|
||||
enum op_types { read_op = 0, write_op = 1,
|
||||
connect_op = 1, except_op = 2, max_ops = 3 };
|
||||
|
||||
// Per-descriptor queues.
|
||||
class descriptor_state : operation
|
||||
{
|
||||
friend class epoll_reactor;
|
||||
friend class object_pool_access;
|
||||
|
||||
descriptor_state* next_;
|
||||
descriptor_state* prev_;
|
||||
|
||||
mutex mutex_;
|
||||
epoll_reactor* reactor_;
|
||||
int descriptor_;
|
||||
uint32_t registered_events_;
|
||||
op_queue<reactor_op> op_queue_[max_ops];
|
||||
bool try_speculative_[max_ops];
|
||||
bool shutdown_;
|
||||
|
||||
BOOST_ASIO_DECL descriptor_state(bool locking);
|
||||
void set_ready_events(uint32_t events) { task_result_ = events; }
|
||||
void add_ready_events(uint32_t events) { task_result_ |= events; }
|
||||
BOOST_ASIO_DECL operation* perform_io(uint32_t events);
|
||||
BOOST_ASIO_DECL static void do_complete(
|
||||
void* owner, operation* base,
|
||||
const boost::system::error_code& ec, std::size_t bytes_transferred);
|
||||
};
|
||||
|
||||
// Per-descriptor data.
|
||||
typedef descriptor_state* per_descriptor_data;
|
||||
|
||||
// Constructor.
|
||||
BOOST_ASIO_DECL epoll_reactor(boost::asio::execution_context& ctx);
|
||||
|
||||
// Destructor.
|
||||
BOOST_ASIO_DECL ~epoll_reactor();
|
||||
|
||||
// Destroy all user-defined handler objects owned by the service.
|
||||
BOOST_ASIO_DECL void shutdown();
|
||||
|
||||
// Recreate internal descriptors following a fork.
|
||||
BOOST_ASIO_DECL void notify_fork(
|
||||
boost::asio::execution_context::fork_event fork_ev);
|
||||
|
||||
// Initialise the task.
|
||||
BOOST_ASIO_DECL void init_task();
|
||||
|
||||
// Register a socket with the reactor. Returns 0 on success, system error
|
||||
// code on failure.
|
||||
BOOST_ASIO_DECL int register_descriptor(socket_type descriptor,
|
||||
per_descriptor_data& descriptor_data);
|
||||
|
||||
// Register a descriptor with an associated single operation. Returns 0 on
|
||||
// success, system error code on failure.
|
||||
BOOST_ASIO_DECL int register_internal_descriptor(
|
||||
int op_type, socket_type descriptor,
|
||||
per_descriptor_data& descriptor_data, reactor_op* op);
|
||||
|
||||
// Move descriptor registration from one descriptor_data object to another.
|
||||
BOOST_ASIO_DECL void move_descriptor(socket_type descriptor,
|
||||
per_descriptor_data& target_descriptor_data,
|
||||
per_descriptor_data& source_descriptor_data);
|
||||
|
||||
// Post a reactor operation for immediate completion.
|
||||
void post_immediate_completion(reactor_op* op, bool is_continuation)
|
||||
{
|
||||
scheduler_.post_immediate_completion(op, is_continuation);
|
||||
}
|
||||
|
||||
// Start a new operation. The reactor operation will be performed when the
|
||||
// given descriptor is flagged as ready, or an error has occurred.
|
||||
BOOST_ASIO_DECL void start_op(int op_type, socket_type descriptor,
|
||||
per_descriptor_data& descriptor_data, reactor_op* op,
|
||||
bool is_continuation, bool allow_speculative);
|
||||
|
||||
// Cancel all operations associated with the given descriptor. The
|
||||
// handlers associated with the descriptor will be invoked with the
|
||||
// operation_aborted error.
|
||||
BOOST_ASIO_DECL void cancel_ops(socket_type descriptor,
|
||||
per_descriptor_data& descriptor_data);
|
||||
|
||||
// Cancel any operations that are running against the descriptor and remove
|
||||
// its registration from the reactor. The reactor resources associated with
|
||||
// the descriptor must be released by calling cleanup_descriptor_data.
|
||||
BOOST_ASIO_DECL void deregister_descriptor(socket_type descriptor,
|
||||
per_descriptor_data& descriptor_data, bool closing);
|
||||
|
||||
// Remove the descriptor's registration from the reactor. The reactor
|
||||
// resources associated with the descriptor must be released by calling
|
||||
// cleanup_descriptor_data.
|
||||
BOOST_ASIO_DECL void deregister_internal_descriptor(
|
||||
socket_type descriptor, per_descriptor_data& descriptor_data);
|
||||
|
||||
// Perform any post-deregistration cleanup tasks associated with the
|
||||
// descriptor data.
|
||||
BOOST_ASIO_DECL void cleanup_descriptor_data(
|
||||
per_descriptor_data& descriptor_data);
|
||||
|
||||
// Add a new timer queue to the reactor.
|
||||
template <typename Time_Traits>
|
||||
void add_timer_queue(timer_queue<Time_Traits>& timer_queue);
|
||||
|
||||
// Remove a timer queue from the reactor.
|
||||
template <typename Time_Traits>
|
||||
void remove_timer_queue(timer_queue<Time_Traits>& timer_queue);
|
||||
|
||||
// Schedule a new operation in the given timer queue to expire at the
|
||||
// specified absolute time.
|
||||
template <typename Time_Traits>
|
||||
void schedule_timer(timer_queue<Time_Traits>& queue,
|
||||
const typename Time_Traits::time_type& time,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op);
|
||||
|
||||
// Cancel the timer operations associated with the given token. Returns the
|
||||
// number of operations that have been posted or dispatched.
|
||||
template <typename Time_Traits>
|
||||
std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& timer,
|
||||
std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
|
||||
|
||||
// Move the timer operations associated with the given timer.
|
||||
template <typename Time_Traits>
|
||||
void move_timer(timer_queue<Time_Traits>& queue,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& target,
|
||||
typename timer_queue<Time_Traits>::per_timer_data& source);
|
||||
|
||||
// Run epoll once until interrupted or events are ready to be dispatched.
|
||||
BOOST_ASIO_DECL void run(long usec, op_queue<operation>& ops);
|
||||
|
||||
// Interrupt the select loop.
|
||||
BOOST_ASIO_DECL void interrupt();
|
||||
|
||||
private:
|
||||
// The hint to pass to epoll_create to size its data structures.
|
||||
enum { epoll_size = 20000 };
|
||||
|
||||
// Create the epoll file descriptor. Throws an exception if the descriptor
|
||||
// cannot be created.
|
||||
BOOST_ASIO_DECL static int do_epoll_create();
|
||||
|
||||
// Create the timerfd file descriptor. Does not throw.
|
||||
BOOST_ASIO_DECL static int do_timerfd_create();
|
||||
|
||||
// Allocate a new descriptor state object.
|
||||
BOOST_ASIO_DECL descriptor_state* allocate_descriptor_state();
|
||||
|
||||
// Free an existing descriptor state object.
|
||||
BOOST_ASIO_DECL void free_descriptor_state(descriptor_state* s);
|
||||
|
||||
// Helper function to add a new timer queue.
|
||||
BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue);
|
||||
|
||||
// Helper function to remove a timer queue.
|
||||
BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue);
|
||||
|
||||
// Called to recalculate and update the timeout.
|
||||
BOOST_ASIO_DECL void update_timeout();
|
||||
|
||||
// Get the timeout value for the epoll_wait call. The timeout value is
|
||||
// returned as a number of milliseconds. A return value of -1 indicates
|
||||
// that epoll_wait should block indefinitely.
|
||||
BOOST_ASIO_DECL int get_timeout(int msec);
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_TIMERFD)
|
||||
// Get the timeout value for the timer descriptor. The return value is the
|
||||
// flag argument to be used when calling timerfd_settime.
|
||||
BOOST_ASIO_DECL int get_timeout(itimerspec& ts);
|
||||
#endif // defined(BOOST_ASIO_HAS_TIMERFD)
|
||||
|
||||
// The scheduler implementation used to post completions.
|
||||
scheduler& scheduler_;
|
||||
|
||||
// Mutex to protect access to internal data.
|
||||
mutex mutex_;
|
||||
|
||||
// The interrupter is used to break a blocking epoll_wait call.
|
||||
select_interrupter interrupter_;
|
||||
|
||||
// The epoll file descriptor.
|
||||
int epoll_fd_;
|
||||
|
||||
// The timer file descriptor.
|
||||
int timer_fd_;
|
||||
|
||||
// The timer queues.
|
||||
timer_queue_set timer_queues_;
|
||||
|
||||
// Whether the service has been shut down.
|
||||
bool shutdown_;
|
||||
|
||||
// Mutex to protect access to the registered descriptors.
|
||||
mutex registered_descriptors_mutex_;
|
||||
|
||||
// Keep track of all registered descriptors.
|
||||
object_pool<descriptor_state> registered_descriptors_;
|
||||
|
||||
// Helper class to do post-perform_io cleanup.
|
||||
struct perform_io_cleanup_on_block_exit;
|
||||
friend struct perform_io_cleanup_on_block_exit;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/impl/epoll_reactor.hpp>
|
||||
#if defined(BOOST_ASIO_HEADER_ONLY)
|
||||
# include <boost/asio/detail/impl/epoll_reactor.ipp>
|
||||
#endif // defined(BOOST_ASIO_HEADER_ONLY)
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_EPOLL)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_EPOLL_REACTOR_HPP
|
50
boost/asio/detail/event.hpp
Normal file
50
boost/asio/detail/event.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// detail/event.hpp
|
||||
// ~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_EVENT_HPP
|
||||
#define BOOST_ASIO_DETAIL_EVENT_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_THREADS)
|
||||
# include <boost/asio/detail/null_event.hpp>
|
||||
#elif defined(BOOST_ASIO_WINDOWS)
|
||||
# include <boost/asio/detail/win_event.hpp>
|
||||
#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
||||
# include <boost/asio/detail/posix_event.hpp>
|
||||
#elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)
|
||||
# include <boost/asio/detail/std_event.hpp>
|
||||
#else
|
||||
# error Only Windows, POSIX and std::condition_variable are supported!
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_HAS_THREADS)
|
||||
typedef null_event event;
|
||||
#elif defined(BOOST_ASIO_WINDOWS)
|
||||
typedef win_event event;
|
||||
#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
||||
typedef posix_event event;
|
||||
#elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)
|
||||
typedef std_event event;
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_EVENT_HPP
|
85
boost/asio/detail/eventfd_select_interrupter.hpp
Normal file
85
boost/asio/detail/eventfd_select_interrupter.hpp
Normal file
@ -0,0 +1,85 @@
|
||||
//
|
||||
// detail/eventfd_select_interrupter.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2008 Roelof Naude (roelof.naude at gmail 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_EVENTFD_SELECT_INTERRUPTER_HPP
|
||||
#define BOOST_ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_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_EVENTFD)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class eventfd_select_interrupter
|
||||
{
|
||||
public:
|
||||
// Constructor.
|
||||
BOOST_ASIO_DECL eventfd_select_interrupter();
|
||||
|
||||
// Destructor.
|
||||
BOOST_ASIO_DECL ~eventfd_select_interrupter();
|
||||
|
||||
// Recreate the interrupter's descriptors. Used after a fork.
|
||||
BOOST_ASIO_DECL void recreate();
|
||||
|
||||
// Interrupt the select call.
|
||||
BOOST_ASIO_DECL void interrupt();
|
||||
|
||||
// Reset the select interrupt. Returns true if the call was interrupted.
|
||||
BOOST_ASIO_DECL bool reset();
|
||||
|
||||
// Get the read descriptor to be passed to select.
|
||||
int read_descriptor() const
|
||||
{
|
||||
return read_descriptor_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Open the descriptors. Throws on error.
|
||||
BOOST_ASIO_DECL void open_descriptors();
|
||||
|
||||
// Close the descriptors.
|
||||
BOOST_ASIO_DECL void close_descriptors();
|
||||
|
||||
// The read end of a connection used to interrupt the select call. This file
|
||||
// descriptor is passed to select such that when it is time to stop, a single
|
||||
// 64bit value will be written on the other end of the connection and this
|
||||
// descriptor will become readable.
|
||||
int read_descriptor_;
|
||||
|
||||
// The write end of a connection used to interrupt the select call. A single
|
||||
// 64bit non-zero value may be written to this to wake up the select which is
|
||||
// waiting for the other end to become readable. This descriptor will only
|
||||
// differ from the read descriptor when a pipe is used.
|
||||
int write_descriptor_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HEADER_ONLY)
|
||||
# include <boost/asio/detail/impl/eventfd_select_interrupter.ipp>
|
||||
#endif // defined(BOOST_ASIO_HEADER_ONLY)
|
||||
|
||||
#endif // defined(BOOST_ASIO_HAS_EVENTFD)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_EVENTFD_SELECT_INTERRUPTER_HPP
|
106
boost/asio/detail/executor_function.hpp
Normal file
106
boost/asio/detail/executor_function.hpp
Normal file
@ -0,0 +1,106 @@
|
||||
//
|
||||
// detail/executor_function.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_EXECUTOR_FUNCTION_HPP
|
||||
#define BOOST_ASIO_DETAIL_EXECUTOR_FUNCTION_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/detail/handler_alloc_helpers.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class executor_function_base
|
||||
{
|
||||
public:
|
||||
void complete()
|
||||
{
|
||||
func_(this, true);
|
||||
}
|
||||
|
||||
void destroy()
|
||||
{
|
||||
func_(this, false);
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef void (*func_type)(executor_function_base*, bool);
|
||||
|
||||
executor_function_base(func_type func)
|
||||
: func_(func)
|
||||
{
|
||||
}
|
||||
|
||||
// Prevents deletion through this type.
|
||||
~executor_function_base()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
func_type func_;
|
||||
};
|
||||
|
||||
template <typename Function, typename Alloc>
|
||||
class executor_function : public executor_function_base
|
||||
{
|
||||
public:
|
||||
BOOST_ASIO_DEFINE_TAGGED_HANDLER_ALLOCATOR_PTR(
|
||||
thread_info_base::executor_function_tag, executor_function);
|
||||
|
||||
template <typename F>
|
||||
executor_function(BOOST_ASIO_MOVE_ARG(F) f, const Alloc& allocator)
|
||||
: executor_function_base(&executor_function::do_complete),
|
||||
function_(BOOST_ASIO_MOVE_CAST(F)(f)),
|
||||
allocator_(allocator)
|
||||
{
|
||||
}
|
||||
|
||||
static void do_complete(executor_function_base* base, bool call)
|
||||
{
|
||||
// Take ownership of the function object.
|
||||
executor_function* o(static_cast<executor_function*>(base));
|
||||
Alloc allocator(o->allocator_);
|
||||
ptr p = { detail::addressof(allocator), o, o };
|
||||
|
||||
// Make a copy of the function 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 function may be the true owner of the memory
|
||||
// associated with the function. Consequently, a local copy of the function
|
||||
// is required to ensure that any owning sub-object remains valid until
|
||||
// after we have deallocated the memory here.
|
||||
Function function(BOOST_ASIO_MOVE_CAST(Function)(o->function_));
|
||||
p.reset();
|
||||
|
||||
// Make the upcall if required.
|
||||
if (call)
|
||||
{
|
||||
function();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Function function_;
|
||||
Alloc allocator_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_EXECUTOR_FUNCTION_HPP
|
86
boost/asio/detail/executor_op.hpp
Normal file
86
boost/asio/detail/executor_op.hpp
Normal file
@ -0,0 +1,86 @@
|
||||
//
|
||||
// detail/executor_op.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_EXECUTOR_OP_HPP
|
||||
#define BOOST_ASIO_DETAIL_EXECUTOR_OP_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/detail/fenced_block.hpp>
|
||||
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_invoke_helpers.hpp>
|
||||
#include <boost/asio/detail/scheduler_operation.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename Handler, typename Alloc,
|
||||
typename Operation = scheduler_operation>
|
||||
class executor_op : public Operation
|
||||
{
|
||||
public:
|
||||
BOOST_ASIO_DEFINE_HANDLER_ALLOCATOR_PTR(executor_op);
|
||||
|
||||
template <typename H>
|
||||
executor_op(BOOST_ASIO_MOVE_ARG(H) h, const Alloc& allocator)
|
||||
: Operation(&executor_op::do_complete),
|
||||
handler_(BOOST_ASIO_MOVE_CAST(H)(h)),
|
||||
allocator_(allocator)
|
||||
{
|
||||
}
|
||||
|
||||
static void do_complete(void* owner, Operation* base,
|
||||
const boost::system::error_code& /*ec*/,
|
||||
std::size_t /*bytes_transferred*/)
|
||||
{
|
||||
// Take ownership of the handler object.
|
||||
executor_op* o(static_cast<executor_op*>(base));
|
||||
Alloc allocator(o->allocator_);
|
||||
ptr p = { detail::addressof(allocator), o, o };
|
||||
|
||||
BOOST_ASIO_HANDLER_COMPLETION((*o));
|
||||
|
||||
// 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(BOOST_ASIO_MOVE_CAST(Handler)(o->handler_));
|
||||
p.reset();
|
||||
|
||||
// Make the upcall if required.
|
||||
if (owner)
|
||||
{
|
||||
fenced_block b(fenced_block::half);
|
||||
BOOST_ASIO_HANDLER_INVOCATION_BEGIN(());
|
||||
boost_asio_handler_invoke_helpers::invoke(handler, handler);
|
||||
BOOST_ASIO_HANDLER_INVOCATION_END;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Handler handler_;
|
||||
Alloc allocator_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_EXECUTOR_OP_HPP
|
41
boost/asio/detail/fd_set_adapter.hpp
Normal file
41
boost/asio/detail/fd_set_adapter.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
//
|
||||
// detail/fd_set_adapter.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_FD_SET_ADAPTER_HPP
|
||||
#define BOOST_ASIO_DETAIL_FD_SET_ADAPTER_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_WINDOWS_RUNTIME)
|
||||
|
||||
#include <boost/asio/detail/posix_fd_set_adapter.hpp>
|
||||
#include <boost/asio/detail/win_fd_set_adapter.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
|
||||
typedef win_fd_set_adapter fd_set_adapter;
|
||||
#else
|
||||
typedef posix_fd_set_adapter fd_set_adapter;
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_FD_SET_ADAPTER_HPP
|
82
boost/asio/detail/fenced_block.hpp
Normal file
82
boost/asio/detail/fenced_block.hpp
Normal file
@ -0,0 +1,82 @@
|
||||
//
|
||||
// detail/fenced_block.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_FENCED_BLOCK_HPP
|
||||
#define BOOST_ASIO_DETAIL_FENCED_BLOCK_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_THREADS) \
|
||||
|| defined(BOOST_ASIO_DISABLE_FENCED_BLOCK)
|
||||
# include <boost/asio/detail/null_fenced_block.hpp>
|
||||
#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
# include <boost/asio/detail/std_fenced_block.hpp>
|
||||
#elif defined(__MACH__) && defined(__APPLE__)
|
||||
# include <boost/asio/detail/macos_fenced_block.hpp>
|
||||
#elif defined(__sun)
|
||||
# include <boost/asio/detail/solaris_fenced_block.hpp>
|
||||
#elif defined(__GNUC__) && defined(__arm__) \
|
||||
&& !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
|
||||
# include <boost/asio/detail/gcc_arm_fenced_block.hpp>
|
||||
#elif defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
|
||||
# include <boost/asio/detail/gcc_hppa_fenced_block.hpp>
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
# include <boost/asio/detail/gcc_x86_fenced_block.hpp>
|
||||
#elif defined(__GNUC__) \
|
||||
&& ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
|
||||
&& !defined(__INTEL_COMPILER) && !defined(__ICL) \
|
||||
&& !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
|
||||
# include <boost/asio/detail/gcc_sync_fenced_block.hpp>
|
||||
#elif defined(BOOST_ASIO_WINDOWS) && !defined(UNDER_CE)
|
||||
# include <boost/asio/detail/win_fenced_block.hpp>
|
||||
#else
|
||||
# include <boost/asio/detail/null_fenced_block.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_HAS_THREADS) \
|
||||
|| defined(BOOST_ASIO_DISABLE_FENCED_BLOCK)
|
||||
typedef null_fenced_block fenced_block;
|
||||
#elif defined(BOOST_ASIO_HAS_STD_ATOMIC)
|
||||
typedef std_fenced_block fenced_block;
|
||||
#elif defined(__MACH__) && defined(__APPLE__)
|
||||
typedef macos_fenced_block fenced_block;
|
||||
#elif defined(__sun)
|
||||
typedef solaris_fenced_block fenced_block;
|
||||
#elif defined(__GNUC__) && defined(__arm__) \
|
||||
&& !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
|
||||
typedef gcc_arm_fenced_block fenced_block;
|
||||
#elif defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
|
||||
typedef gcc_hppa_fenced_block fenced_block;
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
typedef gcc_x86_fenced_block fenced_block;
|
||||
#elif defined(__GNUC__) \
|
||||
&& ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
|
||||
&& !defined(__INTEL_COMPILER) && !defined(__ICL) \
|
||||
&& !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
|
||||
typedef gcc_sync_fenced_block fenced_block;
|
||||
#elif defined(BOOST_ASIO_WINDOWS) && !defined(UNDER_CE)
|
||||
typedef win_fenced_block fenced_block;
|
||||
#else
|
||||
typedef null_fenced_block fenced_block;
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_FENCED_BLOCK_HPP
|
40
boost/asio/detail/functional.hpp
Normal file
40
boost/asio/detail/functional.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// detail/functional.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_FUNCTIONAL_HPP
|
||||
#define BOOST_ASIO_DETAIL_FUNCTIONAL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#if !defined(BOOST_ASIO_HAS_STD_FUNCTION)
|
||||
# include <boost/function.hpp>
|
||||
#endif // !defined(BOOST_ASIO_HAS_STD_FUNCTION)
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_STD_FUNCTION)
|
||||
using std::function;
|
||||
#else // defined(BOOST_ASIO_HAS_STD_FUNCTION)
|
||||
using boost::function;
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_FUNCTION)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_FUNCTIONAL_HPP
|
93
boost/asio/detail/gcc_arm_fenced_block.hpp
Normal file
93
boost/asio/detail/gcc_arm_fenced_block.hpp
Normal file
@ -0,0 +1,93 @@
|
||||
//
|
||||
// detail/gcc_arm_fenced_block.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_GCC_ARM_FENCED_BLOCK_HPP
|
||||
#define BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_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(__GNUC__) && defined(__arm__)
|
||||
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class gcc_arm_fenced_block
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
enum half_t { half };
|
||||
enum full_t { full };
|
||||
|
||||
// Constructor for a half fenced block.
|
||||
explicit gcc_arm_fenced_block(half_t)
|
||||
{
|
||||
}
|
||||
|
||||
// Constructor for a full fenced block.
|
||||
explicit gcc_arm_fenced_block(full_t)
|
||||
{
|
||||
barrier();
|
||||
}
|
||||
|
||||
// Destructor.
|
||||
~gcc_arm_fenced_block()
|
||||
{
|
||||
barrier();
|
||||
}
|
||||
|
||||
private:
|
||||
static void barrier()
|
||||
{
|
||||
#if defined(__ARM_ARCH_4__) \
|
||||
|| defined(__ARM_ARCH_4T__) \
|
||||
|| defined(__ARM_ARCH_5__) \
|
||||
|| defined(__ARM_ARCH_5E__) \
|
||||
|| defined(__ARM_ARCH_5T__) \
|
||||
|| defined(__ARM_ARCH_5TE__) \
|
||||
|| defined(__ARM_ARCH_5TEJ__) \
|
||||
|| defined(__ARM_ARCH_6__) \
|
||||
|| defined(__ARM_ARCH_6J__) \
|
||||
|| defined(__ARM_ARCH_6K__) \
|
||||
|| defined(__ARM_ARCH_6Z__) \
|
||||
|| defined(__ARM_ARCH_6ZK__) \
|
||||
|| defined(__ARM_ARCH_6T2__)
|
||||
# if defined(__thumb__)
|
||||
// This is just a placeholder and almost certainly not sufficient.
|
||||
__asm__ __volatile__ ("" : : : "memory");
|
||||
# else // defined(__thumb__)
|
||||
int a = 0, b = 0;
|
||||
__asm__ __volatile__ ("swp %0, %1, [%2]"
|
||||
: "=&r"(a) : "r"(1), "r"(&b) : "memory", "cc");
|
||||
# endif // defined(__thumb__)
|
||||
#else
|
||||
// ARMv7 and later.
|
||||
__asm__ __volatile__ ("dmb" : : : "memory");
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(__GNUC__) && defined(__arm__)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_GCC_ARM_FENCED_BLOCK_HPP
|
70
boost/asio/detail/gcc_hppa_fenced_block.hpp
Normal file
70
boost/asio/detail/gcc_hppa_fenced_block.hpp
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// detail/gcc_hppa_fenced_block.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_GCC_HPPA_FENCED_BLOCK_HPP
|
||||
#define BOOST_ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_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(__GNUC__) && (defined(__hppa) || defined(__hppa__))
|
||||
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class gcc_hppa_fenced_block
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
enum half_t { half };
|
||||
enum full_t { full };
|
||||
|
||||
// Constructor for a half fenced block.
|
||||
explicit gcc_hppa_fenced_block(half_t)
|
||||
{
|
||||
}
|
||||
|
||||
// Constructor for a full fenced block.
|
||||
explicit gcc_hppa_fenced_block(full_t)
|
||||
{
|
||||
barrier();
|
||||
}
|
||||
|
||||
// Destructor.
|
||||
~gcc_hppa_fenced_block()
|
||||
{
|
||||
barrier();
|
||||
}
|
||||
|
||||
private:
|
||||
static void barrier()
|
||||
{
|
||||
// This is just a placeholder and almost certainly not sufficient.
|
||||
__asm__ __volatile__ ("" : : : "memory");
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP
|
67
boost/asio/detail/gcc_sync_fenced_block.hpp
Normal file
67
boost/asio/detail/gcc_sync_fenced_block.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// detail/gcc_sync_fenced_block.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_GCC_SYNC_FENCED_BLOCK_HPP
|
||||
#define BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_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(__GNUC__) \
|
||||
&& ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
|
||||
&& !defined(__INTEL_COMPILER) && !defined(__ICL) \
|
||||
&& !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
|
||||
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class gcc_sync_fenced_block
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
enum half_or_full_t { half, full };
|
||||
|
||||
// Constructor.
|
||||
explicit gcc_sync_fenced_block(half_or_full_t)
|
||||
: value_(0)
|
||||
{
|
||||
__sync_lock_test_and_set(&value_, 1);
|
||||
}
|
||||
|
||||
// Destructor.
|
||||
~gcc_sync_fenced_block()
|
||||
{
|
||||
__sync_lock_release(&value_);
|
||||
}
|
||||
|
||||
private:
|
||||
int value_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(__GNUC__)
|
||||
// && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
|
||||
// && !defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
// && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
|
101
boost/asio/detail/gcc_x86_fenced_block.hpp
Normal file
101
boost/asio/detail/gcc_x86_fenced_block.hpp
Normal file
@ -0,0 +1,101 @@
|
||||
//
|
||||
// detail/gcc_x86_fenced_block.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_GCC_X86_FENCED_BLOCK_HPP
|
||||
#define BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_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(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
class gcc_x86_fenced_block
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
enum half_t { half };
|
||||
enum full_t { full };
|
||||
|
||||
// Constructor for a half fenced block.
|
||||
explicit gcc_x86_fenced_block(half_t)
|
||||
{
|
||||
}
|
||||
|
||||
// Constructor for a full fenced block.
|
||||
explicit gcc_x86_fenced_block(full_t)
|
||||
{
|
||||
lbarrier();
|
||||
}
|
||||
|
||||
// Destructor.
|
||||
~gcc_x86_fenced_block()
|
||||
{
|
||||
sbarrier();
|
||||
}
|
||||
|
||||
private:
|
||||
static int barrier()
|
||||
{
|
||||
int r = 0, m = 1;
|
||||
__asm__ __volatile__ (
|
||||
"xchgl %0, %1" :
|
||||
"=r"(r), "=m"(m) :
|
||||
"0"(1), "m"(m) :
|
||||
"memory", "cc");
|
||||
return r;
|
||||
}
|
||||
|
||||
static void lbarrier()
|
||||
{
|
||||
#if defined(__SSE2__)
|
||||
# if (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
__builtin_ia32_lfence();
|
||||
# else // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
__asm__ __volatile__ ("lfence" ::: "memory");
|
||||
# endif // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
#else // defined(__SSE2__)
|
||||
barrier();
|
||||
#endif // defined(__SSE2__)
|
||||
}
|
||||
|
||||
static void sbarrier()
|
||||
{
|
||||
#if defined(__SSE2__)
|
||||
# if (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
__builtin_ia32_sfence();
|
||||
# else // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
__asm__ __volatile__ ("sfence" ::: "memory");
|
||||
# endif // (__GNUC__ >= 4) && !defined(__INTEL_COMPILER) && !defined(__ICL)
|
||||
#else // defined(__SSE2__)
|
||||
barrier();
|
||||
#endif // defined(__SSE2__)
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_GCC_X86_FENCED_BLOCK_HPP
|
54
boost/asio/detail/global.hpp
Normal file
54
boost/asio/detail/global.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
//
|
||||
// detail/global.hpp
|
||||
// ~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_GLOBAL_HPP
|
||||
#define BOOST_ASIO_DETAIL_GLOBAL_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_THREADS)
|
||||
# include <boost/asio/detail/null_global.hpp>
|
||||
#elif defined(BOOST_ASIO_WINDOWS)
|
||||
# include <boost/asio/detail/win_global.hpp>
|
||||
#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
||||
# include <boost/asio/detail/posix_global.hpp>
|
||||
#elif defined(BOOST_ASIO_HAS_STD_CALL_ONCE)
|
||||
# include <boost/asio/detail/std_global.hpp>
|
||||
#else
|
||||
# error Only Windows, POSIX and std::call_once are supported!
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
inline T& global()
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_THREADS)
|
||||
return null_global<T>();
|
||||
#elif defined(BOOST_ASIO_WINDOWS)
|
||||
return win_global<T>();
|
||||
#elif defined(BOOST_ASIO_HAS_PTHREADS)
|
||||
return posix_global<T>();
|
||||
#elif defined(BOOST_ASIO_HAS_STD_CALL_ONCE)
|
||||
return std_global<T>();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_GLOBAL_HPP
|
244
boost/asio/detail/handler_alloc_helpers.hpp
Normal file
244
boost/asio/detail/handler_alloc_helpers.hpp
Normal file
@ -0,0 +1,244 @@
|
||||
//
|
||||
// detail/handler_alloc_helpers.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_HANDLER_ALLOC_HELPERS_HPP
|
||||
#define BOOST_ASIO_DETAIL_HANDLER_ALLOC_HELPERS_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/detail/memory.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/recycling_allocator.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
// Calls to asio_handler_allocate and asio_handler_deallocate must be made from
|
||||
// a namespace that does not contain any overloads of these functions. The
|
||||
// boost_asio_handler_alloc_helpers namespace is defined here for that purpose.
|
||||
namespace boost_asio_handler_alloc_helpers {
|
||||
|
||||
template <typename Handler>
|
||||
inline void* allocate(std::size_t s, Handler& h)
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
|
||||
return ::operator new(s);
|
||||
#else
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(s, boost::asio::detail::addressof(h));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
inline void deallocate(void* p, std::size_t s, Handler& h)
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
|
||||
::operator delete(p);
|
||||
#else
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(p, s, boost::asio::detail::addressof(h));
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace boost_asio_handler_alloc_helpers
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
template <typename Handler, typename T>
|
||||
class hook_allocator
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
template <typename U>
|
||||
struct rebind
|
||||
{
|
||||
typedef hook_allocator<Handler, U> other;
|
||||
};
|
||||
|
||||
explicit hook_allocator(Handler& h)
|
||||
: handler_(h)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
hook_allocator(const hook_allocator<Handler, U>& a)
|
||||
: handler_(a.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
T* allocate(std::size_t n)
|
||||
{
|
||||
return static_cast<T*>(
|
||||
boost_asio_handler_alloc_helpers::allocate(sizeof(T) * n, handler_));
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t n)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(p, sizeof(T) * n, handler_);
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler& handler_;
|
||||
};
|
||||
|
||||
template <typename Handler>
|
||||
class hook_allocator<Handler, void>
|
||||
{
|
||||
public:
|
||||
typedef void value_type;
|
||||
|
||||
template <typename U>
|
||||
struct rebind
|
||||
{
|
||||
typedef hook_allocator<Handler, U> other;
|
||||
};
|
||||
|
||||
explicit hook_allocator(Handler& h)
|
||||
: handler_(h)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
hook_allocator(const hook_allocator<Handler, U>& a)
|
||||
: handler_(a.handler_)
|
||||
{
|
||||
}
|
||||
|
||||
//private:
|
||||
Handler& handler_;
|
||||
};
|
||||
|
||||
template <typename Handler, typename Allocator>
|
||||
struct get_hook_allocator
|
||||
{
|
||||
typedef Allocator type;
|
||||
|
||||
static type get(Handler&, const Allocator& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Handler, typename T>
|
||||
struct get_hook_allocator<Handler, std::allocator<T> >
|
||||
{
|
||||
typedef hook_allocator<Handler, T> type;
|
||||
|
||||
static type get(Handler& handler, const std::allocator<T>&)
|
||||
{
|
||||
return type(handler);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_ASIO_DEFINE_HANDLER_PTR(op) \
|
||||
struct ptr \
|
||||
{ \
|
||||
Handler* h; \
|
||||
op* v; \
|
||||
op* p; \
|
||||
~ptr() \
|
||||
{ \
|
||||
reset(); \
|
||||
} \
|
||||
static op* allocate(Handler& handler) \
|
||||
{ \
|
||||
typedef typename ::boost::asio::associated_allocator< \
|
||||
Handler>::type associated_allocator_type; \
|
||||
typedef typename ::boost::asio::detail::get_hook_allocator< \
|
||||
Handler, associated_allocator_type>::type hook_allocator_type; \
|
||||
BOOST_ASIO_REBIND_ALLOC(hook_allocator_type, op) a( \
|
||||
::boost::asio::detail::get_hook_allocator< \
|
||||
Handler, associated_allocator_type>::get( \
|
||||
handler, ::boost::asio::get_associated_allocator(handler))); \
|
||||
return a.allocate(1); \
|
||||
} \
|
||||
void reset() \
|
||||
{ \
|
||||
if (p) \
|
||||
{ \
|
||||
p->~op(); \
|
||||
p = 0; \
|
||||
} \
|
||||
if (v) \
|
||||
{ \
|
||||
typedef typename ::boost::asio::associated_allocator< \
|
||||
Handler>::type associated_allocator_type; \
|
||||
typedef typename ::boost::asio::detail::get_hook_allocator< \
|
||||
Handler, associated_allocator_type>::type hook_allocator_type; \
|
||||
BOOST_ASIO_REBIND_ALLOC(hook_allocator_type, op) a( \
|
||||
::boost::asio::detail::get_hook_allocator< \
|
||||
Handler, associated_allocator_type>::get( \
|
||||
*h, ::boost::asio::get_associated_allocator(*h))); \
|
||||
a.deallocate(static_cast<op*>(v), 1); \
|
||||
v = 0; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#define BOOST_ASIO_DEFINE_TAGGED_HANDLER_ALLOCATOR_PTR(purpose, op) \
|
||||
struct ptr \
|
||||
{ \
|
||||
const Alloc* a; \
|
||||
void* v; \
|
||||
op* p; \
|
||||
~ptr() \
|
||||
{ \
|
||||
reset(); \
|
||||
} \
|
||||
static op* allocate(const Alloc& a) \
|
||||
{ \
|
||||
typedef typename ::boost::asio::detail::get_recycling_allocator< \
|
||||
Alloc, purpose>::type recycling_allocator_type; \
|
||||
BOOST_ASIO_REBIND_ALLOC(recycling_allocator_type, op) a1( \
|
||||
::boost::asio::detail::get_recycling_allocator< \
|
||||
Alloc, purpose>::get(a)); \
|
||||
return a1.allocate(1); \
|
||||
} \
|
||||
void reset() \
|
||||
{ \
|
||||
if (p) \
|
||||
{ \
|
||||
p->~op(); \
|
||||
p = 0; \
|
||||
} \
|
||||
if (v) \
|
||||
{ \
|
||||
typedef typename ::boost::asio::detail::get_recycling_allocator< \
|
||||
Alloc, purpose>::type recycling_allocator_type; \
|
||||
BOOST_ASIO_REBIND_ALLOC(recycling_allocator_type, op) a1( \
|
||||
::boost::asio::detail::get_recycling_allocator< \
|
||||
Alloc, purpose>::get(*a)); \
|
||||
a1.deallocate(static_cast<op*>(v), 1); \
|
||||
v = 0; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#define BOOST_ASIO_DEFINE_HANDLER_ALLOCATOR_PTR(op) \
|
||||
BOOST_ASIO_DEFINE_TAGGED_HANDLER_ALLOCATOR_PTR( \
|
||||
::boost::asio::detail::thread_info_base::default_tag, op ) \
|
||||
/**/
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_HANDLER_ALLOC_HELPERS_HPP
|
45
boost/asio/detail/handler_cont_helpers.hpp
Normal file
45
boost/asio/detail/handler_cont_helpers.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// detail/handler_cont_helpers.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_HANDLER_CONT_HELPERS_HPP
|
||||
#define BOOST_ASIO_DETAIL_HANDLER_CONT_HELPERS_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/detail/memory.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
// Calls to asio_handler_is_continuation must be made from a namespace that
|
||||
// does not contain overloads of this function. This namespace is defined here
|
||||
// for that purpose.
|
||||
namespace boost_asio_handler_cont_helpers {
|
||||
|
||||
template <typename Context>
|
||||
inline bool is_continuation(Context& context)
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
|
||||
return false;
|
||||
#else
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
boost::asio::detail::addressof(context));
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace boost_asio_handler_cont_helpers
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_HANDLER_CONT_HELPERS_HPP
|
57
boost/asio/detail/handler_invoke_helpers.hpp
Normal file
57
boost/asio/detail/handler_invoke_helpers.hpp
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// detail/handler_invoke_helpers.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_HANDLER_INVOKE_HELPERS_HPP
|
||||
#define BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_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/detail/memory.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
// Calls to asio_handler_invoke must be made from a namespace that does not
|
||||
// contain overloads of this function. The boost_asio_handler_invoke_helpers
|
||||
// namespace is defined here for that purpose.
|
||||
namespace boost_asio_handler_invoke_helpers {
|
||||
|
||||
template <typename Function, typename Context>
|
||||
inline void invoke(Function& function, Context& context)
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
|
||||
Function tmp(function);
|
||||
tmp();
|
||||
#else
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(function, boost::asio::detail::addressof(context));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename Function, typename Context>
|
||||
inline void invoke(const Function& function, Context& context)
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
|
||||
Function tmp(function);
|
||||
tmp();
|
||||
#else
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(function, boost::asio::detail::addressof(context));
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace boost_asio_handler_invoke_helpers
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
|
242
boost/asio/detail/handler_tracking.hpp
Normal file
242
boost/asio/detail/handler_tracking.hpp
Normal file
@ -0,0 +1,242 @@
|
||||
//
|
||||
// detail/handler_tracking.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 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_HANDLER_TRACKING_HPP
|
||||
#define BOOST_ASIO_DETAIL_HANDLER_TRACKING_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
class execution_context;
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#if defined(BOOST_ASIO_CUSTOM_HANDLER_TRACKING)
|
||||
# include BOOST_ASIO_CUSTOM_HANDLER_TRACKING
|
||||
#elif defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
|
||||
# include <boost/system/error_code.hpp>
|
||||
# include <boost/asio/detail/cstdint.hpp>
|
||||
# include <boost/asio/detail/static_mutex.hpp>
|
||||
# include <boost/asio/detail/tss_ptr.hpp>
|
||||
#endif // defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_ASIO_CUSTOM_HANDLER_TRACKING)
|
||||
|
||||
// The user-specified header must define the following macros:
|
||||
// - BOOST_ASIO_INHERIT_TRACKED_HANDLER
|
||||
// - BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER
|
||||
// - BOOST_ASIO_HANDLER_TRACKING_INIT
|
||||
// - BOOST_ASIO_HANDLER_CREATION(args)
|
||||
// - BOOST_ASIO_HANDLER_COMPLETION(args)
|
||||
// - BOOST_ASIO_HANDLER_INVOCATION_BEGIN(args)
|
||||
// - BOOST_ASIO_HANDLER_INVOCATION_END
|
||||
// - BOOST_ASIO_HANDLER_OPERATION(args)
|
||||
// - BOOST_ASIO_HANDLER_REACTOR_REGISTRATION(args)
|
||||
// - BOOST_ASIO_HANDLER_REACTOR_DEREGISTRATION(args)
|
||||
// - BOOST_ASIO_HANDLER_REACTOR_READ_EVENT
|
||||
// - BOOST_ASIO_HANDLER_REACTOR_WRITE_EVENT
|
||||
// - BOOST_ASIO_HANDLER_REACTOR_ERROR_EVENT
|
||||
// - BOOST_ASIO_HANDLER_REACTOR_EVENTS(args)
|
||||
// - BOOST_ASIO_HANDLER_REACTOR_OPERATION(args)
|
||||
|
||||
# if !defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
|
||||
# define BOOST_ASIO_ENABLE_HANDLER_TRACKING 1
|
||||
# endif /// !defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
|
||||
|
||||
#elif defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
|
||||
|
||||
class handler_tracking
|
||||
{
|
||||
public:
|
||||
class completion;
|
||||
|
||||
// Base class for objects containing tracked handlers.
|
||||
class tracked_handler
|
||||
{
|
||||
private:
|
||||
// Only the handler_tracking class will have access to the id.
|
||||
friend class handler_tracking;
|
||||
friend class completion;
|
||||
uint64_t id_;
|
||||
|
||||
protected:
|
||||
// Constructor initialises with no id.
|
||||
tracked_handler() : id_(0) {}
|
||||
|
||||
// Prevent deletion through this type.
|
||||
~tracked_handler() {}
|
||||
};
|
||||
|
||||
// Initialise the tracking system.
|
||||
BOOST_ASIO_DECL static void init();
|
||||
|
||||
// Record the creation of a tracked handler.
|
||||
BOOST_ASIO_DECL static void creation(
|
||||
execution_context& context, tracked_handler& h,
|
||||
const char* object_type, void* object,
|
||||
uintmax_t native_handle, const char* op_name);
|
||||
|
||||
class completion
|
||||
{
|
||||
public:
|
||||
// Constructor records that handler is to be invoked with no arguments.
|
||||
BOOST_ASIO_DECL explicit completion(const tracked_handler& h);
|
||||
|
||||
// Destructor records only when an exception is thrown from the handler, or
|
||||
// if the memory is being freed without the handler having been invoked.
|
||||
BOOST_ASIO_DECL ~completion();
|
||||
|
||||
// Records that handler is to be invoked with no arguments.
|
||||
BOOST_ASIO_DECL void invocation_begin();
|
||||
|
||||
// Records that handler is to be invoked with one arguments.
|
||||
BOOST_ASIO_DECL void invocation_begin(const boost::system::error_code& ec);
|
||||
|
||||
// Constructor records that handler is to be invoked with two arguments.
|
||||
BOOST_ASIO_DECL void invocation_begin(
|
||||
const boost::system::error_code& ec, std::size_t bytes_transferred);
|
||||
|
||||
// Constructor records that handler is to be invoked with two arguments.
|
||||
BOOST_ASIO_DECL void invocation_begin(
|
||||
const boost::system::error_code& ec, int signal_number);
|
||||
|
||||
// Constructor records that handler is to be invoked with two arguments.
|
||||
BOOST_ASIO_DECL void invocation_begin(
|
||||
const boost::system::error_code& ec, const char* arg);
|
||||
|
||||
// Record that handler invocation has ended.
|
||||
BOOST_ASIO_DECL void invocation_end();
|
||||
|
||||
private:
|
||||
friend class handler_tracking;
|
||||
uint64_t id_;
|
||||
bool invoked_;
|
||||
completion* next_;
|
||||
};
|
||||
|
||||
// Record an operation that is not directly associated with a handler.
|
||||
BOOST_ASIO_DECL static void operation(execution_context& context,
|
||||
const char* object_type, void* object,
|
||||
uintmax_t native_handle, const char* op_name);
|
||||
|
||||
// Record that a descriptor has been registered with the reactor.
|
||||
BOOST_ASIO_DECL static void reactor_registration(execution_context& context,
|
||||
uintmax_t native_handle, uintmax_t registration);
|
||||
|
||||
// Record that a descriptor has been deregistered from the reactor.
|
||||
BOOST_ASIO_DECL static void reactor_deregistration(execution_context& context,
|
||||
uintmax_t native_handle, uintmax_t registration);
|
||||
|
||||
// Record a reactor-based operation that is associated with a handler.
|
||||
BOOST_ASIO_DECL static void reactor_events(execution_context& context,
|
||||
uintmax_t registration, unsigned events);
|
||||
|
||||
// Record a reactor-based operation that is associated with a handler.
|
||||
BOOST_ASIO_DECL static void reactor_operation(
|
||||
const tracked_handler& h, const char* op_name,
|
||||
const boost::system::error_code& ec);
|
||||
|
||||
// Record a reactor-based operation that is associated with a handler.
|
||||
BOOST_ASIO_DECL static void reactor_operation(
|
||||
const tracked_handler& h, const char* op_name,
|
||||
const boost::system::error_code& ec, std::size_t bytes_transferred);
|
||||
|
||||
// Write a line of output.
|
||||
BOOST_ASIO_DECL static void write_line(const char* format, ...);
|
||||
|
||||
private:
|
||||
struct tracking_state;
|
||||
BOOST_ASIO_DECL static tracking_state* get_state();
|
||||
};
|
||||
|
||||
# define BOOST_ASIO_INHERIT_TRACKED_HANDLER \
|
||||
: public boost::asio::detail::handler_tracking::tracked_handler
|
||||
|
||||
# define BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER \
|
||||
, public boost::asio::detail::handler_tracking::tracked_handler
|
||||
|
||||
# define BOOST_ASIO_HANDLER_TRACKING_INIT \
|
||||
boost::asio::detail::handler_tracking::init()
|
||||
|
||||
# define BOOST_ASIO_HANDLER_CREATION(args) \
|
||||
boost::asio::detail::handler_tracking::creation args
|
||||
|
||||
# define BOOST_ASIO_HANDLER_COMPLETION(args) \
|
||||
boost::asio::detail::handler_tracking::completion tracked_completion args
|
||||
|
||||
# define BOOST_ASIO_HANDLER_INVOCATION_BEGIN(args) \
|
||||
tracked_completion.invocation_begin args
|
||||
|
||||
# define BOOST_ASIO_HANDLER_INVOCATION_END \
|
||||
tracked_completion.invocation_end()
|
||||
|
||||
# define BOOST_ASIO_HANDLER_OPERATION(args) \
|
||||
boost::asio::detail::handler_tracking::operation args
|
||||
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_REGISTRATION(args) \
|
||||
boost::asio::detail::handler_tracking::reactor_registration args
|
||||
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_DEREGISTRATION(args) \
|
||||
boost::asio::detail::handler_tracking::reactor_deregistration args
|
||||
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_READ_EVENT 1
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_WRITE_EVENT 2
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_ERROR_EVENT 4
|
||||
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_EVENTS(args) \
|
||||
boost::asio::detail::handler_tracking::reactor_events args
|
||||
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_OPERATION(args) \
|
||||
boost::asio::detail::handler_tracking::reactor_operation args
|
||||
|
||||
#else // defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
|
||||
|
||||
# define BOOST_ASIO_INHERIT_TRACKED_HANDLER
|
||||
# define BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER
|
||||
# define BOOST_ASIO_HANDLER_TRACKING_INIT (void)0
|
||||
# define BOOST_ASIO_HANDLER_CREATION(args) (void)0
|
||||
# define BOOST_ASIO_HANDLER_COMPLETION(args) (void)0
|
||||
# define BOOST_ASIO_HANDLER_INVOCATION_BEGIN(args) (void)0
|
||||
# define BOOST_ASIO_HANDLER_INVOCATION_END (void)0
|
||||
# define BOOST_ASIO_HANDLER_OPERATION(args) (void)0
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_REGISTRATION(args) (void)0
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_DEREGISTRATION(args) (void)0
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_READ_EVENT 0
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_WRITE_EVENT 0
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_ERROR_EVENT 0
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_EVENTS(args) (void)0
|
||||
# define BOOST_ASIO_HANDLER_REACTOR_OPERATION(args) (void)0
|
||||
|
||||
#endif // defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_HEADER_ONLY)
|
||||
# include <boost/asio/detail/impl/handler_tracking.ipp>
|
||||
#endif // defined(BOOST_ASIO_HEADER_ONLY)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_HANDLER_TRACKING_HPP
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user