mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Tidy up ripple modules for namespace support
This commit is contained in:
@@ -231,9 +231,9 @@ std::string STAmount::createHumanCurrency (const uint160& uCurrency)
|
||||
Blob vucVersion = sit.getRaw (16 / 8);
|
||||
Blob vucReserved = sit.getRaw (24 / 8);
|
||||
|
||||
bool bIso = ::isZero (vucZeros.begin (), vucZeros.size ()) // Leading zeros
|
||||
&& ::isZero (vucVersion.begin (), vucVersion.size ()) // Zero version
|
||||
&& ::isZero (vucReserved.begin (), vucReserved.size ()); // Reserved is zero.
|
||||
bool bIso = isZeroFilled (vucZeros.begin (), vucZeros.size ()) // Leading zeros
|
||||
&& isZeroFilled (vucVersion.begin (), vucVersion.size ()) // Zero version
|
||||
&& isZeroFilled (vucReserved.begin (), vucReserved.size ()); // Reserved is zero.
|
||||
|
||||
if (bIso)
|
||||
{
|
||||
|
||||
@@ -1308,14 +1308,29 @@ UPTR_T<STObject> STObject::parseJson (const Json::Value& object, SField::ref inN
|
||||
|
||||
case STI_UINT32:
|
||||
if (value.isString ())
|
||||
{
|
||||
data.push_back (new STUInt32 (field, lexical_cast_st<uint32> (value.asString ())));
|
||||
}
|
||||
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 ())
|
||||
{
|
||||
data.push_back (new STUInt32 (field, static_cast<uint32> (value.asUInt ())));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error ("Incorrect type");
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case STI_UINT64:
|
||||
|
||||
@@ -260,17 +260,29 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
boost::ptr_vector<SerializedType> mData;
|
||||
const SOTemplate* mType;
|
||||
// VFALCO TODO these parameters should not be const references.
|
||||
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
|
||||
{
|
||||
return new STObject (*this);
|
||||
}
|
||||
|
||||
STObject (SField::ref name, boost::ptr_vector<SerializedType>& data) : SerializedType (name), mType (NULL)
|
||||
{
|
||||
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 ();
|
||||
}
|
||||
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 ();
|
||||
}
|
||||
namespace boost
|
||||
{
|
||||
template<> struct range_mutable_iterator<STArray>
|
||||
{
|
||||
typedef STArray::iterator type;
|
||||
};
|
||||
template<> struct range_const_iterator<STArray>
|
||||
{
|
||||
typedef STArray::const_iterator type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -728,6 +728,16 @@ public:
|
||||
STAmount getRound () const;
|
||||
void roundSelf ();
|
||||
|
||||
private:
|
||||
template <class Iterator>
|
||||
static bool isZeroFilled (Iterator first, int iSize)
|
||||
{
|
||||
while (iSize && !*first++)
|
||||
--iSize;
|
||||
|
||||
return !iSize;
|
||||
}
|
||||
|
||||
private:
|
||||
uint160 mCurrency; // Compared by ==. Always update mIsNative.
|
||||
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 ();
|
||||
}
|
||||
|
||||
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
|
||||
class STPathSet : public SerializedType
|
||||
{
|
||||
@@ -1423,21 +1418,6 @@ inline std::vector<STPath>::const_iterator range_end (const STPathSet& x)
|
||||
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
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
@ingroup ripple_data
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include "ripple_data.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <limits.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -40,22 +41,24 @@
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/pem.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>
|
||||
|
||||
// VFALCO TODO fix these warnings!
|
||||
#ifdef _MSC_VER
|
||||
//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length"
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4018) // signed/unsigned mismatch
|
||||
//#pragma warning (disable: 4244) // conversion, possible loss of data
|
||||
#endif
|
||||
|
||||
#include "ripple_data.h"
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
namespace ripple
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "crypto/ripple_Base58.h" // for RippleAddress
|
||||
#include "crypto/ripple_CKey.h" // needs RippleAddress VFALCO TODO remove this dependency cycle
|
||||
#include "crypto/ripple_RFC1751.h"
|
||||
@@ -90,11 +93,15 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
|
||||
|
||||
#include "utility/ripple_JSONCache.cpp"
|
||||
|
||||
// VFALCO TODO Fix this for SConstruct
|
||||
#ifdef _MSC_VER
|
||||
#include "ripple.pb.cc" // BROKEN because of SConstruct
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
//#pragma warning (pop)
|
||||
// VFALCO TODO Fix this for SConstruct
|
||||
#if BEAST_MSVC
|
||||
#include "ripple.pb.cc"
|
||||
#endif
|
||||
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
@defgroup ripple_data
|
||||
*/
|
||||
|
||||
#ifndef RIPPLE_DATA_H
|
||||
#define RIPPLE_DATA_H
|
||||
#ifndef RIPPLE_DATA_RIPPLEHEADER
|
||||
#define RIPPLE_DATA_RIPPLEHEADER
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -52,6 +52,11 @@
|
||||
// additional hierarchy via directories.
|
||||
#include "ripple.pb.h"
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
namespace ripple
|
||||
{
|
||||
#endif
|
||||
|
||||
#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_Base58Data.h"
|
||||
@@ -75,4 +80,112 @@
|
||||
#include "utility/ripple_JSONCache.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
|
||||
|
||||
Reference in New Issue
Block a user