Replace const Type& with Type const& for common types.

* std::string
* RippleAccount
* Account
* Currency
* uint256
* STAmount
* Json::Value
This commit is contained in:
Tom Ritchford
2014-08-03 19:17:56 -04:00
committed by Vinnie Falco
parent f5afe0587f
commit 648ccc7c17
143 changed files with 748 additions and 754 deletions

View File

@@ -79,7 +79,7 @@ err:
class key_error : public std::runtime_error
{
public:
explicit key_error (const std::string& str) : std::runtime_error (str) {}
explicit key_error (std::string const& str) : std::runtime_error (str) {}
};
class CKey
@@ -132,12 +132,12 @@ public:
}
static uint128 PassPhraseToKey (const std::string& passPhrase);
static uint128 PassPhraseToKey (std::string const& passPhrase);
static EC_KEY* GenerateRootDeterministicKey (const uint128& passPhrase);
static EC_KEY* GenerateRootPubKey (BIGNUM* pubGenerator);
static EC_KEY* GeneratePublicDeterministicKey (const RippleAddress& generator, int n);
static EC_KEY* GeneratePrivateDeterministicKey (const RippleAddress& family, const BIGNUM* rootPriv, int n);
static EC_KEY* GeneratePrivateDeterministicKey (const RippleAddress& family, uint256 const& rootPriv, int n);
static EC_KEY* GeneratePublicDeterministicKey (RippleAddress const& generator, int n);
static EC_KEY* GeneratePrivateDeterministicKey (RippleAddress const& family, const BIGNUM* rootPriv, int n);
static EC_KEY* GeneratePrivateDeterministicKey (RippleAddress const& family, uint256 const& rootPriv, int n);
CKey (const uint128& passPhrase) : fSet (false)
{
@@ -146,7 +146,7 @@ public:
assert (pkey);
}
CKey (const RippleAddress& generator, int n) : fSet (false)
CKey (RippleAddress const& generator, int n) : fSet (false)
{
// public deterministic key
pkey = GeneratePublicDeterministicKey (generator, n);
@@ -154,7 +154,7 @@ public:
assert (pkey);
}
CKey (const RippleAddress& base, const BIGNUM* rootPrivKey, int n) : fSet (false)
CKey (RippleAddress const& base, const BIGNUM* rootPrivKey, int n) : fSet (false)
{
// private deterministic key
pkey = GeneratePrivateDeterministicKey (base, rootPrivKey, n);
@@ -169,7 +169,7 @@ public:
}
#if 0
CKey (const RippleAddress& masterKey, int keyNum, bool isPublic) : pkey (nullptr), fSet (false)
CKey (RippleAddress const& masterKey, int keyNum, bool isPublic) : pkey (nullptr), fSet (false)
{
if (isPublic)
SetPubSeq (masterKey, keyNum);
@@ -249,7 +249,7 @@ public:
return SetPubKey (&vchPubKey[0], vchPubKey.size ());
}
bool SetPubKey (const std::string& pubKey)
bool SetPubKey (std::string const& pubKey)
{
return SetPubKey (pubKey.data (), pubKey.size ());
}
@@ -302,7 +302,7 @@ public:
return Verify (hash, &vchSig[0], vchSig.size ());
}
bool Verify (uint256 const& hash, const std::string& sig) const
bool Verify (uint256 const& hash, std::string const& sig) const
{
return Verify (hash, sig.data (), sig.size ());
}

View File

