mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Add a new serialized type: STNumber (#5121)
`STNumber` lets objects and transactions contain multiple fields for quantities of XRP, IOU, or MPT without duplicating information about the "issue" (represented by `STIssue`). It is a straightforward serialization of the `Number` type that uniformly represents those quantities. --------- Co-authored-by: John Freeman <jfreeman08@gmail.com> Co-authored-by: Howard Hinnant <howard.hinnant@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <xrpl/protocol/STArray.h>
|
||||
#include <xrpl/protocol/STBlob.h>
|
||||
#include <xrpl/protocol/STCurrency.h>
|
||||
#include <xrpl/protocol/STNumber.h>
|
||||
#include <xrpl/protocol/STObject.h>
|
||||
|
||||
namespace ripple {
|
||||
@@ -665,6 +666,13 @@ STObject::getFieldCurrency(SField const& field) const
|
||||
return getFieldByConstRef<STCurrency>(field, empty);
|
||||
}
|
||||
|
||||
STNumber const&
|
||||
STObject::getFieldNumber(SField const& field) const
|
||||
{
|
||||
static STNumber const empty{};
|
||||
return getFieldByConstRef<STNumber>(field, empty);
|
||||
}
|
||||
|
||||
void
|
||||
STObject::set(std::unique_ptr<STBase> v)
|
||||
{
|
||||
@@ -765,6 +773,12 @@ STObject::setFieldIssue(SField const& field, STIssue const& v)
|
||||
setFieldUsingAssignment(field, v);
|
||||
}
|
||||
|
||||
void
|
||||
STObject::setFieldNumber(SField const& field, STNumber const& v)
|
||||
{
|
||||
setFieldUsingAssignment(field, v);
|
||||
}
|
||||
|
||||
void
|
||||
STObject::setFieldPathSet(SField const& field, STPathSet const& v)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user