Tidy up ripple modules for namespace support

This commit is contained in:
Vinnie Falco
2013-06-22 22:32:36 -07:00
parent 64c8d406df
commit 0a358ded7a
22 changed files with 327 additions and 191 deletions

View File

@@ -20,4 +20,6 @@
//#define BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES //#define BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES
#endif #endif
#define RIPPLE_USE_NAMESPACE 0
#endif #endif

View File

@@ -183,6 +183,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\ripple_websocket\autosocket\ripple_LogWebsockets.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\ripple_websocket\ripple_websocket.cpp" /> <ClCompile Include="..\..\modules\ripple_websocket\ripple_websocket.cpp" />
<ClCompile Include="..\..\src\cpp\ripple\ripple_Database.cpp"> <ClCompile Include="..\..\src\cpp\ripple\ripple_Database.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
@@ -1242,12 +1248,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\ripple\ripple_LogWebsockets.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="..\..\src\cpp\ripple\ripple_Peer.cpp"> <ClCompile Include="..\..\src\cpp\ripple\ripple_Peer.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>

View File

@@ -414,9 +414,6 @@
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashRouter.cpp"> <ClCompile Include="..\..\src\cpp\ripple\ripple_HashRouter.cpp">
<Filter>1. Modules\ripple_app\refactored</Filter> <Filter>1. Modules\ripple_app\refactored</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\ripple\ripple_LogWebsockets.cpp">
<Filter>1. Modules\ripple_app\refactored</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cpp\ripple\ripple_UniqueNodeList.cpp"> <ClCompile Include="..\..\src\cpp\ripple\ripple_UniqueNodeList.cpp">
<Filter>1. Modules\ripple_app\refactored</Filter> <Filter>1. Modules\ripple_app\refactored</Filter>
</ClCompile> </ClCompile>
@@ -897,6 +894,9 @@
<ClCompile Include="..\..\modules\ripple_core\ripple_core.cpp"> <ClCompile Include="..\..\modules\ripple_core\ripple_core.cpp">
<Filter>1. Modules\ripple_core</Filter> <Filter>1. Modules\ripple_core</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\modules\ripple_websocket\autosocket\ripple_LogWebsockets.cpp">
<Filter>1. Modules\ripple_websocket\autosocket</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\cpp\protobuf\src\google\protobuf\service.h"> <ClInclude Include="..\..\src\cpp\protobuf\src\google\protobuf\service.h">

View File

@@ -375,7 +375,6 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/ripple_FeeVote.cpp" #include "src/cpp/ripple/ripple_FeeVote.cpp"
#include "src/cpp/ripple/ripple_HashedObjectStore.cpp" #include "src/cpp/ripple/ripple_HashedObjectStore.cpp"
#include "src/cpp/ripple/ripple_HashRouter.cpp" #include "src/cpp/ripple/ripple_HashRouter.cpp"
//#include "src/cpp/ripple/ripple_InfoSub.cpp"
#endif #endif
@@ -392,7 +391,6 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/ripple_LedgerHistory.cpp" #include "src/cpp/ripple/ripple_LedgerHistory.cpp"
#include "src/cpp/ripple/ripple_LoadEvent.cpp" #include "src/cpp/ripple/ripple_LoadEvent.cpp"
#include "src/cpp/ripple/ripple_LoadMonitor.cpp" #include "src/cpp/ripple/ripple_LoadMonitor.cpp"
#include "src/cpp/ripple/ripple_LogWebsockets.cpp"
#include "src/cpp/ripple/ripple_LoadFeeTrack.cpp" #include "src/cpp/ripple/ripple_LoadFeeTrack.cpp"
#include "src/cpp/ripple/ripple_OrderBook.cpp" #include "src/cpp/ripple/ripple_OrderBook.cpp"
#include "src/cpp/ripple/ripple_PathRequest.cpp" #include "src/cpp/ripple/ripple_PathRequest.cpp"

View File

@@ -48,16 +48,4 @@ public:
std::string toString () const; std::string toString () const;
}; };
// VFALCO TODO these parameters should not be const references.
template<typename T, typename U> T range_check_cast (const U& value, const T& minimum, const T& maximum)
{
if ((value < minimum) || (value > maximum))
throw std::runtime_error ("Value out of range");
return static_cast<T> (value);
}
#endif #endif
// vim:ts=4

