mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Merged boost 1.35 branch to trunk.
This commit is contained in:
parent
42d3a4e097
commit
41fdcd8eba
32
src/3rdparty/3rdparty.vcproj
vendored
32
src/3rdparty/3rdparty.vcproj
vendored
@ -150,30 +150,6 @@
|
||||
<Filter
|
||||
Name="boost"
|
||||
>
|
||||
<Filter
|
||||
Name="libs"
|
||||
>
|
||||
<Filter
|
||||
Name="system"
|
||||
>
|
||||
<Filter
|
||||
Name="src"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\boost\libs\system\src\error_code.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="sigslot"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\sigslot\sigslot.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="sqlite"
|
||||
@ -199,6 +175,14 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="sigslot"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\sigslot\sigslot.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
12
src/3rdparty/include/boost/algorithm/string.hpp
vendored
12
src/3rdparty/include/boost/algorithm/string.hpp
vendored
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library string_algo.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ALGO_HPP
|
||||
#define BOOST_STRING_ALGO_HPP
|
||||
@ -20,7 +21,6 @@
|
||||
#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>
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library case_conv.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CASE_CONV_HPP
|
||||
#define BOOST_STRING_CASE_CONV_HPP
|
||||
@ -15,6 +16,7 @@
|
||||
#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>
|
||||
@ -55,11 +57,10 @@ namespace boost {
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
Output,
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
return ::boost::algorithm::detail::transform_range_copy(
|
||||
Output,
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
@ -72,15 +73,10 @@ namespace boost {
|
||||
const SequenceT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return SequenceT(
|
||||
make_transform_iterator(
|
||||
begin(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<SequenceT>::type >(Loc)),
|
||||
make_transform_iterator(
|
||||
end(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<SequenceT>::type >(Loc)));
|
||||
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||
Input,
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<SequenceT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to lower case
|
||||
@ -96,10 +92,8 @@ namespace boost {
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(Input),
|
||||
::boost::algorithm::detail::transform_range(
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_lowerF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
@ -128,11 +122,10 @@ namespace boost {
|
||||
const RangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
Output,
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
return ::boost::algorithm::detail::transform_range_copy(
|
||||
Output,
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<RangeT>::type >(Loc));
|
||||
}
|
||||
|
||||
@ -145,16 +138,10 @@ namespace boost {
|
||||
const SequenceT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return SequenceT(
|
||||
make_transform_iterator(
|
||||
begin(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<SequenceT>::type >(Loc)),
|
||||
make_transform_iterator(
|
||||
end(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<SequenceT>::type >(Loc)));
|
||||
|
||||
return ::boost::algorithm::detail::transform_range_copy<SequenceT>(
|
||||
Input,
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<SequenceT>::type >(Loc));
|
||||
}
|
||||
|
||||
//! Convert to upper case
|
||||
@ -170,10 +157,8 @@ namespace boost {
|
||||
WritableRangeT& Input,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(Input),
|
||||
::boost::algorithm::detail::transform_range(
|
||||
as_literal(Input),
|
||||
::boost::algorithm::detail::to_upperF<
|
||||
typename range_value<WritableRangeT>::type >(Loc));
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library classification.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CLASSIFICATION_HPP
|
||||
#define BOOST_STRING_CLASSIFICATION_HPP
|
||||
@ -13,9 +14,11 @@
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/algorithm/string/detail/classification.hpp>
|
||||
#include <boost/algorithm/string/predicate_facade.hpp>
|
||||
|
||||
|
||||
/*! \file
|
||||
Classification predicates are included in the library to give
|
||||
some more convenience when using algorithms like \c trim() and \c all().
|
||||
@ -200,7 +203,7 @@ namespace boost {
|
||||
is_any_of( const RangeT& Set )
|
||||
{
|
||||
return detail::is_any_ofF<
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>(Set);
|
||||
BOOST_STRING_TYPENAME range_value<RangeT>::type>(as_literal(Set));
|
||||
}
|
||||
|
||||
//! is_from_range predicate
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library compare.hpp header file -------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_COMPARE_HPP
|
||||
#define BOOST_STRING_COMPARE_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library concept.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CONCEPT_HPP
|
||||
#define BOOST_STRING_CONCEPT_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library config.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CONFIG_HPP
|
||||
#define BOOST_STRING_CONFIG_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library constants.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CONSTANTS_HPP
|
||||
#define BOOST_STRING_CONSTANTS_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library string_funct.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
@ -60,6 +61,49 @@ namespace boost {
|
||||
const std::locale& m_Loc;
|
||||
};
|
||||
|
||||
// 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(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
Output,
|
||||
Functor);
|
||||
}
|
||||
|
||||
// Transform a range (in-place)
|
||||
template<typename RangeT, typename FunctorT>
|
||||
void transform_range(
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
std::transform(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(Input),
|
||||
Functor);
|
||||
}
|
||||
|
||||
template<typename SequenceT, typename RangeT, typename FunctorT>
|
||||
inline SequenceT transform_range_copy(
|
||||
const RangeT& Input,
|
||||
FunctorT Functor)
|
||||
{
|
||||
return SequenceT(
|
||||
make_transform_iterator(
|
||||
begin(Input),
|
||||
Functor),
|
||||
make_transform_iterator(
|
||||
end(Input),
|
||||
Functor));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library classification.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_CLASSIFICATION_DETAIL_HPP
|
||||
#define BOOST_STRING_CLASSIFICATION_DETAIL_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library find_format.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library find_format_all.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library find_format_store.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library find_iterator.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
|
||||
#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library finder.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FINDER_DETAIL_HPP
|
||||
#define BOOST_STRING_FINDER_DETAIL_HPP
|
||||
@ -18,6 +19,7 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
@ -1,9 +1,10 @@
|
||||
// Boost string_algo library formatter.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library predicate.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_PREDICATE_DETAIL_HPP
|
||||
#define BOOST_STRING_PREDICATE_DETAIL_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library replace_storage.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library sequence.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_DETAIL_SEQUENCE_HPP
|
||||
#define BOOST_STRING_DETAIL_SEQUENCE_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library trim.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_TRIM_DETAIL_HPP
|
||||
#define BOOST_STRING_TRIM_DETAIL_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library util.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_UTIL_DETAIL_HPP
|
||||
#define BOOST_STRING_UTIL_DETAIL_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library erase.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ERASE_HPP
|
||||
#define BOOST_STRING_ERASE_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library find.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_HPP
|
||||
#define BOOST_STRING_FIND_HPP
|
||||
@ -16,8 +17,7 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/finder.hpp>
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
@ -48,19 +48,21 @@ namespace boost {
|
||||
*/
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find(
|
||||
RangeT& Input,
|
||||
FinderT Finder)
|
||||
const FinderT& Finder)
|
||||
{
|
||||
return Finder(begin(Input),end(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
return Finder(begin(lit_input),end(lit_input));
|
||||
}
|
||||
|
||||
// find_first -----------------------------------------------//
|
||||
|
||||
//! Find first algorithm
|
||||
/*!
|
||||
Search for the first occurence of the substring in the input.
|
||||
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.
|
||||
@ -74,13 +76,12 @@ namespace boost {
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_first(
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return first_finder(Search)(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, first_finder(Search));
|
||||
}
|
||||
|
||||
//! Find first algorithm ( case insensitive )
|
||||
@ -101,21 +102,20 @@ namespace boost {
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_first(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return first_finder(Search,is_iequal(Loc))(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, first_finder(Search,is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_last -----------------------------------------------//
|
||||
|
||||
//! Find last algorithm
|
||||
/*!
|
||||
Search for the last occurence of the substring in the input.
|
||||
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.
|
||||
@ -129,13 +129,12 @@ namespace boost {
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_last(
|
||||
Range1T& Input,
|
||||
const Range2T& Search)
|
||||
{
|
||||
return last_finder(Search)(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, last_finder(Search));
|
||||
}
|
||||
|
||||
//! Find last algorithm ( case insensitive )
|
||||
@ -156,21 +155,20 @@ namespace boost {
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_last(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return last_finder(Search, is_iequal(Loc))(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, last_finder(Search, is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_nth ----------------------------------------------------------------------//
|
||||
|
||||
//! Find n-th algorithm
|
||||
/*!
|
||||
Search for the n-th (zero-indexed) occurence of the substring in the
|
||||
Search for the n-th (zero-indexed) occurrence of the substring in the
|
||||
input.
|
||||
|
||||
\param Input A string which will be searched.
|
||||
@ -185,14 +183,13 @@ namespace boost {
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
find_nth(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth)
|
||||
{
|
||||
return nth_finder(Search,Nth)(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, nth_finder(Search,Nth));
|
||||
}
|
||||
|
||||
//! Find n-th algorithm ( case insensitive ).
|
||||
@ -216,15 +213,14 @@ namespace boost {
|
||||
*/
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<Range1T>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<Range1T>::type>
|
||||
ifind_nth(
|
||||
Range1T& Input,
|
||||
const Range2T& Search,
|
||||
int Nth,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return nth_finder(Search,Nth,is_iequal(Loc))(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, nth_finder(Search,Nth,is_iequal(Loc)));
|
||||
}
|
||||
|
||||
// find_head ----------------------------------------------------------------------//
|
||||
@ -249,13 +245,12 @@ namespace boost {
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_head(
|
||||
RangeT& Input,
|
||||
int N)
|
||||
{
|
||||
return head_finder(N)(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, head_finder(N));
|
||||
}
|
||||
|
||||
// find_tail ----------------------------------------------------------------------//
|
||||
@ -281,13 +276,12 @@ namespace boost {
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_tail(
|
||||
RangeT& Input,
|
||||
int N)
|
||||
{
|
||||
return tail_finder(N)(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, tail_finder(N));
|
||||
}
|
||||
|
||||
// find_token --------------------------------------------------------------------//
|
||||
@ -311,14 +305,13 @@ namespace boost {
|
||||
*/
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline iterator_range<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
find_token(
|
||||
RangeT& Input,
|
||||
PredicateT Pred,
|
||||
token_compress_mode_type eCompress=token_compress_off)
|
||||
{
|
||||
return token_finder(Pred, eCompress)(
|
||||
begin(Input),end(Input));
|
||||
return find(Input, token_finder(Pred, eCompress));
|
||||
}
|
||||
|
||||
} // namespace algorithm
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library find_format.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FIND_FORMAT_HPP
|
||||
#define BOOST_STRING_FIND_FORMAT_HPP
|
||||
@ -16,6 +17,7 @@
|
||||
#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>
|
||||
@ -68,11 +70,13 @@ namespace boost {
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
return detail::find_format_copy_impl(
|
||||
Output,
|
||||
Input,
|
||||
lit_input,
|
||||
Formatter,
|
||||
Finder( begin(Input), end(Input) ) );
|
||||
Finder( begin(lit_input), end(lit_input) ) );
|
||||
}
|
||||
|
||||
//! Generic replace algorithm
|
||||
@ -176,12 +180,14 @@ namespace boost {
|
||||
FormatterT,
|
||||
FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
return detail::find_format_all_copy_impl(
|
||||
Output,
|
||||
Input,
|
||||
lit_input,
|
||||
Finder,
|
||||
Formatter,
|
||||
Finder(begin(Input), end(Input)));
|
||||
Finder(begin(lit_input), end(lit_input)));
|
||||
}
|
||||
|
||||
//! Generic replace all algorithm
|
||||
|
@ -1,10 +1,12 @@
|
||||
// Boost string_algo library find_iterator.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-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 http://www.boost.org for updates, documentation, and revision history.
|
||||
// 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_FIND_ITERATOR_HPP
|
||||
#define BOOST_STRING_FIND_ITERATOR_HPP
|
||||
@ -16,7 +18,8 @@
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/find_iterator.hpp>
|
||||
|
||||
@ -114,10 +117,12 @@ namespace boost {
|
||||
find_iterator(
|
||||
RangeT& Col,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_Match(begin(Col),begin(Col)),
|
||||
m_End(end(Col))
|
||||
detail::find_iterator_base<IteratorT>(Finder,0)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(as_literal(Col));
|
||||
m_Match=make_iterator_range(begin(lit_col), begin(lit_col));
|
||||
m_End=end(lit_col);
|
||||
|
||||
increment();
|
||||
}
|
||||
|
||||
@ -180,13 +185,13 @@ namespace boost {
|
||||
*/
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline find_iterator<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
make_find_iterator(
|
||||
RangeT& Collection,
|
||||
FinderT Finder)
|
||||
{
|
||||
return find_iterator<BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>(
|
||||
begin(Collection), end(Collection), Finder);
|
||||
return find_iterator<BOOST_STRING_TYPENAME range_iterator<RangeT>::type>(
|
||||
Collection, Finder);
|
||||
}
|
||||
|
||||
// split iterator -----------------------------------------------//
|
||||
@ -278,11 +283,13 @@ namespace boost {
|
||||
RangeT& Col,
|
||||
FinderT Finder ) :
|
||||
detail::find_iterator_base<IteratorT>(Finder,0),
|
||||
m_Match(begin(Col),begin(Col)),
|
||||
m_Next(begin(Col)),
|
||||
m_End(end(Col)),
|
||||
m_bEof(false)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_col(as_literal(Col));
|
||||
m_Match=make_iterator_range(begin(lit_col), begin(lit_col));
|
||||
m_Next=begin(lit_col);
|
||||
m_End=end(lit_col);
|
||||
|
||||
increment();
|
||||
}
|
||||
|
||||
@ -356,13 +363,13 @@ namespace boost {
|
||||
*/
|
||||
template<typename RangeT, typename FinderT>
|
||||
inline split_iterator<
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type>
|
||||
make_split_iterator(
|
||||
RangeT& Collection,
|
||||
FinderT Finder)
|
||||
{
|
||||
return split_iterator<BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type>(
|
||||
begin(Collection), end(Collection), Finder);
|
||||
return split_iterator<BOOST_STRING_TYPENAME range_iterator<RangeT>::type>(
|
||||
Collection, Finder);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library finder.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FINDER_HPP
|
||||
#define BOOST_STRING_FINDER_HPP
|
||||
@ -45,35 +46,35 @@ namespace boost {
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c first_finder object
|
||||
*/
|
||||
template<typename ContainerT>
|
||||
template<typename RangeT>
|
||||
inline detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
is_equal>
|
||||
first_finder( const ContainerT& Search )
|
||||
first_finder( const RangeT& Search )
|
||||
{
|
||||
return
|
||||
detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<ContainerT>::type,
|
||||
is_equal>( Search, is_equal() ) ;
|
||||
range_const_iterator<RangeT>::type,
|
||||
is_equal>( as_literal(Search), is_equal() ) ;
|
||||
}
|
||||
|
||||
//! "First" finder
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename ContainerT,typename PredicateT>
|
||||
template<typename RangeT,typename PredicateT>
|
||||
inline detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
PredicateT>
|
||||
first_finder(
|
||||
const ContainerT& Search, PredicateT Comp )
|
||||
const RangeT& Search, PredicateT Comp )
|
||||
{
|
||||
return
|
||||
detail::first_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<ContainerT>::type,
|
||||
PredicateT>( Search, Comp );
|
||||
range_const_iterator<RangeT>::type,
|
||||
PredicateT>( as_literal(Search), Comp );
|
||||
}
|
||||
|
||||
//! "Last" finder
|
||||
@ -86,33 +87,33 @@ namespace boost {
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c last_finder object
|
||||
*/
|
||||
template<typename ContainerT>
|
||||
template<typename RangeT>
|
||||
inline detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
is_equal>
|
||||
last_finder( const ContainerT& Search )
|
||||
last_finder( const RangeT& Search )
|
||||
{
|
||||
return
|
||||
detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<ContainerT>::type,
|
||||
is_equal>( Search, is_equal() );
|
||||
range_const_iterator<RangeT>::type,
|
||||
is_equal>( as_literal(Search), is_equal() );
|
||||
}
|
||||
//! "Last" finder
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename ContainerT, typename PredicateT>
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
PredicateT>
|
||||
last_finder( const ContainerT& Search, PredicateT Comp )
|
||||
last_finder( const RangeT& Search, PredicateT Comp )
|
||||
{
|
||||
return
|
||||
detail::last_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<ContainerT>::type,
|
||||
PredicateT>( Search, Comp ) ;
|
||||
range_const_iterator<RangeT>::type,
|
||||
PredicateT>( as_literal(Search), Comp ) ;
|
||||
}
|
||||
|
||||
//! "Nth" finder
|
||||
@ -126,38 +127,38 @@ namespace boost {
|
||||
\param Comp An element comparison predicate
|
||||
\return An instance of the \c nth_finder object
|
||||
*/
|
||||
template<typename ContainerT>
|
||||
template<typename RangeT>
|
||||
inline detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
is_equal>
|
||||
nth_finder(
|
||||
const ContainerT& Search,
|
||||
const RangeT& Search,
|
||||
int Nth)
|
||||
{
|
||||
return
|
||||
detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<ContainerT>::type,
|
||||
is_equal>( Search, Nth, is_equal() ) ;
|
||||
range_const_iterator<RangeT>::type,
|
||||
is_equal>( as_literal(Search), Nth, is_equal() ) ;
|
||||
}
|
||||
//! "Nth" finder
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template<typename ContainerT, typename PredicateT>
|
||||
template<typename RangeT, typename PredicateT>
|
||||
inline detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<ContainerT>::type,
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
|
||||
PredicateT>
|
||||
nth_finder(
|
||||
const ContainerT& Search,
|
||||
const RangeT& Search,
|
||||
int Nth,
|
||||
PredicateT Comp )
|
||||
{
|
||||
return
|
||||
detail::nth_finderF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<ContainerT>::type,
|
||||
PredicateT>( Search, Nth, Comp );
|
||||
range_const_iterator<RangeT>::type,
|
||||
PredicateT>( as_literal(Search), Nth, Comp );
|
||||
}
|
||||
|
||||
//! "Head" finder
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library formatter.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_FORMATTER_HPP
|
||||
#define BOOST_STRING_FORMATTER_HPP
|
||||
@ -13,6 +14,7 @@
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/formatter.hpp>
|
||||
|
||||
@ -41,10 +43,14 @@ namespace boost {
|
||||
\return An instance of the \c const_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::const_formatF<RangeT>
|
||||
inline detail::const_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
|
||||
const_formatter(const RangeT& Format)
|
||||
{
|
||||
return detail::const_formatF<RangeT>(Format);
|
||||
return detail::const_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >(as_literal(Format));
|
||||
}
|
||||
|
||||
//! Identity formatter
|
||||
@ -55,10 +61,14 @@ namespace boost {
|
||||
\return An instance of the \c identity_formatter object.
|
||||
*/
|
||||
template<typename RangeT>
|
||||
inline detail::identity_formatF<RangeT>
|
||||
inline detail::identity_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
|
||||
identity_formatter()
|
||||
{
|
||||
return detail::identity_formatF<RangeT>();
|
||||
return detail::identity_formatF<
|
||||
iterator_range<
|
||||
BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
|
||||
}
|
||||
|
||||
//! Empty formatter
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library iter_find.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_ITER_FIND_HPP
|
||||
#define BOOST_STRING_ITER_FIND_HPP
|
||||
@ -18,8 +19,9 @@
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
|
||||
#include <boost/algorithm/string/concept.hpp>
|
||||
#include <boost/algorithm/string/find_iterator.hpp>
|
||||
@ -74,24 +76,26 @@ namespace boost {
|
||||
{
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_result_iterator<RangeT>::type input_iterator_type;
|
||||
range_iterator<RangeT>::type input_iterator_type;
|
||||
typedef find_iterator<input_iterator_type> find_iterator_type;
|
||||
typedef detail::copy_iterator_rangeF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_value<SequenceSequenceT>::type,
|
||||
input_iterator_type> copy_range_type;
|
||||
|
||||
input_iterator_type InputEnd=end(Input);
|
||||
input_iterator_type InputEnd=end(lit_input);
|
||||
|
||||
typedef transform_iterator<copy_range_type, find_iterator_type>
|
||||
transform_iter_type;
|
||||
|
||||
transform_iter_type itBegin=
|
||||
make_transform_iterator(
|
||||
find_iterator_type( begin(Input), InputEnd, Finder ),
|
||||
find_iterator_type( begin(lit_input), InputEnd, Finder ),
|
||||
copy_range_type());
|
||||
|
||||
transform_iter_type itEnd=
|
||||
@ -141,24 +145,26 @@ namespace boost {
|
||||
{
|
||||
function_requires<
|
||||
FinderConcept<FinderT,
|
||||
BOOST_STRING_TYPENAME range_result_iterator<RangeT>::type> >();
|
||||
BOOST_STRING_TYPENAME range_iterator<RangeT>::type> >();
|
||||
|
||||
iterator_range<BOOST_STRING_TYPENAME range_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_result_iterator<RangeT>::type input_iterator_type;
|
||||
range_iterator<RangeT>::type input_iterator_type;
|
||||
typedef split_iterator<input_iterator_type> find_iterator_type;
|
||||
typedef detail::copy_iterator_rangeF<
|
||||
BOOST_STRING_TYPENAME
|
||||
range_value<SequenceSequenceT>::type,
|
||||
input_iterator_type> copy_range_type;
|
||||
|
||||
input_iterator_type InputEnd=end(Input);
|
||||
input_iterator_type InputEnd=end(lit_input);
|
||||
|
||||
typedef transform_iterator<copy_range_type, find_iterator_type>
|
||||
transform_iter_type;
|
||||
|
||||
transform_iter_type itBegin=
|
||||
make_transform_iterator(
|
||||
find_iterator_type( begin(Input), InputEnd, Finder ),
|
||||
find_iterator_type( begin(lit_input), InputEnd, Finder ),
|
||||
copy_range_type() );
|
||||
|
||||
transform_iter_type itEnd=
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library predicate.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_PREDICATE_HPP
|
||||
#define BOOST_STRING_PREDICATE_HPP
|
||||
@ -15,6 +16,8 @@
|
||||
#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.hpp>
|
||||
|
||||
#include <boost/algorithm/string/compare.hpp>
|
||||
#include <boost/algorithm/string/find.hpp>
|
||||
@ -56,16 +59,19 @@ namespace boost {
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(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=end(Input);
|
||||
Iterator2T TestEnd=end(Test);
|
||||
Iterator1T InputEnd=end(lit_input);
|
||||
Iterator2T TestEnd=end(lit_test);
|
||||
|
||||
Iterator1T it=begin(Input);
|
||||
Iterator2T pit=begin(Test);
|
||||
Iterator1T it=begin(lit_input);
|
||||
Iterator2T pit=begin(lit_test);
|
||||
for(;
|
||||
it!=InputEnd && pit!=TestEnd;
|
||||
++it,++pit)
|
||||
@ -135,6 +141,9 @@ namespace boost {
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(as_literal(Test));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<Range1T>::type Iterator1T;
|
||||
typedef BOOST_STRING_TYPENAME boost::detail::
|
||||
@ -142,10 +151,10 @@ namespace boost {
|
||||
|
||||
return detail::
|
||||
ends_with_iter_select(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(Test),
|
||||
end(Test),
|
||||
begin(lit_input),
|
||||
end(lit_input),
|
||||
begin(lit_test),
|
||||
end(lit_test),
|
||||
Comp,
|
||||
category());
|
||||
}
|
||||
@ -206,14 +215,17 @@ namespace boost {
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
if (empty(Test))
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(as_literal(Test));
|
||||
|
||||
if (empty(lit_test))
|
||||
{
|
||||
// Empty range is contained always
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use the temporary variable to make VACPP happy
|
||||
bool bResult=(first_finder(Test,Comp)(begin(Input), end(Input)));
|
||||
bool bResult=(first_finder(lit_test,Comp)(begin(lit_input), end(lit_input)));
|
||||
return bResult;
|
||||
}
|
||||
|
||||
@ -274,16 +286,19 @@ namespace boost {
|
||||
const Range2T& Test,
|
||||
PredicateT Comp)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_input(as_literal(Input));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_test(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=end(Input);
|
||||
Iterator2T TestEnd=end(Test);
|
||||
Iterator1T InputEnd=end(lit_input);
|
||||
Iterator2T TestEnd=end(lit_test);
|
||||
|
||||
Iterator1T it=begin(Input);
|
||||
Iterator2T pit=begin(Test);
|
||||
Iterator1T it=begin(lit_input);
|
||||
Iterator2T pit=begin(lit_test);
|
||||
for(;
|
||||
it!=InputEnd && pit!=TestEnd;
|
||||
++it,++pit)
|
||||
@ -357,11 +372,14 @@ namespace boost {
|
||||
const Range2T& Arg2,
|
||||
PredicateT Pred)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range1T>::type> lit_arg1(as_literal(Arg1));
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<Range2T>::type> lit_arg2(as_literal(Arg2));
|
||||
|
||||
return std::lexicographical_compare(
|
||||
begin(Arg1),
|
||||
end(Arg1),
|
||||
begin(Arg2),
|
||||
end(Arg2),
|
||||
begin(lit_arg1),
|
||||
end(lit_arg1),
|
||||
begin(lit_arg2),
|
||||
end(lit_arg2),
|
||||
Pred);
|
||||
}
|
||||
|
||||
@ -374,12 +392,7 @@ namespace boost {
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2)
|
||||
{
|
||||
return std::lexicographical_compare(
|
||||
begin(Arg1),
|
||||
end(Arg1),
|
||||
begin(Arg2),
|
||||
end(Arg2),
|
||||
is_less());
|
||||
return lexicographical_compare(Arg1, Arg2, is_less());
|
||||
}
|
||||
|
||||
//! Lexicographical compare predicate (case-insensitive)
|
||||
@ -393,6 +406,7 @@ namespace boost {
|
||||
|
||||
\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
|
||||
@ -400,14 +414,10 @@ namespace boost {
|
||||
template<typename Range1T, typename Range2T>
|
||||
inline bool ilexicographical_compare(
|
||||
const Range1T& Arg1,
|
||||
const Range2T& Arg2)
|
||||
const Range2T& Arg2,
|
||||
const std::locale& Loc=std::locale())
|
||||
{
|
||||
return std::lexicographical_compare(
|
||||
begin(Arg1),
|
||||
end(Arg1),
|
||||
begin(Arg2),
|
||||
end(Arg2),
|
||||
is_iless());
|
||||
return lexicographical_compare(Arg1, Arg2, is_iless(Loc));
|
||||
}
|
||||
|
||||
|
||||
@ -429,11 +439,13 @@ namespace boost {
|
||||
const RangeT& Input,
|
||||
PredicateT Pred)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(as_literal(Input));
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type Iterator1T;
|
||||
|
||||
Iterator1T InputEnd=end(Input);
|
||||
for( Iterator1T It=begin(Input); It!=InputEnd; ++It)
|
||||
Iterator1T InputEnd=end(lit_input);
|
||||
for( Iterator1T It=begin(lit_input); It!=InputEnd; ++It)
|
||||
{
|
||||
if (!Pred(*It))
|
||||
return false;
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library predicate_facade.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_PREDICATE_FACADE_HPP
|
||||
#define BOOST_STRING_PREDICATE_FACADE_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library replace.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_REPLACE_HPP
|
||||
#define BOOST_STRING_REPLACE_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library sequence_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_SEQUENCE_TRAITS_HPP
|
||||
#define BOOST_STRING_SEQUENCE_TRAITS_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library split.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2006. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_SPLIT_HPP
|
||||
#define BOOST_STRING_SPLIT_HPP
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library list_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library slist_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library string_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library std_containers_traits.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library trim.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// See http://www.boost.org/ for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_STRING_TRIM_HPP
|
||||
#define BOOST_STRING_TRIM_HPP
|
||||
@ -15,6 +16,8 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <boost/algorithm/string/detail/trim.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
@ -60,12 +63,14 @@ namespace boost {
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(as_literal(Input));
|
||||
|
||||
std::copy(
|
||||
::boost::algorithm::detail::trim_begin(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(lit_range),
|
||||
end(lit_range),
|
||||
IsSpace ),
|
||||
end(Input),
|
||||
end(lit_range),
|
||||
Output);
|
||||
|
||||
return Output;
|
||||
@ -166,11 +171,13 @@ namespace boost {
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace )
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(as_literal(Input));
|
||||
|
||||
std::copy(
|
||||
begin(Input),
|
||||
begin(lit_range),
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(lit_range),
|
||||
end(lit_range),
|
||||
IsSpace ),
|
||||
Output );
|
||||
|
||||
@ -276,16 +283,18 @@ namespace boost {
|
||||
const RangeT& Input,
|
||||
PredicateT IsSpace)
|
||||
{
|
||||
iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_range(as_literal(Input));
|
||||
|
||||
BOOST_STRING_TYPENAME
|
||||
range_const_iterator<RangeT>::type TrimEnd=
|
||||
::boost::algorithm::detail::trim_end(
|
||||
begin(Input),
|
||||
end(Input),
|
||||
begin(lit_range),
|
||||
end(lit_range),
|
||||
IsSpace);
|
||||
|
||||
std::copy(
|
||||
detail::trim_begin(
|
||||
begin(Input), TrimEnd, IsSpace),
|
||||
begin(lit_range), TrimEnd, IsSpace),
|
||||
TrimEnd,
|
||||
Output
|
||||
);
|
||||
|
@ -1,11 +1,12 @@
|
||||
// Boost string_algo library yes_no_type.hpp header file ---------------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. 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)
|
||||
// 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.
|
||||
// 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
|
||||
|
132
src/3rdparty/include/boost/archive/array/iarchive.hpp
vendored
Normal file
132
src/3rdparty/include/boost/archive/array/iarchive.hpp
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
#ifndef BOOST_ARCHIVE_ARRAY_IARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_ARRAY_IARCHIVE_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// 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)
|
||||
|
||||
|
||||
#include <boost/archive/basic_archive.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/detail/common_iarchive.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace archive { namespace array {
|
||||
|
||||
// To conveniently array-optimize an input archive X:
|
||||
//
|
||||
// * Derive it from iarchive<X, Impl>, where Impl is an
|
||||
// archive implementation base class from
|
||||
// Boost.Serialization
|
||||
//
|
||||
// * add a member function template that implements the
|
||||
// procedure for serializing arrays of T (for appropriate T)
|
||||
//
|
||||
// template <class T>
|
||||
// load_array(serialization::array<T> &, unsigned int)
|
||||
//
|
||||
// * add a unary MPL lambda expression member called
|
||||
// use_array_optimization whose result is convertible to
|
||||
// mpl::true_ iff array elements of type T can be serialized
|
||||
// with the load_array member function, and to mpl::false_ if
|
||||
// the unoptimized procedure must be used.
|
||||
|
||||
template <class Archive>
|
||||
class iarchive
|
||||
: public archive::detail::common_iarchive<Archive>
|
||||
{
|
||||
typedef archive::detail::common_iarchive<Archive> Base;
|
||||
public:
|
||||
iarchive(unsigned int flags)
|
||||
: archive::detail::common_iarchive<Archive>(flags)
|
||||
{}
|
||||
|
||||
|
||||
// save_override for std::vector and serialization::array dispatches to
|
||||
// save_optimized with an additional argument.
|
||||
//
|
||||
// If that argument is of type mpl::true_, an optimized serialization is provided
|
||||
// If it is false, we just forward to the default serialization in the base class
|
||||
|
||||
//the default version dispatches to the base class
|
||||
template<class T>
|
||||
void load_optimized(T &t, unsigned int version, mpl::false_)
|
||||
{
|
||||
Base::load_override(t, version);
|
||||
}
|
||||
|
||||
// the optimized implementation for vector uses serialization::array
|
||||
// template<class U, class Allocator>
|
||||
// void load_optimized(
|
||||
// std::vector<U, Allocator> &t, unsigned int version, mpl::true_)
|
||||
// {
|
||||
// t.clear();
|
||||
// // retrieve number of elements
|
||||
// serialization::collection_size_type count;
|
||||
// *this->This() >> BOOST_SERIALIZATION_NVP(count);
|
||||
// t.resize(count);
|
||||
// if (!t.empty())
|
||||
// * this->This() >> serialization::make_array(serialization::detail::get_data(t),t.size());
|
||||
// }
|
||||
|
||||
// the optimized implementation for serialization::array uses save_array
|
||||
template<class ValueType>
|
||||
void load_optimized(
|
||||
serialization::array<ValueType> &t, unsigned int version, mpl::true_)
|
||||
{
|
||||
this->This()->load_array(t,version);
|
||||
}
|
||||
|
||||
|
||||
// to load a vector:
|
||||
// if the value type is trivially constructable or an optimized array save exists,
|
||||
// then we can use the optimized version
|
||||
|
||||
// template<class ValueType, class Allocator>
|
||||
// void load_override(std::vector<ValueType,Allocator> &x, unsigned int version)
|
||||
// {
|
||||
// typedef typename mpl::and_<
|
||||
// mpl::not_<is_same<ValueType,bool> >,
|
||||
// mpl::apply1<
|
||||
// BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
// , ValueType>
|
||||
// >::type use_optimized;
|
||||
// load_optimized(x,version, use_optimized() );
|
||||
// }
|
||||
|
||||
|
||||
// dispatch loading of arrays to the optimized version where supported
|
||||
template<class ValueType>
|
||||
void load_override(serialization::array<ValueType> const& x, unsigned int version)
|
||||
{
|
||||
typedef typename mpl::apply1<
|
||||
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
, ValueType
|
||||
>::type use_optimized;
|
||||
load_optimized(const_cast<serialization::array<ValueType>&>(x),version,use_optimized());
|
||||
}
|
||||
|
||||
// Load everything else in the usual way, forwarding on to the base class
|
||||
template<class T>
|
||||
void load_override(T & x, unsigned BOOST_PFTO int version)
|
||||
{
|
||||
Base::load_override(x, static_cast<unsigned int>(version));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} } } // end namespace boost::archive::array
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
|
130
src/3rdparty/include/boost/archive/array/oarchive.hpp
vendored
Normal file
130
src/3rdparty/include/boost/archive/array/oarchive.hpp
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
#ifndef BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
#define BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
|
||||
// (C) Copyright 2005 Matthias Troyer and Dave Abrahams
|
||||
// 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)
|
||||
|
||||
|
||||
#include <boost/archive/basic_archive.hpp>
|
||||
#include <boost/archive/detail/common_oarchive.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/detail/get_data.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
namespace boost { namespace archive { namespace array {
|
||||
|
||||
// To conveniently array-optimize an output archive X:
|
||||
//
|
||||
// * Derive it from oarchive<X, Impl>, where Impl is an
|
||||
// archive implementation base class from
|
||||
// Boost.Serialization
|
||||
//
|
||||
// * add a member function template that implements the
|
||||
// procedure for serializing arrays of T (for appropriate T)
|
||||
//
|
||||
// template <class T>
|
||||
// save_array(serialization::array<T> const &, unsigned int)
|
||||
//
|
||||
// * add a unary MPL lambda expression member called
|
||||
// use_array_optimization whose result is convertible to
|
||||
// mpl::true_ iff array elements of type T can be serialized
|
||||
// with the load_array member function, and to mpl::false_ if
|
||||
// the unoptimized procedure must be used.
|
||||
|
||||
template <class Archive>
|
||||
class oarchive
|
||||
: public archive::detail::common_oarchive<Archive>
|
||||
{
|
||||
typedef archive::detail::common_oarchive<Archive> Base;
|
||||
public:
|
||||
|
||||
oarchive(unsigned int flags)
|
||||
: archive::detail::common_oarchive<Archive>(flags)
|
||||
{}
|
||||
|
||||
// save_override for std::vector and serialization::array dispatches to
|
||||
// save_optimized with an additional argument.
|
||||
//
|
||||
// If that argument is of type mpl::true_, an optimized serialization is provided
|
||||
// If it is false, we just forward to the default serialization in the base class
|
||||
|
||||
//the default version dispatches to the base class
|
||||
template<class T>
|
||||
void save_optimized(T const &t, unsigned int version, mpl::false_)
|
||||
{
|
||||
Base::save_override(t, version);
|
||||
}
|
||||
|
||||
|
||||
// the optimized implementation for vector uses serialization::array
|
||||
// template<class ValueType, class Allocator>
|
||||
// void save_optimized(
|
||||
// const std::vector<ValueType, Allocator> &t, unsigned int, mpl::true_)
|
||||
// {
|
||||
// const serialization::collection_size_type count(t.size());
|
||||
// * this->This() << BOOST_SERIALIZATION_NVP(count);
|
||||
// if (!t.empty())
|
||||
// * this->This() << serialization::make_array(serialization::detail::get_data(t),t.size());
|
||||
// }
|
||||
|
||||
// the optimized implementation for serialization::array uses save_array
|
||||
template<class ValueType>
|
||||
void save_optimized(
|
||||
const serialization::array<ValueType> &t, unsigned int version, mpl::true_)
|
||||
{
|
||||
this->This()->save_array(t,version);
|
||||
}
|
||||
|
||||
|
||||
// to save a vector:
|
||||
// if the value type is trivially constructable or an optimized array save exists,
|
||||
// then we can use the optimized version
|
||||
|
||||
// template<class ValueType, class Allocator>
|
||||
// void save_override(std::vector<ValueType,Allocator> const &x, unsigned int version)
|
||||
// {
|
||||
// typedef BOOST_DEDUCED_TYPENAME remove_const<ValueType>::type value_type;
|
||||
// typedef typename mpl::and_<
|
||||
// mpl::not_<is_same<value_type,bool> >,
|
||||
// mpl::apply1<
|
||||
// BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
// , value_type>
|
||||
// >::type use_optimized;
|
||||
// save_optimized(x,version,use_optimized() );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// dispatch saving of arrays to the optimized version where supported
|
||||
template<class ValueType>
|
||||
void save_override(serialization::array<ValueType> const& x, unsigned int version)
|
||||
{
|
||||
typedef typename mpl::apply1<
|
||||
BOOST_DEDUCED_TYPENAME Archive::use_array_optimization
|
||||
, BOOST_DEDUCED_TYPENAME remove_const<ValueType>::type
|
||||
>::type use_optimized;
|
||||
save_optimized(x,version,use_optimized());
|
||||
}
|
||||
|
||||
// Load everything else in the usual way, forwarding on to the
|
||||
// Base class
|
||||
template<class T>
|
||||
void save_override(T const& x, unsigned BOOST_PFTO int version)
|
||||
{
|
||||
Base::save_override(x, static_cast<unsigned int>(version));
|
||||
}
|
||||
};
|
||||
|
||||
} } } // end namespace boost::archive::array
|
||||
|
||||
|
||||
#endif // BOOST_ARCHIVE_ARRAY_OARCHIVE_HPP
|
||||
|
@ -117,14 +117,4 @@ BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type, primitive_type)
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type, primitive_type)
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// Make sure that the export.hpp header isn't included before any archive header
|
||||
// Doing so would inhibit construction of correct mpl list of known archive
|
||||
// types which in turn would inhibit instantiation of all combinations of
|
||||
// serialization/archive types.
|
||||
|
||||
#ifdef BOOST_SERIALIZATION_EXPORT_HPP
|
||||
#error "export.hpp must not be included before any archive header"
|
||||
#endif
|
||||
|
||||
#endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
#include <boost/archive/detail/common_iarchive.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/archive/array/iarchive.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
@ -40,7 +40,7 @@ namespace archive {
|
||||
// class basic_binary_iarchive - read serialized objects from a input binary stream
|
||||
template<class Archive>
|
||||
class basic_binary_iarchive :
|
||||
public detail::common_iarchive<Archive>
|
||||
public array::iarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
@ -56,11 +56,10 @@ public:
|
||||
// fot templates in the absence of partial function
|
||||
// template ordering. If we get here pass to base class
|
||||
// note extra nonsense to sneak it pass the borland compiers
|
||||
typedef detail::common_iarchive<Archive> detail_common_iarchive;
|
||||
typedef array::iarchive<Archive> array_iarchive;
|
||||
template<class T>
|
||||
void load_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
this->detail_common_iarchive::load_override(t, 0);
|
||||
void load_override(T & t, BOOST_PFTO int){
|
||||
this->array_iarchive::load_override(t, 0);
|
||||
}
|
||||
// binary files don't include the optional information
|
||||
void load_override(class_id_optional_type & /* t */, int){}
|
||||
@ -69,39 +68,44 @@ public:
|
||||
// for these pseudo prmitive types.
|
||||
void load_override(version_type & t, int){
|
||||
// upto 255 versions
|
||||
unsigned char x;
|
||||
unsigned char x=0;
|
||||
* this->This() >> x;
|
||||
t = version_type(x);
|
||||
}
|
||||
void load_override(class_id_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x;
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = class_id_type(x);
|
||||
}
|
||||
void load_override(class_id_reference_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x;
|
||||
int_least16_t x=0;
|
||||
* this->This() >> x;
|
||||
t = class_id_reference_type(x);
|
||||
}
|
||||
void load_override(object_id_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x;
|
||||
uint_least32_t x=0;
|
||||
* this->This() >> x;
|
||||
t = object_id_type(x);
|
||||
}
|
||||
void load_override(object_reference_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x;
|
||||
uint_least32_t x=0;
|
||||
* this->This() >> x;
|
||||
t = object_reference_type(x);
|
||||
}
|
||||
void load_override(tracking_type & t, int){
|
||||
char x;
|
||||
char x=0;
|
||||
* this->This() >> x;
|
||||
t = (0 != x);
|
||||
}
|
||||
void load_override(serialization::collection_size_type & t, int){
|
||||
unsigned int x=0;
|
||||
* this->This() >> x;
|
||||
t = serialization::collection_size_type(x);
|
||||
}
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load_override(class_name_type & t, int);
|
||||
@ -109,7 +113,7 @@ public:
|
||||
init();
|
||||
|
||||
basic_binary_iarchive(unsigned int flags) :
|
||||
detail::common_iarchive<Archive>(flags)
|
||||
array_iarchive(flags)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -48,6 +48,9 @@ namespace std{
|
||||
#include <boost/archive/basic_streambuf_locale_saver.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/serialization/is_bitwise_serializable.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
@ -86,6 +89,7 @@ public:
|
||||
load_binary(& t, sizeof(t));
|
||||
int i = t;
|
||||
assert(0 == i || 1 == i);
|
||||
(void)i; // warning suppression for release builds.
|
||||
}
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
load(std::string &s);
|
||||
@ -108,6 +112,21 @@ public:
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_binary_iprimitive();
|
||||
public:
|
||||
// we provide an optimized load for all fundamental types
|
||||
//typedef serialization::is_bitwise_serializable<mpl::_1>
|
||||
// use_array_optimization;
|
||||
struct use_array_optimization {
|
||||
template <class T>
|
||||
struct apply : public serialization::is_bitwise_serializable<T> {};
|
||||
};
|
||||
|
||||
// the optimized load_array dispatches to load_binary
|
||||
template <class ValueType>
|
||||
void load_array(serialization::array<ValueType>& a, unsigned int)
|
||||
{
|
||||
load_binary(a.address(),a.count()*sizeof(ValueType));
|
||||
}
|
||||
|
||||
void
|
||||
load_binary(void *address, std::size_t count);
|
||||
};
|
||||
@ -146,7 +165,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
|
||||
static_cast<Elem *>(address),
|
||||
s
|
||||
);
|
||||
if(count != static_cast<std::size_t>(s))
|
||||
if(scount != static_cast<std::streamsize>(s))
|
||||
boost::throw_exception(
|
||||
archive_exception(archive_exception::stream_error)
|
||||
);
|
||||
@ -157,7 +176,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load_binary(
|
||||
// boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
Elem t;
|
||||
scount = m_sb.sgetn(& t, 1);
|
||||
if(count != 1)
|
||||
if(scount != 1)
|
||||
boost::throw_exception(
|
||||
archive_exception(archive_exception::stream_error)
|
||||
);
|
||||
|
@ -27,8 +27,10 @@
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/archive/detail/common_oarchive.hpp>
|
||||
#include <boost/archive/array/oarchive.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
#include <boost/archive/array/oarchive.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
@ -41,12 +43,9 @@ namespace archive {
|
||||
// by a program built with the same tools for the same machne. This class
|
||||
// does have the virtue of buiding the smalles archive in the minimum amount
|
||||
// of time. So under some circumstances it may be he right choice.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class basic_text_iarchive - read serialized objects from a input text stream
|
||||
template<class Archive>
|
||||
class basic_binary_oarchive :
|
||||
public detail::common_oarchive<Archive>
|
||||
public array::oarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
@ -59,10 +58,14 @@ public:
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
#endif
|
||||
// any datatype not specifed below will be handled by base class
|
||||
typedef detail::common_oarchive<Archive> detail_common_oarchive;
|
||||
typedef array::oarchive<Archive> array_oarchive;
|
||||
template<class T>
|
||||
void save_override(const T & t, BOOST_PFTO int){
|
||||
this->array_oarchive::save_override(t, 0);
|
||||
}
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int){
|
||||
this->detail_common_oarchive::save_override(t, 0);
|
||||
this->save_override(const_cast<const T &>(t), 0);
|
||||
}
|
||||
// binary files don't include the optional information
|
||||
void save_override(const class_id_optional_type & /* t */, int){}
|
||||
@ -70,22 +73,22 @@ public:
|
||||
void save_override(const version_type & t, int){
|
||||
// upto 255 versions
|
||||
// note:t.t resolves borland ambguity
|
||||
unsigned char x = t.t;
|
||||
const unsigned char x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x = t.t;
|
||||
const int_least16_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_reference_type & t, int){
|
||||
// upto 32K classes
|
||||
int_least16_t x = t.t;
|
||||
const int_least16_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const object_id_type & t, int){
|
||||
// upto 2G objects
|
||||
uint_least32_t x = t.t;
|
||||
const uint_least32_t x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const object_reference_type & t, int){
|
||||
@ -94,7 +97,7 @@ public:
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const tracking_type & t, int){
|
||||
char x = t.t;
|
||||
const char x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
|
||||
@ -104,11 +107,17 @@ public:
|
||||
* this->This() << s;
|
||||
}
|
||||
|
||||
void save_override(const serialization::collection_size_type & t, int){
|
||||
// for backward compatibility, 64 bit integer or variable length integer would be preferred
|
||||
unsigned int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
|
||||
basic_binary_oarchive(unsigned int flags) :
|
||||
detail::common_oarchive<Archive>(flags)
|
||||
array_oarchive(flags)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -46,6 +46,9 @@ namespace std{
|
||||
#include <boost/archive/basic_streambuf_locale_saver.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/serialization/is_bitwise_serializable.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
@ -101,6 +104,7 @@ public:
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
init();
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_binary_oprimitive(
|
||||
std::basic_streambuf<Elem, Tr> & sb,
|
||||
@ -109,6 +113,24 @@ public:
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_binary_oprimitive();
|
||||
public:
|
||||
|
||||
// we provide an optimized save for all fundamental types
|
||||
// typedef serialization::is_bitwise_serializable<mpl::_1>
|
||||
// use_array_optimization;
|
||||
// workaround without using mpl lambdas
|
||||
struct use_array_optimization {
|
||||
template <class T>
|
||||
struct apply : public serialization::is_bitwise_serializable<T> {};
|
||||
};
|
||||
|
||||
|
||||
// the optimized save_array dispatches to save_binary
|
||||
template <class ValueType>
|
||||
void save_array(serialization::array<ValueType> const& a, unsigned int)
|
||||
{
|
||||
save_binary(a.address(),a.count()*sizeof(ValueType));
|
||||
}
|
||||
|
||||
void save_binary(const void *address, std::size_t count);
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
{
|
||||
this->detail_common_iarchive::load_override(t, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Borland compilers has a problem with strong type. Try to fix this here
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
void load_override(version_type & t, int){
|
||||
@ -70,7 +70,7 @@ public:
|
||||
t.t = version_type(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// text file don't include the optional information
|
||||
void load_override(class_id_optional_type & /*t*/, int){}
|
||||
|
||||
|
@ -78,36 +78,39 @@ public:
|
||||
// start new objects on a new line
|
||||
void save_override(const object_id_type & t, int){
|
||||
this->This()->newline();
|
||||
// and and invoke prmitive to underlying value
|
||||
// note extra .t to funciton with Borland 5.51 compiler
|
||||
// and invoke prmitive to underlying value
|
||||
this->This()->save(t.t);
|
||||
}
|
||||
|
||||
void save_override(const object_reference_type & t, int){
|
||||
this->This()->newline();
|
||||
// and and invoke prmitive to underlying value
|
||||
// note extra .t to funciton with Borland 5.51 compiler
|
||||
// and invoke prmitive to underlying value
|
||||
this->This()->save(t.t);
|
||||
}
|
||||
|
||||
// note the following four overrides are necessary for some borland
|
||||
// compilers(5.51) which don't handle BOOST_STRONG_TYPE properly.
|
||||
void save_override(const version_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
const unsigned int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
const int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_reference_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
const int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
|
||||
// text file don't include the optional information
|
||||
void save_override(const class_id_optional_type & /* t */, int){}
|
||||
|
||||
// note the following four overrides are necessary for some borland
|
||||
// compilers which don't handle BOOST_STRONG_TYPE properly.
|
||||
void save_override(const version_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
unsigned int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_id_reference_type & t, int){
|
||||
// note:t.t resolves borland ambguity
|
||||
int x = t.t;
|
||||
* this->This() << x;
|
||||
}
|
||||
void save_override(const class_name_type & t, int){
|
||||
const std::string s(t);
|
||||
* this->This() << s;
|
||||
|
@ -89,10 +89,8 @@ public:
|
||||
void save(const bool t){
|
||||
// trap usage of invalid uninitialized boolean which would
|
||||
// otherwise crash on load.
|
||||
#ifndef NDEBUG
|
||||
int i = t;
|
||||
assert(0 == i || 1 == i);
|
||||
#endif
|
||||
if(os.fail())
|
||||
boost::throw_exception(archive_exception(archive_exception::stream_error));
|
||||
os << t;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
xml_archive_tag_mismatch,
|
||||
xml_archive_tag_name_error
|
||||
} exception_code;
|
||||
xml_archive_exception(exception_code /* c */)
|
||||
xml_archive_exception(exception_code c)
|
||||
{}
|
||||
virtual const char *what( ) const throw( )
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_xml_iarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// (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)
|
||||
@ -25,6 +25,8 @@
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
@ -33,7 +35,7 @@ namespace archive {
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// class xml_iarchive - read serialized objects from a input text stream
|
||||
template<class Archive>
|
||||
class basic_xml_iarchive :
|
||||
class basic_xml_iarchive :
|
||||
public detail::common_iarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
@ -60,7 +62,8 @@ public:
|
||||
// If your program fails to compile here, its most likely due to
|
||||
// not specifying an nvp wrapper around the variable to
|
||||
// be serialized.
|
||||
BOOST_STATIC_ASSERT(0 == sizeof(T));
|
||||
BOOST_MPL_ASSERT((serialization::is_wrapper<T>));
|
||||
this->detail_common_iarchive::load_override(t, 0);
|
||||
}
|
||||
|
||||
// Anything not an attribute - see below - should be a name value
|
||||
@ -71,7 +74,7 @@ public:
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
const
|
||||
#endif
|
||||
boost::serialization::nvp<T> & t,
|
||||
boost::serialization::nvp<T> & t,
|
||||
int
|
||||
){
|
||||
load_start(t.name());
|
||||
@ -101,9 +104,9 @@ public:
|
||||
// handle this.
|
||||
// void load_override(class_name_type & t, int);
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_xml_iarchive(unsigned int flags);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_xml_iarchive();
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// basic_xml_oarchive.hpp
|
||||
|
||||
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
||||
// (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)
|
||||
@ -24,15 +24,18 @@
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// class basic_xml_oarchive - write serialized objects to a xml output stream
|
||||
template<class Archive>
|
||||
class basic_xml_oarchive :
|
||||
class basic_xml_oarchive :
|
||||
public detail::common_oarchive<Archive>
|
||||
{
|
||||
protected:
|
||||
@ -42,8 +45,10 @@ public:
|
||||
// for some inexplicable reason insertion of "class" generates compile erro
|
||||
// on msvc 7.1
|
||||
friend detail::interface_oarchive<Archive>;
|
||||
friend class save_access;
|
||||
#else
|
||||
friend class detail::interface_oarchive<Archive>;
|
||||
friend class save_access;
|
||||
#endif
|
||||
// special stuff for xml output
|
||||
unsigned int depth;
|
||||
@ -55,13 +60,13 @@ public:
|
||||
init();
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
write_attribute(
|
||||
const char *attribute_name,
|
||||
const char *attribute_name,
|
||||
int t,
|
||||
const char *conjunction = "=\""
|
||||
);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
write_attribute(
|
||||
const char *attribute_name,
|
||||
const char *attribute_name,
|
||||
const char *key
|
||||
);
|
||||
// helpers used below
|
||||
@ -80,7 +85,8 @@ public:
|
||||
// If your program fails to compile here, its most likely due to
|
||||
// not specifying an nvp wrapper around the variable to
|
||||
// be serialized.
|
||||
BOOST_STATIC_ASSERT(0 == sizeof(T));
|
||||
BOOST_MPL_ASSERT((serialization::is_wrapper<T>));
|
||||
this->detail_common_oarchive::save_override(t, 0);
|
||||
}
|
||||
|
||||
// special treatment for name-value pairs.
|
||||
@ -90,7 +96,7 @@ public:
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
const
|
||||
#endif
|
||||
::boost::serialization::nvp<T> & t,
|
||||
::boost::serialization::nvp<T> & t,
|
||||
int
|
||||
){
|
||||
save_start(t.name());
|
||||
@ -117,9 +123,9 @@ public:
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
save_override(const tracking_type & t, int);
|
||||
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
basic_xml_oarchive(unsigned int flags);
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
||||
~basic_xml_oarchive();
|
||||
};
|
||||
|
||||
|
@ -22,6 +22,43 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// do not derive from the classes below. If you want to extend this functionality
|
||||
// via inhertance, derived from text_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
|
||||
// same as binary_iarchive below - without the shared_ptr_helper
|
||||
class naked_binary_iarchive :
|
||||
public binary_iarchive_impl<
|
||||
boost::archive::naked_binary_iarchive,
|
||||
std::istream::char_type,
|
||||
std::istream::traits_type
|
||||
>
|
||||
{
|
||||
public:
|
||||
naked_binary_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_iarchive, std::istream::char_type, std::istream::traits_type
|
||||
>(is, flags)
|
||||
{}
|
||||
naked_binary_iarchive(std::streambuf & bsb, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_iarchive, std::istream::char_type, std::istream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from binary_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
@ -30,7 +67,8 @@ class binary_iarchive :
|
||||
boost::archive::binary_iarchive,
|
||||
std::istream::char_type,
|
||||
std::istream::traits_type
|
||||
>
|
||||
>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
binary_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
@ -48,8 +86,7 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_iarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_iarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_IARCHIVE_HPP
|
||||
|
@ -43,11 +43,12 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
typedef binary_oarchive naked_binary_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_oarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_BINARY_OARCHIVE_HPP
|
||||
|
@ -27,9 +27,43 @@
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from binary_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
// same as binary_wiarchive below - without the shared_ptr_helper
|
||||
class naked_binary_wiarchive :
|
||||
public binary_iarchive_impl<
|
||||
boost::archive::naked_binary_wiarchive,
|
||||
std::wistream::char_type,
|
||||
std::wistream::traits_type
|
||||
>
|
||||
{
|
||||
public:
|
||||
naked_binary_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_wiarchive,
|
||||
std::wistream::char_type,
|
||||
std::wistream::traits_type
|
||||
>(is, flags)
|
||||
{}
|
||||
naked_binary_wiarchive(std::wstreambuf & bsb, unsigned int flags = 0) :
|
||||
binary_iarchive_impl<
|
||||
naked_binary_wiarchive,
|
||||
std::wistream::char_type,
|
||||
std::wistream::traits_type
|
||||
>(bsb, flags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class binary_wiarchive :
|
||||
public binary_iarchive_impl<
|
||||
binary_wiarchive, std::wistream::char_type, std::wistream::traits_type
|
||||
@ -51,9 +85,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_wiarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_wiarchive)
|
||||
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif // BOOST_ARCHIVE_BINARY_WIARCHIVE_HPP
|
||||
|
@ -48,12 +48,13 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
typedef binary_woarchive naked_binary_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::binary_woarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::binary_woarchive)
|
||||
|
||||
#endif // BOOST_NO_STD_WSTREAMBUF
|
||||
#endif // BOOST_ARCHIVE_BINARY_WOARCHIVE_HPP
|
||||
|
@ -20,19 +20,22 @@
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
|
||||
namespace std{
|
||||
#if defined(__LIBCOMO__)
|
||||
using ::mbstate_t;
|
||||
#elif defined(__QNXNTO__)
|
||||
using std::mbstate_t;
|
||||
//using std::mbstate_t;
|
||||
#elif defined(BOOST_DINKUMWARE_STDLIB) && BOOST_DINKUMWARE_STDLIB == 1
|
||||
using ::mbstate_t;
|
||||
#elif defined(__SGI_STL_PORT)
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::codecvt;
|
||||
using ::mbstate_t;
|
||||
#endif
|
||||
#elif defined(BOOST_RWSTD_VER)
|
||||
using ::mbstate_t;
|
||||
#endif
|
||||
} // namespace std
|
||||
|
||||
namespace boost {
|
||||
@ -56,7 +59,7 @@ public:
|
||||
template<>
|
||||
class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
{
|
||||
virtual std::codecvt_base::result
|
||||
virtual BOOST_ARCHIVE_DECL(std::codecvt_base::result)
|
||||
do_out(
|
||||
std::mbstate_t & state,
|
||||
const wchar_t * first1,
|
||||
@ -66,7 +69,7 @@ class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t>
|
||||
char * last2,
|
||||
char * & next2
|
||||
) const;
|
||||
virtual std::codecvt_base::result
|
||||
virtual BOOST_ARCHIVE_DECL(std::codecvt_base::result)
|
||||
do_in(
|
||||
std::mbstate_t & state,
|
||||
const char * first1,
|
||||
|
@ -13,3 +13,8 @@
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4251 4231 4660 4275)
|
||||
#endif
|
||||
|
||||
#if defined( __BORLANDC__ )
|
||||
#pragma nopushoptwarn
|
||||
#endif
|
||||
|
||||
|
@ -12,3 +12,8 @@
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
#if defined( __BORLANDC__ )
|
||||
#pragma nopushoptwarn
|
||||
#endif
|
||||
|
||||
|
@ -65,16 +65,8 @@ protected:
|
||||
public:
|
||||
// note: NOT part of the public API.
|
||||
void next_object_pointer(void *t);
|
||||
void register_basic_serializer(const basic_iserializer & bis);
|
||||
void
|
||||
lookup_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
shared_ptr<void> & sph
|
||||
);
|
||||
void
|
||||
insert_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
shared_ptr<void> & sph
|
||||
void register_basic_serializer(
|
||||
const basic_iserializer & bis
|
||||
);
|
||||
void load_object(
|
||||
void *t,
|
||||
|
@ -62,7 +62,7 @@ class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_oarchive
|
||||
virtual void vsave(const class_name_type & t) = 0;
|
||||
virtual void vsave(const tracking_type t) = 0;
|
||||
protected:
|
||||
basic_oarchive(unsigned int flags);
|
||||
basic_oarchive(unsigned int flags = 0);
|
||||
// account for bogus gcc warning
|
||||
#if defined(__GNUC__)
|
||||
virtual
|
||||
@ -70,16 +70,8 @@ protected:
|
||||
~basic_oarchive();
|
||||
public:
|
||||
// note: NOT part of the public interface
|
||||
void register_basic_serializer(const basic_oserializer & bos);
|
||||
void
|
||||
lookup_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
shared_ptr<void> & sph
|
||||
);
|
||||
void
|
||||
insert_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
shared_ptr<void> & sph
|
||||
void register_basic_serializer(
|
||||
const basic_oserializer & bos
|
||||
);
|
||||
void save_object(
|
||||
const void *x,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <boost/archive/detail/basic_iarchive.hpp>
|
||||
#include <boost/archive/detail/interface_iarchive.hpp>
|
||||
#include <boost/archive/detail/iserializer.hpp>
|
||||
#include <boost/archive/detail/register_archive.hpp>
|
||||
#include <boost/pfto.hpp>
|
||||
|
||||
namespace boost {
|
||||
@ -31,6 +32,7 @@ class common_iarchive :
|
||||
public basic_iarchive,
|
||||
public interface_iarchive<Archive>
|
||||
{
|
||||
friend class interface_iarchive<Archive>;
|
||||
private:
|
||||
virtual void vload(version_type & t){
|
||||
* this->This() >> t;
|
||||
@ -61,7 +63,7 @@ protected:
|
||||
void load_start(const char *name){}
|
||||
void load_end(const char *name){}
|
||||
// default archive initialization
|
||||
common_iarchive(unsigned int flags) :
|
||||
common_iarchive(unsigned int flags = 0) :
|
||||
basic_iarchive(flags),
|
||||
interface_iarchive<Archive>()
|
||||
{}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <boost/archive/detail/basic_oarchive.hpp>
|
||||
#include <boost/archive/detail/interface_oarchive.hpp>
|
||||
#include <boost/archive/detail/oserializer.hpp>
|
||||
#include <boost/archive/detail/register_archive.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
@ -30,6 +31,7 @@ class common_oarchive :
|
||||
public basic_oarchive,
|
||||
public interface_oarchive<Archive>
|
||||
{
|
||||
friend class interface_oarchive<Archive>;
|
||||
private:
|
||||
virtual void vsave(const version_type t){
|
||||
* this->This() << t;
|
||||
@ -61,10 +63,9 @@ protected:
|
||||
void save_override(T & t, BOOST_PFTO int){
|
||||
archive::save(* this->This(), t);
|
||||
}
|
||||
|
||||
void save_start(const char *name){}
|
||||
void save_end(const char *name){}
|
||||
common_oarchive(unsigned int flags) :
|
||||
common_oarchive(unsigned int flags = 0) :
|
||||
basic_oarchive(flags),
|
||||
interface_oarchive<Archive>()
|
||||
{}
|
||||
|
45
src/3rdparty/include/boost/archive/detail/dynamically_initialized.hpp
vendored
Normal file
45
src/3rdparty/include/boost/archive/detail/dynamically_initialized.hpp
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright David Abrahams 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)
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_DYNAMICALLY_INITIALIZED_DWA2006524_HPP
|
||||
# define BOOST_ARCHIVE_DETAIL_DYNAMICALLY_INITIALIZED_DWA2006524_HPP
|
||||
|
||||
# include <boost/serialization/force_include.hpp>
|
||||
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
|
||||
//
|
||||
// Provides a dynamically-initialized (singleton) instance of T in a
|
||||
// way that avoids LNK1179 on vc6. See http://tinyurl.com/ljdp8 or
|
||||
// http://lists.boost.org/Archives/boost/2006/05/105286.php for
|
||||
// details.
|
||||
//
|
||||
template <class T>
|
||||
struct dynamically_initialized
|
||||
{
|
||||
protected:
|
||||
static T& instance;
|
||||
private:
|
||||
static T& get_instance();
|
||||
#if defined(__GNUC__)
|
||||
// Workaround "warning: all member functions in class `
|
||||
// boost::archive::detail::dynamically_initialized<T>' are private"
|
||||
public:
|
||||
void work_around_gcc_warning();
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T>
|
||||
T& dynamically_initialized<T>::instance
|
||||
= dynamically_initialized<T>::get_instance();
|
||||
|
||||
template <class T>
|
||||
T& dynamically_initialized<T>::get_instance()
|
||||
{
|
||||
static T instance_;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
}}} // namespace boost::archive::detail
|
||||
|
||||
#endif // BOOST_ARCHIVE_DETAIL_DYNAMICALLY_INITIALIZED_DWA2006524_HPP
|
@ -28,10 +28,11 @@ class shared_ptr;
|
||||
namespace serialization {
|
||||
class extended_type_info;
|
||||
} // namespace serialization
|
||||
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
|
||||
class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
|
||||
|
||||
template<class Archive>
|
||||
class interface_iarchive
|
||||
@ -50,28 +51,13 @@ public:
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const basic_pointer_iserializer * register_type(T * = NULL){
|
||||
const basic_pointer_iserializer *
|
||||
register_type(T * = NULL){
|
||||
const basic_pointer_iserializer & bpis =
|
||||
instantiate_pointer_iserializer(
|
||||
static_cast<Archive *>(NULL),
|
||||
static_cast<T *>(NULL)
|
||||
);
|
||||
pointer_iserializer<Archive, T>::get_instance();
|
||||
this->This()->register_basic_serializer(bpis.get_basic_serializer());
|
||||
return & bpis;
|
||||
}
|
||||
void lookup_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
boost::shared_ptr<void> & sph
|
||||
){
|
||||
this->This()->lookup_basic_helper(eti, sph);
|
||||
}
|
||||
|
||||
void insert_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
shared_ptr<void> & sph
|
||||
){
|
||||
this->This()->insert_basic_helper(eti, sph);
|
||||
}
|
||||
template<class T>
|
||||
Archive & operator>>(T & t){
|
||||
this->This()->load_override(t, 0);
|
||||
|
@ -32,7 +32,7 @@ namespace serialization {
|
||||
namespace archive {
|
||||
namespace detail {
|
||||
|
||||
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
|
||||
class BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_oserializer;
|
||||
|
||||
template<class Archive>
|
||||
class interface_oarchive
|
||||
@ -51,29 +51,14 @@ public:
|
||||
}
|
||||
|
||||
template<class T>
|
||||
const basic_pointer_oserializer * register_type(const T * = NULL){
|
||||
const basic_pointer_oserializer *
|
||||
register_type(const T * = NULL){
|
||||
const basic_pointer_oserializer & bpos =
|
||||
instantiate_pointer_oserializer(
|
||||
static_cast<Archive *>(NULL),
|
||||
static_cast<T *>(NULL)
|
||||
);
|
||||
pointer_oserializer<Archive, T>::get_instance();
|
||||
this->This()->register_basic_serializer(bpos.get_basic_serializer());
|
||||
return & bpos;
|
||||
}
|
||||
|
||||
void lookup_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
boost::shared_ptr<void> & sph
|
||||
){
|
||||
this->This()->lookup_basic_helper(eti, sph);
|
||||
}
|
||||
|
||||
void insert_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
shared_ptr<void> & sph
|
||||
){
|
||||
this->This()->insert_basic_helper(eti, sph);
|
||||
}
|
||||
template<class T>
|
||||
Archive & operator<<(T & t){
|
||||
this->This()->save_override(t, 0);
|
||||
|
@ -44,6 +44,7 @@ namespace std{
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/type_traits/remove_all_extents.hpp>
|
||||
#include <boost/serialization/is_abstract.hpp>
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
@ -57,6 +58,7 @@ namespace std{
|
||||
#include <boost/mpl/list.hpp>
|
||||
#include <boost/mpl/empty.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
#ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
|
||||
#include <boost/serialization/extended_type_info_typeid.hpp>
|
||||
@ -65,7 +67,7 @@ namespace std{
|
||||
#include <boost/archive/detail/basic_iarchive.hpp>
|
||||
#include <boost/archive/detail/basic_iserializer.hpp>
|
||||
#include <boost/archive/detail/archive_pointer_iserializer.hpp>
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
#include <boost/archive/detail/dynamically_initialized.hpp>
|
||||
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
@ -74,9 +76,9 @@ namespace std{
|
||||
#include <boost/serialization/tracking.hpp>
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/binary_object.hpp>
|
||||
#include <boost/serialization/void_cast.hpp>
|
||||
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
namespace boost {
|
||||
|
||||
namespace serialization {
|
||||
@ -127,7 +129,7 @@ public:
|
||||
return boost::serialization::tracking_level<T>::value
|
||||
== boost::serialization::track_always
|
||||
|| boost::serialization::tracking_level<T>::value
|
||||
== boost::serialization::track_selectivly
|
||||
== boost::serialization::track_selectively
|
||||
&& serialized_as_pointer();
|
||||
}
|
||||
virtual unsigned int version() const {
|
||||
@ -140,7 +142,7 @@ public:
|
||||
>::type::is_polymorphic::type typex;
|
||||
return typex::value;
|
||||
}
|
||||
static iserializer & instantiate(){
|
||||
static iserializer & get_instance(){
|
||||
static iserializer instance;
|
||||
return instance;
|
||||
}
|
||||
@ -162,15 +164,14 @@ BOOST_DLLEXPORT void iserializer<Archive, T>::load_object_data(
|
||||
);
|
||||
}
|
||||
|
||||
// instantiation of this template creates a static object. Note inversion of
|
||||
// normal argument order to workaround bizarre error in MSVC 6.0 which only
|
||||
// manifests iftself during compiler time.
|
||||
template<class T, class Archive>
|
||||
class pointer_iserializer : public archive_pointer_iserializer<Archive>
|
||||
template<class Archive, class T>
|
||||
class pointer_iserializer
|
||||
: public archive_pointer_iserializer<Archive>
|
||||
, public dynamically_initialized<pointer_iserializer<Archive,T> >
|
||||
{
|
||||
private:
|
||||
virtual const basic_iserializer & get_basic_serializer() const {
|
||||
return iserializer<Archive, T>::instantiate();
|
||||
return iserializer<Archive, T>::get_instance();
|
||||
}
|
||||
virtual BOOST_DLLEXPORT void load_object_ptr(
|
||||
basic_iarchive & ar,
|
||||
@ -182,32 +183,18 @@ public:
|
||||
#endif
|
||||
// private constructor to inhibit any existence other than the
|
||||
// static one. Note GCC doesn't permit constructor to be private
|
||||
explicit BOOST_DLLEXPORT pointer_iserializer() BOOST_USED;
|
||||
static const pointer_iserializer instance;
|
||||
BOOST_DLLEXPORT pointer_iserializer() BOOST_USED;
|
||||
friend struct dynamically_initialized<pointer_iserializer<Archive,T> >;
|
||||
public:
|
||||
// at least one compiler (CW) seems to require that serialize_adl
|
||||
// be explicitly instantiated. Still under investigation.
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
#if !defined(__BORLANDC__)
|
||||
void (* const m)(Archive &, T &, const unsigned);
|
||||
boost::serialization::extended_type_info * (* e)();
|
||||
#endif
|
||||
static BOOST_DLLEXPORT const pointer_iserializer & instantiate() BOOST_USED;
|
||||
virtual ~pointer_iserializer(){};
|
||||
BOOST_DLLEXPORT static const pointer_iserializer & get_instance() BOOST_USED;
|
||||
};
|
||||
|
||||
template<class T, class Archive>
|
||||
BOOST_DLLEXPORT const pointer_iserializer<T, Archive> &
|
||||
pointer_iserializer<T, Archive>::instantiate() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
// note: instances of this template to be constructed before the main
|
||||
// is called in order for things to be initialized properly. For this
|
||||
// reason, hiding the instance in a static function as was done above
|
||||
// won't work here so we created a free instance here.
|
||||
template<class T, class Archive>
|
||||
const pointer_iserializer<T, Archive> pointer_iserializer<T, Archive>::instance;
|
||||
|
||||
// note trick to be sure that operator new is using class specific
|
||||
// version if such exists. Due to Peter Dimov.
|
||||
// note: the following fails if T has no default constructor.
|
||||
@ -278,19 +265,15 @@ private:
|
||||
T* m_p;
|
||||
};
|
||||
|
||||
template<class T, class Archive>
|
||||
BOOST_DLLEXPORT void pointer_iserializer<T, Archive>::load_object_ptr(
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT void pointer_iserializer<Archive, T>::load_object_ptr(
|
||||
basic_iarchive & ar,
|
||||
void * & x,
|
||||
const unsigned int file_version
|
||||
) const {
|
||||
) const
|
||||
{
|
||||
Archive & ar_impl = boost::smart_cast_reference<Archive &>(ar);
|
||||
|
||||
// if(0 != (ar.get_flags() & no_object_creation)){
|
||||
// ar_impl >> boost::serialization::make_nvp(NULL, * static_cast<T *>(x));
|
||||
// return;
|
||||
// }
|
||||
|
||||
auto_ptr_with_deleter<T> ap(heap_allocator<T>::invoke());
|
||||
if(NULL == ap.get())
|
||||
boost::throw_exception(std::bad_alloc()) ;
|
||||
@ -312,6 +295,7 @@ BOOST_DLLEXPORT void pointer_iserializer<T, Archive>::load_object_ptr(
|
||||
);
|
||||
}
|
||||
BOOST_CATCH(...){
|
||||
ap.release();
|
||||
BOOST_RETHROW;
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@ -320,25 +304,32 @@ BOOST_DLLEXPORT void pointer_iserializer<T, Archive>::load_object_ptr(
|
||||
ap.release();
|
||||
}
|
||||
|
||||
template<class T, class Archive>
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
BOOST_DLLEXPORT pointer_iserializer<T, Archive>::pointer_iserializer() :
|
||||
template<class Archive, class T>
|
||||
#if !defined(__BORLANDC__)
|
||||
BOOST_DLLEXPORT pointer_iserializer<Archive, T>::pointer_iserializer() :
|
||||
archive_pointer_iserializer<Archive>(
|
||||
* boost::serialization::type_info_implementation<T>::type::get_instance()
|
||||
),
|
||||
m(boost::serialization::serialize_adl<Archive, T>),
|
||||
e(boost::serialization::type_info_implementation<T>::type::get_instance)
|
||||
#else
|
||||
BOOST_DLLEXPORT pointer_iserializer<T, Archive>::pointer_iserializer() :
|
||||
BOOST_DLLEXPORT pointer_iserializer<Archive, T>::pointer_iserializer() :
|
||||
archive_pointer_iserializer<Archive>(
|
||||
* boost::serialization::type_info_implementation<T>::type::get_instance()
|
||||
)
|
||||
#endif
|
||||
{
|
||||
iserializer<Archive, T> & bis = iserializer<Archive, T>::instantiate();
|
||||
iserializer<Archive, T> & bis = iserializer<Archive, T>::get_instance();
|
||||
bis.set_bpis(this);
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT const pointer_iserializer<Archive, T> &
|
||||
pointer_iserializer<Archive, T>::get_instance() {
|
||||
// note: comeau complains without full qualification
|
||||
return dynamically_initialized<pointer_iserializer<Archive,T> >::instance;
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
struct load_non_pointer_type {
|
||||
// note this bounces the call right back to the archive
|
||||
@ -370,7 +361,7 @@ struct load_non_pointer_type {
|
||||
// its not called that way - so fix it her
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::remove_const<T>::type typex;
|
||||
void * x = & const_cast<typex &>(t);
|
||||
ar.load_object(x, iserializer<Archive, T>::instantiate());
|
||||
ar.load_object(x, iserializer<Archive, T>::get_instance());
|
||||
}
|
||||
};
|
||||
|
||||
@ -506,6 +497,8 @@ struct load_enum_type {
|
||||
template<class Archive, class T>
|
||||
struct load_array_type {
|
||||
static void invoke(Archive &ar, T &t){
|
||||
typedef typename remove_all_extents<T>::type value_type;
|
||||
|
||||
// convert integers to correct enum to load
|
||||
int current_count = sizeof(t) / (
|
||||
static_cast<char *>(static_cast<void *>(&t[1]))
|
||||
@ -517,12 +510,11 @@ struct load_array_type {
|
||||
boost::throw_exception(archive::archive_exception(
|
||||
boost::archive::archive_exception::array_size_too_short
|
||||
));
|
||||
int i;
|
||||
for(i = 0; i < count; ++i)
|
||||
ar >> boost::serialization::make_nvp("item", t[i]);
|
||||
ar >> serialization::make_array(static_cast<value_type*>(&t[0]),count);
|
||||
}
|
||||
};
|
||||
|
||||
#if 0
|
||||
// note bogus arguments to workaround msvc 6 silent runtime failure
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT
|
||||
@ -539,10 +531,9 @@ instantiate_pointer_iserializer(
|
||||
Archive * /* ar = NULL */,
|
||||
T * /* t = NULL */
|
||||
){
|
||||
// note: reversal of order of arguments to work around msvc 6.0 bug
|
||||
// that manifests itself while trying to link.
|
||||
return pointer_iserializer<T, Archive>::instantiate();
|
||||
return pointer_iserializer<Archive,T>::instance;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // detail
|
||||
|
||||
@ -572,7 +563,7 @@ inline void load(Archive &ar, T &t){
|
||||
|
||||
// BORLAND
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
|
||||
// borland has a couple fo problems
|
||||
// borland has a couple of problems
|
||||
// a) if function is partiall specialized - see below
|
||||
// const paramters are transformed to non-const ones
|
||||
// b) implementation of base_object can't be made to work
|
||||
@ -585,21 +576,19 @@ inline void load(Archive &ar, const T & t){
|
||||
}
|
||||
#endif
|
||||
|
||||
// let wrappers through. (Someday implement is_wrapper)
|
||||
// let wrappers through.
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
template<class Archive, class T>
|
||||
inline void load(Archive &ar, const serialization::nvp<T> &t){
|
||||
boost::archive::load(ar, const_cast<serialization::nvp<T> &>(t));
|
||||
}
|
||||
template<class Archive>
|
||||
inline void load(Archive &ar, const serialization::binary_object &t){
|
||||
boost::archive::load(ar, const_cast<serialization::binary_object &>(t));
|
||||
inline void load_wrapper(Archive &ar, const T&t, mpl::true_){
|
||||
boost::archive::load(ar, const_cast<T&>(t));
|
||||
}
|
||||
|
||||
//template<class Archive, class T>
|
||||
//inline void load(Archive &ar, const serialization::binary_object &t){
|
||||
// load(ar, const_cast<binary_object &>(t));
|
||||
//}
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
|
||||
template<class Archive, class T>
|
||||
inline void load(Archive &ar, const T&t){
|
||||
load_wrapper(ar,t,serialization::is_wrapper<T>());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // namespace archive
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <boost/type_traits/is_volatile.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_all_extents.hpp>
|
||||
#include <boost/serialization/is_abstract.hpp>
|
||||
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
@ -57,6 +58,7 @@
|
||||
#include <boost/archive/detail/basic_oarchive.hpp>
|
||||
#include <boost/archive/detail/basic_oserializer.hpp>
|
||||
#include <boost/archive/detail/archive_pointer_oserializer.hpp>
|
||||
#include <boost/archive/detail/dynamically_initialized.hpp>
|
||||
|
||||
#include <boost/serialization/force_include.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
@ -66,6 +68,8 @@
|
||||
#include <boost/serialization/type_info_implementation.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/void_cast.hpp>
|
||||
#include <boost/serialization/array.hpp>
|
||||
#include <boost/serialization/collection_size_type.hpp>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
@ -100,7 +104,7 @@ class oserializer : public basic_oserializer
|
||||
private:
|
||||
// private constructor to inhibit any existence other than the
|
||||
// static one
|
||||
explicit oserializer() :
|
||||
explicit BOOST_DLLEXPORT oserializer() :
|
||||
basic_oserializer(
|
||||
* boost::serialization::type_info_implementation<T>::type::get_instance()
|
||||
)
|
||||
@ -118,7 +122,7 @@ public:
|
||||
// if(0 != (flags & no_tracking))
|
||||
// return false;
|
||||
return boost::serialization::tracking_level<T>::value == boost::serialization::track_always
|
||||
|| boost::serialization::tracking_level<T>::value == boost::serialization::track_selectivly
|
||||
|| boost::serialization::tracking_level<T>::value == boost::serialization::track_selectively
|
||||
&& serialized_as_pointer();
|
||||
}
|
||||
virtual unsigned int version() const {
|
||||
@ -130,7 +134,7 @@ public:
|
||||
>::type::is_polymorphic::type typex;
|
||||
return typex::value;
|
||||
}
|
||||
static oserializer & instantiate(){
|
||||
static oserializer & get_instance(){
|
||||
static oserializer instance;
|
||||
return instance;
|
||||
}
|
||||
@ -151,15 +155,14 @@ BOOST_DLLEXPORT void oserializer<Archive, T>::save_object_data(
|
||||
);
|
||||
}
|
||||
|
||||
// instantiation of this template creates a static object. Note inversion of
|
||||
// normal argument order to workaround bizarre error in MSVC 6.0 which only
|
||||
// manifests iftself during compiler time.
|
||||
template<class T, class Archive>
|
||||
class pointer_oserializer : public archive_pointer_oserializer<Archive>
|
||||
template<class Archive, class T>
|
||||
class pointer_oserializer
|
||||
: public archive_pointer_oserializer<Archive>
|
||||
, public dynamically_initialized<pointer_oserializer<Archive,T> >
|
||||
{
|
||||
private:
|
||||
virtual const basic_oserializer & get_basic_serializer() const {
|
||||
return oserializer<Archive, T>::instantiate();
|
||||
return oserializer<Archive, T>::get_instance();
|
||||
}
|
||||
virtual BOOST_DLLEXPORT void save_object_ptr(
|
||||
basic_oarchive & ar,
|
||||
@ -171,33 +174,19 @@ public:
|
||||
// private constructor to inhibit any existence other than the
|
||||
// static one. Note GCC doesn't permit constructor to be private
|
||||
explicit BOOST_DLLEXPORT pointer_oserializer() BOOST_USED;
|
||||
static const pointer_oserializer instance;
|
||||
friend struct dynamically_initialized<pointer_oserializer<Archive,T> >;
|
||||
public:
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
#if !defined(__BORLANDC__)
|
||||
// at least one compiler (CW) seems to require that serialize_adl
|
||||
// be explicitly instantiated. Still under investigation.
|
||||
void (* const m)(Archive &, T &, const unsigned);
|
||||
boost::serialization::extended_type_info * (* e)();
|
||||
#endif
|
||||
static BOOST_DLLEXPORT const pointer_oserializer & instantiate() BOOST_USED;
|
||||
virtual ~pointer_oserializer(){}
|
||||
BOOST_DLLEXPORT static const pointer_oserializer & get_instance() BOOST_USED;
|
||||
};
|
||||
|
||||
template<class T, class Archive>
|
||||
BOOST_DLLEXPORT const pointer_oserializer<T, Archive> &
|
||||
pointer_oserializer<T, Archive>::instantiate(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
// note: instances of this template to be constructed before the main
|
||||
// is called in order for things to be initialized properly. For this
|
||||
// reason, hiding the instance in a static function as was done above
|
||||
// won't work here so we created a free instance here.
|
||||
template<class T, class Archive>
|
||||
const pointer_oserializer<T, Archive> pointer_oserializer<T, Archive>::instance;
|
||||
|
||||
template<class T, class Archive>
|
||||
BOOST_DLLEXPORT void pointer_oserializer<T, Archive>::save_object_ptr(
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT void pointer_oserializer<Archive, T>::save_object_ptr(
|
||||
basic_oarchive & ar,
|
||||
const void * x
|
||||
) const {
|
||||
@ -215,26 +204,33 @@ BOOST_DLLEXPORT void pointer_oserializer<T, Archive>::save_object_ptr(
|
||||
ar_impl << boost::serialization::make_nvp(NULL, * t);
|
||||
}
|
||||
|
||||
template<class T, class Archive>
|
||||
#if ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
BOOST_DLLEXPORT pointer_oserializer<T, Archive>::pointer_oserializer() :
|
||||
template<class Archive, class T>
|
||||
#if !defined(__BORLANDC__)
|
||||
BOOST_DLLEXPORT pointer_oserializer<Archive, T>::pointer_oserializer() :
|
||||
archive_pointer_oserializer<Archive>(
|
||||
* boost::serialization::type_info_implementation<T>::type::get_instance()
|
||||
),
|
||||
m(boost::serialization::serialize_adl<Archive, T>),
|
||||
e(boost::serialization::type_info_implementation<T>::type::get_instance)
|
||||
#else
|
||||
BOOST_DLLEXPORT pointer_oserializer<T, Archive>::pointer_oserializer() :
|
||||
BOOST_DLLEXPORT pointer_oserializer<Archive, T>::pointer_oserializer() :
|
||||
archive_pointer_oserializer<Archive>(
|
||||
* boost::serialization::type_info_implementation<T>::type::get_instance()
|
||||
)
|
||||
#endif
|
||||
{
|
||||
// make sure appropriate member function is instantiated
|
||||
oserializer<Archive, T> & bos = oserializer<Archive, T>::instantiate();
|
||||
oserializer<Archive, T> & bos = oserializer<Archive, T>::get_instance();
|
||||
bos.set_bpos(this);
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
BOOST_DLLEXPORT const pointer_oserializer<Archive, T> &
|
||||
pointer_oserializer<Archive, T>::get_instance() {
|
||||
// note: comeau complains without full qualification
|
||||
return dynamically_initialized<pointer_oserializer<Archive,T> >::instance;
|
||||
}
|
||||
|
||||
template<class Archive, class T>
|
||||
struct save_non_pointer_type {
|
||||
// note this bounces the call right back to the archive
|
||||
@ -260,7 +256,7 @@ struct save_non_pointer_type {
|
||||
// serialization level and class version
|
||||
struct save_standard {
|
||||
static void invoke(Archive &ar, const T & t){
|
||||
ar.save_object(& t, oserializer<Archive, T>::instantiate());
|
||||
ar.save_object(& t, oserializer<Archive, T>::get_instance());
|
||||
}
|
||||
};
|
||||
|
||||
@ -481,6 +477,8 @@ template<class Archive, class T>
|
||||
struct save_array_type
|
||||
{
|
||||
static void invoke(Archive &ar, const T &t){
|
||||
typedef typename remove_all_extents<T>::type value_type;
|
||||
|
||||
save_access::end_preamble(ar);
|
||||
// consider alignment
|
||||
int count = sizeof(t) / (
|
||||
@ -488,12 +486,12 @@ struct save_array_type
|
||||
- static_cast<const char *>(static_cast<const void *>(&t[0]))
|
||||
);
|
||||
ar << BOOST_SERIALIZATION_NVP(count);
|
||||
int i;
|
||||
for(i = 0; i < count; ++i)
|
||||
ar << boost::serialization::make_nvp("item", t[i]);
|
||||
ar << serialization::make_array(static_cast<value_type const*>(&t[0]),count);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
// note bogus arguments to workaround msvc 6 silent runtime failure
|
||||
// declaration to satisfy gcc
|
||||
template<class Archive, class T>
|
||||
@ -509,10 +507,9 @@ instantiate_pointer_oserializer(
|
||||
Archive * /* ar = NULL */,
|
||||
T * /* t = NULL */
|
||||
){
|
||||
// note: reversal of order of arguments to work around msvc 6.0 bug
|
||||
// that manifests itself while trying to link.
|
||||
return pointer_oserializer<T, Archive>::instantiate();
|
||||
return pointer_oserializer<Archive, T>::instance;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // detail
|
||||
|
||||
@ -557,12 +554,13 @@ struct check_tracking {
|
||||
|
||||
template<class Archive, class T>
|
||||
inline void save(Archive & ar, T &t){
|
||||
// if your program traps here, it indicates taht your doing one of the following:
|
||||
// if your program traps here, it indicates that your doing one of the following:
|
||||
// a) serializing an object of a type marked "track_never" through a pointer.
|
||||
// b) saving an non-const object of a type not markd "track_never)
|
||||
// Either of these conditions may be an indicator of an error usage of the
|
||||
// serialization library and should be double checked. See documentation on
|
||||
// object tracking.
|
||||
// object tracking. Also, see the "rationale" section of the documenation
|
||||
// for motivation for this checking.
|
||||
BOOST_STATIC_ASSERT(check_tracking<T>::value);
|
||||
save(ar, const_cast<const T &>(t));
|
||||
}
|
||||
|
47
src/3rdparty/include/boost/archive/detail/register_archive.hpp
vendored
Normal file
47
src/3rdparty/include/boost/archive/detail/register_archive.hpp
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright David Abrahams 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)
|
||||
#ifndef BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP
|
||||
# define BOOST_ARCHIVE_DETAIL_REGISTER_ARCHIVE_DWA2006521_HPP
|
||||
|
||||
# include <boost/type_traits/add_pointer.hpp>
|
||||
|
||||
namespace boost { namespace archive { namespace detail {
|
||||
|
||||
template <class Archive, class Serializable>
|
||||
struct ptr_serialization_support;
|
||||
|
||||
// We could've just used ptr_serialization_support, above, but using
|
||||
// it with only a forward declaration causes vc6/7 to complain about a
|
||||
// missing instantiate member, even if it has one. This is just a
|
||||
// friendly layer of indirection.
|
||||
template <class Archive, class Serializable>
|
||||
struct _ptr_serialization_support
|
||||
: ptr_serialization_support<Archive,Serializable>
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
// This function gets called, but its only purpose is to participate
|
||||
// in overload resolution with the functions declared by
|
||||
// BOOST_SERIALIZATION_REGISTER_ARCHIVE, below.
|
||||
template <class Serializable>
|
||||
void instantiate_ptr_serialization(Serializable*, int) {}
|
||||
|
||||
// The function declaration generated by this macro never actually
|
||||
// gets called, but its return type gets instantiated, and that's
|
||||
// enough to cause registration of serialization functions between
|
||||
// Archive and any exported Serializable type. See also:
|
||||
// boost/serialization/export.hpp
|
||||
# define BOOST_SERIALIZATION_REGISTER_ARCHIVE(Archive) \
|
||||
namespace boost { namespace archive { namespace detail { \
|
||||
\
|
||||
template <class Serializable> \
|
||||
typename _ptr_serialization_support<Archive, Serializable>::type \
|
||||
instantiate_ptr_serialization( Serializable*, Archive* ); \
|
||||
\
|
||||
}}}
|
||||
|
||||
}}} // namespace boost::archive::detail
|
||||
|
||||
#endif // BOOST_ARCHIVE_DETAIL_INSTANTIATE_SERIALIZE_DWA2006521_HPP
|
@ -1,9 +1,8 @@
|
||||
// Copyright © 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu). Permission to copy,
|
||||
// use, modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided "as is"
|
||||
// without express or implied warranty, and with no claim as to its suitability
|
||||
// for any purpose.
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
|
||||
// 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_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
|
||||
#define BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP
|
||||
|
@ -79,7 +79,7 @@ basic_binary_iprimitive<Archive, Elem, Tr>::load(wchar_t * ws)
|
||||
{
|
||||
std::size_t l;
|
||||
this->This()->load(l);
|
||||
load_binary(ws, l);
|
||||
load_binary(ws, l * sizeof(wchar_t) / sizeof(char));
|
||||
ws[l / sizeof(wchar_t)] = L'\0';
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ basic_xml_oarchive<Archive>::end_preamble(){
|
||||
pending_preamble = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
template<class Archive>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int)
|
||||
@ -168,6 +168,29 @@ basic_xml_oarchive<Archive>::save_override(const version_type & t, int)
|
||||
int i = t.t; // extra .t is for borland
|
||||
write_attribute(VERSION(), i);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class Archive>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
basic_xml_oarchive<Archive>::save_override(const object_id_type & t, int)
|
||||
{
|
||||
write_attribute(OBJECT_ID(), t, "=\"_");
|
||||
}
|
||||
template<class Archive>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
basic_xml_oarchive<Archive>::save_override(
|
||||
const object_reference_type & t,
|
||||
int
|
||||
){
|
||||
write_attribute(OBJECT_REFERENCE(), t, "=\"_");
|
||||
}
|
||||
template<class Archive>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
basic_xml_oarchive<Archive>::save_override(const version_type & t, int)
|
||||
{
|
||||
write_attribute(VERSION(), t);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
basic_xml_oarchive<Archive>::save_override(const class_id_type & t, int)
|
||||
@ -199,11 +222,12 @@ basic_xml_oarchive<Archive>::save_override(const class_name_type & t, int)
|
||||
return;
|
||||
write_attribute(CLASS_NAME(), key);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
||||
basic_xml_oarchive<Archive>::save_override(const tracking_type & t, int)
|
||||
{
|
||||
write_attribute(TRACKING(), t.t); // extra .t is for borland
|
||||
write_attribute(TRACKING(), t.t);
|
||||
}
|
||||
|
||||
template<class Archive>
|
||||
|
@ -32,6 +32,7 @@ namespace std{
|
||||
#include <boost/archive/detail/iserializer.hpp>
|
||||
#include <boost/archive/detail/interface_iarchive.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/archive/detail/register_archive.hpp>
|
||||
|
||||
// determine if its necessary to handle (u)int64_t specifically
|
||||
// i.e. that its not a synonym for (unsigned) long
|
||||
@ -54,7 +55,9 @@ namespace detail {
|
||||
class basic_iserializer;
|
||||
}
|
||||
|
||||
class polymorphic_iarchive :
|
||||
class polymorphic_iarchive;
|
||||
|
||||
class polymorphic_iarchive_impl :
|
||||
public detail::interface_iarchive<polymorphic_iarchive>
|
||||
{
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
@ -98,21 +101,13 @@ public:
|
||||
virtual void load_start(const char * name) = 0;
|
||||
virtual void load_end(const char * name) = 0;
|
||||
virtual void register_basic_serializer(const detail::basic_iserializer & bis) = 0;
|
||||
virtual void lookup_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
boost::shared_ptr<void> & sph
|
||||
) = 0;
|
||||
virtual void insert_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
boost::shared_ptr<void> & sph
|
||||
) = 0;
|
||||
|
||||
// msvc and borland won't automatically pass these to the base class so
|
||||
// make it explicit here
|
||||
template<class T>
|
||||
void load_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
archive::load(* this, t);
|
||||
archive::load(* this->This(), t);
|
||||
}
|
||||
// special treatment for name-value pairs.
|
||||
template<class T>
|
||||
@ -124,9 +119,11 @@ public:
|
||||
int
|
||||
){
|
||||
load_start(t.name());
|
||||
archive::load(* this, t.value());
|
||||
archive::load(* this->This(), t.value());
|
||||
load_end(t.name());
|
||||
}
|
||||
protected:
|
||||
virtual ~polymorphic_iarchive_impl(){}
|
||||
public:
|
||||
// utility function implemented by all legal archives
|
||||
virtual void set_library_version(unsigned int archive_library_version) = 0;
|
||||
@ -157,8 +154,24 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::polymorphic_iarchive)
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class polymorphic_iarchive :
|
||||
public polymorphic_iarchive_impl,
|
||||
public detail::shared_ptr_helper
|
||||
{};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_iarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_POLYMORPHIC_IARCHIVE_HPP
|
||||
|
@ -31,6 +31,7 @@ namespace std{
|
||||
#include <boost/archive/detail/oserializer.hpp>
|
||||
#include <boost/archive/detail/interface_oarchive.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/archive/detail/register_archive.hpp>
|
||||
|
||||
// determine if its necessary to handle (u)int64_t specifically
|
||||
// i.e. that its not a synonym for (unsigned) long
|
||||
@ -53,7 +54,9 @@ namespace detail {
|
||||
class basic_oserializer;
|
||||
}
|
||||
|
||||
class polymorphic_oarchive :
|
||||
class polymorphic_oarchive;
|
||||
|
||||
class polymorphic_oarchive_impl :
|
||||
public detail::interface_oarchive<polymorphic_oarchive>
|
||||
{
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
@ -97,14 +100,6 @@ public:
|
||||
virtual void save_start(const char * name) = 0;
|
||||
virtual void save_end(const char * name) = 0;
|
||||
virtual void register_basic_serializer(const detail::basic_oserializer & bos) = 0;
|
||||
virtual void lookup_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
boost::shared_ptr<void> & sph
|
||||
) = 0;
|
||||
virtual void insert_basic_helper(
|
||||
const boost::serialization::extended_type_info * const eti,
|
||||
shared_ptr<void> & sph
|
||||
) = 0;
|
||||
|
||||
virtual void end_preamble() = 0;
|
||||
|
||||
@ -113,7 +108,7 @@ public:
|
||||
template<class T>
|
||||
void save_override(T & t, BOOST_PFTO int)
|
||||
{
|
||||
archive::save(* this, t);
|
||||
archive::save(* this->This(), t);
|
||||
}
|
||||
// special treatment for name-value pairs.
|
||||
template<class T>
|
||||
@ -124,9 +119,11 @@ public:
|
||||
::boost::serialization::nvp<T> & t, int
|
||||
){
|
||||
save_start(t.name());
|
||||
archive::save(* this, t.const_value());
|
||||
archive::save(* this->This(), t.const_value());
|
||||
save_end(t.name());
|
||||
}
|
||||
protected:
|
||||
virtual ~polymorphic_oarchive_impl(){}
|
||||
public:
|
||||
// utility functions implemented by all legal archives
|
||||
virtual unsigned int get_flags() const = 0;
|
||||
@ -143,11 +140,15 @@ public:
|
||||
) = 0;
|
||||
};
|
||||
|
||||
// note: preserve naming symmetry
|
||||
class polymorphic_oarchive :
|
||||
public polymorphic_oarchive_impl
|
||||
{};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::polymorphic_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::polymorphic_oarchive)
|
||||
|
||||
#endif // BOOST_ARCHIVE_POLYMORPHIC_OARCHIVE_HPP
|
||||
|
149
src/3rdparty/include/boost/archive/shared_ptr_helper.hpp
vendored
Normal file
149
src/3rdparty/include/boost/archive/shared_ptr_helper.hpp
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
#ifndef BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP
|
||||
#define BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// shared_ptr.hpp: serialization for boost shared pointer
|
||||
|
||||
// (C) Copyright 2004 Robert Ramey and Martin Ecker
|
||||
// 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 <map>
|
||||
#include <list>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/serialization/shared_ptr_132.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
namespace boost_132 {
|
||||
template<class T> class shared_ptr;
|
||||
}
|
||||
namespace boost {
|
||||
template<class T> class shared_ptr;
|
||||
namespace serialization {
|
||||
class extended_type_info;
|
||||
template<class Archive, class T>
|
||||
inline void load(
|
||||
Archive & ar,
|
||||
boost::shared_ptr<T> &t,
|
||||
const unsigned int file_version
|
||||
);
|
||||
}
|
||||
|
||||
namespace archive{
|
||||
namespace detail {
|
||||
|
||||
struct null_deleter {
|
||||
void operator()(void const *) const {}
|
||||
};
|
||||
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// a common class for holding various types of shared pointers
|
||||
|
||||
class shared_ptr_helper {
|
||||
typedef std::map<void*, shared_ptr<void> > collection_type;
|
||||
typedef collection_type::const_iterator iterator_type;
|
||||
// list of shared_pointers create accessable by raw pointer. This
|
||||
// is used to "match up" shared pointers loaded at different
|
||||
// points in the archive. Note, we delay construction until
|
||||
// it is actually used since this is by default included as
|
||||
// a "mix-in" even if shared_ptr isn't used.
|
||||
collection_type * m_pointers;
|
||||
|
||||
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
public:
|
||||
#else
|
||||
template<class Archive, class T>
|
||||
friend inline void boost::serialization::load(
|
||||
Archive & ar,
|
||||
boost::shared_ptr<T> &t,
|
||||
const unsigned int file_version
|
||||
);
|
||||
#endif
|
||||
|
||||
// list of loaded pointers. This is used to be sure that the pointers
|
||||
// stay around long enough to be "matched" with other pointers loaded
|
||||
// by the same archive. These are created with a "null_deleter" so that
|
||||
// when this list is destroyed - the underlaying raw pointers are not
|
||||
// destroyed. This has to be done because the pointers are also held by
|
||||
// new system which is disjoint from this set. This is implemented
|
||||
// by a change in load_construct_data below. It makes this file suitable
|
||||
// only for loading pointers into a 1.33 or later boost system.
|
||||
std::list<boost_132::shared_ptr<void> > * m_pointers_132;
|
||||
|
||||
// return a void pointer to the most derived type
|
||||
template<class T>
|
||||
void * object_identifier(T * t) const {
|
||||
const boost::serialization::extended_type_info * true_type
|
||||
= boost::serialization::type_info_implementation<T>::type
|
||||
::get_derived_extended_type_info(*t);
|
||||
// note:if this exception is thrown, be sure that derived pointer
|
||||
// is either registered or exported.
|
||||
if(NULL == true_type)
|
||||
boost::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unregistered_class
|
||||
)
|
||||
);
|
||||
const boost::serialization::extended_type_info * this_type
|
||||
= boost::serialization::type_info_implementation<T>::type::get_instance();
|
||||
void * vp = void_downcast(*true_type, *this_type, t);
|
||||
return vp;
|
||||
}
|
||||
template<class T>
|
||||
void reset(shared_ptr<T> & s, T * r){
|
||||
if(NULL == r){
|
||||
s.reset();
|
||||
return;
|
||||
}
|
||||
// get pointer to the most derived object. This is effectively
|
||||
// the object identifer
|
||||
void * od = object_identifier(r);
|
||||
|
||||
if(NULL == m_pointers)
|
||||
m_pointers = new collection_type;
|
||||
|
||||
iterator_type it = m_pointers->find(od);
|
||||
|
||||
if(it == m_pointers->end()){
|
||||
s.reset(r);
|
||||
m_pointers->insert(collection_type::value_type(od,s));
|
||||
}
|
||||
else{
|
||||
s = static_pointer_cast<T>((*it).second);
|
||||
}
|
||||
}
|
||||
void append(const boost_132::shared_ptr<void> & t){
|
||||
if(NULL == m_pointers_132)
|
||||
m_pointers_132 = new std::list<boost_132::shared_ptr<void> >;
|
||||
m_pointers_132->push_back(t);
|
||||
}
|
||||
public:
|
||||
shared_ptr_helper() :
|
||||
m_pointers(NULL),
|
||||
m_pointers_132(NULL)
|
||||
{}
|
||||
~shared_ptr_helper(){
|
||||
if(NULL != m_pointers)
|
||||
delete m_pointers;
|
||||
if(NULL != m_pointers_132)
|
||||
delete m_pointers_132;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARCHIVE_SHARED_PTR_HELPER_HPP
|
@ -21,6 +21,7 @@
|
||||
#include <boost/archive/detail/auto_link_archive.hpp>
|
||||
#include <boost/archive/basic_text_iprimitive.hpp>
|
||||
#include <boost/archive/basic_text_iarchive.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
|
||||
|
||||
@ -73,14 +74,38 @@ protected:
|
||||
~text_iarchive_impl(){};
|
||||
};
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// do not derive from the classes below. If you want to extend this functionality
|
||||
// via inhertance, derived from text_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
class text_iarchive :
|
||||
public text_iarchive_impl<text_iarchive>
|
||||
|
||||
// same as text_iarchive below - without the shared_ptr_helper
|
||||
class naked_text_iarchive :
|
||||
public text_iarchive_impl<naked_text_iarchive>
|
||||
{
|
||||
public:
|
||||
naked_text_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
text_iarchive_impl<naked_text_iarchive>(is, flags)
|
||||
{}
|
||||
~naked_text_iarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class text_iarchive :
|
||||
public text_iarchive_impl<text_iarchive>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
|
||||
text_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
text_iarchive_impl<text_iarchive>(is, flags)
|
||||
{}
|
||||
@ -90,9 +115,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_iarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_iarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
@ -88,12 +88,13 @@ public:
|
||||
~text_oarchive(){}
|
||||
};
|
||||
|
||||
typedef text_oarchive naked_text_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_oarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
@ -72,11 +72,36 @@ protected:
|
||||
~text_wiarchive_impl(){};
|
||||
};
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from text_wiarchive_impl instead. This will
|
||||
// do not derive from the classes below. If you want to extend this functionality
|
||||
// via inhertance, derived from text_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
|
||||
// same as text_wiarchive below - without the shared_ptr_helper
|
||||
class naked_text_wiarchive :
|
||||
public text_wiarchive_impl<naked_text_wiarchive>
|
||||
{
|
||||
public:
|
||||
naked_text_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
text_wiarchive_impl<naked_text_wiarchive>(is, flags)
|
||||
{}
|
||||
~naked_text_wiarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class text_wiarchive :
|
||||
public text_wiarchive_impl<text_wiarchive>
|
||||
public text_wiarchive_impl<text_wiarchive>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
text_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
@ -88,9 +113,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_wiarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_wiarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
@ -114,12 +114,13 @@ public:
|
||||
~text_woarchive(){}
|
||||
};
|
||||
|
||||
typedef text_woarchive naked_text_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::text_woarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::text_woarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
@ -83,14 +83,36 @@ protected:
|
||||
~xml_iarchive_impl();
|
||||
};
|
||||
|
||||
// we use the following because we can't use
|
||||
// typedef xml_iarchive_impl<xml_iarchive_impl<...> > xml_iarchive;
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from xml_iarchive_impl instead. This will
|
||||
// do not derive from the classes below. If you want to extend this functionality
|
||||
// via inhertance, derived from text_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
|
||||
// same as xml_iarchive below - without the shared_ptr_helper
|
||||
class naked_xml_iarchive :
|
||||
public xml_iarchive_impl<naked_xml_iarchive>
|
||||
{
|
||||
public:
|
||||
naked_xml_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
xml_iarchive_impl<naked_xml_iarchive>(is, flags)
|
||||
{}
|
||||
~naked_xml_iarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class xml_iarchive :
|
||||
public xml_iarchive_impl<xml_iarchive>
|
||||
public xml_iarchive_impl<xml_iarchive>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
xml_iarchive(std::istream & is, unsigned int flags = 0) :
|
||||
@ -102,9 +124,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_iarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_iarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
@ -48,9 +48,9 @@ public:
|
||||
friend class save_access;
|
||||
protected:
|
||||
#endif
|
||||
void end_preamble(){
|
||||
basic_xml_oarchive<Archive>::end_preamble();
|
||||
}
|
||||
//void end_preamble(){
|
||||
// basic_xml_oarchive<Archive>::end_preamble();
|
||||
//}
|
||||
template<class T>
|
||||
void save(const T & t){
|
||||
basic_text_oprimitive<std::ostream>::save(t);
|
||||
@ -101,12 +101,13 @@ public:
|
||||
~xml_oarchive(){}
|
||||
};
|
||||
|
||||
typedef xml_oarchive naked_xml_oarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_oarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_oarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
@ -87,14 +87,36 @@ protected:
|
||||
~xml_wiarchive_impl();
|
||||
};
|
||||
|
||||
// we use the following because we can't use
|
||||
// typedef xml_wiarchive_impl<xml_wiarchive_impl<...> > xml_wiarchive;
|
||||
|
||||
// do not derive from this class. If you want to extend this functionality
|
||||
// via inhertance, derived from xml_wiarchive_impl instead. This will
|
||||
// do not derive from the classes below. If you want to extend this functionality
|
||||
// via inhertance, derived from text_iarchive_impl instead. This will
|
||||
// preserve correct static polymorphism.
|
||||
|
||||
// same as xml_wiarchive below - without the shared_ptr_helper
|
||||
class naked_xml_wiarchive :
|
||||
public xml_wiarchive_impl<naked_xml_wiarchive>
|
||||
{
|
||||
public:
|
||||
naked_xml_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
xml_wiarchive_impl<naked_xml_wiarchive>(is, flags)
|
||||
{}
|
||||
~naked_xml_wiarchive(){}
|
||||
};
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// note special treatment of shared_ptr. This type needs a special
|
||||
// structure associated with every archive. We created a "mix-in"
|
||||
// class to provide this functionality. Since shared_ptr holds a
|
||||
// special esteem in the boost library - we included it here by default.
|
||||
#include <boost/archive/shared_ptr_helper.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace archive {
|
||||
|
||||
class xml_wiarchive :
|
||||
public xml_wiarchive_impl<xml_wiarchive>
|
||||
public xml_wiarchive_impl<xml_wiarchive>,
|
||||
public detail::shared_ptr_helper
|
||||
{
|
||||
public:
|
||||
xml_wiarchive(std::wistream & is, unsigned int flags = 0) :
|
||||
@ -106,9 +128,8 @@ public:
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_wiarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_wiarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
@ -58,9 +58,9 @@ public:
|
||||
friend class save_access;
|
||||
protected:
|
||||
#endif
|
||||
void end_preamble(){
|
||||
basic_xml_oarchive<Archive>::end_preamble();
|
||||
}
|
||||
//void end_preamble(){
|
||||
// basic_xml_oarchive<Archive>::end_preamble();
|
||||
//}
|
||||
template<class T>
|
||||
void
|
||||
save(const T & t){
|
||||
@ -113,12 +113,13 @@ public:
|
||||
~xml_woarchive(){}
|
||||
};
|
||||
|
||||
typedef xml_woarchive naked_xml_woarchive;
|
||||
|
||||
} // namespace archive
|
||||
} // namespace boost
|
||||
|
||||
// required by smart_cast for compilers not implementing
|
||||
// partial template specialization
|
||||
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(boost::archive::xml_woarchive)
|
||||
// required by export
|
||||
BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::archive::xml_woarchive)
|
||||
|
||||
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
|
||||
|
||||
|
4
src/3rdparty/include/boost/array.hpp
vendored
4
src/3rdparty/include/boost/array.hpp
vendored
@ -157,7 +157,7 @@ namespace boost {
|
||||
// check range (may be private because it is static)
|
||||
static void rangecheck (size_type i) {
|
||||
if (i >= size()) {
|
||||
throw std::range_error("array<>: index out of range");
|
||||
throw std::out_of_range("array<>: index out of range");
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ namespace boost {
|
||||
|
||||
// check range (may be private because it is static)
|
||||
static reference failed_rangecheck () {
|
||||
std::range_error e("attempt to access element of an empty array");
|
||||
std::out_of_range e("attempt to access element of an empty array");
|
||||
boost::throw_exception(e);
|
||||
//
|
||||
// We need to return something here to keep
|
||||
|
146
src/3rdparty/include/boost/asio.hpp
vendored
146
src/3rdparty/include/boost/asio.hpp
vendored
@ -1,73 +1,73 @@
|
||||
//
|
||||
// asio.hpp
|
||||
// ~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 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)
|
||||
//
|
||||
// See www.boost.org/libs/asio for documentation.
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_HPP
|
||||
#define BOOST_ASIO_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/basic_datagram_socket.hpp>
|
||||
#include <boost/asio/basic_deadline_timer.hpp>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/basic_socket_acceptor.hpp>
|
||||
#include <boost/asio/basic_socket_iostream.hpp>
|
||||
#include <boost/asio/basic_socket_streambuf.hpp>
|
||||
#include <boost/asio/basic_stream_socket.hpp>
|
||||
#include <boost/asio/basic_streambuf.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/buffered_read_stream_fwd.hpp>
|
||||
#include <boost/asio/buffered_read_stream.hpp>
|
||||
#include <boost/asio/buffered_stream_fwd.hpp>
|
||||
#include <boost/asio/buffered_stream.hpp>
|
||||
#include <boost/asio/buffered_write_stream_fwd.hpp>
|
||||
#include <boost/asio/buffered_write_stream.hpp>
|
||||
#include <boost/asio/completion_condition.hpp>
|
||||
#include <boost/asio/datagram_socket_service.hpp>
|
||||
#include <boost/asio/deadline_timer_service.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
#include <boost/asio/ip/basic_endpoint.hpp>
|
||||
#include <boost/asio/ip/basic_resolver.hpp>
|
||||
#include <boost/asio/ip/basic_resolver_entry.hpp>
|
||||
#include <boost/asio/ip/basic_resolver_iterator.hpp>
|
||||
#include <boost/asio/ip/basic_resolver_query.hpp>
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
#include <boost/asio/ip/multicast.hpp>
|
||||
#include <boost/asio/ip/resolver_query_base.hpp>
|
||||
#include <boost/asio/ip/resolver_service.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
#include <boost/asio/ip/unicast.hpp>
|
||||
#include <boost/asio/ip/v6_only.hpp>
|
||||
#include <boost/asio/is_read_buffered.hpp>
|
||||
#include <boost/asio/is_write_buffered.hpp>
|
||||
#include <boost/asio/placeholders.hpp>
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/asio/read_until.hpp>
|
||||
#include <boost/asio/socket_acceptor_service.hpp>
|
||||
#include <boost/asio/socket_base.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <boost/asio/time_traits.hpp>
|
||||
#include <boost/asio/version.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_HPP
|
||||
//
|
||||
// asio.hpp
|
||||
// ~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See www.boost.org/libs/asio for documentation.
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_HPP
|
||||
#define BOOST_ASIO_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/basic_datagram_socket.hpp>
|
||||
#include <boost/asio/basic_deadline_timer.hpp>
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/basic_socket_acceptor.hpp>
|
||||
#include <boost/asio/basic_socket_iostream.hpp>
|
||||
#include <boost/asio/basic_socket_streambuf.hpp>
|
||||
#include <boost/asio/basic_stream_socket.hpp>
|
||||
#include <boost/asio/basic_streambuf.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/buffered_read_stream_fwd.hpp>
|
||||
#include <boost/asio/buffered_read_stream.hpp>
|
||||
#include <boost/asio/buffered_stream_fwd.hpp>
|
||||
#include <boost/asio/buffered_stream.hpp>
|
||||
#include <boost/asio/buffered_write_stream_fwd.hpp>
|
||||
#include <boost/asio/buffered_write_stream.hpp>
|
||||
#include <boost/asio/completion_condition.hpp>
|
||||
#include <boost/asio/datagram_socket_service.hpp>
|
||||
#include <boost/asio/deadline_timer_service.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
#include <boost/asio/ip/basic_endpoint.hpp>
|
||||
#include <boost/asio/ip/basic_resolver.hpp>
|
||||
#include <boost/asio/ip/basic_resolver_entry.hpp>
|
||||
#include <boost/asio/ip/basic_resolver_iterator.hpp>
|
||||
#include <boost/asio/ip/basic_resolver_query.hpp>
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
#include <boost/asio/ip/multicast.hpp>
|
||||
#include <boost/asio/ip/resolver_query_base.hpp>
|
||||
#include <boost/asio/ip/resolver_service.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
#include <boost/asio/ip/unicast.hpp>
|
||||
#include <boost/asio/ip/v6_only.hpp>
|
||||
#include <boost/asio/is_read_buffered.hpp>
|
||||
#include <boost/asio/is_write_buffered.hpp>
|
||||
#include <boost/asio/placeholders.hpp>
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/asio/read_until.hpp>
|
||||
#include <boost/asio/socket_acceptor_service.hpp>
|
||||
#include <boost/asio/socket_base.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <boost/asio/time_traits.hpp>
|
||||
#include <boost/asio/version.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_HPP
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,383 +1,383 @@
|
||||
//
|
||||
// basic_deadline_timer.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
#define BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/deadline_timer_service.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Provides waitable timer functionality.
|
||||
/**
|
||||
* The basic_deadline_timer class template provides the ability to perform a
|
||||
* blocking or asynchronous wait for a timer to expire.
|
||||
*
|
||||
* Most applications will use the boost::asio::deadline_timer typedef.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Examples
|
||||
* Performing a blocking wait:
|
||||
* @code
|
||||
* // Construct a timer without setting an expiry time.
|
||||
* boost::asio::deadline_timer timer(io_service);
|
||||
*
|
||||
* // Set an expiry time relative to now.
|
||||
* timer.expires_from_now(boost::posix_time::seconds(5));
|
||||
*
|
||||
* // Wait for the timer to expire.
|
||||
* timer.wait();
|
||||
* @endcode
|
||||
*
|
||||
* @par
|
||||
* Performing an asynchronous wait:
|
||||
* @code
|
||||
* void handler(const boost::system::error_code& error)
|
||||
* {
|
||||
* if (!error)
|
||||
* {
|
||||
* // Timer expired.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Construct a timer with an absolute expiry time.
|
||||
* boost::asio::deadline_timer timer(io_service,
|
||||
* boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
|
||||
*
|
||||
* // Start an asynchronous wait.
|
||||
* timer.async_wait(handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Changing an active deadline_timer's expiry time
|
||||
*
|
||||
* Changing the expiry time of a timer while there are pending asynchronous
|
||||
* waits causes those wait operations to be cancelled. To ensure that the action
|
||||
* associated with the timer is performed only once, use something like this:
|
||||
* used:
|
||||
*
|
||||
* @code
|
||||
* void on_some_event()
|
||||
* {
|
||||
* if (my_timer.expires_from_now(seconds(5)) > 0)
|
||||
* {
|
||||
* // We managed to cancel the timer. Start new asynchronous wait.
|
||||
* my_timer.async_wait(on_timeout);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Too late, timer has already expired!
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void on_timeout(const boost::system::error_code& e)
|
||||
* {
|
||||
* if (e != boost::asio::error::operation_aborted)
|
||||
* {
|
||||
* // Timer was not cancelled, take necessary action.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @li The boost::asio::basic_deadline_timer::expires_from_now() function
|
||||
* cancels any pending asynchronous waits, and returns the number of
|
||||
* asynchronous waits that were cancelled. If it returns 0 then you were too
|
||||
* late and the wait handler has already been executed, or will soon be
|
||||
* executed. If it returns 1 then the wait handler was successfully cancelled.
|
||||
*
|
||||
* @li If a wait handler is cancelled, the boost::system::error_code passed to
|
||||
* it contains the value boost::asio::error::operation_aborted.
|
||||
*/
|
||||
template <typename Time,
|
||||
typename TimeTraits = boost::asio::time_traits<Time>,
|
||||
typename TimerService = deadline_timer_service<Time, TimeTraits> >
|
||||
class basic_deadline_timer
|
||||
: public basic_io_object<TimerService>
|
||||
{
|
||||
public:
|
||||
/// The time traits type.
|
||||
typedef TimeTraits traits_type;
|
||||
|
||||
/// The time type.
|
||||
typedef typename traits_type::time_type time_type;
|
||||
|
||||
/// The duration type.
|
||||
typedef typename traits_type::duration_type duration_type;
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* This constructor creates a timer without setting an expiry time. The
|
||||
* expires_at() or expires_from_now() functions must be called to set an
|
||||
* expiry time before the timer can be waited on.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*/
|
||||
explicit basic_deadline_timer(boost::asio::io_service& io_service)
|
||||
: basic_io_object<TimerService>(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time as an absolute time.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, expressed
|
||||
* as an absolute time.
|
||||
*/
|
||||
basic_deadline_timer(boost::asio::io_service& io_service,
|
||||
const time_type& expiry_time)
|
||||
: basic_io_object<TimerService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_at(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, relative to
|
||||
* now.
|
||||
*/
|
||||
basic_deadline_timer(boost::asio::io_service& io_service,
|
||||
const duration_type& expiry_time)
|
||||
: basic_io_object<TimerService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_from_now(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
std::size_t cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*/
|
||||
std::size_t cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
time_type expires_at() const
|
||||
{
|
||||
return this->service.expires_at(this->implementation);
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
std::size_t expires_at(const time_type& expiry_time)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_at(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*/
|
||||
std::size_t expires_at(const time_type& expiry_time,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.expires_at(this->implementation, expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
duration_type expires_from_now() const
|
||||
{
|
||||
return this->service.expires_from_now(this->implementation);
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration_type& expiry_time)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_from_now(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration_type& expiry_time,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.expires_from_now(
|
||||
this->implementation, expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void wait()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.wait(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
void wait(boost::system::error_code& ec)
|
||||
{
|
||||
this->service.wait(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous wait on the timer.
|
||||
/**
|
||||
* This function may be used to initiate an asynchronous wait against the
|
||||
* timer. It always returns immediately.
|
||||
*
|
||||
* For each call to async_wait(), the supplied handler will be called exactly
|
||||
* once. The handler will be called when:
|
||||
*
|
||||
* @li The timer has expired.
|
||||
*
|
||||
* @li The timer was cancelled, in which case the handler is passed the error
|
||||
* code boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param handler The handler to be called when the timer expires. Copies
|
||||
* will be made of the handler as required. The function signature of the
|
||||
* handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error // Result of operation.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*/
|
||||
template <typename WaitHandler>
|
||||
void async_wait(WaitHandler handler)
|
||||
{
|
||||
this->service.async_wait(this->implementation, handler);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
//
|
||||
// basic_deadline_timer.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
#define BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/basic_io_object.hpp>
|
||||
#include <boost/asio/deadline_timer_service.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Provides waitable timer functionality.
|
||||
/**
|
||||
* The basic_deadline_timer class template provides the ability to perform a
|
||||
* blocking or asynchronous wait for a timer to expire.
|
||||
*
|
||||
* Most applications will use the boost::asio::deadline_timer typedef.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Examples
|
||||
* Performing a blocking wait:
|
||||
* @code
|
||||
* // Construct a timer without setting an expiry time.
|
||||
* boost::asio::deadline_timer timer(io_service);
|
||||
*
|
||||
* // Set an expiry time relative to now.
|
||||
* timer.expires_from_now(boost::posix_time::seconds(5));
|
||||
*
|
||||
* // Wait for the timer to expire.
|
||||
* timer.wait();
|
||||
* @endcode
|
||||
*
|
||||
* @par
|
||||
* Performing an asynchronous wait:
|
||||
* @code
|
||||
* void handler(const boost::system::error_code& error)
|
||||
* {
|
||||
* if (!error)
|
||||
* {
|
||||
* // Timer expired.
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Construct a timer with an absolute expiry time.
|
||||
* boost::asio::deadline_timer timer(io_service,
|
||||
* boost::posix_time::time_from_string("2005-12-07 23:59:59.000"));
|
||||
*
|
||||
* // Start an asynchronous wait.
|
||||
* timer.async_wait(handler);
|
||||
* @endcode
|
||||
*
|
||||
* @par Changing an active deadline_timer's expiry time
|
||||
*
|
||||
* Changing the expiry time of a timer while there are pending asynchronous
|
||||
* waits causes those wait operations to be cancelled. To ensure that the action
|
||||
* associated with the timer is performed only once, use something like this:
|
||||
* used:
|
||||
*
|
||||
* @code
|
||||
* void on_some_event()
|
||||
* {
|
||||
* if (my_timer.expires_from_now(seconds(5)) > 0)
|
||||
* {
|
||||
* // We managed to cancel the timer. Start new asynchronous wait.
|
||||
* my_timer.async_wait(on_timeout);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* // Too late, timer has already expired!
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* void on_timeout(const boost::system::error_code& e)
|
||||
* {
|
||||
* if (e != boost::asio::error::operation_aborted)
|
||||
* {
|
||||
* // Timer was not cancelled, take necessary action.
|
||||
* }
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @li The boost::asio::basic_deadline_timer::expires_from_now() function
|
||||
* cancels any pending asynchronous waits, and returns the number of
|
||||
* asynchronous waits that were cancelled. If it returns 0 then you were too
|
||||
* late and the wait handler has already been executed, or will soon be
|
||||
* executed. If it returns 1 then the wait handler was successfully cancelled.
|
||||
*
|
||||
* @li If a wait handler is cancelled, the boost::system::error_code passed to
|
||||
* it contains the value boost::asio::error::operation_aborted.
|
||||
*/
|
||||
template <typename Time,
|
||||
typename TimeTraits = boost::asio::time_traits<Time>,
|
||||
typename TimerService = deadline_timer_service<Time, TimeTraits> >
|
||||
class basic_deadline_timer
|
||||
: public basic_io_object<TimerService>
|
||||
{
|
||||
public:
|
||||
/// The time traits type.
|
||||
typedef TimeTraits traits_type;
|
||||
|
||||
/// The time type.
|
||||
typedef typename traits_type::time_type time_type;
|
||||
|
||||
/// The duration type.
|
||||
typedef typename traits_type::duration_type duration_type;
|
||||
|
||||
/// Constructor.
|
||||
/**
|
||||
* This constructor creates a timer without setting an expiry time. The
|
||||
* expires_at() or expires_from_now() functions must be called to set an
|
||||
* expiry time before the timer can be waited on.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*/
|
||||
explicit basic_deadline_timer(boost::asio::io_service& io_service)
|
||||
: basic_io_object<TimerService>(io_service)
|
||||
{
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time as an absolute time.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, expressed
|
||||
* as an absolute time.
|
||||
*/
|
||||
basic_deadline_timer(boost::asio::io_service& io_service,
|
||||
const time_type& expiry_time)
|
||||
: basic_io_object<TimerService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_at(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
}
|
||||
|
||||
/// Constructor to set a particular expiry time relative to now.
|
||||
/**
|
||||
* This constructor creates a timer and sets the expiry time.
|
||||
*
|
||||
* @param io_service The io_service object that the timer will use to dispatch
|
||||
* handlers for any asynchronous operations performed on the timer.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer, relative to
|
||||
* now.
|
||||
*/
|
||||
basic_deadline_timer(boost::asio::io_service& io_service,
|
||||
const duration_type& expiry_time)
|
||||
: basic_io_object<TimerService>(io_service)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.expires_from_now(this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
std::size_t cancel()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.cancel(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Cancel any asynchronous operations that are waiting on the timer.
|
||||
/**
|
||||
* This function forces the completion of any pending asynchronous wait
|
||||
* operations against the timer. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* Cancelling the timer does not change the expiry time.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*/
|
||||
std::size_t cancel(boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.cancel(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
time_type expires_at() const
|
||||
{
|
||||
return this->service.expires_at(this->implementation);
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
std::size_t expires_at(const time_type& expiry_time)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_at(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time as an absolute time.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*/
|
||||
std::size_t expires_at(const time_type& expiry_time,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.expires_at(this->implementation, expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Get the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function may be used to obtain the timer's current expiry time.
|
||||
* Whether the timer has expired or not does not affect this value.
|
||||
*/
|
||||
duration_type expires_from_now() const
|
||||
{
|
||||
return this->service.expires_from_now(this->implementation);
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration_type& expiry_time)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t s = this->service.expires_from_now(
|
||||
this->implementation, expiry_time, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Set the timer's expiry time relative to now.
|
||||
/**
|
||||
* This function sets the expiry time. Any pending asynchronous wait
|
||||
* operations will be cancelled. The handler for each cancelled operation will
|
||||
* be invoked with the boost::asio::error::operation_aborted error code.
|
||||
*
|
||||
* @param expiry_time The expiry time to be used for the timer.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*
|
||||
* @return The number of asynchronous operations that were cancelled.
|
||||
*/
|
||||
std::size_t expires_from_now(const duration_type& expiry_time,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return this->service.expires_from_now(
|
||||
this->implementation, expiry_time, ec);
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @throws boost::system::system_error Thrown on failure.
|
||||
*/
|
||||
void wait()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
this->service.wait(this->implementation, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
}
|
||||
|
||||
/// Perform a blocking wait on the timer.
|
||||
/**
|
||||
* This function is used to wait for the timer to expire. This function
|
||||
* blocks and does not return until the timer has expired.
|
||||
*
|
||||
* @param ec Set to indicate what error occurred, if any.
|
||||
*/
|
||||
void wait(boost::system::error_code& ec)
|
||||
{
|
||||
this->service.wait(this->implementation, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous wait on the timer.
|
||||
/**
|
||||
* This function may be used to initiate an asynchronous wait against the
|
||||
* timer. It always returns immediately.
|
||||
*
|
||||
* For each call to async_wait(), the supplied handler will be called exactly
|
||||
* once. The handler will be called when:
|
||||
*
|
||||
* @li The timer has expired.
|
||||
*
|
||||
* @li The timer was cancelled, in which case the handler is passed the error
|
||||
* code boost::asio::error::operation_aborted.
|
||||
*
|
||||
* @param handler The handler to be called when the timer expires. Copies
|
||||
* will be made of the handler as required. The function signature of the
|
||||
* handler must be:
|
||||
* @code void handler(
|
||||
* const boost::system::error_code& error // Result of operation.
|
||||
* ); @endcode
|
||||
* Regardless of whether the asynchronous operation completes immediately or
|
||||
* not, the handler will not be invoked from within this function. Invocation
|
||||
* of the handler will be performed in a manner equivalent to using
|
||||
* boost::asio::io_service::post().
|
||||
*/
|
||||
template <typename WaitHandler>
|
||||
void async_wait(WaitHandler handler)
|
||||
{
|
||||
this->service.async_wait(this->implementation, handler);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_DEADLINE_TIMER_HPP
|
||||
|
182
src/3rdparty/include/boost/asio/basic_io_object.hpp
vendored
182
src/3rdparty/include/boost/asio/basic_io_object.hpp
vendored
@ -1,91 +1,91 @@
|
||||
//
|
||||
// basic_io_object.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_IO_OBJECT_HPP
|
||||
#define BOOST_ASIO_BASIC_IO_OBJECT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Base class for all I/O objects.
|
||||
template <typename IoObjectService>
|
||||
class basic_io_object
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the service that will be used to provide I/O operations.
|
||||
typedef IoObjectService service_type;
|
||||
|
||||
/// The underlying implementation type of I/O object.
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
/**
|
||||
* This function may be used to obtain the io_service object that the I/O
|
||||
* object uses to dispatch handlers for asynchronous operations.
|
||||
*
|
||||
* @return A reference to the io_service object that the I/O object will use
|
||||
* to dispatch handlers. Ownership is not transferred to the caller.
|
||||
*/
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return service.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
/**
|
||||
* This function may be used to obtain the io_service object that the I/O
|
||||
* object uses to dispatch handlers for asynchronous operations.
|
||||
*
|
||||
* @return A reference to the io_service object that the I/O object will use
|
||||
* to dispatch handlers. Ownership is not transferred to the caller.
|
||||
*/
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return service.get_io_service();
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Construct a basic_io_object.
|
||||
explicit basic_io_object(boost::asio::io_service& io_service)
|
||||
: service(boost::asio::use_service<IoObjectService>(io_service))
|
||||
{
|
||||
service.construct(implementation);
|
||||
}
|
||||
|
||||
/// Protected destructor to prevent deletion through this type.
|
||||
~basic_io_object()
|
||||
{
|
||||
service.destroy(implementation);
|
||||
}
|
||||
|
||||
// The backend service implementation.
|
||||
service_type& service;
|
||||
|
||||
// The underlying native implementation.
|
||||
implementation_type implementation;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_IO_OBJECT_HPP
|
||||
//
|
||||
// basic_io_object.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_IO_OBJECT_HPP
|
||||
#define BOOST_ASIO_BASIC_IO_OBJECT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Base class for all I/O objects.
|
||||
template <typename IoObjectService>
|
||||
class basic_io_object
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the service that will be used to provide I/O operations.
|
||||
typedef IoObjectService service_type;
|
||||
|
||||
/// The underlying implementation type of I/O object.
|
||||
typedef typename service_type::implementation_type implementation_type;
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
/**
|
||||
* This function may be used to obtain the io_service object that the I/O
|
||||
* object uses to dispatch handlers for asynchronous operations.
|
||||
*
|
||||
* @return A reference to the io_service object that the I/O object will use
|
||||
* to dispatch handlers. Ownership is not transferred to the caller.
|
||||
*/
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return service.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
/**
|
||||
* This function may be used to obtain the io_service object that the I/O
|
||||
* object uses to dispatch handlers for asynchronous operations.
|
||||
*
|
||||
* @return A reference to the io_service object that the I/O object will use
|
||||
* to dispatch handlers. Ownership is not transferred to the caller.
|
||||
*/
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return service.get_io_service();
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Construct a basic_io_object.
|
||||
explicit basic_io_object(boost::asio::io_service& io_service)
|
||||
: service(boost::asio::use_service<IoObjectService>(io_service))
|
||||
{
|
||||
service.construct(implementation);
|
||||
}
|
||||
|
||||
/// Protected destructor to prevent deletion through this type.
|
||||
~basic_io_object()
|
||||
{
|
||||
service.destroy(implementation);
|
||||
}
|
||||
|
||||
// The backend service implementation.
|
||||
service_type& service;
|
||||
|
||||
// The underlying native implementation.
|
||||
implementation_type implementation;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_IO_OBJECT_HPP
|
||||
|
2032
src/3rdparty/include/boost/asio/basic_socket.hpp
vendored
2032
src/3rdparty/include/boost/asio/basic_socket.hpp
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,148 +1,150 @@
|
||||
//
|
||||
// basic_socket_iostream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
#define BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/basic_socket_streambuf.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
#define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5
|
||||
#endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// explicit basic_socket_iostream(T1 x1, ..., Tn xn)
|
||||
// : basic_iostream<char>(&this->boost::base_from_member<
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService> >::member)
|
||||
// {
|
||||
// if (rdbuf()->connect(x1, ..., xn) == 0)
|
||||
// this->setstate(std::ios_base::failbit);
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
: std::basic_iostream<char>(&this->boost::base_from_member< \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member) \
|
||||
{ \
|
||||
if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \
|
||||
this->setstate(std::ios_base::failbit); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// void connect(T1 x1, ..., Tn xn)
|
||||
// {
|
||||
// if (rdbuf()->connect(x1, ..., xn) == 0)
|
||||
// this->setstate(std::ios_base::failbit);
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
void connect(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
{ \
|
||||
if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \
|
||||
this->setstate(std::ios_base::failbit); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Iostream interface for a socket.
|
||||
template <typename Protocol,
|
||||
typename StreamSocketService = stream_socket_service<Protocol> >
|
||||
class basic_socket_iostream
|
||||
: public boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >,
|
||||
public std::basic_iostream<char>
|
||||
{
|
||||
public:
|
||||
/// Construct a basic_socket_iostream without establishing a connection.
|
||||
basic_socket_iostream()
|
||||
: std::basic_iostream<char>(&this->boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Establish a connection to an endpoint corresponding to a resolver query.
|
||||
/**
|
||||
* This constructor automatically establishes a connection based on the
|
||||
* supplied resolver query parameters. The arguments are used to construct
|
||||
* a resolver query object.
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
explicit basic_socket_iostream(T1 t1, ..., TN tn);
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY),
|
||||
BOOST_ASIO_PRIVATE_CTR_DEF, _ )
|
||||
#endif
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Establish a connection to an endpoint corresponding to a resolver query.
|
||||
/**
|
||||
* This function automatically establishes a connection based on the supplied
|
||||
* resolver query parameters. The arguments are used to construct a resolver
|
||||
* query object.
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
void connect(T1 t1, ..., TN tn);
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY),
|
||||
BOOST_ASIO_PRIVATE_CONNECT_DEF, _ )
|
||||
#endif
|
||||
|
||||
/// Close the connection.
|
||||
void close()
|
||||
{
|
||||
if (rdbuf()->close() == 0)
|
||||
this->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
/// Return a pointer to the underlying streambuf.
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* rdbuf() const
|
||||
{
|
||||
return const_cast<basic_socket_streambuf<Protocol, StreamSocketService>*>(
|
||||
&this->boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_ASIO_PRIVATE_CTR_DEF
|
||||
#undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
//
|
||||
// basic_socket_iostream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
#define BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/basic_socket_streambuf.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
#define BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY 5
|
||||
#endif // !defined(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY)
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// explicit basic_socket_iostream(T1 x1, ..., Tn xn)
|
||||
// : basic_iostream<char>(&this->boost::base_from_member<
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService> >::member)
|
||||
// {
|
||||
// if (rdbuf()->connect(x1, ..., xn) == 0)
|
||||
// this->setstate(std::ios_base::failbit);
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CTR_DEF(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
: std::basic_iostream<char>(&this->boost::base_from_member< \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member) \
|
||||
{ \
|
||||
tie(this); \
|
||||
if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \
|
||||
this->setstate(std::ios_base::failbit); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// void connect(T1 x1, ..., Tn xn)
|
||||
// {
|
||||
// if (rdbuf()->connect(x1, ..., xn) == 0)
|
||||
// this->setstate(std::ios_base::failbit);
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CONNECT_DEF(z, n, data) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
void connect(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
{ \
|
||||
if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \
|
||||
this->setstate(std::ios_base::failbit); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Iostream interface for a socket.
|
||||
template <typename Protocol,
|
||||
typename StreamSocketService = stream_socket_service<Protocol> >
|
||||
class basic_socket_iostream
|
||||
: public boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >,
|
||||
public std::basic_iostream<char>
|
||||
{
|
||||
public:
|
||||
/// Construct a basic_socket_iostream without establishing a connection.
|
||||
basic_socket_iostream()
|
||||
: std::basic_iostream<char>(&this->boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member)
|
||||
{
|
||||
tie(this);
|
||||
}
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Establish a connection to an endpoint corresponding to a resolver query.
|
||||
/**
|
||||
* This constructor automatically establishes a connection based on the
|
||||
* supplied resolver query parameters. The arguments are used to construct
|
||||
* a resolver query object.
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
explicit basic_socket_iostream(T1 t1, ..., TN tn);
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY),
|
||||
BOOST_ASIO_PRIVATE_CTR_DEF, _ )
|
||||
#endif
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Establish a connection to an endpoint corresponding to a resolver query.
|
||||
/**
|
||||
* This function automatically establishes a connection based on the supplied
|
||||
* resolver query parameters. The arguments are used to construct a resolver
|
||||
* query object.
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
void connect(T1 t1, ..., TN tn);
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_IOSTREAM_MAX_ARITY),
|
||||
BOOST_ASIO_PRIVATE_CONNECT_DEF, _ )
|
||||
#endif
|
||||
|
||||
/// Close the connection.
|
||||
void close()
|
||||
{
|
||||
if (rdbuf()->close() == 0)
|
||||
this->setstate(std::ios_base::failbit);
|
||||
}
|
||||
|
||||
/// Return a pointer to the underlying streambuf.
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* rdbuf() const
|
||||
{
|
||||
return const_cast<basic_socket_streambuf<Protocol, StreamSocketService>*>(
|
||||
&this->boost::base_from_member<
|
||||
basic_socket_streambuf<Protocol, StreamSocketService> >::member);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_ASIO_PRIVATE_CTR_DEF
|
||||
#undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_SOCKET_IOSTREAM_HPP
|
||||
|
@ -1,286 +1,286 @@
|
||||
//
|
||||
// basic_socket_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
#define BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <streambuf>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
#define BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY 5
|
||||
#endif // !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
// T1 x1, ..., Tn xn)
|
||||
// {
|
||||
// init_buffers();
|
||||
// boost::system::error_code ec;
|
||||
// this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
// typedef typename Protocol::resolver_query resolver_query;
|
||||
// resolver_query query(x1, ..., xn);
|
||||
// resolve_and_connect(query, ec);
|
||||
// return !ec ? this : 0;
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CONNECT_DEF( z, n, data ) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
{ \
|
||||
init_buffers(); \
|
||||
boost::system::error_code ec; \
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec); \
|
||||
typedef typename Protocol::resolver_query resolver_query; \
|
||||
resolver_query query(BOOST_PP_ENUM_PARAMS(n, x)); \
|
||||
resolve_and_connect(query, ec); \
|
||||
return !ec ? this : 0; \
|
||||
} \
|
||||
/**/
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Iostream streambuf for a socket.
|
||||
template <typename Protocol,
|
||||
typename StreamSocketService = stream_socket_service<Protocol> >
|
||||
class basic_socket_streambuf
|
||||
: public std::streambuf,
|
||||
private boost::base_from_member<io_service>,
|
||||
public basic_socket<Protocol, StreamSocketService>
|
||||
{
|
||||
public:
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// Construct a basic_socket_streambuf without establishing a connection.
|
||||
basic_socket_streambuf()
|
||||
: basic_socket<Protocol, StreamSocketService>(
|
||||
boost::base_from_member<boost::asio::io_service>::member),
|
||||
unbuffered_(false)
|
||||
{
|
||||
init_buffers();
|
||||
}
|
||||
|
||||
/// Destructor flushes buffered data.
|
||||
virtual ~basic_socket_streambuf()
|
||||
{
|
||||
if (pptr() != pbase())
|
||||
overflow(traits_type::eof());
|
||||
}
|
||||
|
||||
/// Establish a connection.
|
||||
/**
|
||||
* This function establishes a connection to the specified endpoint.
|
||||
*
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
const endpoint_type& endpoint)
|
||||
{
|
||||
init_buffers();
|
||||
boost::system::error_code ec;
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
this->basic_socket<Protocol, StreamSocketService>::connect(endpoint, ec);
|
||||
return !ec ? this : 0;
|
||||
}
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Establish a connection.
|
||||
/**
|
||||
* This function automatically establishes a connection based on the supplied
|
||||
* resolver query parameters. The arguments are used to construct a resolver
|
||||
* query object.
|
||||
*
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
T1 t1, ..., TN tn);
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY),
|
||||
BOOST_ASIO_PRIVATE_CONNECT_DEF, _ )
|
||||
#endif
|
||||
|
||||
/// Close the connection.
|
||||
/**
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
sync();
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
if (!ec)
|
||||
init_buffers();
|
||||
return !ec ? this : 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
int_type underflow()
|
||||
{
|
||||
if (gptr() == egptr())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = this->service.receive(
|
||||
this->implementation,
|
||||
boost::asio::buffer(boost::asio::buffer(get_buffer_) + putback_max),
|
||||
0, ec);
|
||||
if (ec)
|
||||
return traits_type::eof();
|
||||
setg(get_buffer_.begin(), get_buffer_.begin() + putback_max,
|
||||
get_buffer_.begin() + putback_max + bytes_transferred);
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
|
||||
int_type overflow(int_type c)
|
||||
{
|
||||
if (unbuffered_)
|
||||
{
|
||||
if (traits_type::eq_int_type(c, traits_type::eof()))
|
||||
{
|
||||
// Nothing to do.
|
||||
return traits_type::not_eof(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send the single character immediately.
|
||||
boost::system::error_code ec;
|
||||
char_type ch = traits_type::to_char_type(c);
|
||||
this->service.send(this->implementation,
|
||||
boost::asio::buffer(&ch, sizeof(char_type)), 0, ec);
|
||||
if (ec)
|
||||
return traits_type::eof();
|
||||
return c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send all data in the output buffer.
|
||||
boost::asio::const_buffer buffer =
|
||||
boost::asio::buffer(pbase(), pptr() - pbase());
|
||||
while (boost::asio::buffer_size(buffer) > 0)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = this->service.send(
|
||||
this->implementation, boost::asio::buffer(buffer),
|
||||
0, ec);
|
||||
if (ec)
|
||||
return traits_type::eof();
|
||||
buffer = buffer + bytes_transferred;
|
||||
}
|
||||
setp(put_buffer_.begin(), put_buffer_.end());
|
||||
|
||||
// If the new character is eof then our work here is done.
|
||||
if (traits_type::eq_int_type(c, traits_type::eof()))
|
||||
return traits_type::not_eof(c);
|
||||
|
||||
// Add the new character to the output buffer.
|
||||
*pptr() = traits_type::to_char_type(c);
|
||||
pbump(1);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
int sync()
|
||||
{
|
||||
return overflow(traits_type::eof());
|
||||
}
|
||||
|
||||
std::streambuf* setbuf(char_type* s, std::streamsize n)
|
||||
{
|
||||
if (pptr() == pbase() && s == 0 && n == 0)
|
||||
{
|
||||
unbuffered_ = true;
|
||||
setp(0, 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
void init_buffers()
|
||||
{
|
||||
setg(get_buffer_.begin(),
|
||||
get_buffer_.begin() + putback_max,
|
||||
get_buffer_.begin() + putback_max);
|
||||
if (unbuffered_)
|
||||
setp(0, 0);
|
||||
else
|
||||
setp(put_buffer_.begin(), put_buffer_.end());
|
||||
}
|
||||
|
||||
void resolve_and_connect(const typename Protocol::resolver_query& query,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
typedef typename Protocol::resolver resolver_type;
|
||||
typedef typename Protocol::resolver_iterator iterator_type;
|
||||
resolver_type resolver(
|
||||
boost::base_from_member<boost::asio::io_service>::member);
|
||||
iterator_type i = resolver.resolve(query, ec);
|
||||
if (!ec)
|
||||
{
|
||||
iterator_type end;
|
||||
ec = boost::asio::error::host_not_found;
|
||||
while (ec && i != end)
|
||||
{
|
||||
this->basic_socket<Protocol, StreamSocketService>::close();
|
||||
this->basic_socket<Protocol, StreamSocketService>::connect(*i, ec);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum { putback_max = 8 };
|
||||
enum { buffer_size = 512 };
|
||||
boost::array<char, buffer_size> get_buffer_;
|
||||
boost::array<char, buffer_size> put_buffer_;
|
||||
bool unbuffered_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
//
|
||||
// basic_socket_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
#define BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <streambuf>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/stream_socket_service.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
#define BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY 5
|
||||
#endif // !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
|
||||
|
||||
// A macro that should expand to:
|
||||
// template <typename T1, ..., typename Tn>
|
||||
// basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
// T1 x1, ..., Tn xn)
|
||||
// {
|
||||
// init_buffers();
|
||||
// boost::system::error_code ec;
|
||||
// this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
// typedef typename Protocol::resolver_query resolver_query;
|
||||
// resolver_query query(x1, ..., xn);
|
||||
// resolve_and_connect(query, ec);
|
||||
// return !ec ? this : 0;
|
||||
// }
|
||||
// This macro should only persist within this file.
|
||||
|
||||
#define BOOST_ASIO_PRIVATE_CONNECT_DEF( z, n, data ) \
|
||||
template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect( \
|
||||
BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
|
||||
{ \
|
||||
init_buffers(); \
|
||||
boost::system::error_code ec; \
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec); \
|
||||
typedef typename Protocol::resolver_query resolver_query; \
|
||||
resolver_query query(BOOST_PP_ENUM_PARAMS(n, x)); \
|
||||
resolve_and_connect(query, ec); \
|
||||
return !ec ? this : 0; \
|
||||
} \
|
||||
/**/
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Iostream streambuf for a socket.
|
||||
template <typename Protocol,
|
||||
typename StreamSocketService = stream_socket_service<Protocol> >
|
||||
class basic_socket_streambuf
|
||||
: public std::streambuf,
|
||||
private boost::base_from_member<io_service>,
|
||||
public basic_socket<Protocol, StreamSocketService>
|
||||
{
|
||||
public:
|
||||
/// The endpoint type.
|
||||
typedef typename Protocol::endpoint endpoint_type;
|
||||
|
||||
/// Construct a basic_socket_streambuf without establishing a connection.
|
||||
basic_socket_streambuf()
|
||||
: basic_socket<Protocol, StreamSocketService>(
|
||||
boost::base_from_member<boost::asio::io_service>::member),
|
||||
unbuffered_(false)
|
||||
{
|
||||
init_buffers();
|
||||
}
|
||||
|
||||
/// Destructor flushes buffered data.
|
||||
virtual ~basic_socket_streambuf()
|
||||
{
|
||||
if (pptr() != pbase())
|
||||
overflow(traits_type::eof());
|
||||
}
|
||||
|
||||
/// Establish a connection.
|
||||
/**
|
||||
* This function establishes a connection to the specified endpoint.
|
||||
*
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
const endpoint_type& endpoint)
|
||||
{
|
||||
init_buffers();
|
||||
boost::system::error_code ec;
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
this->basic_socket<Protocol, StreamSocketService>::connect(endpoint, ec);
|
||||
return !ec ? this : 0;
|
||||
}
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// Establish a connection.
|
||||
/**
|
||||
* This function automatically establishes a connection based on the supplied
|
||||
* resolver query parameters. The arguments are used to construct a resolver
|
||||
* query object.
|
||||
*
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
template <typename T1, ..., typename TN>
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* connect(
|
||||
T1 t1, ..., TN tn);
|
||||
#else
|
||||
BOOST_PP_REPEAT_FROM_TO(
|
||||
1, BOOST_PP_INC(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY),
|
||||
BOOST_ASIO_PRIVATE_CONNECT_DEF, _ )
|
||||
#endif
|
||||
|
||||
/// Close the connection.
|
||||
/**
|
||||
* @return \c this if a connection was successfully established, a null
|
||||
* pointer otherwise.
|
||||
*/
|
||||
basic_socket_streambuf<Protocol, StreamSocketService>* close()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
sync();
|
||||
this->basic_socket<Protocol, StreamSocketService>::close(ec);
|
||||
if (!ec)
|
||||
init_buffers();
|
||||
return !ec ? this : 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
int_type underflow()
|
||||
{
|
||||
if (gptr() == egptr())
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = this->service.receive(
|
||||
this->implementation,
|
||||
boost::asio::buffer(boost::asio::buffer(get_buffer_) + putback_max),
|
||||
0, ec);
|
||||
if (ec)
|
||||
return traits_type::eof();
|
||||
setg(get_buffer_.begin(), get_buffer_.begin() + putback_max,
|
||||
get_buffer_.begin() + putback_max + bytes_transferred);
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
|
||||
int_type overflow(int_type c)
|
||||
{
|
||||
if (unbuffered_)
|
||||
{
|
||||
if (traits_type::eq_int_type(c, traits_type::eof()))
|
||||
{
|
||||
// Nothing to do.
|
||||
return traits_type::not_eof(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send the single character immediately.
|
||||
boost::system::error_code ec;
|
||||
char_type ch = traits_type::to_char_type(c);
|
||||
this->service.send(this->implementation,
|
||||
boost::asio::buffer(&ch, sizeof(char_type)), 0, ec);
|
||||
if (ec)
|
||||
return traits_type::eof();
|
||||
return c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send all data in the output buffer.
|
||||
boost::asio::const_buffer buffer =
|
||||
boost::asio::buffer(pbase(), pptr() - pbase());
|
||||
while (boost::asio::buffer_size(buffer) > 0)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::size_t bytes_transferred = this->service.send(
|
||||
this->implementation, boost::asio::buffer(buffer),
|
||||
0, ec);
|
||||
if (ec)
|
||||
return traits_type::eof();
|
||||
buffer = buffer + bytes_transferred;
|
||||
}
|
||||
setp(put_buffer_.begin(), put_buffer_.end());
|
||||
|
||||
// If the new character is eof then our work here is done.
|
||||
if (traits_type::eq_int_type(c, traits_type::eof()))
|
||||
return traits_type::not_eof(c);
|
||||
|
||||
// Add the new character to the output buffer.
|
||||
*pptr() = traits_type::to_char_type(c);
|
||||
pbump(1);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
int sync()
|
||||
{
|
||||
return overflow(traits_type::eof());
|
||||
}
|
||||
|
||||
std::streambuf* setbuf(char_type* s, std::streamsize n)
|
||||
{
|
||||
if (pptr() == pbase() && s == 0 && n == 0)
|
||||
{
|
||||
unbuffered_ = true;
|
||||
setp(0, 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
void init_buffers()
|
||||
{
|
||||
setg(get_buffer_.begin(),
|
||||
get_buffer_.begin() + putback_max,
|
||||
get_buffer_.begin() + putback_max);
|
||||
if (unbuffered_)
|
||||
setp(0, 0);
|
||||
else
|
||||
setp(put_buffer_.begin(), put_buffer_.end());
|
||||
}
|
||||
|
||||
void resolve_and_connect(const typename Protocol::resolver_query& query,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
typedef typename Protocol::resolver resolver_type;
|
||||
typedef typename Protocol::resolver_iterator iterator_type;
|
||||
resolver_type resolver(
|
||||
boost::base_from_member<boost::asio::io_service>::member);
|
||||
iterator_type i = resolver.resolve(query, ec);
|
||||
if (!ec)
|
||||
{
|
||||
iterator_type end;
|
||||
ec = boost::asio::error::host_not_found;
|
||||
while (ec && i != end)
|
||||
{
|
||||
this->basic_socket<Protocol, StreamSocketService>::close();
|
||||
this->basic_socket<Protocol, StreamSocketService>::connect(*i, ec);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum { putback_max = 8 };
|
||||
enum { buffer_size = 512 };
|
||||
boost::array<char, buffer_size> get_buffer_;
|
||||
boost::array<char, buffer_size> put_buffer_;
|
||||
bool unbuffered_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_ASIO_PRIVATE_CONNECT_DEF
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP
|
||||
|
1440
src/3rdparty/include/boost/asio/basic_stream_socket.hpp
vendored
1440
src/3rdparty/include/boost/asio/basic_stream_socket.hpp
vendored
File diff suppressed because it is too large
Load Diff
404
src/3rdparty/include/boost/asio/basic_streambuf.hpp
vendored
404
src/3rdparty/include/boost/asio/basic_streambuf.hpp
vendored
@ -1,202 +1,202 @@
|
||||
//
|
||||
// basic_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_STREAMBUF_HPP
|
||||
#define BOOST_ASIO_BASIC_STREAMBUF_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <streambuf>
|
||||
#include <vector>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Automatically resizable buffer class based on std::streambuf.
|
||||
template <typename Allocator = std::allocator<char> >
|
||||
class basic_streambuf
|
||||
: public std::streambuf,
|
||||
private noncopyable
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The type used to represent the get area as a list of buffers.
|
||||
typedef implementation_defined const_buffers_type;
|
||||
|
||||
/// The type used to represent the put area as a list of buffers.
|
||||
typedef implementation_defined mutable_buffers_type;
|
||||
#else
|
||||
typedef boost::asio::const_buffers_1 const_buffers_type;
|
||||
typedef boost::asio::mutable_buffers_1 mutable_buffers_type;
|
||||
#endif
|
||||
|
||||
/// Construct a buffer with a specified maximum size.
|
||||
explicit basic_streambuf(
|
||||
std::size_t max_size = (std::numeric_limits<std::size_t>::max)(),
|
||||
const Allocator& allocator = Allocator())
|
||||
: max_size_(max_size),
|
||||
buffer_(allocator)
|
||||
{
|
||||
std::size_t pend = (std::min<std::size_t>)(max_size_, buffer_delta);
|
||||
buffer_.resize((std::max<std::size_t>)(pend, 1));
|
||||
setg(&buffer_[0], &buffer_[0], &buffer_[0]);
|
||||
setp(&buffer_[0], &buffer_[0] + pend);
|
||||
}
|
||||
|
||||
/// Return the size of the get area in characters.
|
||||
std::size_t size() const
|
||||
{
|
||||
return pptr() - gptr();
|
||||
}
|
||||
|
||||
/// Return the maximum size of the buffer.
|
||||
std::size_t max_size() const
|
||||
{
|
||||
return max_size_;
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the get area.
|
||||
const_buffers_type data() const
|
||||
{
|
||||
return boost::asio::buffer(boost::asio::const_buffer(gptr(),
|
||||
(pptr() - gptr()) * sizeof(char_type)));
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the put area, with the given size.
|
||||
mutable_buffers_type prepare(std::size_t size)
|
||||
{
|
||||
reserve(size);
|
||||
return boost::asio::buffer(boost::asio::mutable_buffer(
|
||||
pptr(), size * sizeof(char_type)));
|
||||
}
|
||||
|
||||
/// Move the start of the put area by the specified number of characters.
|
||||
void commit(std::size_t n)
|
||||
{
|
||||
if (pptr() + n > epptr())
|
||||
n = epptr() - pptr();
|
||||
pbump(static_cast<int>(n));
|
||||
}
|
||||
|
||||
/// Move the start of the get area by the specified number of characters.
|
||||
void consume(std::size_t n)
|
||||
{
|
||||
while (n > 0)
|
||||
{
|
||||
sbumpc();
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
enum { buffer_delta = 128 };
|
||||
|
||||
int_type underflow()
|
||||
{
|
||||
if (gptr() < pptr())
|
||||
{
|
||||
setg(&buffer_[0], gptr(), pptr());
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
|
||||
int_type overflow(int_type c)
|
||||
{
|
||||
if (!traits_type::eq_int_type(c, traits_type::eof()))
|
||||
{
|
||||
if (pptr() == epptr())
|
||||
{
|
||||
std::size_t buffer_size = pptr() - gptr();
|
||||
if (buffer_size < max_size_ && max_size_ - buffer_size < buffer_delta)
|
||||
{
|
||||
reserve(max_size_ - buffer_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
reserve(buffer_delta);
|
||||
}
|
||||
}
|
||||
|
||||
*pptr() = traits_type::to_char_type(c);
|
||||
pbump(1);
|
||||
return c;
|
||||
}
|
||||
|
||||
return traits_type::not_eof(c);
|
||||
}
|
||||
|
||||
void reserve(std::size_t n)
|
||||
{
|
||||
// Get current stream positions as offsets.
|
||||
std::size_t gnext = gptr() - &buffer_[0];
|
||||
std::size_t gend = egptr() - &buffer_[0];
|
||||
std::size_t pnext = pptr() - &buffer_[0];
|
||||
std::size_t pend = epptr() - &buffer_[0];
|
||||
|
||||
// Check if there is already enough space in the put area.
|
||||
if (n <= pend - pnext)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Shift existing contents of get area to start of buffer.
|
||||
if (gnext > 0)
|
||||
{
|
||||
std::rotate(&buffer_[0], &buffer_[0] + gnext, &buffer_[0] + pend);
|
||||
gend -= gnext;
|
||||
pnext -= gnext;
|
||||
}
|
||||
|
||||
// Ensure buffer is large enough to hold at least the specified size.
|
||||
if (n > pend - pnext)
|
||||
{
|
||||
if (n <= max_size_ && pnext <= max_size_ - n)
|
||||
{
|
||||
buffer_.resize((std::max<std::size_t>)(pnext + n, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::length_error("boost::asio::streambuf too long");
|
||||
}
|
||||
}
|
||||
|
||||
// Update stream positions.
|
||||
setg(&buffer_[0], &buffer_[0], &buffer_[0] + gend);
|
||||
setp(&buffer_[0] + pnext, &buffer_[0] + pnext + n);
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t max_size_;
|
||||
std::vector<char_type, Allocator> buffer_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_STREAMBUF_HPP
|
||||
//
|
||||
// basic_streambuf.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BASIC_STREAMBUF_HPP
|
||||
#define BOOST_ASIO_BASIC_STREAMBUF_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <streambuf>
|
||||
#include <vector>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Automatically resizable buffer class based on std::streambuf.
|
||||
template <typename Allocator = std::allocator<char> >
|
||||
class basic_streambuf
|
||||
: public std::streambuf,
|
||||
private noncopyable
|
||||
{
|
||||
public:
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The type used to represent the get area as a list of buffers.
|
||||
typedef implementation_defined const_buffers_type;
|
||||
|
||||
/// The type used to represent the put area as a list of buffers.
|
||||
typedef implementation_defined mutable_buffers_type;
|
||||
#else
|
||||
typedef boost::asio::const_buffers_1 const_buffers_type;
|
||||
typedef boost::asio::mutable_buffers_1 mutable_buffers_type;
|
||||
#endif
|
||||
|
||||
/// Construct a buffer with a specified maximum size.
|
||||
explicit basic_streambuf(
|
||||
std::size_t max_size = (std::numeric_limits<std::size_t>::max)(),
|
||||
const Allocator& allocator = Allocator())
|
||||
: max_size_(max_size),
|
||||
buffer_(allocator)
|
||||
{
|
||||
std::size_t pend = (std::min<std::size_t>)(max_size_, buffer_delta);
|
||||
buffer_.resize((std::max<std::size_t>)(pend, 1));
|
||||
setg(&buffer_[0], &buffer_[0], &buffer_[0]);
|
||||
setp(&buffer_[0], &buffer_[0] + pend);
|
||||
}
|
||||
|
||||
/// Return the size of the get area in characters.
|
||||
std::size_t size() const
|
||||
{
|
||||
return pptr() - gptr();
|
||||
}
|
||||
|
||||
/// Return the maximum size of the buffer.
|
||||
std::size_t max_size() const
|
||||
{
|
||||
return max_size_;
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the get area.
|
||||
const_buffers_type data() const
|
||||
{
|
||||
return boost::asio::buffer(boost::asio::const_buffer(gptr(),
|
||||
(pptr() - gptr()) * sizeof(char_type)));
|
||||
}
|
||||
|
||||
/// Get a list of buffers that represents the put area, with the given size.
|
||||
mutable_buffers_type prepare(std::size_t size)
|
||||
{
|
||||
reserve(size);
|
||||
return boost::asio::buffer(boost::asio::mutable_buffer(
|
||||
pptr(), size * sizeof(char_type)));
|
||||
}
|
||||
|
||||
/// Move the start of the put area by the specified number of characters.
|
||||
void commit(std::size_t n)
|
||||
{
|
||||
if (pptr() + n > epptr())
|
||||
n = epptr() - pptr();
|
||||
pbump(static_cast<int>(n));
|
||||
}
|
||||
|
||||
/// Move the start of the get area by the specified number of characters.
|
||||
void consume(std::size_t n)
|
||||
{
|
||||
while (n > 0)
|
||||
{
|
||||
sbumpc();
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
enum { buffer_delta = 128 };
|
||||
|
||||
int_type underflow()
|
||||
{
|
||||
if (gptr() < pptr())
|
||||
{
|
||||
setg(&buffer_[0], gptr(), pptr());
|
||||
return traits_type::to_int_type(*gptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
|
||||
int_type overflow(int_type c)
|
||||
{
|
||||
if (!traits_type::eq_int_type(c, traits_type::eof()))
|
||||
{
|
||||
if (pptr() == epptr())
|
||||
{
|
||||
std::size_t buffer_size = pptr() - gptr();
|
||||
if (buffer_size < max_size_ && max_size_ - buffer_size < buffer_delta)
|
||||
{
|
||||
reserve(max_size_ - buffer_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
reserve(buffer_delta);
|
||||
}
|
||||
}
|
||||
|
||||
*pptr() = traits_type::to_char_type(c);
|
||||
pbump(1);
|
||||
return c;
|
||||
}
|
||||
|
||||
return traits_type::not_eof(c);
|
||||
}
|
||||
|
||||
void reserve(std::size_t n)
|
||||
{
|
||||
// Get current stream positions as offsets.
|
||||
std::size_t gnext = gptr() - &buffer_[0];
|
||||
std::size_t gend = egptr() - &buffer_[0];
|
||||
std::size_t pnext = pptr() - &buffer_[0];
|
||||
std::size_t pend = epptr() - &buffer_[0];
|
||||
|
||||
// Check if there is already enough space in the put area.
|
||||
if (n <= pend - pnext)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Shift existing contents of get area to start of buffer.
|
||||
if (gnext > 0)
|
||||
{
|
||||
std::rotate(&buffer_[0], &buffer_[0] + gnext, &buffer_[0] + pend);
|
||||
gend -= gnext;
|
||||
pnext -= gnext;
|
||||
}
|
||||
|
||||
// Ensure buffer is large enough to hold at least the specified size.
|
||||
if (n > pend - pnext)
|
||||
{
|
||||
if (n <= max_size_ && pnext <= max_size_ - n)
|
||||
{
|
||||
buffer_.resize((std::max<std::size_t>)(pnext + n, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::length_error("boost::asio::streambuf too long");
|
||||
}
|
||||
}
|
||||
|
||||
// Update stream positions.
|
||||
setg(&buffer_[0], &buffer_[0], &buffer_[0] + gend);
|
||||
setp(&buffer_[0] + pnext, &buffer_[0] + pnext + n);
|
||||
}
|
||||
|
||||
private:
|
||||
std::size_t max_size_;
|
||||
std::vector<char_type, Allocator> buffer_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BASIC_STREAMBUF_HPP
|
||||
|
1605
src/3rdparty/include/boost/asio/buffer.hpp
vendored
1605
src/3rdparty/include/boost/asio/buffer.hpp
vendored
File diff suppressed because it is too large
Load Diff
@ -1,416 +1,416 @@
|
||||
//
|
||||
// buffered_read_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 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_BUFFERED_READ_STREAM_HPP
|
||||
#define BOOST_ASIO_BUFFERED_READ_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffered_read_stream_fwd.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/detail/bind_handler.hpp>
|
||||
#include <boost/asio/detail/buffer_resize_guard.hpp>
|
||||
#include <boost/asio/detail/buffered_stream_storage.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Adds buffering to the read-related operations of a stream.
|
||||
/**
|
||||
* The buffered_read_stream class template can be used to add buffering to the
|
||||
* synchronous and asynchronous read operations of a stream.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, Sync_Read_Stream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Stream>
|
||||
class buffered_read_stream
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the next layer.
|
||||
typedef typename boost::remove_reference<Stream>::type next_layer_type;
|
||||
|
||||
/// The type of the lowest layer.
|
||||
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The default buffer size.
|
||||
static const std::size_t default_buffer_size = implementation_defined;
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
|
||||
#endif
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_read_stream(Arg& a)
|
||||
: next_layer_(a),
|
||||
storage_(default_buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
buffered_read_stream(Arg& a, std::size_t buffer_size)
|
||||
: next_layer_(a),
|
||||
storage_(buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Get a reference to the next layer.
|
||||
next_layer_type& next_layer()
|
||||
{
|
||||
return next_layer_;
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
void close()
|
||||
{
|
||||
next_layer_.close();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.close(ec);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written.
|
||||
/// Throws an exception on failure.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
return next_layer_.write_some(buffers);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.write_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write. The data being written must be valid for the
|
||||
/// lifetime of the asynchronous operation.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
{
|
||||
next_layer_.async_write_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation. Throws an exception on failure.
|
||||
std::size_t fill()
|
||||
{
|
||||
detail::buffer_resize_guard<detail::buffered_stream_storage>
|
||||
resize_guard(storage_);
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
storage_.resize(previous_size + next_layer_.read_some(buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size)));
|
||||
resize_guard.commit();
|
||||
return storage_.size() - previous_size;
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation, or 0 if an error occurred.
|
||||
std::size_t fill(boost::system::error_code& ec)
|
||||
{
|
||||
detail::buffer_resize_guard<detail::buffered_stream_storage>
|
||||
resize_guard(storage_);
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
storage_.resize(previous_size + next_layer_.read_some(buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size),
|
||||
ec));
|
||||
resize_guard.commit();
|
||||
return storage_.size() - previous_size;
|
||||
}
|
||||
|
||||
template <typename ReadHandler>
|
||||
class fill_handler
|
||||
{
|
||||
public:
|
||||
fill_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage,
|
||||
std::size_t previous_size, ReadHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
previous_size_(previous_size),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec,
|
||||
std::size_t bytes_transferred)
|
||||
{
|
||||
storage_.resize(previous_size_ + bytes_transferred);
|
||||
io_service_.dispatch(detail::bind_handler(
|
||||
handler_, ec, bytes_transferred));
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
std::size_t previous_size_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous fill.
|
||||
template <typename ReadHandler>
|
||||
void async_fill(ReadHandler handler)
|
||||
{
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
next_layer_.async_read_some(
|
||||
buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size),
|
||||
fill_handler<ReadHandler>(get_io_service(),
|
||||
storage_, previous_size, handler));
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read. Throws
|
||||
/// an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
if (storage_.empty())
|
||||
fill();
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read or 0 if
|
||||
/// an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
if (storage_.empty() && !fill(ec))
|
||||
return 0;
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
class read_some_handler
|
||||
{
|
||||
public:
|
||||
read_some_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage,
|
||||
const MutableBufferSequence& buffers, ReadHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec, std::size_t)
|
||||
{
|
||||
if (ec || storage_.empty())
|
||||
{
|
||||
std::size_t length = 0;
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, length));
|
||||
}
|
||||
else
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers_.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers_.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter),
|
||||
storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
storage_.consume(bytes_copied);
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
MutableBufferSequence buffers_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous read. The buffer into which the data will be read
|
||||
/// must be valid for the lifetime of the asynchronous operation.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
{
|
||||
if (storage_.empty())
|
||||
{
|
||||
async_fill(read_some_handler<MutableBufferSequence, ReadHandler>(
|
||||
get_io_service(), storage_, buffers, handler));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::size_t length = copy(buffers);
|
||||
get_io_service().post(detail::bind_handler(
|
||||
handler, boost::system::error_code(), length));
|
||||
}
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read.
|
||||
/// Throws an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers)
|
||||
{
|
||||
if (storage_.empty())
|
||||
fill();
|
||||
return peek_copy(buffers);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
if (storage_.empty() && !fill(ec))
|
||||
return 0;
|
||||
return peek_copy(buffers);
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail()
|
||||
{
|
||||
return storage_.size();
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail(boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
return storage_.size();
|
||||
}
|
||||
|
||||
private:
|
||||
/// Copy data out of the internal buffer to the specified target buffer.
|
||||
/// Returns the number of bytes copied.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t copy(const MutableBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
storage_.consume(bytes_copied);
|
||||
return bytes_copied;
|
||||
}
|
||||
|
||||
/// Copy data from the internal buffer to the specified target buffer, without
|
||||
/// removing the data from the internal buffer. Returns the number of bytes
|
||||
/// copied.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek_copy(const MutableBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
return bytes_copied;
|
||||
}
|
||||
|
||||
/// The next layer.
|
||||
Stream next_layer_;
|
||||
|
||||
// The data in the buffer.
|
||||
detail::buffered_stream_storage storage_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_READ_STREAM_HPP
|
||||
//
|
||||
// buffered_read_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BUFFERED_READ_STREAM_HPP
|
||||
#define BOOST_ASIO_BUFFERED_READ_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffered_read_stream_fwd.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/detail/bind_handler.hpp>
|
||||
#include <boost/asio/detail/buffer_resize_guard.hpp>
|
||||
#include <boost/asio/detail/buffered_stream_storage.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Adds buffering to the read-related operations of a stream.
|
||||
/**
|
||||
* The buffered_read_stream class template can be used to add buffering to the
|
||||
* synchronous and asynchronous read operations of a stream.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, Sync_Read_Stream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Stream>
|
||||
class buffered_read_stream
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the next layer.
|
||||
typedef typename boost::remove_reference<Stream>::type next_layer_type;
|
||||
|
||||
/// The type of the lowest layer.
|
||||
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The default buffer size.
|
||||
static const std::size_t default_buffer_size = implementation_defined;
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
|
||||
#endif
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_read_stream(Arg& a)
|
||||
: next_layer_(a),
|
||||
storage_(default_buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
buffered_read_stream(Arg& a, std::size_t buffer_size)
|
||||
: next_layer_(a),
|
||||
storage_(buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Get a reference to the next layer.
|
||||
next_layer_type& next_layer()
|
||||
{
|
||||
return next_layer_;
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
void close()
|
||||
{
|
||||
next_layer_.close();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.close(ec);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written.
|
||||
/// Throws an exception on failure.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
return next_layer_.write_some(buffers);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.write_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write. The data being written must be valid for the
|
||||
/// lifetime of the asynchronous operation.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
{
|
||||
next_layer_.async_write_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation. Throws an exception on failure.
|
||||
std::size_t fill()
|
||||
{
|
||||
detail::buffer_resize_guard<detail::buffered_stream_storage>
|
||||
resize_guard(storage_);
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
storage_.resize(previous_size + next_layer_.read_some(buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size)));
|
||||
resize_guard.commit();
|
||||
return storage_.size() - previous_size;
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation, or 0 if an error occurred.
|
||||
std::size_t fill(boost::system::error_code& ec)
|
||||
{
|
||||
detail::buffer_resize_guard<detail::buffered_stream_storage>
|
||||
resize_guard(storage_);
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
storage_.resize(previous_size + next_layer_.read_some(buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size),
|
||||
ec));
|
||||
resize_guard.commit();
|
||||
return storage_.size() - previous_size;
|
||||
}
|
||||
|
||||
template <typename ReadHandler>
|
||||
class fill_handler
|
||||
{
|
||||
public:
|
||||
fill_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage,
|
||||
std::size_t previous_size, ReadHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
previous_size_(previous_size),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec,
|
||||
std::size_t bytes_transferred)
|
||||
{
|
||||
storage_.resize(previous_size_ + bytes_transferred);
|
||||
io_service_.dispatch(detail::bind_handler(
|
||||
handler_, ec, bytes_transferred));
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
std::size_t previous_size_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous fill.
|
||||
template <typename ReadHandler>
|
||||
void async_fill(ReadHandler handler)
|
||||
{
|
||||
std::size_t previous_size = storage_.size();
|
||||
storage_.resize(storage_.capacity());
|
||||
next_layer_.async_read_some(
|
||||
buffer(
|
||||
storage_.data() + previous_size,
|
||||
storage_.size() - previous_size),
|
||||
fill_handler<ReadHandler>(get_io_service(),
|
||||
storage_, previous_size, handler));
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read. Throws
|
||||
/// an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
if (storage_.empty())
|
||||
fill();
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read or 0 if
|
||||
/// an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
if (storage_.empty() && !fill(ec))
|
||||
return 0;
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
class read_some_handler
|
||||
{
|
||||
public:
|
||||
read_some_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage,
|
||||
const MutableBufferSequence& buffers, ReadHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec, std::size_t)
|
||||
{
|
||||
if (ec || storage_.empty())
|
||||
{
|
||||
std::size_t length = 0;
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, length));
|
||||
}
|
||||
else
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers_.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers_.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter),
|
||||
storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
storage_.consume(bytes_copied);
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
MutableBufferSequence buffers_;
|
||||
ReadHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous read. The buffer into which the data will be read
|
||||
/// must be valid for the lifetime of the asynchronous operation.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
{
|
||||
if (storage_.empty())
|
||||
{
|
||||
async_fill(read_some_handler<MutableBufferSequence, ReadHandler>(
|
||||
get_io_service(), storage_, buffers, handler));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::size_t length = copy(buffers);
|
||||
get_io_service().post(detail::bind_handler(
|
||||
handler, boost::system::error_code(), length));
|
||||
}
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read.
|
||||
/// Throws an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers)
|
||||
{
|
||||
if (storage_.empty())
|
||||
fill();
|
||||
return peek_copy(buffers);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
if (storage_.empty() && !fill(ec))
|
||||
return 0;
|
||||
return peek_copy(buffers);
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail()
|
||||
{
|
||||
return storage_.size();
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail(boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
return storage_.size();
|
||||
}
|
||||
|
||||
private:
|
||||
/// Copy data out of the internal buffer to the specified target buffer.
|
||||
/// Returns the number of bytes copied.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t copy(const MutableBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
storage_.consume(bytes_copied);
|
||||
return bytes_copied;
|
||||
}
|
||||
|
||||
/// Copy data from the internal buffer to the specified target buffer, without
|
||||
/// removing the data from the internal buffer. Returns the number of bytes
|
||||
/// copied.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek_copy(const MutableBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t bytes_avail = storage_.size();
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename MutableBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename MutableBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && bytes_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t max_length = buffer_size(*iter);
|
||||
std::size_t length = (max_length < bytes_avail)
|
||||
? max_length : bytes_avail;
|
||||
memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
|
||||
bytes_copied += length;
|
||||
bytes_avail -= length;
|
||||
}
|
||||
|
||||
return bytes_copied;
|
||||
}
|
||||
|
||||
/// The next layer.
|
||||
Stream next_layer_;
|
||||
|
||||
// The data in the buffer.
|
||||
detail::buffered_stream_storage storage_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_READ_STREAM_HPP
|
||||
|
@ -1,31 +1,31 @@
|
||||
//
|
||||
// buffered_read_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 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_BUFFERED_READ_STREAM_FWD_HPP
|
||||
#define BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Stream>
|
||||
class buffered_read_stream;
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP
|
||||
//
|
||||
// buffered_read_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP
|
||||
#define BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Stream>
|
||||
class buffered_read_stream;
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_READ_STREAM_FWD_HPP
|
||||
|
504
src/3rdparty/include/boost/asio/buffered_stream.hpp
vendored
504
src/3rdparty/include/boost/asio/buffered_stream.hpp
vendored
@ -1,252 +1,252 @@
|
||||
//
|
||||
// buffered_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 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_BUFFERED_STREAM_HPP
|
||||
#define BOOST_ASIO_BUFFERED_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffered_read_stream.hpp>
|
||||
#include <boost/asio/buffered_write_stream.hpp>
|
||||
#include <boost/asio/buffered_stream_fwd.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Adds buffering to the read- and write-related operations of a stream.
|
||||
/**
|
||||
* The buffered_stream class template can be used to add buffering to the
|
||||
* synchronous and asynchronous read and write operations of a stream.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Stream>
|
||||
class buffered_stream
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the next layer.
|
||||
typedef typename boost::remove_reference<Stream>::type next_layer_type;
|
||||
|
||||
/// The type of the lowest layer.
|
||||
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_stream(Arg& a)
|
||||
: inner_stream_impl_(a),
|
||||
stream_impl_(inner_stream_impl_)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_stream(Arg& a, std::size_t read_buffer_size,
|
||||
std::size_t write_buffer_size)
|
||||
: inner_stream_impl_(a, write_buffer_size),
|
||||
stream_impl_(inner_stream_impl_, read_buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Get a reference to the next layer.
|
||||
next_layer_type& next_layer()
|
||||
{
|
||||
return stream_impl_.next_layer().next_layer();
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return stream_impl_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return stream_impl_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return stream_impl_.get_io_service();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
void close()
|
||||
{
|
||||
stream_impl_.close();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.close(ec);
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation. Throws an
|
||||
/// exception on failure.
|
||||
std::size_t flush()
|
||||
{
|
||||
return stream_impl_.next_layer().flush();
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation, or 0 if an
|
||||
/// error occurred.
|
||||
std::size_t flush(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.next_layer().flush(ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous flush.
|
||||
template <typename WriteHandler>
|
||||
void async_flush(WriteHandler handler)
|
||||
{
|
||||
return stream_impl_.next_layer().async_flush(handler);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written.
|
||||
/// Throws an exception on failure.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
return stream_impl_.write_some(buffers);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.write_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write. The data being written must be valid for the
|
||||
/// lifetime of the asynchronous operation.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
{
|
||||
stream_impl_.async_write_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation. Throws an exception on failure.
|
||||
std::size_t fill()
|
||||
{
|
||||
return stream_impl_.fill();
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation, or 0 if an error occurred.
|
||||
std::size_t fill(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.fill(ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous fill.
|
||||
template <typename ReadHandler>
|
||||
void async_fill(ReadHandler handler)
|
||||
{
|
||||
stream_impl_.async_fill(handler);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read. Throws
|
||||
/// an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return stream_impl_.read_some(buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read or 0 if
|
||||
/// an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.read_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read. The buffer into which the data will be read
|
||||
/// must be valid for the lifetime of the asynchronous operation.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
{
|
||||
stream_impl_.async_read_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read.
|
||||
/// Throws an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return stream_impl_.peek(buffers);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.peek(buffers, ec);
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail()
|
||||
{
|
||||
return stream_impl_.in_avail();
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.in_avail(ec);
|
||||
}
|
||||
|
||||
private:
|
||||
// The buffered write stream.
|
||||
typedef buffered_write_stream<Stream> write_stream_type;
|
||||
write_stream_type inner_stream_impl_;
|
||||
|
||||
// The buffered read stream.
|
||||
typedef buffered_read_stream<write_stream_type&> read_stream_type;
|
||||
read_stream_type stream_impl_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_STREAM_HPP
|
||||
//
|
||||
// buffered_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BUFFERED_STREAM_HPP
|
||||
#define BOOST_ASIO_BUFFERED_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffered_read_stream.hpp>
|
||||
#include <boost/asio/buffered_write_stream.hpp>
|
||||
#include <boost/asio/buffered_stream_fwd.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Adds buffering to the read- and write-related operations of a stream.
|
||||
/**
|
||||
* The buffered_stream class template can be used to add buffering to the
|
||||
* synchronous and asynchronous read and write operations of a stream.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Stream>
|
||||
class buffered_stream
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the next layer.
|
||||
typedef typename boost::remove_reference<Stream>::type next_layer_type;
|
||||
|
||||
/// The type of the lowest layer.
|
||||
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_stream(Arg& a)
|
||||
: inner_stream_impl_(a),
|
||||
stream_impl_(inner_stream_impl_)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_stream(Arg& a, std::size_t read_buffer_size,
|
||||
std::size_t write_buffer_size)
|
||||
: inner_stream_impl_(a, write_buffer_size),
|
||||
stream_impl_(inner_stream_impl_, read_buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Get a reference to the next layer.
|
||||
next_layer_type& next_layer()
|
||||
{
|
||||
return stream_impl_.next_layer().next_layer();
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return stream_impl_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return stream_impl_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return stream_impl_.get_io_service();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
void close()
|
||||
{
|
||||
stream_impl_.close();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.close(ec);
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation. Throws an
|
||||
/// exception on failure.
|
||||
std::size_t flush()
|
||||
{
|
||||
return stream_impl_.next_layer().flush();
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation, or 0 if an
|
||||
/// error occurred.
|
||||
std::size_t flush(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.next_layer().flush(ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous flush.
|
||||
template <typename WriteHandler>
|
||||
void async_flush(WriteHandler handler)
|
||||
{
|
||||
return stream_impl_.next_layer().async_flush(handler);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written.
|
||||
/// Throws an exception on failure.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
return stream_impl_.write_some(buffers);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.write_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous write. The data being written must be valid for the
|
||||
/// lifetime of the asynchronous operation.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
{
|
||||
stream_impl_.async_write_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation. Throws an exception on failure.
|
||||
std::size_t fill()
|
||||
{
|
||||
return stream_impl_.fill();
|
||||
}
|
||||
|
||||
/// Fill the buffer with some data. Returns the number of bytes placed in the
|
||||
/// buffer as a result of the operation, or 0 if an error occurred.
|
||||
std::size_t fill(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.fill(ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous fill.
|
||||
template <typename ReadHandler>
|
||||
void async_fill(ReadHandler handler)
|
||||
{
|
||||
stream_impl_.async_fill(handler);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read. Throws
|
||||
/// an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return stream_impl_.read_some(buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read or 0 if
|
||||
/// an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.read_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read. The buffer into which the data will be read
|
||||
/// must be valid for the lifetime of the asynchronous operation.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
{
|
||||
stream_impl_.async_read_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read.
|
||||
/// Throws an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return stream_impl_.peek(buffers);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.peek(buffers, ec);
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail()
|
||||
{
|
||||
return stream_impl_.in_avail();
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail(boost::system::error_code& ec)
|
||||
{
|
||||
return stream_impl_.in_avail(ec);
|
||||
}
|
||||
|
||||
private:
|
||||
// The buffered write stream.
|
||||
typedef buffered_write_stream<Stream> write_stream_type;
|
||||
write_stream_type inner_stream_impl_;
|
||||
|
||||
// The buffered read stream.
|
||||
typedef buffered_read_stream<write_stream_type&> read_stream_type;
|
||||
read_stream_type stream_impl_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_STREAM_HPP
|
||||
|
@ -1,31 +1,31 @@
|
||||
//
|
||||
// buffered_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 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_BUFFERED_STREAM_FWD_HPP
|
||||
#define BOOST_ASIO_BUFFERED_STREAM_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Stream>
|
||||
class buffered_stream;
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_STREAM_FWD_HPP
|
||||
//
|
||||
// buffered_stream_fwd.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BUFFERED_STREAM_FWD_HPP
|
||||
#define BOOST_ASIO_BUFFERED_STREAM_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
template <typename Stream>
|
||||
class buffered_stream;
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_STREAM_FWD_HPP
|
||||
|
@ -1,370 +1,370 @@
|
||||
//
|
||||
// buffered_write_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2007 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_BUFFERED_WRITE_STREAM_HPP
|
||||
#define BOOST_ASIO_BUFFERED_WRITE_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffered_write_stream_fwd.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/completion_condition.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <boost/asio/detail/bind_handler.hpp>
|
||||
#include <boost/asio/detail/buffered_stream_storage.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Adds buffering to the write-related operations of a stream.
|
||||
/**
|
||||
* The buffered_write_stream class template can be used to add buffering to the
|
||||
* synchronous and asynchronous write operations of a stream.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Stream>
|
||||
class buffered_write_stream
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the next layer.
|
||||
typedef typename boost::remove_reference<Stream>::type next_layer_type;
|
||||
|
||||
/// The type of the lowest layer.
|
||||
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The default buffer size.
|
||||
static const std::size_t default_buffer_size = implementation_defined;
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
|
||||
#endif
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_write_stream(Arg& a)
|
||||
: next_layer_(a),
|
||||
storage_(default_buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
buffered_write_stream(Arg& a, std::size_t buffer_size)
|
||||
: next_layer_(a),
|
||||
storage_(buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Get a reference to the next layer.
|
||||
next_layer_type& next_layer()
|
||||
{
|
||||
return next_layer_;
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
void close()
|
||||
{
|
||||
next_layer_.close();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.close(ec);
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation. Throws an
|
||||
/// exception on failure.
|
||||
std::size_t flush()
|
||||
{
|
||||
std::size_t bytes_written = write(next_layer_,
|
||||
buffer(storage_.data(), storage_.size()));
|
||||
storage_.consume(bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation, or 0 if an
|
||||
/// error occurred.
|
||||
std::size_t flush(boost::system::error_code& ec)
|
||||
{
|
||||
std::size_t bytes_written = write(next_layer_,
|
||||
buffer(storage_.data(), storage_.size()),
|
||||
transfer_all(), ec);
|
||||
storage_.consume(bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
template <typename WriteHandler>
|
||||
class flush_handler
|
||||
{
|
||||
public:
|
||||
flush_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage, WriteHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec,
|
||||
std::size_t bytes_written)
|
||||
{
|
||||
storage_.consume(bytes_written);
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_written));
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous flush.
|
||||
template <typename WriteHandler>
|
||||
void async_flush(WriteHandler handler)
|
||||
{
|
||||
async_write(next_layer_, buffer(storage_.data(), storage_.size()),
|
||||
flush_handler<WriteHandler>(get_io_service(), storage_, handler));
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written.
|
||||
/// Throws an exception on failure.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
if (storage_.size() == storage_.capacity())
|
||||
flush();
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written,
|
||||
/// or 0 if an error occurred and the error handler did not throw.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
if (storage_.size() == storage_.capacity() && !flush(ec))
|
||||
return 0;
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
class write_some_handler
|
||||
{
|
||||
public:
|
||||
write_some_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage,
|
||||
const ConstBufferSequence& buffers, WriteHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec, std::size_t)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
std::size_t length = 0;
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, length));
|
||||
}
|
||||
else
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename ConstBufferSequence::const_iterator iter = buffers_.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers_.end();
|
||||
for (; iter != end && space_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t bytes_avail = buffer_size(*iter);
|
||||
std::size_t length = (bytes_avail < space_avail)
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + bytes_copied + length);
|
||||
memcpy(storage_.data() + orig_size + bytes_copied,
|
||||
buffer_cast<const void*>(*iter), length);
|
||||
bytes_copied += length;
|
||||
space_avail -= length;
|
||||
}
|
||||
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
ConstBufferSequence buffers_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous write. The data being written must be valid for the
|
||||
/// lifetime of the asynchronous operation.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
{
|
||||
if (storage_.size() == storage_.capacity())
|
||||
{
|
||||
async_flush(write_some_handler<ConstBufferSequence, WriteHandler>(
|
||||
get_io_service(), storage_, buffers, handler));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::size_t bytes_copied = copy(buffers);
|
||||
get_io_service().post(detail::bind_handler(
|
||||
handler, boost::system::error_code(), bytes_copied));
|
||||
}
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read. Throws
|
||||
/// an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return next_layer_.read_some(buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read or 0 if
|
||||
/// an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.read_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read. The buffer into which the data will be read
|
||||
/// must be valid for the lifetime of the asynchronous operation.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
{
|
||||
next_layer_.async_read_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read.
|
||||
/// Throws an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return next_layer_.peek(buffers);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.peek(buffers, ec);
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail()
|
||||
{
|
||||
return next_layer_.in_avail();
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail(boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.in_avail(ec);
|
||||
}
|
||||
|
||||
private:
|
||||
/// Copy data into the internal buffer from the specified source buffer.
|
||||
/// Returns the number of bytes copied.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t copy(const ConstBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename ConstBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && space_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t bytes_avail = buffer_size(*iter);
|
||||
std::size_t length = (bytes_avail < space_avail)
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + bytes_copied + length);
|
||||
memcpy(storage_.data() + orig_size + bytes_copied,
|
||||
buffer_cast<const void*>(*iter), length);
|
||||
bytes_copied += length;
|
||||
space_avail -= length;
|
||||
}
|
||||
|
||||
return bytes_copied;
|
||||
}
|
||||
|
||||
/// The next layer.
|
||||
Stream next_layer_;
|
||||
|
||||
// The data in the buffer.
|
||||
detail::buffered_stream_storage storage_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_WRITE_STREAM_HPP
|
||||
//
|
||||
// buffered_write_stream.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_BUFFERED_WRITE_STREAM_HPP
|
||||
#define BOOST_ASIO_BUFFERED_WRITE_STREAM_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#include <boost/asio/buffered_write_stream_fwd.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/completion_condition.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <boost/asio/detail/bind_handler.hpp>
|
||||
#include <boost/asio/detail/buffered_stream_storage.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
/// Adds buffering to the write-related operations of a stream.
|
||||
/**
|
||||
* The buffered_write_stream class template can be used to add buffering to the
|
||||
* synchronous and asynchronous write operations of a stream.
|
||||
*
|
||||
* @par Thread Safety
|
||||
* @e Distinct @e objects: Safe.@n
|
||||
* @e Shared @e objects: Unsafe.
|
||||
*
|
||||
* @par Concepts:
|
||||
* AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
|
||||
*/
|
||||
template <typename Stream>
|
||||
class buffered_write_stream
|
||||
: private noncopyable
|
||||
{
|
||||
public:
|
||||
/// The type of the next layer.
|
||||
typedef typename boost::remove_reference<Stream>::type next_layer_type;
|
||||
|
||||
/// The type of the lowest layer.
|
||||
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
|
||||
|
||||
#if defined(GENERATING_DOCUMENTATION)
|
||||
/// The default buffer size.
|
||||
static const std::size_t default_buffer_size = implementation_defined;
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
|
||||
#endif
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
explicit buffered_write_stream(Arg& a)
|
||||
: next_layer_(a),
|
||||
storage_(default_buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct, passing the specified argument to initialise the next layer.
|
||||
template <typename Arg>
|
||||
buffered_write_stream(Arg& a, std::size_t buffer_size)
|
||||
: next_layer_(a),
|
||||
storage_(buffer_size)
|
||||
{
|
||||
}
|
||||
|
||||
/// Get a reference to the next layer.
|
||||
next_layer_type& next_layer()
|
||||
{
|
||||
return next_layer_;
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
lowest_layer_type& lowest_layer()
|
||||
{
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// (Deprecated: use get_io_service().) Get the io_service associated with
|
||||
/// the object.
|
||||
boost::asio::io_service& io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Get the io_service associated with the object.
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return next_layer_.get_io_service();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
void close()
|
||||
{
|
||||
next_layer_.close();
|
||||
}
|
||||
|
||||
/// Close the stream.
|
||||
boost::system::error_code close(boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.close(ec);
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation. Throws an
|
||||
/// exception on failure.
|
||||
std::size_t flush()
|
||||
{
|
||||
std::size_t bytes_written = write(next_layer_,
|
||||
buffer(storage_.data(), storage_.size()));
|
||||
storage_.consume(bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
/// Flush all data from the buffer to the next layer. Returns the number of
|
||||
/// bytes written to the next layer on the last write operation, or 0 if an
|
||||
/// error occurred.
|
||||
std::size_t flush(boost::system::error_code& ec)
|
||||
{
|
||||
std::size_t bytes_written = write(next_layer_,
|
||||
buffer(storage_.data(), storage_.size()),
|
||||
transfer_all(), ec);
|
||||
storage_.consume(bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
template <typename WriteHandler>
|
||||
class flush_handler
|
||||
{
|
||||
public:
|
||||
flush_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage, WriteHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec,
|
||||
std::size_t bytes_written)
|
||||
{
|
||||
storage_.consume(bytes_written);
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_written));
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous flush.
|
||||
template <typename WriteHandler>
|
||||
void async_flush(WriteHandler handler)
|
||||
{
|
||||
async_write(next_layer_, buffer(storage_.data(), storage_.size()),
|
||||
flush_handler<WriteHandler>(get_io_service(), storage_, handler));
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written.
|
||||
/// Throws an exception on failure.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers)
|
||||
{
|
||||
if (storage_.size() == storage_.capacity())
|
||||
flush();
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
/// Write the given data to the stream. Returns the number of bytes written,
|
||||
/// or 0 if an error occurred and the error handler did not throw.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
if (storage_.size() == storage_.capacity() && !flush(ec))
|
||||
return 0;
|
||||
return copy(buffers);
|
||||
}
|
||||
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
class write_some_handler
|
||||
{
|
||||
public:
|
||||
write_some_handler(boost::asio::io_service& io_service,
|
||||
detail::buffered_stream_storage& storage,
|
||||
const ConstBufferSequence& buffers, WriteHandler handler)
|
||||
: io_service_(io_service),
|
||||
storage_(storage),
|
||||
buffers_(buffers),
|
||||
handler_(handler)
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const boost::system::error_code& ec, std::size_t)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
std::size_t length = 0;
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, length));
|
||||
}
|
||||
else
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename ConstBufferSequence::const_iterator iter = buffers_.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers_.end();
|
||||
for (; iter != end && space_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t bytes_avail = buffer_size(*iter);
|
||||
std::size_t length = (bytes_avail < space_avail)
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + bytes_copied + length);
|
||||
memcpy(storage_.data() + orig_size + bytes_copied,
|
||||
buffer_cast<const void*>(*iter), length);
|
||||
bytes_copied += length;
|
||||
space_avail -= length;
|
||||
}
|
||||
|
||||
io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
boost::asio::io_service& io_service_;
|
||||
detail::buffered_stream_storage& storage_;
|
||||
ConstBufferSequence buffers_;
|
||||
WriteHandler handler_;
|
||||
};
|
||||
|
||||
/// Start an asynchronous write. The data being written must be valid for the
|
||||
/// lifetime of the asynchronous operation.
|
||||
template <typename ConstBufferSequence, typename WriteHandler>
|
||||
void async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteHandler handler)
|
||||
{
|
||||
if (storage_.size() == storage_.capacity())
|
||||
{
|
||||
async_flush(write_some_handler<ConstBufferSequence, WriteHandler>(
|
||||
get_io_service(), storage_, buffers, handler));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::size_t bytes_copied = copy(buffers);
|
||||
get_io_service().post(detail::bind_handler(
|
||||
handler, boost::system::error_code(), bytes_copied));
|
||||
}
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read. Throws
|
||||
/// an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return next_layer_.read_some(buffers);
|
||||
}
|
||||
|
||||
/// Read some data from the stream. Returns the number of bytes read or 0 if
|
||||
/// an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.read_some(buffers, ec);
|
||||
}
|
||||
|
||||
/// Start an asynchronous read. The buffer into which the data will be read
|
||||
/// must be valid for the lifetime of the asynchronous operation.
|
||||
template <typename MutableBufferSequence, typename ReadHandler>
|
||||
void async_read_some(const MutableBufferSequence& buffers,
|
||||
ReadHandler handler)
|
||||
{
|
||||
next_layer_.async_read_some(buffers, handler);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read.
|
||||
/// Throws an exception on failure.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers)
|
||||
{
|
||||
return next_layer_.peek(buffers);
|
||||
}
|
||||
|
||||
/// Peek at the incoming data on the stream. Returns the number of bytes read,
|
||||
/// or 0 if an error occurred.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t peek(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.peek(buffers, ec);
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail()
|
||||
{
|
||||
return next_layer_.in_avail();
|
||||
}
|
||||
|
||||
/// Determine the amount of data that may be read without blocking.
|
||||
std::size_t in_avail(boost::system::error_code& ec)
|
||||
{
|
||||
return next_layer_.in_avail(ec);
|
||||
}
|
||||
|
||||
private:
|
||||
/// Copy data into the internal buffer from the specified source buffer.
|
||||
/// Returns the number of bytes copied.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t copy(const ConstBufferSequence& buffers)
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
|
||||
std::size_t orig_size = storage_.size();
|
||||
std::size_t space_avail = storage_.capacity() - orig_size;
|
||||
std::size_t bytes_copied = 0;
|
||||
|
||||
typename ConstBufferSequence::const_iterator iter = buffers.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers.end();
|
||||
for (; iter != end && space_avail > 0; ++iter)
|
||||
{
|
||||
std::size_t bytes_avail = buffer_size(*iter);
|
||||
std::size_t length = (bytes_avail < space_avail)
|
||||
? bytes_avail : space_avail;
|
||||
storage_.resize(orig_size + bytes_copied + length);
|
||||
memcpy(storage_.data() + orig_size + bytes_copied,
|
||||
buffer_cast<const void*>(*iter), length);
|
||||
bytes_copied += length;
|
||||
space_avail -= length;
|
||||
}
|
||||
|
||||
return bytes_copied;
|
||||
}
|
||||
|
||||
/// The next layer.
|
||||
Stream next_layer_;
|
||||
|
||||
// The data in the buffer.
|
||||
detail::buffered_stream_storage storage_;
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_BUFFERED_WRITE_STREAM_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