mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Parse UINT64 as hex.
This commit is contained in:
@@ -939,7 +939,7 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
||||
|
||||
case STI_UINT64:
|
||||
if (value.isString())
|
||||
data.push_back(new STUInt64(field, lexical_cast_st<uint64>(value.asString())));
|
||||
data.push_back(new STUInt64(field, uintFromHex(value.asString())));
|
||||
else if (value.isInt())
|
||||
data.push_back(new STUInt64(field,
|
||||
range_check_cast<uint64>(value.asInt(), 0, 18446744073709551615ull)));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "uint256.h"
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
//
|
||||
@@ -67,6 +68,16 @@ std::vector<unsigned char> strUnHex(const std::string& strSrc)
|
||||
return strCopy(strTmp);
|
||||
}
|
||||
|
||||
uint64_t uintFromHex(const std::string& strSrc)
|
||||
{
|
||||
uint64_t uValue = 0;
|
||||
|
||||
BOOST_FOREACH(char c, strSrc)
|
||||
uValue = (uValue << 4) | charUnHex(c);
|
||||
|
||||
return uValue;
|
||||
}
|
||||
|
||||
//
|
||||
// Misc string
|
||||
//
|
||||
|
||||
@@ -162,6 +162,8 @@ bool isZero(Iterator first, int iSize)
|
||||
int charUnHex(char cDigit);
|
||||
void strUnHex(std::string& strDst, const std::string& strSrc);
|
||||
|
||||
uint64_t uintFromHex(const std::string& strSrc);
|
||||
|
||||
std::vector<unsigned char> strUnHex(const std::string& strSrc);
|
||||
|
||||
std::vector<unsigned char> strCopy(const std::string& strSrc);
|
||||
|
||||
Reference in New Issue
Block a user