rippled
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
xrpl::STNumber Class Reference

A serializable number. More...

#include <STNumber.h>

Inheritance diagram for xrpl::STNumber:
Inheritance graph
[legend]
Collaboration diagram for xrpl::STNumber:
Collaboration graph
[legend]

Public Types

using value_type = Number
 

Public Member Functions

 STNumber ()=default
 
 STNumber (SField const &field, Number const &value=Number())
 
 STNumber (SerialIter &sit, SField const &field)
 
SerializedTypeID getSType () const override
 
std::string getText () const override
 
void add (Serializer &s) const override
 
Number const & value () const
 
void setValue (Number const &v)
 
STNumberoperator= (Number const &rhs)
 
bool isEquivalent (STBase const &t) const override
 
bool isDefault () const override
 
void associateAsset (Asset const &a) override
 
 operator Number () const
 
 STBase ()
 
 STBase (STBase const &)=default
 
 STBase (SField const &n)
 
bool operator== (STBase const &t) const
 
bool operator!= (STBase const &t) const
 
template<class D >
D & downcast ()
 
template<class D >
D const & downcast () const
 
template<class D >
D const & downcast () const
 
virtual std::string getFullText () const
 
virtual Json::Value getJson (JsonOptions=JsonOptions::none) const
 
void setFName (SField const &n)
 A STBase is a field.
 
SField const & getFName () const
 
void addFieldID (Serializer &s) const
 

Static Protected Member Functions

template<class T >
static STBaseemplace (std::size_t n, void *buf, T &&val)
 

Protected Attributes

std::optional< Assetasset_
 

Private Member Functions

STBasecopy (std::size_t n, void *buf) const override
 
STBasemove (std::size_t n, void *buf) override
 

Static Private Member Functions

static auto & getCounter () noexcept
 

Private Attributes

Number value_
 
SField const * fName
 

Detailed Description

A serializable number.

This type is-a Number, and can be used everywhere that is accepted. This type simply integrates Number with the serialization framework, letting it be used for fields in ledger entries and transactions. It is effectively an STAmount sans Asset: it can represent a value of any token type (XRP, IOU, or MPT) without paying the storage cost of duplicating asset information that may be deduced from the context.

STNumber derives from STTakesAsset, so that it can be associated with the related Asset during transaction processing. Which asset is relevant depends on the object and transaction. As of this writing, only Vault, LoanBroker, and Loan objects use STNumber fields. All of those fields represent amounts of the Vault's Asset, so they should be associated with the Vault's Asset.

e.g. associateAsset(*loanSle, asset); associateAsset(*brokerSle, asset); associateAsset(*vaultSle, asset);

Definition at line 34 of file STNumber.h.

Member Typedef Documentation

◆ value_type

Definition at line 40 of file STNumber.h.

Constructor & Destructor Documentation

◆ STNumber() [1/3]

xrpl::STNumber::STNumber ( )
default

◆ STNumber() [2/3]

xrpl::STNumber::STNumber ( SField const &  field,
Number const &  value = Number() 
)
explicit

Definition at line 23 of file STNumber.cpp.

◆ STNumber() [3/3]

xrpl::STNumber::STNumber ( SerialIter sit,
SField const &  field 
)

Definition at line 27 of file STNumber.cpp.

Member Function Documentation

◆ getSType()

SerializedTypeID xrpl::STNumber::getSType ( ) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 37 of file STNumber.cpp.

◆ getText()

std::string xrpl::STNumber::getText ( ) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 43 of file STNumber.cpp.

◆ add()

void xrpl::STNumber::add ( Serializer s) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 59 of file STNumber.cpp.

◆ value()

Number const & xrpl::STNumber::value ( ) const

Definition at line 105 of file STNumber.cpp.

◆ setValue()

void xrpl::STNumber::setValue ( Number const &  v)

Definition at line 111 of file STNumber.cpp.

◆ operator=()

