mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-13 15:45:54 +00:00
Move and add some template metaprogramming classes
This commit is contained in:
@@ -83,6 +83,13 @@
|
||||
<ClInclude Include="..\..\beast\mpl\RemoveVolatile.h" />
|
||||
<ClInclude Include="..\..\beast\Net.h" />
|
||||
<ClInclude Include="..\..\beast\net\IPEndpoint.h" />
|
||||
<ClInclude Include="..\..\beast\StaticAssert.h" />
|
||||
<ClInclude Include="..\..\beast\TypeTraits.h" />
|
||||
<ClInclude Include="..\..\beast\type_traits\IntegralConstant.h" />
|
||||
<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\EnableIf.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" />
|
||||
|
||||
@@ -195,6 +195,12 @@
|
||||
<Filter Include="beast\net\impl">
|
||||
<UniqueIdentifier>{93670bc9-a748-42bd-8118-8de30c468b16}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\type_traits">
|
||||
<UniqueIdentifier>{85158eb2-9340-4b3d-a136-f7631c7f1b7c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="beast\utility">
|
||||
<UniqueIdentifier>{56d34c67-7027-44ba-9f09-4591ce4afb36}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\modules\beast_core\beast_core.h">
|
||||
@@ -1044,6 +1050,27 @@
|
||||
<ClInclude Include="..\..\beast\Net.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\TypeTraits.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\type_traits\IsSigned.h">
|
||||
<Filter>beast\type_traits</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\type_traits\IntegralConstant.h">
|
||||
<Filter>beast\type_traits</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\type_traits\IsIntegral.h">
|
||||
<Filter>beast\type_traits</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\type_traits\RemoveSigned.h">
|
||||
<Filter>beast\type_traits</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\utility\EnableIf.h">
|
||||
<Filter>beast\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\beast\StaticAssert.h">
|
||||
<Filter>beast</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
||||
|
||||
45
beast/StaticAssert.h
Normal file
45
beast/StaticAssert.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_STATICASSERT_H_INCLUDED
|
||||
#define BEAST_STATICASSERT_H_INCLUDED
|
||||
|
||||
#ifndef DOXYGEN
|
||||
namespace beast
|
||||
{
|
||||
template <bool b>
|
||||
struct BeastStaticAssert;
|
||||
|
||||
template <>
|
||||
struct BeastStaticAssert <true>
|
||||
{
|
||||
static void dummy() {}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
/** A compile-time assertion macro.
|
||||
If the expression parameter is false, the macro will cause a compile error.
|
||||
(The actual error message that the compiler generates may be completely
|
||||
bizarre and seem to have no relation to the place where you put the
|
||||
static_assert though!)
|
||||
*/
|
||||
#define static_bassert(expression) beast::BeastStaticAssert<expression>::dummy();
|
||||
|
||||
#endif
|
||||
28
beast/TypeTraits.h
Normal file
28
beast/TypeTraits.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_TYPETRAITS_H_INCLUDED
|
||||
#define BEAST_TYPETRAITS_H_INCLUDED
|
||||
|
||||
#include "type_traits/IntegralConstant.h"
|
||||
#include "type_traits/IsIntegral.h"
|
||||
#include "type_traits/IsSigned.h"
|
||||
#include "type_traits/RemoveSigned.h"
|
||||
|
||||
#endif
|
||||
@@ -21,6 +21,7 @@
|
||||
#define BEAST_NET_IPENDPOINT_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
#include "../mpl/IfCond.h"
|
||||
@@ -130,7 +131,8 @@ public:
|
||||
return
|
||||
((value&0xff000000)==0x0a000000) || // Prefix /8, 10.##.#.#
|
||||
((value&0xfff00000)==0xac100000) || // Prefix /12 172.16.#.# - 172.31.#.#
|
||||
((value&0xffff0000)==0xc0a80000) ; // Prefix /16 192.168.#.#
|
||||
((value&0xffff0000)==0xc0a80000) || // Prefix /16 192.168.#.#
|
||||
isLoopback();
|
||||
}
|
||||
|
||||
/** Returns `true` if this is a broadcast address. */
|
||||
@@ -602,13 +604,22 @@ inline std::ostream& operator<< (std::ostream &os, IPEndpoint::V6 const& addr)
|
||||
return os;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream &os, IPEndpoint const& endpoint)
|
||||
inline std::ostream& operator<< (std::ostream &os, IPEndpoint const& ep)
|
||||
{
|
||||
os << endpoint.to_string();
|
||||
os << ep.to_string();
|
||||
return os;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/** Input stream conversions. */
|
||||
/** @{ */
|
||||
inline std::istream& operator>> (std::istream &is, IPEndpoint::V6&)
|
||||
{
|
||||
//is >> addr.to_string();
|
||||
return is;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,9 +22,164 @@
|
||||
namespace beast
|
||||
{
|
||||
|
||||
namespace parse
|
||||
{
|
||||
|
||||
/** Require and consume the specified character from the input.
|
||||
@return `true` if the character matched.
|
||||
*/
|
||||
bool expect (std::istream& is, char v)
|
||||
{
|
||||
char c;
|
||||
if (is.get(c) && v == c)
|
||||
return true;
|
||||
|
||||
is.unget();
|
||||
is.setstate (std::ios_base::failbit);
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/** Used to disambiguate 8-bit integers from characters. */
|
||||
template <typename IntType>
|
||||
struct integer_holder
|
||||
{
|
||||
IntType* pi;
|
||||
explicit integer_holder (IntType& i)
|
||||
: pi (&i)
|
||||
{
|
||||
}
|
||||
template <typename OtherIntType>
|
||||
IntType& operator= (OtherIntType o) const
|
||||
{
|
||||
*pi = o;
|
||||
return *pi;
|
||||
}
|
||||
};
|
||||
|
||||
/** Parse 8-bit unsigned integer. */
|
||||
std::istream& operator>> (std::istream& is, integer_holder <uint8> const& i)
|
||||
{
|
||||
uint16 v;
|
||||
is >> v;
|
||||
if (! (v>=0 && v<=255))
|
||||
{
|
||||
is.setstate (std::ios_base::failbit);
|
||||
return is;
|
||||
}
|
||||
i = uint8(v);
|
||||
return is;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Free function for template argument deduction. */
|
||||
template <typename IntType>
|
||||
detail::integer_holder <IntType> integer (IntType& i)
|
||||
{
|
||||
return detail::integer_holder <IntType> (i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Parse IPv4 address. */
|
||||
std::istream& operator>> (std::istream &is, IPEndpoint::V4& addr)
|
||||
{
|
||||
uint8 octets [4];
|
||||
is >> parse::integer (octets [0]);
|
||||
for (int i = 1; i < 4; ++i)
|
||||
{
|
||||
if (!is || !parse::expect (is, '.'))
|
||||
return is;
|
||||
is >> parse::integer (octets [i]);
|
||||
if (!is)
|
||||
return is;
|
||||
}
|
||||
addr = IPEndpoint::V4 (octets[0], octets[1], octets[2], octets[3]);
|
||||
return is;
|
||||
}
|
||||
|
||||
/** Parse an IPEndpoint.
|
||||
@note Currently only IPv4 addresses are supported.
|
||||
*/
|
||||
inline std::istream& operator>> (std::istream &is, IPEndpoint& ep)
|
||||
{
|
||||
IPEndpoint::V4 v4;
|
||||
is >> v4;
|
||||
if (is.fail())
|
||||
return is;
|
||||
|
||||
if (is.rdbuf()->in_avail()>0)
|
||||
{
|
||||
char c;
|
||||
is.get(c);
|
||||
if (c != ':')
|
||||
{
|
||||
is.unget();
|
||||
ep = IPEndpoint (v4);
|
||||
return is;
|
||||
}
|
||||
|
||||
uint16 port;
|
||||
is >> port;
|
||||
if (is.fail())
|
||||
return is;
|
||||
|
||||
ep = IPEndpoint (v4, port);
|
||||
}
|
||||
else
|
||||
{
|
||||
ep = IPEndpoint (v4);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class IPEndpointTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
bool parse (char const* text, IPEndpoint& ep)
|
||||
{
|
||||
std::string input (text);
|
||||
std::istringstream stream (input);
|
||||
stream >> ep;
|
||||
return !stream.fail();
|
||||
}
|
||||
|
||||
void shouldPass (char const* text)
|
||||
{
|
||||
IPEndpoint ep;
|
||||
expect (parse (text, ep));
|
||||
expect (ep.to_string() == std::string(text));
|
||||
}
|
||||
|
||||
void shouldFail (char const* text)
|
||||
{
|
||||
IPEndpoint ep;
|
||||
unexpected (parse (text, ep));
|
||||
}
|
||||
|
||||
void testParse ()
|
||||
{
|
||||
beginTestCase ("parse");
|
||||
|
||||
shouldPass ("0.0.0.0");
|
||||
shouldPass ("192.168.0.1");
|
||||
shouldPass ("168.127.149.132");
|
||||
shouldPass ("168.127.149.132:80");
|
||||
shouldPass ("168.127.149.132:54321");
|
||||
|
||||
shouldFail ("");
|
||||
shouldFail ("255");
|
||||
shouldFail ("512");
|
||||
shouldFail ("1.2.3.256");
|
||||
shouldFail ("1.2.3:80");
|
||||
}
|
||||
|
||||
void testPrint ()
|
||||
{
|
||||
beginTestCase ("addresses");
|
||||
@@ -36,7 +191,7 @@ public:
|
||||
expect ( ep.isPrivate());
|
||||
expect (!ep.isBroadcast());
|
||||
expect (!ep.isMulticast());
|
||||
expect (!ep.isLoopback());
|
||||
expect ( ep.isLoopback());
|
||||
expect (ep.to_string() == "127.0.0.1:80");
|
||||
|
||||
ep = IPEndpoint::V4(10,0,0,1);
|
||||
@@ -60,6 +215,7 @@ public:
|
||||
void runTest ()
|
||||
{
|
||||
testPrint();
|
||||
testParse();
|
||||
}
|
||||
|
||||
IPEndpointTests () : UnitTest ("IPEndpoint", "beast")
|
||||
|
||||
41
beast/type_traits/IntegralConstant.h
Normal file
41
beast/type_traits/IntegralConstant.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_TYPE_TRAITS_INTEGRALCONSTANT_H_INCLUDED
|
||||
#define BEAST_TYPE_TRAITS_INTEGRALCONSTANT_H_INCLUDED
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
// ideas from boost
|
||||
|
||||
template <class T, T val>
|
||||
struct IntegralConstant
|
||||
{
|
||||
typedef IntegralConstant <T, val> type;
|
||||
typedef T value_type;
|
||||
static const T value = val;
|
||||
};
|
||||
|
||||
typedef IntegralConstant <bool, true> TrueType;
|
||||
typedef IntegralConstant <bool, false> FalseType;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
44
beast/type_traits/IsIntegral.h
Normal file
44
beast/type_traits/IsIntegral.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_TYPE_TRAITS_ISINTEGRAL_H_INCLUDED
|
||||
#define BEAST_TYPE_TRAITS_ISINTEGRAL_H_INCLUDED
|
||||
|
||||
#include "IntegralConstant.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
namespace detail
|
||||
|
||||
template <typename T> struct IsIntegral : FalseType { };
|
||||
|
||||
template <> struct IsIntegral <int8> : TrueType { };
|
||||
template <> struct IsIntegral <int16> : TrueType { };
|
||||
template <> struct IsIntegral <int32> : TrueType { };
|
||||
template <> struct IsIntegral <int64> : TrueType { };
|
||||
template <> struct IsIntegral <uint8> : TrueType { };
|
||||
template <> struct IsIntegral <uint16> : TrueType { };
|
||||
template <> struct IsIntegral <uint32> : TrueType { };
|
||||
template <> struct IsIntegral <uint64> : TrueType { };
|
||||
template <> struct IsIntegral <wchar_t> : TrueType { };
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
40
beast/type_traits/IsSigned.h
Normal file
40
beast/type_traits/IsSigned.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_TYPE_TRAITS_ISSIGNED_H_INCLUDED
|
||||
#define BEAST_TYPE_TRAITS_ISSIGNED_H_INCLUDED
|
||||
|
||||
#include "IntegralConstant.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
template <typename T> struct IsSigned : FalseType { };
|
||||
|
||||
template <> struct IsSigned <int8> : TrueType { };
|
||||
template <> struct IsSigned <int16> : TrueType { };
|
||||
template <> struct IsSigned <int32> : TrueType { };
|
||||
template <> struct IsSigned <int64> : TrueType { };
|
||||
template <> struct IsSigned <float> : TrueType { };
|
||||
template <> struct IsSigned <double> : TrueType { };
|
||||
template <> struct IsSigned <wchar_t> : TrueType { };
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
45
beast/type_traits/RemoveSigned.h
Normal file
45
beast/type_traits/RemoveSigned.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_TYPE_TRAITS_REMOVESIGNED_H_INCLUDED
|
||||
#define BEAST_TYPE_TRAITS_REMOVESIGNED_H_INCLUDED
|
||||
|
||||
#include "IntegralConstant.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
/** Returns an equally sized, unsigned type.
|
||||
Requires:
|
||||
IsIntegral<T>::value == true
|
||||
*/
|
||||
template <typename T>
|
||||
struct RemoveSigned
|
||||
{
|
||||
typedef T type;
|
||||
}
|
||||
|
||||
template <> struct RemoveSigned <int8> { typedef uint8 type; }
|
||||
template <> struct RemoveSigned <int16> { typedef uint16 type; }
|
||||
template <> struct RemoveSigned <int32> { typedef uint32 type; }
|
||||
template <> struct RemoveSigned <int64> { typedef uint64 type; }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
48
beast/utility/EnableIf.h
Normal file
48
beast/utility/EnableIf.h
Normal file
@@ -0,0 +1,48 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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_ENABLEIF_H_INCLUDED
|
||||
#define BEAST_UTILITY_ENABLEIF_H_INCLUDED
|
||||
|
||||
#include "../type_traits/IntegralConstant.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
template <bool Enable, class T = void>
|
||||
struct EnableIfBool : FalseType { typedef T type; };
|
||||
|
||||
template <class T>
|
||||
struct EnableIfBool <false, T> { };
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct EnableIf : public EnableIfBool <Cond::value, T> { };
|
||||
|
||||
template <bool Enable, class T = void>
|
||||
struct DisableIfBool : FalseType { typedef T type; };
|
||||
|
||||
template <class T>
|
||||
struct DisableIfBool <true, T> { };
|
||||
|
||||
template <class Cond, class T = void>
|
||||
struct DisableIf : public DisableIfBool <Cond::value, T> { };
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -24,154 +24,6 @@
|
||||
#ifndef BEAST_CORE_H_INCLUDED
|
||||
#define BEAST_CORE_H_INCLUDED
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
|
||||
@mainpage Beast: A C++ library for peer to peer and client server development.
|
||||
|
||||
### Version 1.0
|
||||
|
||||
Copyright 2008, 2013 by Vinnie Falco \<vinnie.falco@gmail.com\> ([e-mail][0])
|
||||
|
||||
Beast is a source code collection of individual modules containing
|
||||
functionality for a variety of applications, with an emphasis on building
|
||||
concurrent systems. Beast incorporates parts of [JUCE][3] (Jules' Utility
|
||||
Class Extensions), available from [Raw Material Software][4]. Beast has no
|
||||
external dependencies
|
||||
|
||||
Beast is hosted on Github at [https://github.com/vinniefalco/Beast][1]
|
||||
|
||||
The online documentation is at [http://vinniefalco.github.com/Beast][2]
|
||||
|
||||
## Platforms
|
||||
|
||||
All platforms supported by JUCE are also supported by Beast. Currently these
|
||||
platforms include:
|
||||
|
||||
- **Windows**: Applications and VST/RTAS/NPAPI/ActiveX plugins can be built
|
||||
using MS Visual Studio. The results are all fully compatible with Windows
|
||||
XP, Vista or Windows 7.
|
||||
|
||||
- **Mac OS X**: Applications and VST/AudioUnit/RTAS/NPAPI plugins with Xcode.
|
||||
|
||||
- **GNU/Linux**: Applications and plugins can be built for any kernel 2.6 or
|
||||
later.
|
||||
|
||||
- **FreeBSD**: Kernel version 8.4 or higher required.
|
||||
|
||||
- **iOS**: Native iPhone and iPad apps.
|
||||
|
||||
- **Android**: Supported.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This documentation assumes that the reader has a working knowledge of JUCE.
|
||||
Some modules built on external libraries assume that the reader understands
|
||||
the operation of those external libraries. Certain modules assume that the
|
||||
reader understands additional domain-specific information. Modules with
|
||||
additional prerequisites are marked in the documentation.
|
||||
|
||||
## External Modules
|
||||
|
||||
Some modules bring in functionality provided by external libraries. For
|
||||
example, the @ref beast_bzip2 module provides the compression and decompression
|
||||
algorithms in [bZip2][7]. Usage of these external library modules is optional.
|
||||
They come with complete source code, as well as options for using either
|
||||
system or user provided variants of the external libraries: it is not
|
||||
necessary to download additional source code packages to use these modules.
|
||||
|
||||
External code incorporated into Beast is covered by separate licenses. See
|
||||
the licensing information and notes in the corresponding source files for
|
||||
copyright information and terms of use.
|
||||
|
||||
## Integration
|
||||
|
||||
Beast requires recent versions of JUCE. It won't work with versions 1.53 or
|
||||
earlier. To use the library it is necessary to first download JUCE to a
|
||||
location where your development environment can find it. Or, you can use your
|
||||
existing installation of JUCE.
|
||||
|
||||
This library uses the same modularized organizational structure as JUCE. To
|
||||
use a module, first add a path to the list of includes searched by your
|
||||
development environment or project, which points to the Beast directory. Then,
|
||||
add the single corresponding .c or .cpp file to your existing project which
|
||||
already uses JUCE. For example, to use the @ref beast_core module, add the file
|
||||
beast_core.cpp to your project. Some modules depend on other modules.
|
||||
|
||||
To use a module, include the appropriate header from within your source code.
|
||||
For example, to access classes in the @ref beast_concurrent module, use this:
|
||||
|
||||
@code
|
||||
|
||||
#include "modules/beast_concurrent/beast_concurrent.h"
|
||||
|
||||
@endcode
|
||||
|
||||
Then add the corresponding file beast_concurrent.cpp to your build.
|
||||
|
||||
## AppConfig
|
||||
|
||||
Some Beast features can be controlled at compilation time through
|
||||
preprocessor directives. The available choices of compilation options are
|
||||
described in AppConfig.h, located in the AppConfigTemplate directory. Copy
|
||||
the provided settings into your existing AppConfig.h (a file used by JUCE
|
||||
convention).
|
||||
|
||||
## License
|
||||
|
||||
This library contains portions of other open source products covered by
|
||||
separate licenses. Please see the corresponding source files for specific
|
||||
terms.
|
||||
|
||||
Beast is provided under the terms of The ISC License:
|
||||
|
||||
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.
|
||||
|
||||
Some files contain portions of these external projects, licensed separately:
|
||||
|
||||
- [bZip2][7] is Copyright (C) 1996-2010 Julian R Seward. All rights
|
||||
reserved. See the corresponding file LICENSE for licensing terms.
|
||||
|
||||
- [Soci][13] is Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton, and
|
||||
various others noted in the corresponding source files. Soci is distributed
|
||||
under the [Boost Software License, Version 1.0][14].
|
||||
|
||||
- [SQLite][15], placed in the public domain.
|
||||
|
||||
[0]: mailto:vinnie.falco@gmail.com "Vinnie Falco (Email)"
|
||||
[1]: https://github.com/vinniefalco/Beast "Beast Project"
|
||||
[2]: http://vinniefalco.github.com/Beast/ "Beast Documentation"
|
||||
[3]: http://rawmaterialsoftware.com/juce.php "JUCE"
|
||||
[4]: http://rawmaterialsoftware.com/ "Raw Material Software"
|
||||
[5]: http://www.gnu.org/licenses/gpl-2.0.html "GNU General Public License, version 2"
|
||||
[6]: http://rawmaterialsoftware.com/jucelicense.php "JUCE Licenses"
|
||||
[7]: http://www.bzip.org/ "bZip2: Home"
|
||||
[8]: http://freetype.org/ "The FreeType Project"
|
||||
[9]: http://www.freetype.org/FTL.TXT "The FreeType Project License"
|
||||
[10]: http://www.lua.org/ "The Programming Language Lua"
|
||||
[11]: http://opensource.org/licenses/ISC "The ISC License"
|
||||
[12]: https://github.com/vinniefalco/LuaBridge
|
||||
[13]: http://soci.sourceforge.net/ "SOCI"
|
||||
[14]: http://www.boost.org/LICENSE_1_0.txt "Boost Software License, Version 1.0"
|
||||
[15]: http://sqlite.org/ "SQLite Home Page"
|
||||
[16]: http://developer.kde.org/~wheeler/taglib.html "TagLib"
|
||||
[17]: http://www.gnu.org/licenses/lgpl-2.1.html "Gnu Lesser General Public License, version 2.1"
|
||||
[18]: http://www.mozilla.org/MPL/1.1/ "Mozilla Public License"
|
||||
|
||||
@copyright Copyright 2008-2013 by Vinnie Falco \<vinnie.falco@gmail.com\> ([e-mail][0])
|
||||
@copyright Provided under the [ISC LIcense][11]
|
||||
*/
|
||||
|
||||
// TargetPlatform.h should not use anything from BeastConfig.h
|
||||
#include "../../beast/Config.h"
|
||||
#include "system/BeastConfigCheck.h"
|
||||
@@ -225,6 +77,7 @@ Some files contain portions of these external projects, licensed separately:
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "../../beast/CStdInt.h"
|
||||
#include "../../beast/StaticAssert.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
|
||||
@@ -128,21 +128,6 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef DOXYGEN
|
||||
namespace beast
|
||||
{
|
||||
template <bool b> struct BeastStaticAssert;
|
||||
template <> struct BeastStaticAssert <true> { static void dummy() {} };
|
||||
}
|
||||
#endif
|
||||
|
||||
/** A compile-time assertion macro.
|
||||
If the expression parameter is false, the macro will cause a compile error. (The actual error
|
||||
message that the compiler generates may be completely bizarre and seem to have no relation to
|
||||
the place where you put the static_assert though!)
|
||||
*/
|
||||
#define static_bassert(expression) beast::BeastStaticAssert<expression>::dummy();
|
||||
|
||||
/** This macro can be added to class definitions to disable the use of new/delete to
|
||||
allocate the object on the heap, forcing it to only be used as a stack or member variable.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user