View File

@@ -10,9 +10,13 @@
@ingroup ripple_basics @ingroup ripple_basics
*/ */
#include <iostream> #include "ripple_basics.h"
#include <fstream>
#include <fstream>
#include <iostream>
// VFALCO TODO Rewrite Sustain to use beast::Process
//
// These are for Sustain Linux variants // These are for Sustain Linux variants
#ifdef __linux__ #ifdef __linux__
#include <sys/types.h> #include <sys/types.h>
@@ -27,7 +31,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/asio.hpp> // for stupid parseIpPort #include <boost/asio.hpp> // VFALCO NOTE just for parseIpPort (!)
#include <boost/regex.hpp> #include <boost/regex.hpp>
// VFALCO TODO Replace OpenSSL randomness with a dependency-free implementation // VFALCO TODO Replace OpenSSL randomness with a dependency-free implementation
@@ -39,16 +43,16 @@
// //
#include <openssl/rand.h> // Because of ripple_RandomNumbers.cpp #include <openssl/rand.h> // Because of ripple_RandomNumbers.cpp
#ifdef BEAST_WIN32
#include <windows.h> // for ripple_RandomNumbers.cpp
#include <wincrypt.h> // for ripple_RandomNumbers.cpp
// Winsock #defines 'max' and does other stupid things so put it last
#include <Winsock2.h> // for ripple_ByteOrder.cpp
#endif
#include "ripple_basics.h" #if RIPPLE_USE_NAMESPACE
namespace ripple
{
// VFALCO TODO fix these warnings!
#ifdef _MSC_VER
//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length"
//#pragma warning (disable: 4018) // signed/unsigned mismatch
//#pragma warning (disable: 4244) // conversion, possible loss of data
#endif #endif
#include "containers/ripple_RangeSet.cpp" #include "containers/ripple_RangeSet.cpp"
@@ -65,16 +69,10 @@
#include "utility/ripple_Time.cpp" #include "utility/ripple_Time.cpp"
#include "utility/ripple_UptimeTimer.cpp" #include "utility/ripple_UptimeTimer.cpp"
#ifdef WIN32
#include <windows.h> // for ripple_RandomNumbers.cpp
#include <wincrypt.h> // for ripple_RandomNumbers.cpp
// Winsock #defines 'max' and does other stupid things so put it last
#include <Winsock2.h> // for ripple_ByteOrder.cpp
#endif
#include "utility/ripple_RandomNumbers.cpp" // has Win32/Posix dependencies #include "utility/ripple_RandomNumbers.cpp" // has Win32/Posix dependencies
#include "types/ripple_UInt256.cpp" #include "types/ripple_UInt256.cpp"
#ifdef _MSC_VER #if RIPPLE_USE_NAMESPACE
//#pragma warning (pop) }
#endif #endif

View File

@@ -17,41 +17,43 @@
@defgroup ripple_basics @defgroup ripple_basics
*/ */
#ifndef RIPPLE_BASICS_H #ifndef RIPPLE_BASICS_RIPPLEHEADER
#define RIPPLE_BASICS_H #define RIPPLE_BASICS_RIPPLEHEADER
#include <ctime>
#include <limits>
#include <list>
#include <sstream>
#include <string>
// UInt256
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <climits> #include <climits>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <ctime>
#include <functional> #include <functional>
#include <limits>
#include <list>
#include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/version.hpp> #include <boost/version.hpp>
#if BOOST_VERSION < 104700 #if BOOST_VERSION < 104700
#error Boost 1.47 or later is required #error Ripple requires Boost version 1.47 or later
#endif #endif
#include <boost/thread/recursive_mutex.hpp> // VFALCO TODO Move all boost includes into ripple_BoostHeaders.h
#include <boost/filesystem.hpp> // VFALCO TODO try to eliminate thie dependency //
#include <boost/unordered_map.hpp> #include <boost/bind.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/foreach.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/unordered_map.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/ref.hpp>
#include <boost/make_shared.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/function.hpp>
#include <boost/functional/hash.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/make_shared.hpp>
#include <boost/ref.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/unordered_map.hpp>
// ByteOrder // ByteOrder
#ifdef WIN32 #ifdef WIN32
@@ -64,28 +66,22 @@
# include <sys/types.h> # include <sys/types.h>
#endif #endif
// StringUtilities
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
// UInt256
#include <boost/functional/hash.hpp>
// ripple_PlatformMacros.h
#include <boost/bind.hpp>
#include <boost/function.hpp>
// VFALCO TODO remove this dependency!!!
#include <openssl/dh.h> // for DiffieHellmanUtil #include <openssl/dh.h> // for DiffieHellmanUtil
#include <openssl/ripemd.h> // For HashUtilities #include <openssl/ripemd.h> // For HashUtilities
#include <openssl/sha.h> // For HashUtilities #include <openssl/sha.h> // For HashUtilities
#include "BeastConfig.h" #include "BeastConfig.h" // Must come before any Beast includes
#include "modules/beast_core/beast_core.h" #include "modules/beast_core/beast_core.h"
#include "modules/beast_basics/beast_basics.h" #include "modules/beast_basics/beast_basics.h"
#include "../ripple_json/ripple_json.h" #include "../ripple_json/ripple_json.h"
#if RIPPLE_USE_NAMESPACE
namespace ripple
{
#endif
#include "utility/ripple_IntegerTypes.h" // must come first #include "utility/ripple_IntegerTypes.h" // must come first
#include "utility/ripple_Log.h" // Needed by others #include "utility/ripple_Log.h" // Needed by others
@@ -111,4 +107,8 @@
#include "containers/ripple_SecureAllocator.h" #include "containers/ripple_SecureAllocator.h"
#include "containers/ripple_TaggedCache.h" #include "containers/ripple_TaggedCache.h"
#if RIPPLE_USE_NAMESPACE
}
#endif
#endif #endif

View File

@@ -150,15 +150,6 @@ inline static std::string sqlEscape (Blob const& vecSrc)
return j; return j;
} }
template<class Iterator>
bool isZero (Iterator first, int iSize)
{
while (iSize && !*first++)
--iSize;
return !iSize;
}
int charUnHex (char cDigit); int charUnHex (char cDigit);
int strUnHex (std::string& strDst, const std::string& strSrc); int strUnHex (std::string& strDst, const std::string& strSrc);