@@ -24,7 +24,7 @@ namespace ripple {
// Functions to add CKey support for deterministic EC keys
// <-- seed
uint128 CKey::PassPhraseToKey (const std::string& passPhrase)
uint128 CKey::PassPhraseToKey (std::string const& passPhrase)
{
Serializer s;
@@ -189,7 +189,7 @@ EC_KEY* CKey::GenerateRootPubKey (BIGNUM* pubGenerator)
}
// --> public generator
static BIGNUM* makeHash (const RippleAddress& pubGen, int seq, BIGNUM* order)
static BIGNUM* makeHash (RippleAddress const& pubGen, int seq, BIGNUM* order)
{
int subSeq = 0;
BIGNUM* ret = nullptr;
@@ -212,7 +212,7 @@ static BIGNUM* makeHash (const RippleAddress& pubGen, int seq, BIGNUM* order)
}
// --> public generator
EC_KEY* CKey::GeneratePublicDeterministicKey (const RippleAddress& pubGen, int seq)
EC_KEY* CKey::GeneratePublicDeterministicKey (RippleAddress const& pubGen, int seq)
{
// publicKey(n) = rootPublicKey EC_POINT_+ Hash(pubHash|seq)*point
BIGNUM* generator = BN_bin2bn (
@@ -285,14 +285,14 @@ EC_KEY* CKey::GeneratePublicDeterministicKey (const RippleAddress& pubGen, int s
return success ? pkey : nullptr;
}
EC_KEY* CKey::GeneratePrivateDeterministicKey (const RippleAddress& pubGen, uint256 const& u, int seq)
EC_KEY* CKey::GeneratePrivateDeterministicKey (RippleAddress const& pubGen, uint256 const& u, int seq)
{
CBigNum bn (u);
return GeneratePrivateDeterministicKey (pubGen, static_cast<BIGNUM*> (&bn), seq);
}
// --> root private key
EC_KEY* CKey::GeneratePrivateDeterministicKey (const RippleAddress& pubGen, const BIGNUM* rootPrivKey, int seq)
EC_KEY* CKey::GeneratePrivateDeterministicKey (RippleAddress const& pubGen, const BIGNUM* rootPrivKey, int seq)
{
// privateKey(n) = (rootPrivateKey + Hash(pubHash|seq)) % order
BN_CTX* ctx = BN_CTX_new ();

View File

@@ -276,7 +276,7 @@ unsigned long RFC1751::extract (char* s, int start, int length)
// Encode 8 bytes in 'c' as a string of English words.
// Returns a pointer to a static buffer
void RFC1751::btoe (std::string& strHuman, const std::string& strData)
void RFC1751::btoe (std::string& strHuman, std::string const& strData)
{
char caBuffer[9]; /* add in room for the parity 2 bits*/
int p, i;
@@ -350,7 +350,7 @@ void RFC1751::standard (std::string& strWord)
}
// Binary search of dictionary.
int RFC1751::wsrch (const std::string& strWord, int iMin, int iMax)
int RFC1751::wsrch (std::string const& strWord, int iMin, int iMax)
{
int iResult = -1;
@@ -434,7 +434,7 @@ int RFC1751::etob (std::string& strData, std::vector<std::string> vsHuman)
-1 if badly formed string
-2 if words are okay but parity is wrong.
*/
int RFC1751::getKeyFromEnglish (std::string& strKey, const std::string& strHuman)
int RFC1751::getKeyFromEnglish (std::string& strKey, std::string const& strHuman)
{
std::vector<std::string> vWords;
std::string strFirst, strSecond;
@@ -463,7 +463,7 @@ int RFC1751::getKeyFromEnglish (std::string& strKey, const std::string& strHuman
/** Convert to human from a 128 bit key in big-endian format
*/
void RFC1751::getEnglishFromKey (std::string& strHuman, const std::string& strKey)
void RFC1751::getEnglishFromKey (std::string& strHuman, std::string const& strKey)
{
std::string strFirst, strSecond;

View File

@@ -25,9 +25,9 @@ namespace ripple {
class RFC1751
{
public:
static int getKeyFromEnglish (std::string& strKey, const std::string& strHuman);
static int getKeyFromEnglish (std::string& strKey, std::string const& strHuman);
static void getEnglishFromKey (std::string& strHuman, const std::string& strKey);
static void getEnglishFromKey (std::string& strHuman, std::string const& strKey);
/** Chooses a single dictionary word from the data.
@@ -40,10 +40,10 @@ public:
private:
static unsigned long extract (char* s, int start, int length);
static void btoe (std::string& strHuman, const std::string& strData);
static void btoe (std::string& strHuman, std::string const& strData);
static void insert (char* s, int x, int start, int length);
static void standard (std::string& strWord);
static int wsrch (const std::string& strWord, int iMin, int iMax);
static int wsrch (std::string const& strWord, int iMin, int iMax);
static int etob (std::string& strData, std::vector<std::string> vsHuman);
static char const* s_dictionary [];

View File

@@ -145,7 +145,7 @@ std::string SField::getName () const
std::to_string(fieldValue);
}
SField::ref SField::getField (const std::string& fieldName)
SField::ref SField::getField (std::string const& fieldName)
{
// OPTIMIZEME me with a map. CHECKME this is case sensitive
StaticScopedLockType sl (getMutex ());

View File

@@ -131,7 +131,7 @@ public:
~SField ();
static SField::ref getField (int fieldCode);
static SField::ref getField (const std::string& fieldName);
static SField::ref getField (std::string const& fieldName);
static SField::ref getField (int type, int value)
{
return getField (FIELD_CODE (type, value));

View File

@@ -75,7 +75,7 @@ std::string RippleAddress::humanAddressType () const
// NodePublic
//
RippleAddress RippleAddress::createNodePublic (const RippleAddress& naSeed)
RippleAddress RippleAddress::createNodePublic (RippleAddress const& naSeed)
{
CKey ckSeed (naSeed.getSeed ());
RippleAddress naNew;
@@ -95,7 +95,7 @@ RippleAddress RippleAddress::createNodePublic (Blob const& vPublic)
return naNew;
}
RippleAddress RippleAddress::createNodePublic (const std::string& strPublic)
RippleAddress RippleAddress::createNodePublic (std::string const& strPublic)
{
RippleAddress naNew;
@@ -153,7 +153,7 @@ std::string RippleAddress::humanNodePublic () const
}
}
bool RippleAddress::setNodePublic (const std::string& strPublic)
bool RippleAddress::setNodePublic (std::string const& strPublic)
{
mIsValid = SetString (strPublic, VER_NODE_PUBLIC, Base58::getRippleAlphabet ());
@@ -187,7 +187,7 @@ bool RippleAddress::verifyNodePublic (uint256 const& hash, Blob const& vchSig, E
return bVerified;
}
bool RippleAddress::verifyNodePublic (uint256 const& hash, const std::string& strSig, ECDSA fullyCanonical) const
bool RippleAddress::verifyNodePublic (uint256 const& hash, std::string const& strSig, ECDSA fullyCanonical) const
{
Blob vchSig (strSig.begin (), strSig.end ());
@@ -198,7 +198,7 @@ bool RippleAddress::verifyNodePublic (uint256 const& hash, const std::string& st
// NodePrivate
//
RippleAddress RippleAddress::createNodePrivate (const RippleAddress& naSeed)
RippleAddress RippleAddress::createNodePrivate (RippleAddress const& naSeed)
{
uint256 uPrivKey;
RippleAddress naNew;
@@ -256,7 +256,7 @@ std::string RippleAddress::humanNodePrivate () const
}
}
bool RippleAddress::setNodePrivate (const std::string& strPrivate)
bool RippleAddress::setNodePrivate (std::string const& strPrivate)
{
mIsValid = SetString (strPrivate, VER_NODE_PRIVATE, Base58::getRippleAlphabet ());
@@ -361,7 +361,7 @@ std::string RippleAddress::humanAccountID () const
}
bool RippleAddress::setAccountID (
const std::string& strAccountID, Base58::Alphabet const& alphabet)
std::string const& strAccountID, Base58::Alphabet const& alphabet)
{
if (strAccountID.empty ())
{
@@ -388,7 +388,7 @@ void RippleAddress::setAccountID (Account const& hash160)
//
RippleAddress RippleAddress::createAccountPublic (
const RippleAddress& generator, int iSeq)
RippleAddress const& generator, int iSeq)
{
CKey ckPub (generator, iSeq);
RippleAddress naNew;
@@ -435,7 +435,7 @@ std::string RippleAddress::humanAccountPublic () const
}
}
bool RippleAddress::setAccountPublic (const std::string& strPublic)
bool RippleAddress::setAccountPublic (std::string const& strPublic)
{
mIsValid = SetString (strPublic, VER_ACCOUNT_PUBLIC, Base58::getRippleAlphabet ());
@@ -449,7 +449,7 @@ void RippleAddress::setAccountPublic (Blob const& vPublic)
SetData (VER_ACCOUNT_PUBLIC, vPublic);
}
void RippleAddress::setAccountPublic (const RippleAddress& generator, int seq)
void RippleAddress::setAccountPublic (RippleAddress const& generator, int seq)
{
CKey pubkey = CKey (generator, seq);
@@ -491,7 +491,7 @@ RippleAddress RippleAddress::createAccountID (Account const& account)
//
RippleAddress RippleAddress::createAccountPrivate (
const RippleAddress& generator, const RippleAddress& naSeed, int iSeq)
RippleAddress const& generator, RippleAddress const& naSeed, int iSeq)
{
RippleAddress naNew;
@@ -530,7 +530,7 @@ std::string RippleAddress::humanAccountPrivate () const
}
}
bool RippleAddress::setAccountPrivate (const std::string& strPrivate)
bool RippleAddress::setAccountPrivate (std::string const& strPrivate)
{
mIsValid = SetString (
strPrivate, VER_ACCOUNT_PRIVATE, Base58::getRippleAlphabet ());
@@ -551,7 +551,7 @@ void RippleAddress::setAccountPrivate (uint256 hash256)
}
void RippleAddress::setAccountPrivate (
const RippleAddress& generator, const RippleAddress& naSeed, int seq)
RippleAddress const& generator, RippleAddress const& naSeed, int seq)
{
CKey ckPubkey = CKey (naSeed.getSeed ());
CKey ckPrivkey = CKey (generator, ckPubkey.GetSecretBN (), seq);
@@ -585,7 +585,7 @@ bool RippleAddress::accountPrivateSign (uint256 const& uHash, Blob& vucSig) cons
}
Blob RippleAddress::accountPrivateEncrypt (
const RippleAddress& naPublicTo, Blob const& vucPlainText) const
RippleAddress const& naPublicTo, Blob const& vucPlainText) const
{
CKey ckPrivate;
CKey ckPublic;
@@ -616,7 +616,7 @@ Blob RippleAddress::accountPrivateEncrypt (
}
Blob RippleAddress::accountPrivateDecrypt (
const RippleAddress& naPublicFrom, Blob const& vucCipherText) const
RippleAddress const& naPublicFrom, Blob const& vucCipherText) const
{
CKey ckPrivate;
CKey ckPublic;
@@ -682,7 +682,7 @@ std::string RippleAddress::humanGenerator () const
}
}
bool RippleAddress::setGenerator (const std::string& strGenerator)
bool RippleAddress::setGenerator (std::string const& strGenerator)
{
mIsValid = SetString (
strGenerator, VER_FAMILY_GENERATOR, Base58::getRippleAlphabet ());
@@ -695,7 +695,7 @@ void RippleAddress::setGenerator (Blob const& vPublic)
SetData (VER_FAMILY_GENERATOR, vPublic);
}
RippleAddress RippleAddress::createGeneratorPublic (const RippleAddress& naSeed)
RippleAddress RippleAddress::createGeneratorPublic (RippleAddress const& naSeed)
{
CKey ckSeed (naSeed.getSeed ());
RippleAddress naNew;
@@ -765,7 +765,7 @@ std::string RippleAddress::humanSeed () const
}
}
int RippleAddress::setSeed1751 (const std::string& strHuman1751)
int RippleAddress::setSeed1751 (std::string const& strHuman1751)
{
std::string strKey;
int iResult = RFC1751::getKeyFromEnglish (strKey, strHuman1751);
@@ -781,14 +781,14 @@ int RippleAddress::setSeed1751 (const std::string& strHuman1751)
return iResult;
}
bool RippleAddress::setSeed (const std::string& strSeed)
bool RippleAddress::setSeed (std::string const& strSeed)
{
mIsValid = SetString (strSeed, VER_FAMILY_SEED, Base58::getRippleAlphabet ());
return mIsValid;
}
bool RippleAddress::setSeedGeneric (const std::string& strText)
bool RippleAddress::setSeedGeneric (std::string const& strText)
{
RippleAddress naTemp;
bool bResult = true;
@@ -849,7 +849,7 @@ RippleAddress RippleAddress::createSeedRandom ()
return naNew;
}
RippleAddress RippleAddress::createSeedGeneric (const std::string& strText)
RippleAddress RippleAddress::createSeedGeneric (std::string const& strText)
{
RippleAddress naNew;

View File

@@ -79,16 +79,16 @@ public:
std::string humanNodePublic () const;
bool setNodePublic (const std::string& strPublic);
bool setNodePublic (std::string const& strPublic);
void setNodePublic (Blob const& vPublic);
bool verifyNodePublic (uint256 const& hash, Blob const& vchSig,
ECDSA mustBeFullyCanonical) const;
bool verifyNodePublic (uint256 const& hash, const std::string& strSig,
bool verifyNodePublic (uint256 const& hash, std::string const& strSig,
ECDSA mustBeFullyCanonical) const;
static RippleAddress createNodePublic (const RippleAddress& naSeed);
static RippleAddress createNodePublic (RippleAddress const& naSeed);
static RippleAddress createNodePublic (Blob const& vPublic);
static RippleAddress createNodePublic (const std::string& strPublic);
static RippleAddress createNodePublic (std::string const& strPublic);
//
// Node Private
@@ -98,12 +98,12 @@ public:
std::string humanNodePrivate () const;
bool setNodePrivate (const std::string& strPrivate);
bool setNodePrivate (std::string const& strPrivate);
void setNodePrivate (Blob const& vPrivate);
void setNodePrivate (uint256 hash256);
void signNodePrivate (uint256 const& hash, Blob& vchSig) const;
static RippleAddress createNodePrivate (const RippleAddress& naSeed);
static RippleAddress createNodePrivate (RippleAddress const& naSeed);
//
// Accounts IDs
@@ -113,12 +113,12 @@ public:
std::string humanAccountID () const;
bool setAccountID (
const std::string& strAccountID,
std::string const& strAccountID,
Base58::Alphabet const& alphabet = Base58::getRippleAlphabet());
void setAccountID (Account const& hash160In);
#if 0
static RippleAddress createAccountID (const std::string& strAccountID)
static RippleAddress createAccountID (std::string const& strAccountID)
{
RippleAddress na;
na.setAccountID (strAccountID);
@@ -135,9 +135,9 @@ public:
std::string humanAccountPublic () const;
bool setAccountPublic (const std::string& strPublic);
bool setAccountPublic (std::string const& strPublic);
void setAccountPublic (Blob const& vPublic);
void setAccountPublic (const RippleAddress& generator, int seq);
void setAccountPublic (RippleAddress const& generator, int seq);
bool accountPublicVerify (uint256 const& uHash, Blob const& vucSig,
ECDSA mustBeFullyCanonical) const;
@@ -156,7 +156,7 @@ public:
// Create a deterministic public key from a public generator.
static RippleAddress createAccountPublic (
const RippleAddress& naGenerator, int iSeq);
RippleAddress const& naGenerator, int iSeq);
//
// Accounts Private
@@ -165,24 +165,24 @@ public:
std::string humanAccountPrivate () const;
bool setAccountPrivate (const std::string& strPrivate);
bool setAccountPrivate (std::string const& strPrivate);
void setAccountPrivate (Blob const& vPrivate);
void setAccountPrivate (uint256 hash256);
void setAccountPrivate (const RippleAddress& naGenerator,
const RippleAddress& naSeed, int seq);
void setAccountPrivate (RippleAddress const& naGenerator,
RippleAddress const& naSeed, int seq);
bool accountPrivateSign (uint256 const& uHash, Blob& vucSig) const;
// Encrypt a message.
Blob accountPrivateEncrypt (
const RippleAddress& naPublicTo, Blob const& vucPlainText) const;
RippleAddress const& naPublicTo, Blob const& vucPlainText) const;
// Decrypt a message.
Blob accountPrivateDecrypt (
const RippleAddress& naPublicFrom, Blob const& vucCipherText) const;
RippleAddress const& naPublicFrom, Blob const& vucCipherText) const;
static RippleAddress createAccountPrivate (
const RippleAddress& generator, const RippleAddress& seed, int iSeq);
RippleAddress const& generator, RippleAddress const& seed, int iSeq);
static RippleAddress createAccountPrivate (Blob const& vPrivate)
{
@@ -206,12 +206,12 @@ public:
std::string humanGenerator () const;
bool setGenerator (const std::string& strGenerator);
bool setGenerator (std::string const& strGenerator);
void setGenerator (Blob const& vPublic);
// void setGenerator(const RippleAddress& seed);
// void setGenerator(RippleAddress const& seed);
// Create generator for making public deterministic keys.
static RippleAddress createGeneratorPublic (const RippleAddress& naSeed);
static RippleAddress createGeneratorPublic (RippleAddress const& naSeed);
//
// Seeds
@@ -221,14 +221,14 @@ public:
std::string humanSeed () const;
std::string humanSeed1751 () const;
bool setSeed (const std::string& strSeed);
int setSeed1751 (const std::string& strHuman1751);
bool setSeedGeneric (const std::string& strText);
bool setSeed (std::string const& strSeed);
int setSeed1751 (std::string const& strHuman1751);
bool setSeedGeneric (std::string const& strText);
void setSeed (uint128 hash128);
void setSeedRandom ();
static RippleAddress createSeedRandom ();
static RippleAddress createSeedGeneric (const std::string& strText);
static RippleAddress createSeedGeneric (std::string const& strText);
};
//------------------------------------------------------------------------------

View File

@@ -31,7 +31,7 @@ std::string STAmount::getHumanCurrency () const
return to_string (mIssue.currency);
}
bool STAmount::bSetJson (const Json::Value& jvSource)
bool STAmount::bSetJson (Json::Value const& jvSource)
{
try
{
@@ -48,7 +48,7 @@ bool STAmount::bSetJson (const Json::Value& jvSource)
}
}
STAmount::STAmount (SField::ref n, const Json::Value& v)
STAmount::STAmount (SField::ref n, Json::Value const& v)
: SerializedType (n), mValue (0), mOffset (0), mIsNegative (false)
{
Json::Value value, currency, issuer;
@@ -155,7 +155,7 @@ STAmount::STAmount (SField::ref n, const Json::Value& v)
throw std::runtime_error ("invalid amount type");
}
bool STAmount::setValue (const std::string& sAmount)
bool STAmount::setValue (std::string const& sAmount)
{
// Note: mIsNative and mIssue.currency must be set already!
@@ -248,7 +248,7 @@ bool STAmount::setValue (const std::string& sAmount)
// - Float values are in float units.
// - To avoid a mistake float value for native are specified with a "^" in place of a "."
// <-- bValid: true = valid
bool STAmount::setFullValue (const std::string& sAmount, const std::string& sCurrency, const std::string& sIssuer)
bool STAmount::setFullValue (std::string const& sAmount, std::string const& sCurrency, std::string const& sIssuer)
{
//
// Figure out the currency.
@@ -398,7 +398,7 @@ STAmount STAmount::createFromInt64 (SField::ref name, std::int64_t value)
: STAmount (name, static_cast<std::uint64_t> (-value), true);
}
void STAmount::setValue (const STAmount& a)
void STAmount::setValue (STAmount const& a)
{
mIssue = a.mIssue;
mValue = a.mValue;
@@ -412,7 +412,7 @@ void STAmount::setIssue (Issue const& issue) {
mIsNative = isXRP (*this);
}
int STAmount::compare (const STAmount& a) const
int STAmount::compare (STAmount const& a) const
{
// Compares the value of a to the value of this STAmount, amounts must be comparable
if (mIsNegative != a.mIsNegative)
@@ -608,7 +608,7 @@ std::string STAmount::getText () const
return ret;
}
bool STAmount::isComparable (const STAmount& t) const
bool STAmount::isComparable (STAmount const& t) const
{
// are these two STAmount instances in the same currency
if (mIsNative) return t.mIsNative;
@@ -624,14 +624,14 @@ bool STAmount::isEquivalent (const SerializedType& t) const
return v && (*v == *this);
}
void STAmount::throwComparable (const STAmount& t) const
void STAmount::throwComparable (STAmount const& t) const
{
// throw an exception if these two STAmount instances are incomparable
if (!isComparable (t))
throw std::runtime_error ("amounts are not comparable");
}
bool STAmount::operator== (const STAmount& a) const
bool STAmount::operator== (STAmount const& a) const
{
return isComparable (a) &&
mIsNegative == a.mIsNegative &&
@@ -639,7 +639,7 @@ bool STAmount::operator== (const STAmount& a) const
mValue == a.mValue;
}
bool STAmount::operator!= (const STAmount& a) const
bool STAmount::operator!= (STAmount const& a) const
{
return mOffset != a.mOffset ||
mValue != a.mValue ||
@@ -647,37 +647,37 @@ bool STAmount::operator!= (const STAmount& a) const
!isComparable (a);
}
bool STAmount::operator< (const STAmount& a) const
bool STAmount::operator< (STAmount const& a) const
{
throwComparable (a);
return compare (a) < 0;
}
bool STAmount::operator> (const STAmount& a) const
bool STAmount::operator> (STAmount const& a) const
{
throwComparable (a);
return compare (a) > 0;
}
bool STAmount::operator<= (const STAmount& a) const
bool STAmount::operator<= (STAmount const& a) const
{
throwComparable (a);
return compare (a) <= 0;
}
bool STAmount::operator>= (const STAmount& a) const
bool STAmount::operator>= (STAmount const& a) const
{
throwComparable (a);
return compare (a) >= 0;
}
STAmount& STAmount::operator+= (const STAmount& a)
STAmount& STAmount::operator+= (STAmount const& a)
{
*this = *this + a;
return *this;
}
STAmount& STAmount::operator-= (const STAmount& a)
STAmount& STAmount::operator-= (STAmount const& a)
{
*this = *this - a;
return *this;
@@ -770,7 +770,7 @@ STAmount::operator double () const
return static_cast<double> (mValue) * pow (10.0, mOffset);
}
STAmount operator+ (const STAmount& v1, const STAmount& v2)
STAmount operator+ (STAmount const& v1, STAmount const& v2)
{
v1.throwComparable (v2);
@@ -822,7 +822,7 @@ STAmount operator+ (const STAmount& v1, const STAmount& v2)
return STAmount (v1.getFName (), v1.mIssue, -fv, ov1, true);
}
STAmount operator- (const STAmount& v1, const STAmount& v2)
STAmount operator- (STAmount const& v1, STAmount const& v2)
{
v1.throwComparable (v2);
@@ -873,7 +873,7 @@ STAmount operator- (const STAmount& v1, const STAmount& v2)
// NIKB TODO Make Amount::divide skip math if den == QUALITY_ONE
STAmount STAmount::divide (
const STAmount& num, const STAmount& den, Issue const& issue)
STAmount const& num, STAmount const& den, Issue const& issue)
{
if (den == zero)
throw std::runtime_error ("division by zero");
@@ -919,7 +919,7 @@ STAmount STAmount::divide (
}
STAmount STAmount::multiply (
const STAmount& v1, const STAmount& v2, Issue const& issue)
STAmount const& v1, STAmount const& v2, Issue const& issue)
{
if (v1 == zero || v2 == zero)
return STAmount (issue);
@@ -989,7 +989,7 @@ STAmount STAmount::multiply (
// A lower rate is better for the person taking the order.
// The taker gets more for less with a lower rate.
// Zero is returned if the offer is worthless.
std::uint64_t STAmount::getRate (const STAmount& offerOut, const STAmount& offerIn)
std::uint64_t STAmount::getRate (STAmount const& offerOut, STAmount const& offerIn)
{
if (offerOut == zero)
return 0;
@@ -1026,7 +1026,7 @@ STAmount STAmount::setRate (std::uint64_t rate)
}
STAmount STAmount::getPay (
const STAmount& offerOut, const STAmount& offerIn, const STAmount& needed)
STAmount const& offerOut, STAmount const& offerIn, STAmount const& needed)
{
// Someone wants to get (needed) out of the offer, how much should they pay
// in?
@@ -1144,7 +1144,7 @@ Json::Value STAmount::getJson (int) const
class STAmount_test : public beast::unit_test::suite
{
public:
static STAmount serializeAndDeserialize (const STAmount& s)
static STAmount serializeAndDeserialize (STAmount const& s)
{
Serializer ser;
s.add (ser);

View File

@@ -121,7 +121,7 @@ public:
canonicalize ();
}
STAmount (SField::ref, const Json::Value&);
STAmount (SField::ref, Json::Value const&);
static STAmount createFromInt64 (SField::ref n, std::int64_t v);
@@ -131,7 +131,7 @@ public:
return std::unique_ptr<SerializedType> (construct (sit, name));
}
bool bSetJson (const Json::Value& jvSource);
bool bSetJson (Json::Value const& jvSource);
static STAmount saFromRate (std::uint64_t uRate = 0)
{
@@ -219,7 +219,7 @@ public:
}
// Zero while copying currency and issuer.
void clear (const STAmount& saTmpl)
void clear (STAmount const& saTmpl)
{
clear(saTmpl.mIssue);
}
@@ -236,7 +236,7 @@ public:
return *this;
}
int compare (const STAmount&) const;
int compare (STAmount const&) const;
Account const& getIssuer () const
{
@@ -262,11 +262,11 @@ public:
return mIssue;
}
bool setValue (const std::string& sAmount);
bool setValue (std::string const& sAmount);
bool setFullValue (
const std::string& sAmount, const std::string& sCurrency = "",
const std::string& sIssuer = "");
void setValue (const STAmount&);
std::string const& sAmount, std::string const& sCurrency = "",
std::string const& sIssuer = "");
void setValue (STAmount const&);
virtual bool isEquivalent (const SerializedType& t) const;
virtual bool isDefault () const
@@ -274,14 +274,14 @@ public:
return (mValue == 0) && mIsNative;
}
bool operator== (const STAmount&) const;
bool operator!= (const STAmount&) const;
bool operator< (const STAmount&) const;
bool operator> (const STAmount&) const;
bool operator<= (const STAmount&) const;
bool operator>= (const STAmount&) const;
bool isComparable (const STAmount&) const;
void throwComparable (const STAmount&) const;
bool operator== (STAmount const&) const;
bool operator!= (STAmount const&) const;
bool operator< (STAmount const&) const;
bool operator> (STAmount const&) const;
bool operator<= (STAmount const&) const;
bool operator>= (STAmount const&) const;
bool isComparable (STAmount const&) const;
void throwComparable (STAmount const&) const;
// native currency only
bool operator< (std::uint64_t) const;
@@ -292,39 +292,39 @@ public:
STAmount operator- (std::uint64_t) const;
STAmount operator- (void) const;
STAmount& operator+= (const STAmount&);
STAmount& operator-= (const STAmount&);
STAmount& operator+= (STAmount const&);
STAmount& operator-= (STAmount const&);
STAmount& operator+= (std::uint64_t);
STAmount& operator-= (std::uint64_t);
STAmount& operator= (std::uint64_t);
operator double () const;
friend STAmount operator+ (const STAmount& v1, const STAmount& v2);
friend STAmount operator- (const STAmount& v1, const STAmount& v2);
friend STAmount operator+ (STAmount const& v1, STAmount const& v2);
friend STAmount operator- (STAmount const& v1, STAmount const& v2);
static STAmount divide (
const STAmount& v1, const STAmount& v2, Issue const& issue);
STAmount const& v1, STAmount const& v2, Issue const& issue);
static STAmount divide (
const STAmount& v1, const STAmount& v2, const STAmount& saUnit)
STAmount const& v1, STAmount const& v2, STAmount const& saUnit)
{
return divide (v1, v2, saUnit.issue ());
}
static STAmount divide (const STAmount& v1, const STAmount& v2)
static STAmount divide (STAmount const& v1, STAmount const& v2)
{
return divide (v1, v2, v1);
}
static STAmount multiply (
const STAmount& v1, const STAmount& v2, Issue const& issue);
STAmount const& v1, STAmount const& v2, Issue const& issue);
static STAmount multiply (
const STAmount& v1, const STAmount& v2, const STAmount& saUnit)
STAmount const& v1, STAmount const& v2, STAmount const& saUnit)
{
return multiply (v1, v2, saUnit.issue());
}
static STAmount multiply (const STAmount& v1, const STAmount& v2)
static STAmount multiply (STAmount const& v1, STAmount const& v2)
{
return multiply (v1, v2, v1);
}
@@ -336,35 +336,35 @@ public:
*/
// Add, subtract, multiply, or divide rounding result in specified direction
static STAmount addRound (
const STAmount& v1, const STAmount& v2, bool roundUp);
STAmount const& v1, STAmount const& v2, bool roundUp);
static STAmount subRound (
const STAmount& v1, const STAmount& v2, bool roundUp);
STAmount const& v1, STAmount const& v2, bool roundUp);
static STAmount mulRound (
const STAmount& v1, const STAmount& v2, Issue const& issue,
STAmount const& v1, STAmount const& v2, Issue const& issue,
bool roundUp);
static STAmount divRound (
const STAmount& v1, const STAmount& v2, Issue const& issue,
STAmount const& v1, STAmount const& v2, Issue const& issue,
bool roundUp);
static STAmount mulRound (
const STAmount& v1, const STAmount& v2, const STAmount& saUnit,
STAmount const& v1, STAmount const& v2, STAmount const& saUnit,
bool roundUp)
{
return mulRound (v1, v2, saUnit.issue (), roundUp);
}
static STAmount mulRound (
const STAmount& v1, const STAmount& v2, bool roundUp)
STAmount const& v1, STAmount const& v2, bool roundUp)
{
return mulRound (v1, v2, v1.issue (), roundUp);
}
static STAmount divRound (
const STAmount& v1, const STAmount& v2, const STAmount& saUnit,
STAmount const& v1, STAmount const& v2, STAmount const& saUnit,
bool roundUp)
{
return divRound (v1, v2, saUnit.issue (), roundUp);
}
static STAmount divRound (
const STAmount& v1, const STAmount& v2, bool roundUp)
STAmount const& v1, STAmount const& v2, bool roundUp)
{
return divRound (v1, v2, v1.issue (), roundUp);
}
@@ -372,7 +372,7 @@ public:
// Someone is offering X for Y, what is the rate?
// Rate: smaller is better, the taker wants the most out: in/out
static std::uint64_t getRate (
const STAmount& offerOut, const STAmount& offerIn);
STAmount const& offerOut, STAmount const& offerIn);
static STAmount setRate (std::uint64_t rate);
// Someone is offering X for Y, I need Z, how much do I pay
@@ -380,7 +380,7 @@ public:
// WARNING: most methods in rippled have parameters ordered "in, out" - this
// one is ordered "out, in".
static STAmount getPay (
const STAmount& out, const STAmount& in, const STAmount& needed);
STAmount const& out, STAmount const& in, STAmount const& needed);
static STAmount deserialize (SerializerIterator&);

View File

@@ -65,7 +65,7 @@ void STAmount::canonicalizeRound (
<< ":" << offset << (roundUp ? " up" : " down");
}
STAmount STAmount::addRound (const STAmount& v1, const STAmount& v2, bool roundUp)
STAmount STAmount::addRound (STAmount const& v1, STAmount const& v2, bool roundUp)
{
v1.throwComparable (v2);
@@ -137,7 +137,7 @@ STAmount STAmount::addRound (const STAmount& v1, const STAmount& v2, bool roundU
}
}
STAmount STAmount::subRound (const STAmount& v1, const STAmount& v2, bool roundUp)
STAmount STAmount::subRound (STAmount const& v1, STAmount const& v2, bool roundUp)
{
v1.throwComparable (v2);
@@ -211,7 +211,7 @@ STAmount STAmount::subRound (const STAmount& v1, const STAmount& v2, bool roundU
}
STAmount STAmount::mulRound (
const STAmount& v1, const STAmount& v2, Issue const& issue, bool roundUp)
STAmount const& v1, STAmount const& v2, Issue const& issue, bool roundUp)
{
if (v1 == zero || v2 == zero)
return {issue};
@@ -278,7 +278,7 @@ STAmount STAmount::mulRound (
}
STAmount STAmount::divRound (
const STAmount& num, const STAmount& den,
STAmount const& num, STAmount const& den,
Issue const& issue, bool roundUp)
{
if (den == zero)

View File

@@ -44,7 +44,7 @@ public:
bitString_.SetHex (v);
}
STBitString (SField::ref n, const std::string& v) : SerializedType (n)
STBitString (SField::ref n, std::string const& v) : SerializedType (n)
{
bitString_.SetHex (v);
}

View File

@@ -486,9 +486,9 @@ bool STParsedJSON::parse (std::string const& json_name,
return false;
}
const Json::Value& account = pathEl["account"];
const Json::Value& currency = pathEl["currency"];
const Json::Value& issuer = pathEl["issuer"];
Json::Value const& account = pathEl["account"];
Json::Value const& currency = pathEl["currency"];
Json::Value const& issuer = pathEl["issuer"];
bool hasCurrency = false;
Account uAccount, uIssuer;
Currency uCurrency;

View File

@@ -820,7 +820,7 @@ Blob STObject::getFieldVL (SField::ref field) const
return cf->getValue ();
}
const STAmount& STObject::getFieldAmount (SField::ref field) const
STAmount const& STObject::getFieldAmount (SField::ref field) const
{
static STAmount empty;
const SerializedType* rf = peekAtPField (field);
@@ -1034,7 +1034,7 @@ void STObject::setFieldVL (SField::ref field, Blob const& v)
cf->setValue (v);
}
void STObject::setFieldAmount (SField::ref field, const STAmount& v)
void STObject::setFieldAmount (SField::ref field, STAmount const& v)
{
SerializedType* rf = getPField (field, true);
@@ -1271,7 +1271,7 @@ public:
testParseJSONArrayWithInvalidChildrenObjects();
}
bool parseJSONString (const std::string& json, Json::Value& to)
bool parseJSONString (std::string const& json, Json::Value& to)
{
Json::Reader reader;
return (reader.parse(json, to) &&

View File

@@ -204,7 +204,7 @@ public:
Account getFieldAccount160 (SField::ref field) const;
Blob getFieldVL (SField::ref field) const;
const STAmount& getFieldAmount (SField::ref field) const;
STAmount const& getFieldAmount (SField::ref field) const;
STPathSet const& getFieldPathSet (SField::ref field) const;
const STVector256& getFieldV256 (SField::ref field) const;
const STArray& getFieldArray (SField::ref field) const;
@@ -221,7 +221,7 @@ public:
{
setFieldAccount (field, addr.getAccountID ());
}
void setFieldAmount (SField::ref field, const STAmount&);
void setFieldAmount (SField::ref field, STAmount const&);
void setFieldPathSet (SField::ref field, STPathSet const&);
void setFieldV256 (SField::ref field, const STVector256 & v);

View File

@@ -148,7 +148,7 @@ bool STVector256::isEquivalent (const SerializedType& t) const
bool STVector256::hasValue (uint256 const& v) const
{
BOOST_FOREACH (uint256 const & hash, mValue)
BOOST_FOREACH (uint256 const& hash, mValue)
{
if (hash == v)
return true;
@@ -182,7 +182,7 @@ RippleAddress STAccount::getValueNCA () const
return a;
}
void STAccount::setValueNCA (const RippleAddress& nca)
void STAccount::setValueNCA (RippleAddress const& nca)
{
setValueH160 (nca.getAccountID ());
}

View File

@@ -141,7 +141,7 @@ public:
std::string getText () const;
RippleAddress getValueNCA () const;
void setValueNCA (const RippleAddress& nca);
void setValueNCA (RippleAddress const& nca);
template <typename Tag>
void setValueH160 (base_uint<160, Tag> const& v)

View File

@@ -390,7 +390,7 @@ int Serializer::addVL (const void* ptr, int len)
return ret;
}
int Serializer::addVL (const std::string& string)
int Serializer::addVL (std::string const& string)
{
int ret = addRaw (string.size ());

View File

@@ -45,7 +45,7 @@ public:
{
;
}
Serializer (const std::string& data) : mData (data.data (), (data.data ()) + data.size ())
Serializer (std::string const& data) : mData (data.data (), (data.data ()) + data.size ())
{
;
}
@@ -91,7 +91,7 @@ public:
int addZeros (size_t uBytes);
int addVL (Blob const& vector);
int addVL (const std::string& string);
int addVL (std::string const& string);
int addVL (const void* ptr, int len);
// disassemble functions
@@ -168,7 +168,7 @@ public:
{
return getPrefixHash (prefix, & (data.front ()), data.size ());
}
static uint256 getPrefixHash (std::uint32_t prefix, const std::string& strData)
static uint256 getPrefixHash (std::uint32_t prefix, std::string const& strData)
{
return getPrefixHash (prefix, reinterpret_cast<const unsigned char*> (strData.data ()), strData.size ());
}