STNumber & xrpl::STNumber::operator= ( Number const &  rhs)

Definition at line 59 of file STNumber.h.

◆ isEquivalent()

bool xrpl::STNumber::isEquivalent ( STBase const &  t) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 129 of file STNumber.cpp.

◆ isDefault()

bool xrpl::STNumber::isDefault ( ) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 137 of file STNumber.cpp.

◆ associateAsset()

void xrpl::STNumber::associateAsset ( Asset const &  a)
overridevirtual

Reimplemented from xrpl::STTakesAsset.

Definition at line 49 of file STNumber.cpp.

◆ operator Number()

xrpl::STNumber::operator Number ( ) const

Definition at line 73 of file STNumber.h.

◆ copy()

STBase * xrpl::STNumber::copy ( std::size_t  n,
void *  buf 
) const
overrideprivatevirtual

Reimplemented from xrpl::STBase.

Definition at line 117 of file STNumber.cpp.

◆ move()

STBase * xrpl::STNumber::move ( std::size_t  n,
void *  buf 
)
overrideprivatevirtual

Reimplemented from xrpl::STBase.

Definition at line 123 of file STNumber.cpp.

◆ STBase() [1/3]

xrpl::STBase::STBase ( )
inherited

Definition at line 120 of file STBase.cpp.

◆ STBase() [2/3]

xrpl::STBase::STBase ( STBase const &  )
defaultinherited

◆ STBase() [3/3]

xrpl::STBase::STBase ( SField const &  n)
explicitinherited

Definition at line 125 of file STBase.cpp.

◆ operator==()

bool xrpl::STBase::operator== ( STBase const &  t) const
inherited

Definition at line 32 of file STBase.cpp.

◆ operator!=()

bool xrpl::STBase::operator!= ( STBase const &  t) const
inherited

Definition at line 38 of file STBase.cpp.

◆ downcast() [1/3]

template<class D >
D & xrpl::STBase::downcast ( )
inherited

Definition at line 193 of file STBase.h.

◆ downcast() [2/3]

template<class D >
D const & xrpl::STBase::downcast ( ) const
inherited

◆ downcast() [3/3]

template<class D >
D const & xrpl::STBase::downcast ( ) const
inherited

Definition at line 203 of file STBase.h.

◆ getFullText()

std::string xrpl::STBase::getFullText ( ) const
virtualinherited

Reimplemented in xrpl::STAmount, xrpl::STArray, xrpl::STLedgerEntry, xrpl::STObject, and xrpl::STTx.

Definition at line 62 of file STBase.cpp.

◆ getJson()

Json::Value xrpl::STBase::getJson ( JsonOptions  = JsonOptions::none) const
virtualinherited

◆ setFName()

void xrpl::STBase::setFName ( SField const &  n)
inherited

A STBase is a field.

This sets the name.

Definition at line 115 of file STBase.cpp.

◆ getFName()

SField const & xrpl::STBase::getFName ( ) const
inherited

Definition at line 122 of file STBase.cpp.

◆ addFieldID()

void xrpl::STBase::addFieldID ( Serializer s) const
inherited

Definition at line 128 of file STBase.cpp.

◆ emplace()

template<class T >
STBase * xrpl::STBase::emplace ( std::size_t  n,
void *  buf,
T &&  val 
)
staticprotectedinherited

Definition at line 213 of file STBase.h.

◆ getCounter()

static auto & xrpl::CountedObject< STNumber >::getCounter ( )
staticprivatenoexceptinherited

Definition at line 109 of file CountedObject.h.

Member Data Documentation

◆ value_

Number xrpl::STNumber::value_
private

Definition at line 37 of file STNumber.h.

◆ asset_

std::optional<Asset> xrpl::STTakesAsset::asset_
protectedinherited

Definition at line 24 of file STTakesAsset.h.

◆ fName

SField const* xrpl::STBase::fName
privateinherited

Definition at line 116 of file STBase.h.