View File

@@ -231,9 +231,9 @@ std::string STAmount::createHumanCurrency (const uint160& uCurrency)
Blob vucVersion = sit.getRaw (16 / 8); Blob vucVersion = sit.getRaw (16 / 8);
Blob vucReserved = sit.getRaw (24 / 8); Blob vucReserved = sit.getRaw (24 / 8);
bool bIso = ::isZero (vucZeros.begin (), vucZeros.size ()) // Leading zeros bool bIso = isZeroFilled (vucZeros.begin (), vucZeros.size ()) // Leading zeros
&& ::isZero (vucVersion.begin (), vucVersion.size ()) // Zero version && isZeroFilled (vucVersion.begin (), vucVersion.size ()) // Zero version
&& ::isZero (vucReserved.begin (), vucReserved.size ()); // Reserved is zero. && isZeroFilled (vucReserved.begin (), vucReserved.size ()); // Reserved is zero.
if (bIso) if (bIso)
{ {

View File

@@ -1308,14 +1308,29 @@ UPTR_T<STObject> STObject::parseJson (const Json::Value& object, SField::ref inN
case STI_UINT32: case STI_UINT32:
if (value.isString ()) if (value.isString ())
{
data.push_back (new STUInt32 (field, lexical_cast_st<uint32> (value.asString ()))); data.push_back (new STUInt32 (field, lexical_cast_st<uint32> (value.asString ())));
}
else if (value.isInt ()) else if (value.isInt ())
data.push_back (new STUInt32 (field, range_check_cast<uint32> (value.asInt (), 0, 4294967295u))); {
// VFALCO NOTE value.asInt() returns an int, which can never be greater than 7fffffff, but we
// are checking to make sure it is not greater than ffffffff, which can never be
// less than any 32 bit value (signed or unsigned).
//
// It seems this line only cares that value.asInt () is not negative, can someone
// confirm this?
//
#pragma message(BEAST_FILEANDLINE_ "Invalid signed/unsigned comparison")
data.push_back (new STUInt32 (field, range_check_cast <uint32> (value.asInt (), 0u, 4294967295u)));
}
else if (value.isUInt ()) else if (value.isUInt ())
{
data.push_back (new STUInt32 (field, static_cast<uint32> (value.asUInt ()))); data.push_back (new STUInt32 (field, static_cast<uint32> (value.asUInt ())));
}
else else
{
throw std::runtime_error ("Incorrect type"); throw std::runtime_error ("Incorrect type");
}
break; break;
case STI_UINT64: case STI_UINT64:

View File

@@ -260,17 +260,29 @@ public:
} }
private: private:
boost::ptr_vector<SerializedType> mData; // VFALCO TODO these parameters should not be const references.
const SOTemplate* mType; template <typename T, typename U>
static T range_check_cast (const U& value, const T& minimum, const T& maximum)
{
if ((value < minimum) || (value > maximum))
throw std::runtime_error ("Value out of range");
return static_cast<T> (value);
}
STObject* duplicate () const STObject* duplicate () const
{ {
return new STObject (*this); return new STObject (*this);
} }
STObject (SField::ref name, boost::ptr_vector<SerializedType>& data) : SerializedType (name), mType (NULL) STObject (SField::ref name, boost::ptr_vector<SerializedType>& data) : SerializedType (name), mType (NULL)
{ {
mData.swap (data); mData.swap (data);
} }
private:
boost::ptr_vector<SerializedType> mData;
const SOTemplate* mType;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -283,17 +295,6 @@ inline STObject::iterator range_end (STObject& x)
{ {
return x.end (); return x.end ();
} }
namespace boost
{
template<> struct range_mutable_iterator<STObject>
{
typedef STObject::iterator type;
};
template<> struct range_const_iterator<STObject>
{
typedef STObject::const_iterator type;
};
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -481,17 +482,5 @@ inline STArray::iterator range_end (STArray& x)
{ {
return x.end (); return x.end ();
} }
namespace boost
{
template<> struct range_mutable_iterator<STArray>
{
typedef STArray::iterator type;
};
template<> struct range_const_iterator<STArray>
{
typedef STArray::const_iterator type;
};
}
#endif #endif
// vim:ts=4

View File

@@ -728,6 +728,16 @@ public:
STAmount getRound () const; STAmount getRound () const;
void roundSelf (); void roundSelf ();
private:
template <class Iterator>
static bool isZeroFilled (Iterator first, int iSize)
{
while (iSize && !*first++)
--iSize;
return !iSize;
}
private: private:
uint160 mCurrency; // Compared by ==. Always update mIsNative. uint160 mCurrency; // Compared by ==. Always update mIsNative.
uint160 mIssuer; // Not compared by ==. 0 for XRP. uint160 mIssuer; // Not compared by ==. 0 for XRP.
@@ -1291,21 +1301,6 @@ inline std::vector<STPathElement>::const_iterator range_end (const STPath& x)
return x.end (); return x.end ();
} }
namespace boost
{
template<>
struct range_mutable_iterator< STPath >
{
typedef std::vector<STPathElement>::iterator type;
};
template<>
struct range_const_iterator< STPath >
{
typedef std::vector<STPathElement>::const_iterator type;
};
}
// A set of zero or more payment paths // A set of zero or more payment paths
class STPathSet : public SerializedType class STPathSet : public SerializedType
{ {
@@ -1423,21 +1418,6 @@ inline std::vector<STPath>::const_iterator range_end (const STPathSet& x)
return x.end (); return x.end ();
} }
namespace boost
{
template<>
struct range_mutable_iterator< STPathSet >
{
typedef std::vector<STPath>::iterator type;
};
template<>
struct range_const_iterator< STPathSet >
{
typedef std::vector<STPath>::const_iterator type;
};
}
class STVector256 : public SerializedType class STVector256 : public SerializedType
{ {
public: public:

View File

@@ -10,13 +10,14 @@
@ingroup ripple_data @ingroup ripple_data
*/ */
#include <limits.h> #include "ripple_data.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <limits.h>
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -40,22 +41,24 @@
#include <openssl/ecdsa.h> #include <openssl/ecdsa.h>
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/hmac.h> #include <openssl/hmac.h>
#include <openssl/rand.h> //#include <openssl/rand.h> // includes <windows.h> and causes errors due to #define GetMessage
#include <openssl/err.h> #include <openssl/err.h>
// VFALCO TODO fix these warnings! // VFALCO TODO fix these warnings!
#ifdef _MSC_VER #if BEAST_MSVC
//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length" #pragma warning (push)
#pragma warning (disable: 4018) // signed/unsigned mismatch #pragma warning (disable: 4018) // signed/unsigned mismatch
//#pragma warning (disable: 4244) // conversion, possible loss of data
#endif #endif
#include "ripple_data.h"
#ifdef min #ifdef min
#undef min #undef min
#endif #endif
#if RIPPLE_USE_NAMESPACE
namespace ripple
{
#endif
#include "crypto/ripple_Base58.h" // for RippleAddress #include "crypto/ripple_Base58.h" // for RippleAddress
#include "crypto/ripple_CKey.h" // needs RippleAddress VFALCO TODO remove this dependency cycle #include "crypto/ripple_CKey.h" // needs RippleAddress VFALCO TODO remove this dependency cycle
#include "crypto/ripple_RFC1751.h" #include "crypto/ripple_RFC1751.h"
@@ -90,11 +93,15 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
#include "utility/ripple_JSONCache.cpp" #include "utility/ripple_JSONCache.cpp"
// VFALCO TODO Fix this for SConstruct #if RIPPLE_USE_NAMESPACE
#ifdef _MSC_VER }
#include "ripple.pb.cc" // BROKEN because of SConstruct
#endif #endif
#ifdef _MSC_VER // VFALCO TODO Fix this for SConstruct
//#pragma warning (pop) #if BEAST_MSVC
#include "ripple.pb.cc"
#endif
#if BEAST_MSVC
#pragma warning (pop)
#endif #endif

View File

@@ -17,8 +17,8 @@
@defgroup ripple_data @defgroup ripple_data
*/ */
#ifndef RIPPLE_DATA_H #ifndef RIPPLE_DATA_RIPPLEHEADER
#define RIPPLE_DATA_H #define RIPPLE_DATA_RIPPLEHEADER
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@@ -52,6 +52,11 @@
// additional hierarchy via directories. // additional hierarchy via directories.
#include "ripple.pb.h" #include "ripple.pb.h"
#if RIPPLE_USE_NAMESPACE
namespace ripple
{
#endif
#include "crypto/ripple_CBigNum.h" #include "crypto/ripple_CBigNum.h"
#include "crypto/ripple_Base58.h" // VFALCO TODO Can be moved to .cpp if we clean up setAlphabet stuff #include "crypto/ripple_Base58.h" // VFALCO TODO Can be moved to .cpp if we clean up setAlphabet stuff
#include "crypto/ripple_Base58Data.h" #include "crypto/ripple_Base58Data.h"
@@ -75,4 +80,112 @@
#include "utility/ripple_JSONCache.h" #include "utility/ripple_JSONCache.h"
#include "utility/ripple_UptimeTimerAdapter.h" #include "utility/ripple_UptimeTimerAdapter.h"
#if RIPPLE_USE_NAMESPACE
}
#endif
#if RIPPLE_USE_NAMESPACE
namespace boost
{
template <>
struct range_mutable_iterator <ripple::STPath>
{
typedef std::vector <ripple::STPathElement>::iterator type;
};
template <>
struct range_const_iterator <ripple::STPath>
{
typedef std::vector <ripple::STPathElement>::const_iterator type;
};
template <>
struct range_mutable_iterator <ripple::STPathSet>
{
typedef std::vector <ripple::STPath>::iterator type;
};
template <>
struct range_const_iterator <ripple::STPathSet>
{
typedef std::vector <ripple::STPath>::const_iterator type;
};
template <>
struct range_mutable_iterator <ripple::STObject>
{
typedef ripple::STObject::iterator type;
};
template <>
struct range_const_iterator <ripple::STObject>
{
typedef ripple::STObject::const_iterator type;
};
template <>
struct range_mutable_iterator <ripple::STArray>
{
typedef ripple::STArray::iterator type;
};
template <>
struct range_const_iterator <ripple::STArray>
{
typedef ripple::STArray::const_iterator type;
};
}
#else
namespace boost
{
template <>
struct range_mutable_iterator <STPath>
{
typedef std::vector <STPathElement>::iterator type;
};
template <>
struct range_const_iterator <STPath>
{
typedef std::vector <STPathElement>::const_iterator type;
};
template <>
struct range_mutable_iterator <STPathSet>
{
typedef std::vector <STPath>::iterator type;
};
template <>
struct range_const_iterator <STPathSet>
{
typedef std::vector <STPath>::const_iterator type;
};
template <>
struct range_mutable_iterator <STObject>
{
typedef STObject::iterator type;
};
template <>
struct range_const_iterator <STObject>
{
typedef STObject::const_iterator type;
};
template <>
struct range_mutable_iterator <STArray>
{
typedef STArray::iterator type;
};
template <>
struct range_const_iterator <STArray>
{
typedef STArray::const_iterator type;
};
}
#endif
#endif #endif

View File

@@ -12,17 +12,8 @@
#include "ripple_json.h" #include "ripple_json.h"
// VFALCO TODO Remove unneeded includes
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include <stdio.h> #include <iomanip>
#include <string.h>
#include <utility>
#ifdef JSON_USE_CPPTL #ifdef JSON_USE_CPPTL
# include <cpptl/conststring.h> # include <cpptl/conststring.h>
@@ -39,11 +30,15 @@
#define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw #define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw
#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message ); #define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
//#if _MSC_VER >= 1400 // VC++ 8.0 #if RIPPLE_USE_NAMESPACE
//#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated. namespace ripple
//#endif {
#endif
#include "json/json_reader.cpp" #include "json/json_reader.cpp"
#include "json/json_value.cpp" #include "json/json_value.cpp"
#include "json/json_writer.cpp" #include "json/json_writer.cpp"
#if RIPPLE_USE_NAMESPACE
}
#endif

View File

@@ -17,34 +17,39 @@
@defgroup ripple_json @defgroup ripple_json
*/ */
#ifndef RIPPLE_JSON_H #ifndef RIPPLE_JSON_RIPPLEHEADER
#define RIPPLE_JSON_H #define RIPPLE_JSON_RIPPLEHEADER
// VFALCO TODO Remove unneeded includes
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <deque> #include <deque>
#include <iostream>
#include <stack> #include <stack>
#include <string>
#include <vector> #include <vector>
// Needed before these cpptl includes #include "json/json_config.h" // Needed before these cpptl includes
#include "json/json_config.h"
#ifndef JSON_USE_CPPTL_SMALLMAP #ifndef JSON_USE_CPPTL_SMALLMAP
# include <map> # include <map>
#else #else
# include <cpptl/smallmap.h> # include <cpptl/smallmap.h>
#endif #endif
#ifdef JSON_USE_CPPTL #ifdef JSON_USE_CPPTL
# include <cpptl/forwards.h> # include <cpptl/forwards.h>
#endif #endif
#if RIPPLE_USE_NAMESPACE
namespace ripple
{
#endif
#include "json/json_forwards.h" #include "json/json_forwards.h"
#include "json/json_features.h" #include "json/json_features.h"
#include "json/json_value.h" #include "json/json_value.h"
#include "json/json_reader.h" #include "json/json_reader.h"
#include "json/json_writer.h" #include "json/json_writer.h"
#if RIPPLE_USE_NAMESPACE
}
#endif
#endif #endif

View File

@@ -50,7 +50,7 @@
// VFALCO TODO We should try running with SQLITE_THREADSAFE==2 and see what happens. // VFALCO TODO We should try running with SQLITE_THREADSAFE==2 and see what happens.
#if SQLITE_THREADSAFE != 2 #if SQLITE_THREADSAFE != 2
#pragma message(BEAST_FILEANDLINE_"Possible performance issue, SQLITE_THREADSAFE != 2") #pragma message(BEAST_FILEANDLINE_ "Possible performance issue, SQLITE_THREADSAFE != 2")
#endif #endif
#include "sqlite/sqlite3.c" #include "sqlite/sqlite3.c"

View File

@@ -4,5 +4,8 @@
*/ */
//============================================================================== //==============================================================================
#if RIPPLE_USE_NAMESPACE
ripple::LogPartition AutoSocket::AutoSocketPartition ("AutoSocket");
#else
LogPartition AutoSocket::AutoSocketPartition ("AutoSocket"); LogPartition AutoSocket::AutoSocketPartition ("AutoSocket");
#endif

View File

@@ -73,6 +73,10 @@ public:
static bool rfc2818_verify (const std::string& domain, bool preverified, boost::asio::ssl::verify_context& ctx) static bool rfc2818_verify (const std::string& domain, bool preverified, boost::asio::ssl::verify_context& ctx)
{ {
#if RIPPLE_USE_NAMESPACE
using namespace ripple;
#endif
if (boost::asio::ssl::rfc2818_verification (domain) (preverified, ctx)) if (boost::asio::ssl::rfc2818_verification (domain) (preverified, ctx))
return true; return true;
@@ -224,6 +228,10 @@ public:
protected: protected:
void handle_autodetect (callback cbFunc, const error_code& ec, size_t bytesTransferred) void handle_autodetect (callback cbFunc, const error_code& ec, size_t bytesTransferred)
{ {
#if RIPPLE_USE_NAMESPACE
using namespace ripple;
#endif
if (ec) if (ec)
{ {
Log (lsWARNING, AutoSocketPartition) << "Handle autodetect error: " << ec; Log (lsWARNING, AutoSocketPartition) << "Handle autodetect error: " << ec;
@@ -253,8 +261,11 @@ protected:
} }
private: private:
#if RIPPLE_USE_NAMESPACE
static ripple::LogPartition AutoSocketPartition;
#else
static LogPartition AutoSocketPartition; static LogPartition AutoSocketPartition;
#endif
socket_ptr mSocket; socket_ptr mSocket;
bool mSecure; bool mSecure;

View File

@@ -11,6 +11,44 @@ namespace websocketpp
{ {
namespace log namespace log
{ {
#if RIPPLE_USE_NAMESPACE
using namespace ripple;
LogPartition websocketPartition ("WebSocket");
void websocketLog (websocketpp::log::alevel::value v, const std::string& entry)
{
using namespace ripple;
if ((v == websocketpp::log::alevel::DEVEL) || (v == websocketpp::log::alevel::DEBUG_CLOSE))
{
if (websocketPartition.doLog (lsTRACE))
Log (lsDEBUG, websocketPartition) << entry;
}
else if (websocketPartition.doLog (lsDEBUG))
Log (lsDEBUG, websocketPartition) << entry;
}
void websocketLog (websocketpp::log::elevel::value v, const std::string& entry)
{
using namespace ripple;
LogSeverity s = lsDEBUG;
if ((v & websocketpp::log::elevel::INFO) != 0)
s = lsINFO;
else if ((v & websocketpp::log::elevel::FATAL) != 0)
s = lsFATAL;
else if ((v & websocketpp::log::elevel::RERROR) != 0)
s = lsERROR;
else if ((v & websocketpp::log::elevel::WARN) != 0)
s = lsWARNING;
if (websocketPartition.doLog (s))
Log (s, websocketPartition) << entry;
}
#else
LogPartition websocketPartition ("WebSocket"); LogPartition websocketPartition ("WebSocket");
void websocketLog (websocketpp::log::alevel::value v, const std::string& entry) void websocketLog (websocketpp::log::alevel::value v, const std::string& entry)
@@ -40,6 +78,7 @@ void websocketLog (websocketpp::log::elevel::value v, const std::string& entry)
if (websocketPartition.doLog (s)) if (websocketPartition.doLog (s))
Log (s, websocketPartition) << entry; Log (s, websocketPartition) << entry;
} }
#endif
} }
} }

View File

@@ -24,3 +24,4 @@
#include "websocket/src/sha1/sha1.cpp" #include "websocket/src/sha1/sha1.cpp"
#include "autosocket/ripple_AutoSocket.cpp" #include "autosocket/ripple_AutoSocket.cpp"
#include "autosocket/ripple_LogWebsockets.cpp"

View File

@@ -21,13 +21,6 @@
@deprecated @deprecated
*/ */
#include <iostream>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/bind.hpp>
//------------------------------------------------------------------------------
// VFALCO NOTE Log dependencies have wormed their way into websocketpp, // VFALCO NOTE Log dependencies have wormed their way into websocketpp,
// which needs the ripple_basic module to compile. // which needs the ripple_basic module to compile.
@@ -37,6 +30,14 @@
// //
#include "../modules/ripple_basics/ripple_basics.h" #include "../modules/ripple_basics/ripple_basics.h"
#include <iostream>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <boost/bind.hpp>
//------------------------------------------------------------------------------
// VFALCO TODO This include is just to prevent a warning about // VFALCO TODO This include is just to prevent a warning about
// redefinition of __STDC_LIMIT_MACROS. Fix it right. // redefinition of __STDC_LIMIT_MACROS. Fix it right.
// //