mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Reorganize some MPL and Utility classes and files
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
<ClInclude Include="..\..\beast\MPL.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\AddConst.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\IfCond.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\IsCallPossible.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\PointerToOther.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\RemoveConst.h" />
|
||||
<ClInclude Include="..\..\beast\mpl\RemoveConstVolatile.h" />
|
||||
@@ -89,7 +90,9 @@
|
||||
<ClInclude Include="..\..\beast\type_traits\IsIntegral.h" />
|
||||
<ClInclude Include="..\..\beast\type_traits\IsSigned.h" />
|
||||
<ClInclude Include="..\..\beast\type_traits\RemoveSigned.h" />
|
||||
<ClInclude Include="..\..\beast\Utility.h" />
|
||||
<ClInclude Include="..\..\beast\utility\EnableIf.h" />
|
||||
<ClInclude Include="..\..\beast\utility\Journal.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\async\ComposedAsyncOperation.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandler.h" />
|
||||
<ClInclude Include="..\..\modules\beast_asio\async\SharedHandlerAllocator.h" />
|
||||
@@ -165,7 +168,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\Debug.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\Error.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\FatalError.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\Journal.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\ProtectedCall.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\FPUFlags.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\LeakChecked.h" />
|
||||
@@ -367,10 +369,14 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\net\Net.cpp">
|
||||
<ClCompile Include="..\..\beast\net\Net.cpp" />
|
||||
<ClCompile Include="..\..\beast\utility\impl\Journal.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\utility\Utility.cpp" />
|
||||
<ClCompile Include="..\..\modules\beast_asio\async\SharedHandler.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -597,12 +603,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\diagnostic\Journal.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\diagnostic\ProtectedCall.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -201,6 +201,9 @@
|
||||
<Filter Include="beast\utility">
|
||||
<UniqueIdentifier>{56d34c67-7027-44ba-9f09-4591ce4afb36}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\utility\impl">
|
||||
<UniqueIdentifier>{775ab0d6-aa5f-43d7-ab3b-3c01652a9ef1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\modules\beast_core\beast_core.h">
|
||||
@@ -1020,9 +1023,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\StaticObject.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\diagnostic\Journal.h">
|
||||
<Filter>beast_core\diagnostic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_crypto\math\UnsignedInteger.h">
|
||||
<Filter>beast_crypto\math</Filter>
|
||||
</ClInclude>
|
||||
@@ -1071,6 +1071,15 @@
|
||||
<ClInclude Include="..\..\beast\StaticAssert.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\utility\Journal.h">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\Utility.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\mpl\IsCallPossible.h">
|
||||
<Filter>beast\mpl</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
||||
@@ -1577,9 +1586,6 @@
|
||||
<ClCompile Include="..\..\modules\beast_core\diagnostic\Assert.cpp">
|
||||
<Filter>beast_core\diagnostic</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_core\diagnostic\Journal.cpp">
|
||||
<Filter>beast_core\diagnostic</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\beast_crypto\math\UnsignedInteger.cpp">
|
||||
<Filter>beast_crypto\math</Filter>
|
||||
</ClCompile>
|
||||
@@ -1595,6 +1601,12 @@
|
||||
<ClCompile Include="..\..\beast\net\Net.cpp">
|
||||
<Filter>beast\net</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\utility\Utility.cpp">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\beast\utility\impl\Journal.cpp">
|
||||
<Filter>beast\utility\impl</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\TODO.txt">
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "mpl/AddConst.h"
|
||||
#include "mpl/IfCond.h"
|
||||
#include "mpl/IsCallPossible.h"
|
||||
#include "mpl/PointerToOther.h"
|
||||
#include "mpl/RemoveConst.h"
|
||||
#include "mpl/RemoveConstVolatile.h"
|
||||
|
||||
27
beast/Utility.h
Normal file
27
beast/Utility.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_UTILITY_H_INCLUDED
|
||||
#define BEAST_UTILITY_H_INCLUDED
|
||||
|
||||
#include "utility/EnableIf.h"
|
||||
#include "utility/Journal.h"
|
||||
|
||||
#endif
|
||||
|
||||
270
beast/mpl/IsCallPossible.h
Normal file
270
beast/mpl/IsCallPossible.h
Normal file
@@ -0,0 +1,270 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_MPL_ISCALLPOSSIBLE_H_INCLUDED
|
||||
#define BEAST_MPL_ISCALLPOSSIBLE_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
namespace mpl {
|
||||
|
||||
// inspired by Roman Perepelitsa's presentation from comp.lang.c++.moderated
|
||||
// based on the implementation here: http://www.rsdn.ru/forum/cpp/2759773.1.aspx
|
||||
//
|
||||
namespace is_call_possible_detail
|
||||
{
|
||||
template<typename T>
|
||||
struct add_reference
|
||||
{
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct add_reference<T&>
|
||||
{
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
template <typename T> class void_exp_result {};
|
||||
|
||||
template <typename T, typename U>
|
||||
U const& operator,(U const&, void_exp_result<T>);
|
||||
|
||||
template <typename T, typename U>
|
||||
U& operator,(U&, void_exp_result<T>);
|
||||
|
||||
template <typename src_type, typename dest_type>
|
||||
struct clone_constness
|
||||
{
|
||||
typedef dest_type type;
|
||||
};
|
||||
|
||||
template <typename src_type, typename dest_type>
|
||||
struct clone_constness<const src_type, dest_type>
|
||||
{
|
||||
typedef const dest_type type;
|
||||
};
|
||||
}
|
||||
|
||||
#define BEAST_DEFINE_HAS_MEMBER_FUNCTION(trait_name, member_function_name) \
|
||||
template<typename T, typename Signature> class trait_name; \
|
||||
\
|
||||
template<typename T, typename Result> \
|
||||
class trait_name<T, Result(void)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg> \
|
||||
class trait_name<T, Result(Arg)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg1, typename Arg2> \
|
||||
class trait_name<T, Result(Arg1,Arg2)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg1,Arg2); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg1,Arg2), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg1, typename Arg2, typename Arg3> \
|
||||
class trait_name<T, Result(Arg1,Arg2,Arg3)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg1,Arg2,Arg3); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg1,Arg2,Arg3), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg1, typename Arg2, typename Arg3, typename Arg4> \
|
||||
class trait_name<T, Result(Arg1,Arg2,Arg3,Arg4)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg1,Arg2,Arg3,Arg4); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg1,Arg2,Arg3,Arg4), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}
|
||||
|
||||
#define BEAST_DEFINE_IS_CALL_POSSIBLE(trait_name, member_function_name) \
|
||||
struct trait_name##_detail \
|
||||
{ \
|
||||
BEAST_DEFINE_HAS_MEMBER_FUNCTION(has_member, member_function_name); \
|
||||
}; \
|
||||
\
|
||||
template <typename T, typename Signature> \
|
||||
struct trait_name \
|
||||
{ \
|
||||
private: \
|
||||
class yes {}; \
|
||||
class no { yes m[2]; }; \
|
||||
struct derived : public T \
|
||||
{ \
|
||||
using T::member_function_name; \
|
||||
no member_function_name(...) const; \
|
||||
private: derived (); \
|
||||
}; \
|
||||
\
|
||||
typedef typename beast::mpl::is_call_possible_detail::clone_constness<T, derived>::type derived_type; \
|
||||
\
|
||||
template <typename U, typename Result> \
|
||||
struct return_value_check \
|
||||
{ \
|
||||
static yes deduce(Result); \
|
||||
static no deduce(...); \
|
||||
static no deduce(no); \
|
||||
static no deduce(beast::mpl::is_call_possible_detail::void_exp_result<T>); \
|
||||
}; \
|
||||
\
|
||||
template <typename U> \
|
||||
struct return_value_check<U, void> \
|
||||
{ \
|
||||
static yes deduce(...); \
|
||||
static no deduce(no); \
|
||||
}; \
|
||||
\
|
||||
template <bool has_the_member_of_interest, typename F> \
|
||||
struct impl \
|
||||
{ \
|
||||
static const bool value = false; \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg> \
|
||||
struct impl<true, Result(Arg)> \
|
||||
{ \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg>::type arg; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg), beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg1, typename Arg2> \
|
||||
struct impl<true, Result(Arg1,Arg2)> \
|
||||
{ \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg1>::type arg1; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg2>::type arg2; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg1,arg2), beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg1, typename Arg2, typename Arg3> \
|
||||
struct impl<true, Result(Arg1,Arg2,Arg3)> \
|
||||
{ \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg1>::type arg1; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg2>::type arg2; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg3>::type arg3; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg1,arg2,arg3), beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg1, typename Arg2, typename Arg3, typename Arg4> \
|
||||
struct impl<true, Result(Arg1,Arg2,Arg3,Arg4)> \
|
||||
{ \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg1>::type arg1; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg2>::type arg2; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg3>::type arg3; \
|
||||
static typename beast::mpl::is_call_possible_detail::add_reference<Arg4>::type arg4; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg1,arg2,arg3,arg4), \
|
||||
beast::mpl::is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
public: \
|
||||
static const bool value = impl<trait_name##_detail::has_member<T,Signature>::value, Signature>::value; \
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
#include "../CStdInt.h"
|
||||
#include "../mpl/IfCond.h"
|
||||
|
||||
namespace beast
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "../../modules/beast_core/beast_core.h"
|
||||
#include "../../modules/beast_core/beast_core.h" // for UnitTest
|
||||
|
||||
#include "../Config.h"
|
||||
|
||||
#include "impl/IPEndpoint.cpp"
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace beast
|
||||
{
|
||||
|
||||
template <bool Enable, class T = void>
|
||||
struct EnableIfBool : FalseType { typedef T type; };
|
||||
struct EnableIfBool : TrueType { typedef T type; };
|
||||
|
||||
template <class T>
|
||||
struct EnableIfBool <false, T> { };
|
||||
struct EnableIfBool <false, T> : FalseType { };
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct EnableIf : public EnableIfBool <Cond::value, T> { };
|
||||
|
||||
@@ -17,8 +17,13 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_CORE_JOURNAL_H_INCLUDED
|
||||
#define BEAST_CORE_JOURNAL_H_INCLUDED
|
||||
#ifndef BEAST_UTILITY_JOURNAL_H_INCLUDED
|
||||
#define BEAST_UTILITY_JOURNAL_H_INCLUDED
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
/** A generic endpoint for log messages. */
|
||||
class Journal
|
||||
@@ -158,4 +163,6 @@ private:
|
||||
Journal& operator= (Journal const& other); // disallowed
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
24
beast/utility/Utility.cpp
Normal file
24
beast/utility/Utility.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "../../modules/beast_core/beast_core.h"
|
||||
|
||||
#include "impl/Journal.cpp"
|
||||
@@ -17,6 +17,11 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../Journal.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
bool Journal::Sink::active (Severity)
|
||||
{
|
||||
return true;
|
||||
@@ -181,3 +186,4 @@ bool Journal::active (Severity severity) const
|
||||
return m_sink->active (severity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,6 +53,9 @@
|
||||
# define BEAST_SOCKET_VIRTUAL
|
||||
#endif
|
||||
|
||||
#include "../../beast/MPL.h"
|
||||
#include "../../beast/Utility.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
|
||||
@@ -51,12 +51,6 @@ namespace detail
|
||||
|
||||
namespace SocketWrapperMemberChecks
|
||||
{
|
||||
template <bool Enable>
|
||||
struct EnableIf : boost::false_type { };
|
||||
|
||||
template <>
|
||||
struct EnableIf <true> : boost::true_type { };
|
||||
|
||||
BEAST_DEFINE_IS_CALL_POSSIBLE(has_get_io_service, get_io_service);
|
||||
|
||||
BEAST_DEFINE_IS_CALL_POSSIBLE(has_lowest_layer, lowest_layer);
|
||||
@@ -133,6 +127,12 @@ class SocketWrapper
|
||||
, public Uncopyable
|
||||
{
|
||||
public:
|
||||
// Converts a static bool constexpr member named 'value' into
|
||||
// an IntegralConstant for SFINAE overload resolution.
|
||||
//
|
||||
template <class Cond>
|
||||
struct Enabled : public IntegralConstant <bool, Cond::value> { };
|
||||
|
||||
template <typename Arg>
|
||||
explicit SocketWrapper (Arg& arg)
|
||||
: m_object (arg)
|
||||
@@ -232,11 +232,11 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return native_handle (type_name, dest,
|
||||
EnableIf <has_type_native_handle_type <this_layer_type>::value> ());
|
||||
Enabled <has_type_native_handle_type <this_layer_type> > ());
|
||||
}
|
||||
|
||||
bool native_handle (char const* type_name, void* dest,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
char const* const name (typeid (typename this_layer_type::native_handle_type).name ());
|
||||
if (strcmp (name, type_name) == 0)
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
}
|
||||
|
||||
bool native_handle (char const*, void*,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
pure_virtual_called (__FILE__, __LINE__);
|
||||
return false;
|
||||
@@ -266,21 +266,21 @@ public:
|
||||
// Apparently has_get_io_service always results in false
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return get_io_service (
|
||||
EnableIf <has_get_io_service <this_layer_type,
|
||||
boost::asio::io_service&()>::value> ());
|
||||
Enabled <has_get_io_service <this_layer_type,
|
||||
boost::asio::io_service&()> > ());
|
||||
#else
|
||||
return get_io_service (boost::true_type ());
|
||||
return get_io_service (TrueType ());
|
||||
#endif
|
||||
}
|
||||
|
||||
boost::asio::io_service& get_io_service (
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.get_io_service ();
|
||||
}
|
||||
|
||||
boost::asio::io_service& get_io_service (
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
pure_virtual_called (__FILE__, __LINE__);
|
||||
return *static_cast <boost::asio::io_service*>(nullptr);
|
||||
@@ -334,11 +334,11 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return lowest_layer_ptr (type_name,
|
||||
EnableIf <has_type_lowest_layer_type <this_layer_type>::value> ());
|
||||
Enabled <has_type_lowest_layer_type <this_layer_type> > ());
|
||||
}
|
||||
|
||||
void* lowest_layer_ptr (char const* type_name,
|
||||
boost::true_type) const
|
||||
TrueType) const
|
||||
{
|
||||
char const* const name (typeid (typename this_layer_type::lowest_layer_type).name ());
|
||||
if (strcmp (name, type_name) == 0)
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
}
|
||||
|
||||
void* lowest_layer_ptr (char const*,
|
||||
boost::false_type) const
|
||||
FalseType) const
|
||||
{
|
||||
pure_virtual_called (__FILE__, __LINE__);
|
||||
return nullptr;
|
||||
@@ -359,18 +359,18 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return cancel (ec,
|
||||
EnableIf <has_cancel <this_layer_type,
|
||||
error_code (error_code&)>::value> ());
|
||||
Enabled <has_cancel <this_layer_type,
|
||||
error_code (error_code&)> > ());
|
||||
}
|
||||
|
||||
error_code cancel (error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.cancel (ec);
|
||||
}
|
||||
|
||||
error_code cancel (error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
return pure_virtual_error (ec, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -381,19 +381,19 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return shutdown (what, ec,
|
||||
EnableIf <has_shutdown <this_layer_type,
|
||||
error_code (shutdown_type, error_code&)>::value> ());
|
||||
Enabled <has_shutdown <this_layer_type,
|
||||
error_code (shutdown_type, error_code&)> > ());
|
||||
}
|
||||
|
||||
|
||||
error_code shutdown (shutdown_type what, error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.shutdown (what, ec);
|
||||
}
|
||||
|
||||
error_code shutdown (shutdown_type, error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
return pure_virtual_error (ec, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -404,18 +404,18 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return close (ec,
|
||||
EnableIf <has_close <this_layer_type,
|
||||
error_code (error_code&)>::value> ());
|
||||
Enabled <has_close <this_layer_type,
|
||||
error_code (error_code&)> > ());
|
||||
}
|
||||
|
||||
error_code close (error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.close (ec);
|
||||
}
|
||||
|
||||
error_code close (error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
return pure_virtual_error (ec, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -430,12 +430,12 @@ public:
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
typedef typename native_socket <this_layer_type>::socket_type socket_type;
|
||||
return accept (peer, ec,
|
||||
EnableIf <has_accept <this_layer_type,
|
||||
error_code (socket_type&, error_code&)>::value> ());
|
||||
Enabled <has_accept <this_layer_type,
|
||||
error_code (socket_type&, error_code&)> > ());
|
||||
}
|
||||
|
||||
error_code accept (Socket& peer, error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return m_object.accept (
|
||||
@@ -443,7 +443,7 @@ public:
|
||||
}
|
||||
|
||||
error_code accept (Socket&, error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
return pure_virtual_error (ec, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -455,12 +455,12 @@ public:
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
typedef typename native_socket <this_layer_type>::socket_type socket_type;
|
||||
async_accept (peer, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler),
|
||||
EnableIf <has_async_accept <this_layer_type,
|
||||
void (socket_type&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))>::value> ());
|
||||
Enabled <has_async_accept <this_layer_type,
|
||||
void (socket_type&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))> > ());
|
||||
}
|
||||
|
||||
void async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
m_object.async_accept (
|
||||
@@ -469,7 +469,7 @@ public:
|
||||
}
|
||||
|
||||
void async_accept (Socket&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
get_io_service ().wrap (
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler))
|
||||
@@ -485,20 +485,20 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return read_some (buffers, ec,
|
||||
EnableIf <has_read_some <this_layer_type,
|
||||
std::size_t (MutableBuffers const&, error_code&)>::value> ());
|
||||
Enabled <has_read_some <this_layer_type,
|
||||
std::size_t (MutableBuffers const&, error_code&)> > ());
|
||||
}
|
||||
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some (MutableBufferSequence const& buffers, error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.read_some (buffers, ec);
|
||||
}
|
||||
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some (MutableBufferSequence const&, error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
pure_virtual_called (__FILE__, __LINE__);
|
||||
ec = pure_virtual_error ();
|
||||
@@ -511,20 +511,20 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return write_some (buffers, ec,
|
||||
EnableIf <has_write_some <this_layer_type,
|
||||
std::size_t (ConstBuffers const&, error_code&)>::value> ());
|
||||
Enabled <has_write_some <this_layer_type,
|
||||
std::size_t (ConstBuffers const&, error_code&)> > ());
|
||||
}
|
||||
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some (ConstBufferSequence const& buffers, error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.write_some (buffers, ec);
|
||||
}
|
||||
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some (ConstBufferSequence const&, error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
pure_virtual_called (__FILE__, __LINE__);
|
||||
ec = pure_virtual_error ();
|
||||
@@ -537,13 +537,13 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
async_read_some (buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler),
|
||||
EnableIf <has_async_read_some <this_layer_type,
|
||||
void (MutableBuffers const&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))>::value> ());
|
||||
Enabled <has_async_read_some <this_layer_type,
|
||||
void (MutableBuffers const&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))> > ());
|
||||
}
|
||||
|
||||
void async_read_some (MutableBuffers const& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
m_object.async_read_some (buffers,
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler));
|
||||
@@ -551,7 +551,7 @@ public:
|
||||
|
||||
void async_read_some (MutableBuffers const&,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
get_io_service ().wrap (
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler))
|
||||
@@ -564,13 +564,13 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
async_write_some (buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler),
|
||||
EnableIf <has_async_write_some <this_layer_type,
|
||||
void (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))>::value> ());
|
||||
Enabled <has_async_write_some <this_layer_type,
|
||||
void (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))> > ());
|
||||
}
|
||||
|
||||
void async_write_some (ConstBuffers const& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
m_object.async_write_some (buffers,
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler));
|
||||
@@ -578,7 +578,7 @@ public:
|
||||
|
||||
void async_write_some (ConstBuffers const&,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
get_io_service ().wrap (
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler))
|
||||
@@ -624,11 +624,11 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return next_layer_ptr (type_name,
|
||||
EnableIf <has_type_next_layer_type <this_layer_type>::value> ());
|
||||
Enabled <has_type_next_layer_type <this_layer_type> > ());
|
||||
}
|
||||
|
||||
void* next_layer_ptr (char const* type_name,
|
||||
boost::true_type) const
|
||||
TrueType) const
|
||||
{
|
||||
char const* const name (typeid (typename this_layer_type::next_layer_type).name ());
|
||||
if (strcmp (name, type_name) == 0)
|
||||
@@ -637,7 +637,7 @@ public:
|
||||
}
|
||||
|
||||
void* next_layer_ptr (char const*,
|
||||
boost::false_type) const
|
||||
FalseType) const
|
||||
{
|
||||
pure_virtual_called (__FILE__, __LINE__);
|
||||
return nullptr;
|
||||
@@ -661,19 +661,19 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
set_verify_mode (verify_mode,
|
||||
EnableIf <has_set_verify_mode <this_layer_type,
|
||||
void (int)>::value> ());
|
||||
Enabled <has_set_verify_mode <this_layer_type,
|
||||
void (int)> > ());
|
||||
|
||||
}
|
||||
|
||||
void set_verify_mode (int verify_mode,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
m_object.set_verify_mode (verify_mode);
|
||||
}
|
||||
|
||||
void set_verify_mode (int,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
pure_virtual_called (__FILE__, __LINE__);
|
||||
}
|
||||
@@ -684,18 +684,18 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return handshake (type, ec,
|
||||
EnableIf <has_handshake <this_layer_type,
|
||||
error_code (handshake_type, error_code&)>::value> ());
|
||||
Enabled <has_handshake <this_layer_type,
|
||||
error_code (handshake_type, error_code&)> > ());
|
||||
}
|
||||
|
||||
error_code handshake (handshake_type type, error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.handshake (type, ec);
|
||||
}
|
||||
|
||||
error_code handshake (handshake_type, error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
return pure_virtual_error (ec, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -706,20 +706,20 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
async_handshake (type, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler),
|
||||
EnableIf <has_async_handshake <this_layer_type,
|
||||
void (handshake_type, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))>::value> ());
|
||||
Enabled <has_async_handshake <this_layer_type,
|
||||
void (handshake_type, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))> > ());
|
||||
}
|
||||
|
||||
void async_handshake (handshake_type type,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
m_object.async_handshake (type,
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler));
|
||||
}
|
||||
|
||||
void async_handshake (handshake_type, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
get_io_service ().wrap (
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler))
|
||||
@@ -735,19 +735,19 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return handshake (type, buffers, ec,
|
||||
EnableIf <has_handshake <this_layer_type,
|
||||
error_code (handshake_type, ConstBuffers const&, error_code&)>::value> ());
|
||||
Enabled <has_handshake <this_layer_type,
|
||||
error_code (handshake_type, ConstBuffers const&, error_code&)> > ());
|
||||
}
|
||||
|
||||
error_code handshake (handshake_type type,
|
||||
ConstBuffers const& buffers, error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.handshake (type, buffers, ec);
|
||||
}
|
||||
|
||||
error_code handshake (handshake_type, ConstBuffers const&, error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
return pure_virtual_error (ec, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -760,14 +760,14 @@ public:
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
async_handshake (type, buffers,
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler),
|
||||
EnableIf <has_async_handshake <this_layer_type,
|
||||
Enabled <has_async_handshake <this_layer_type,
|
||||
void (handshake_type, ConstBuffers const&,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))>::value> ());
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))> > ());
|
||||
}
|
||||
|
||||
void async_handshake (handshake_type type, ConstBuffers const& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
m_object.async_handshake (type, buffers,
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler));
|
||||
@@ -775,7 +775,7 @@ public:
|
||||
|
||||
void async_handshake (handshake_type, ConstBuffers const&,
|
||||
BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
get_io_service ().wrap (
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler))
|
||||
@@ -790,18 +790,18 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
return shutdown (ec,
|
||||
EnableIf <has_shutdown <this_layer_type,
|
||||
error_code (error_code&)>::value> ());
|
||||
Enabled <has_shutdown <this_layer_type,
|
||||
error_code (error_code&)> > ());
|
||||
}
|
||||
|
||||
error_code shutdown (error_code& ec,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
return m_object.shutdown (ec);
|
||||
}
|
||||
|
||||
error_code shutdown (error_code& ec,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
return pure_virtual_error (ec, __FILE__, __LINE__);
|
||||
}
|
||||
@@ -812,19 +812,19 @@ public:
|
||||
{
|
||||
using namespace detail::SocketWrapperMemberChecks;
|
||||
async_shutdown (BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler),
|
||||
EnableIf <has_async_shutdown <this_layer_type,
|
||||
void (BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))>::value> ());
|
||||
Enabled <has_async_shutdown <this_layer_type,
|
||||
void (BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))> > ());
|
||||
}
|
||||
|
||||
void async_shutdown (BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::true_type)
|
||||
TrueType)
|
||||
{
|
||||
m_object.async_shutdown (
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler));
|
||||
}
|
||||
|
||||
void async_shutdown (BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler,
|
||||
boost::false_type)
|
||||
FalseType)
|
||||
{
|
||||
get_io_service ().wrap (
|
||||
BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler))
|
||||
|
||||
@@ -147,7 +147,6 @@ namespace beast
|
||||
#include "diagnostic/SemanticVersion.cpp"
|
||||
#include "diagnostic/UnitTest.cpp"
|
||||
#include "diagnostic/UnitTestUtilities.cpp"
|
||||
#include "diagnostic/Journal.cpp"
|
||||
|
||||
#include "files/DirectoryIterator.cpp"
|
||||
#include "files/File.cpp"
|
||||
|
||||
@@ -144,7 +144,6 @@ namespace beast
|
||||
#include "text/String.h"
|
||||
#include "time/AtExitHook.h"
|
||||
#include "diagnostic/LeakChecked.h"
|
||||
#include "diagnostic/Journal.h"
|
||||
#include "time/RelativeTime.h"
|
||||
#include "time/Time.h"
|
||||
#include "memory/HeapBlock.h"
|
||||
|
||||
@@ -22,248 +22,6 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// inspired by Roman Perepelitsa's presentation from comp.lang.c++.moderated
|
||||
// based on the implementation here: http://www.rsdn.ru/forum/cpp/2759773.1.aspx
|
||||
//
|
||||
namespace is_call_possible_detail
|
||||
{
|
||||
template<typename T>
|
||||
struct add_reference
|
||||
{
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct add_reference<T&>
|
||||
{
|
||||
typedef T& type;
|
||||
};
|
||||
|
||||
template <typename T> class void_exp_result {};
|
||||
|
||||
template <typename T, typename U>
|
||||
U const& operator,(U const&, void_exp_result<T>);
|
||||
|
||||
template <typename T, typename U>
|
||||
U& operator,(U&, void_exp_result<T>);
|
||||
|
||||
template <typename src_type, typename dest_type>
|
||||
struct clone_constness
|
||||
{
|
||||
typedef dest_type type;
|
||||
};
|
||||
|
||||
template <typename src_type, typename dest_type>
|
||||
struct clone_constness<const src_type, dest_type>
|
||||
{
|
||||
typedef const dest_type type;
|
||||
};
|
||||
}
|
||||
|
||||
#define BEAST_DEFINE_HAS_MEMBER_FUNCTION(trait_name, member_function_name) \
|
||||
template<typename T, typename Signature> class trait_name; \
|
||||
\
|
||||
template<typename T, typename Result> \
|
||||
class trait_name<T, Result(void)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg> \
|
||||
class trait_name<T, Result(Arg)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg1, typename Arg2> \
|
||||
class trait_name<T, Result(Arg1,Arg2)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg1,Arg2); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg1,Arg2), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg1, typename Arg2, typename Arg3> \
|
||||
class trait_name<T, Result(Arg1,Arg2,Arg3)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg1,Arg2,Arg3); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg1,Arg2,Arg3), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}; \
|
||||
\
|
||||
template<typename T, typename Result, typename Arg1, typename Arg2, typename Arg3, typename Arg4> \
|
||||
class trait_name<T, Result(Arg1,Arg2,Arg3,Arg4)> \
|
||||
{ \
|
||||
class yes { char m; }; \
|
||||
class no { yes m[2]; }; \
|
||||
struct base_mixin \
|
||||
{ \
|
||||
Result member_function_name(Arg1,Arg2,Arg3,Arg4); \
|
||||
}; \
|
||||
struct base : public T, public base_mixin { private: base(); }; \
|
||||
template <typename U, U t> class helper{}; \
|
||||
template <typename U> \
|
||||
static no deduce(U*, helper<Result (base_mixin::*)(Arg1,Arg2,Arg3,Arg4), &U::member_function_name>* = 0); \
|
||||
static yes deduce(...); \
|
||||
public: \
|
||||
static const bool value = sizeof(yes) == sizeof(deduce(static_cast<base*>(0))); \
|
||||
}
|
||||
|
||||
#define BEAST_DEFINE_IS_CALL_POSSIBLE(trait_name, member_function_name) \
|
||||
struct trait_name##_detail \
|
||||
{ \
|
||||
BEAST_DEFINE_HAS_MEMBER_FUNCTION(has_member, member_function_name); \
|
||||
}; \
|
||||
\
|
||||
template <typename T, typename Signature> \
|
||||
struct trait_name \
|
||||
{ \
|
||||
private: \
|
||||
class yes {}; \
|
||||
class no { yes m[2]; }; \
|
||||
struct derived : public T \
|
||||
{ \
|
||||
using T::member_function_name; \
|
||||
no member_function_name(...) const; \
|
||||
private: derived (); \
|
||||
}; \
|
||||
\
|
||||
typedef typename is_call_possible_detail::clone_constness<T, derived>::type derived_type; \
|
||||
\
|
||||
template <typename U, typename Result> \
|
||||
struct return_value_check \
|
||||
{ \
|
||||
static yes deduce(Result); \
|
||||
static no deduce(...); \
|
||||
static no deduce(no); \
|
||||
static no deduce(is_call_possible_detail::void_exp_result<T>); \
|
||||
}; \
|
||||
\
|
||||
template <typename U> \
|
||||
struct return_value_check<U, void> \
|
||||
{ \
|
||||
static yes deduce(...); \
|
||||
static no deduce(no); \
|
||||
}; \
|
||||
\
|
||||
template <bool has_the_member_of_interest, typename F> \
|
||||
struct impl \
|
||||
{ \
|
||||
static const bool value = false; \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg> \
|
||||
struct impl<true, Result(Arg)> \
|
||||
{ \
|
||||
static typename is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename is_call_possible_detail::add_reference<Arg>::type arg; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg), is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg1, typename Arg2> \
|
||||
struct impl<true, Result(Arg1,Arg2)> \
|
||||
{ \
|
||||
static typename is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename is_call_possible_detail::add_reference<Arg1>::type arg1; \
|
||||
static typename is_call_possible_detail::add_reference<Arg2>::type arg2; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg1,arg2), is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg1, typename Arg2, typename Arg3> \
|
||||
struct impl<true, Result(Arg1,Arg2,Arg3)> \
|
||||
{ \
|
||||
static typename is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename is_call_possible_detail::add_reference<Arg1>::type arg1; \
|
||||
static typename is_call_possible_detail::add_reference<Arg2>::type arg2; \
|
||||
static typename is_call_possible_detail::add_reference<Arg3>::type arg3; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg1,arg2,arg3), is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
template <typename Result, typename Arg1, typename Arg2, typename Arg3, typename Arg4> \
|
||||
struct impl<true, Result(Arg1,Arg2,Arg3,Arg4)> \
|
||||
{ \
|
||||
static typename is_call_possible_detail::add_reference<derived_type>::type test_me; \
|
||||
static typename is_call_possible_detail::add_reference<Arg1>::type arg1; \
|
||||
static typename is_call_possible_detail::add_reference<Arg2>::type arg2; \
|
||||
static typename is_call_possible_detail::add_reference<Arg3>::type arg3; \
|
||||
static typename is_call_possible_detail::add_reference<Arg4>::type arg4; \
|
||||
\
|
||||
static const bool value = \
|
||||
sizeof( \
|
||||
return_value_check<T, Result>::deduce( \
|
||||
(test_me.member_function_name(arg1,arg2,arg3,arg4), is_call_possible_detail::void_exp_result<T>()) \
|
||||
) \
|
||||
) == sizeof(yes); \
|
||||
}; \
|
||||
\
|
||||
public: \
|
||||
static const bool value = impl<trait_name##_detail::has_member<T,Signature>::value, Signature>::value; \
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/* Brings functional support into our namespace, based on environment.
|
||||
|
||||
Notes on bind
|
||||
|
||||
Reference in New Issue
Block a user