mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
CBase58Data Refactoring:
* Remove unnecessary functions. * Load from a base_uint const& - don't use void pointers. * Free comparison functions. * Explicitly specify encoding alphabet. * Miscellaneous cleanups.
This commit is contained in:
committed by
Vinnie Falco
parent
9a4b9aa69f
commit
1a9fbab165
@@ -114,29 +114,23 @@ public:
|
||||
return raw_encode (&v.front(), &v.back()+1, alphabet, withCheck);
|
||||
}
|
||||
|
||||
// VFALCO NOTE Avoid this interface which uses globals, explicitly
|
||||
// pass the alphabet in the call to encode!
|
||||
//
|
||||
static Alphabet const& getCurrentAlphabet ();
|
||||
static void setCurrentAlphabet (Alphabet const& alphabet);
|
||||
|
||||
template <class Container>
|
||||
static std::string encode (Container const& container)
|
||||
{
|
||||
return encode (container.container.begin(), container.end(),
|
||||
getCurrentAlphabet(), false);
|
||||
getRippleAlphabet(), false);
|
||||
}
|
||||
|
||||
template <class Container>
|
||||
static std::string encodeWithCheck (Container const& container)
|
||||
{
|
||||
return encode (&container.front(), &container.back()+1,
|
||||
getCurrentAlphabet(), true);
|
||||
getRippleAlphabet(), true);
|
||||
}
|
||||
|
||||
static std::string encode (const unsigned char* pbegin, const unsigned char* pend)
|
||||
{
|
||||
return encode (pbegin, pend, getCurrentAlphabet(), false);
|
||||
return encode (pbegin, pend, getRippleAlphabet(), false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -146,13 +140,10 @@ public:
|
||||
static bool raw_decode (char const* first, char const* last,
|
||||
void* dest, std::size_t size, bool checked, Alphabet const& alphabet);
|
||||
|
||||
static bool decode (const char* psz, Blob& vchRet, Alphabet const& alphabet = getCurrentAlphabet ());
|
||||
static bool decode (const char* psz, Blob& vchRet, Alphabet const& alphabet = getRippleAlphabet ());
|
||||
static bool decode (const std::string& str, Blob& vchRet);
|
||||
static bool decodeWithCheck (const char* psz, Blob& vchRet, Alphabet const& alphabet = getCurrentAlphabet());
|
||||
static bool decodeWithCheck (const std::string& str, Blob& vchRet, Alphabet const& alphabet = getCurrentAlphabet());
|
||||
|
||||
private:
|
||||
static Alphabet const* s_currentAlphabet;
|
||||
static bool decodeWithCheck (const char* psz, Blob& vchRet, Alphabet const& alphabet = getRippleAlphabet());
|
||||
static bool decodeWithCheck (const std::string& str, Blob& vchRet, Alphabet const& alphabet = getRippleAlphabet());
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Base58::Alphabet const* Base58::s_currentAlphabet = &Base58::getRippleAlphabet ();
|
||||
|
||||
void Base58::fourbyte_hash256 (void* out, void const* in, std::size_t bytes)
|
||||
{
|
||||
unsigned char const* const p (
|
||||
@@ -88,16 +86,6 @@ std::string Base58::raw_encode (
|
||||
return str;
|
||||
}
|
||||
|
||||
Base58::Alphabet const& Base58::getCurrentAlphabet ()
|
||||
{
|
||||
return *s_currentAlphabet;
|
||||
}
|
||||
|
||||
void Base58::setCurrentAlphabet (Alphabet const& alphabet)
|
||||
{
|
||||
s_currentAlphabet = &alphabet;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool Base58::raw_decode (char const* first, char const* last, void* dest,
|
||||
|
||||
Reference in New Issue
Block a user