Break out the portion that sets the value from the STAmount code.

Fix its mishandling of negative amounts.
Support array types in STAmount JSON input.
This commit is contained in:
JoelKatz
2012-10-02 04:28:01 -07:00
parent 17a99e686b
commit ddab25ab44
2 changed files with 114 additions and 84 deletions

View File

@@ -220,8 +220,6 @@ protected:
: SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off),
mIsNative(isNat), mIsNegative(isNeg) { ; }
STAmount(SField::ref name, const Json::Value& value);
uint64 toUInt64() const;
static uint64 muldiv(uint64, uint64, uint64);
@@ -245,6 +243,8 @@ public:
SerializedType(n), mCurrency(currency), mIssuer(issuer), mValue(v), mOffset(off), mIsNegative(isNeg)
{ canonicalize(); }
STAmount(SField::ref, const Json::Value&);
static STAmount createFromInt64(SField::ref n, int64 v);
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
@@ -288,6 +288,7 @@ public:
void setIssuer(const uint160& uIssuer) { mIssuer = uIssuer; }
const uint160& getCurrency() const { return mCurrency; }
bool setValue(const std::string& sAmount);
bool setFullValue(const std::string& sAmount, const std::string& sCurrency = "", const std::string& sIssuer = "");
void setValue(const STAmount &);