Simplify strHex:

Problem:
- There are several specific overloads with some custom code that can be
  easily replaced using Boost.Hex.

Solution:
- Introduce `strHex(itr, itr)` to return a string given a begin and end
  iterator.
- Remove `strHex(itr, size)` in favor of the `strHex(T)` where T is
  something that has a `begin()` member function. This allows us to
  remove the strHex overloads for `std::string`, Blob, and Slice.
This commit is contained in:
Joe Loser
2018-08-20 22:38:40 -04:00
committed by seelabs
parent 3661dc88fe
commit 1ac9694dbc
17 changed files with 174 additions and 54 deletions

View File

@@ -31,7 +31,7 @@ namespace ripple {
std::ostream&
operator<<(std::ostream& os, PublicKey const& pk)
{
os << strHex(pk.data(), pk.size());
os << strHex(pk);
return os;
}

View File

@@ -31,7 +31,7 @@ STBlob::STBlob (SerialIter& st, SField const& name)
std::string
STBlob::getText () const
{
return strHex (value_.data (), value_.size ());
return strHex (value_);
}
bool

View File

@@ -156,7 +156,7 @@ STPath::getJson (int) const
for (auto it: mPath)
{
Json::Value elem (Json::objectValue);
int iType = it.getNodeType ();
auto const iType = it.getNodeType ();
elem[jss::type] = iType;
elem[jss::type_hex] = strHex (iType);

View File

@@ -51,7 +51,7 @@ SecretKey::SecretKey (Slice const& slice)
std::string
SecretKey::to_string() const
{
return strHex(data(), size());
return strHex(*this);
}
//------------------------------------------------------------------------------

View File

@@ -61,7 +61,7 @@ std::string to_string(Currency const& currency)
}
}
return strHex (currency.begin (), currency.size ());
return strHex (currency);
}
bool to_currency(Currency& currency, std::string const& code)