rippled
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Attributes | Static Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
xrpl::STAmount Class Referencefinal

#include <STAmount.h>

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

Classes

struct  unchecked
 

Public Types

using mantissa_type = std::uint64_t
 
using exponent_type = int
 
using rep = std::pair< mantissa_type, exponent_type >
 
using value_type = STAmount
 

Public Member Functions

 STAmount (SerialIter &sit, SField const &name)
 
template<AssetType A>
 STAmount (SField const &name, A const &asset, mantissa_type mantissa, exponent_type exponent, bool negative, unchecked)
 
template<AssetType A>
 STAmount (A const &asset, mantissa_type mantissa, exponent_type exponent, bool negative, unchecked)
 
template<AssetType A>
 STAmount (SField const &name, A const &asset, mantissa_type mantissa=0, exponent_type exponent=0, bool negative=false)
 
 STAmount (SField const &name, std::int64_t mantissa)
 
 STAmount (SField const &name, std::uint64_t mantissa=0, bool negative=false)
 
 STAmount (std::uint64_t mantissa=0, bool negative=false)
 
 STAmount (SField const &name, STAmount const &amt)
 
template<AssetType A>
 STAmount (A const &asset, std::uint64_t mantissa=0, int exponent=0, bool negative=false)
 
template<AssetType A>
 STAmount (A const &asset, std::uint32_t mantissa, int exponent=0, bool negative=false)
 
template<AssetType A>
 STAmount (A const &asset, std::int64_t mantissa, int exponent=0)
 
template<AssetType A>
 STAmount (A const &asset, int mantissa, int exponent=0)
 
template<AssetType A>
 STAmount (A const &asset, Number const &number)
 
 STAmount (IOUAmount const &amount, Issue const &issue)
 
 STAmount (XRPAmount const &amount)
 
 STAmount (MPTAmount const &amount, MPTIssue const &mptIssue)
 
 operator Number () const
 
int exponent () const noexcept
 
bool integral () const noexcept
 
bool native () const noexcept
 
template<ValidIssueType TIss>
constexpr bool holds () const noexcept
 
bool negative () const noexcept
 
std::uint64_t mantissa () const noexcept
 
Asset const & asset () const
 
template<ValidIssueType TIss>
constexpr TIss const & get () const
 
Issue const & issue () const
 
Currency const & getCurrency () const
 
AccountID const & getIssuer () const
 
int signum () const noexcept
 
STAmount zeroed () const
 Returns a zero value with the same issuer and currency.
 
void setJson (Json::Value &) const
 
STAmount const & value () const noexcept
 
 operator bool () const noexcept
 
STAmountoperator+= (STAmount const &)
 
STAmountoperator-= (STAmount const &)
 
STAmountoperator= (beast::Zero)
 
STAmountoperator= (XRPAmount const &amount)
 
STAmountoperator= (Number const &)
 
void negate ()
 
void clear ()
 
void clear (Asset const &asset)
 
void setIssuer (AccountID const &uIssuer)
 
void setIssue (Asset const &asset)
 Set the Issue for this amount.
 
SerializedTypeID getSType () const override
 
std::string getFullText () const override
 
std::string getText () const override
 
Json::Value getJson (JsonOptions=JsonOptions::none) const override
 
void add (Serializer &s) const override
 
bool isEquivalent (STBase const &t) const override
 
bool isDefault () const override
 
XRPAmount xrp () const
 
IOUAmount iou () const
 
MPTAmount mpt () const
 
template<ValidIssueType TIss>
constexpr TIss const & get () const
 
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
 
void setFName (SField const &n)
 A STBase is a field.
 
SField const & getFName () const
 
void addFieldID (Serializer &s) const
 

Static Public Attributes

static int const cMinOffset = -96
 
static int const cMaxOffset = 80
 
static constexpr std::uint64_t cMinValue = 1'000'000'000'000'000ull
 
static constexpr std::uint64_t cMaxValue = cMinValue * 10 - 1
 
static constexpr std::uint64_t cMaxNative = 9'000'000'000'000'000'000ull
 
static constexpr std::uint64_t cMaxNativeN = 100'000'000'000'000'000ull
 
static constexpr std::uint64_t cIssuedCurrency = 0x8'000'000'000'000'000ull
 
static constexpr std::uint64_t cPositive = 0x4'000'000'000'000'000ull
 
static constexpr std::uint64_t cMPToken = 0x2'000'000'000'000'000ull
 
static constexpr std::uint64_t cValueMask = ~(cPositive | cMPToken)
 
static std::uint64_t const uRateOne = getRate(STAmount(1), STAmount(1))
 

Static Protected Member Functions

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

Private Member Functions

void set (std::int64_t v)
 
void canonicalize ()
 
STBasecopy (std::size_t n, void *buf) const override
 
STBasemove (std::size_t n, void *buf) override
 
STAmountoperator= (IOUAmount const &iou)
 

Static Private Member Functions

static std::unique_ptr< STAmountconstruct (SerialIter &, SField const &name)
 
static auto & getCounter () noexcept
 

Private Attributes

Asset mAsset
 
mantissa_type mValue
 
exponent_type mOffset
 
bool mIsNegative
 
SField const * fName
 

Friends

class detail::STVar
 
STAmount operator+ (STAmount const &v1, STAmount const &v2)
 

Detailed Description

Definition at line 30 of file STAmount.h.

Member Typedef Documentation

◆ mantissa_type

Definition at line 33 of file STAmount.h.

◆ exponent_type

Definition at line 34 of file STAmount.h.

◆ rep

Definition at line 35 of file STAmount.h.

◆ value_type

Definition at line 44 of file STAmount.h.

Constructor & Destructor Documentation

◆ STAmount() [1/16]

xrpl::STAmount::STAmount ( SerialIter sit,
SField const &  name 
)

Definition at line 101 of file STAmount.cpp.

◆ STAmount() [2/16]

template<AssetType A>
xrpl::STAmount::STAmount ( SField const &  name,
A const &  asset,
mantissa_type  mantissa,
exponent_type  exponent,
bool  negative,
unchecked   
)

Definition at line 308 of file STAmount.h.

◆ STAmount() [3/16]

template<AssetType A>
xrpl::STAmount::STAmount ( A const &  asset,
mantissa_type  mantissa,
exponent_type  exponent,
bool  negative,
unchecked   
)

Definition at line 324 of file STAmount.h.

◆ STAmount() [4/16]

template<AssetType A>
xrpl::STAmount::STAmount ( SField const &  name,
A const &  asset,
mantissa_type  mantissa = 0,
exponent_type  exponent = 0,
bool  negative = false 
)

Definition at line 335 of file STAmount.h.

◆ STAmount() [5/16]

xrpl::STAmount::STAmount ( SField const &  name,
std::int64_t  mantissa 
)

Definition at line 183 of file STAmount.cpp.

◆ STAmount() [6/16]

xrpl::STAmount::STAmount ( SField const &  name,
std::uint64_t  mantissa = 0,
bool  negative = false 
)

Definition at line 189 of file STAmount.cpp.

◆ STAmount() [7/16]

xrpl::STAmount::STAmount ( std::uint64_t  mantissa = 0,
bool  negative = false 
)
explicit

Definition at line 217 of file STAmount.cpp.

◆ STAmount() [8/16]

xrpl::STAmount::STAmount ( SField const &  name,
STAmount const &  amt 
)
explicit

Definition at line 202 of file STAmount.cpp.

◆ STAmount() [9/16]

template<AssetType A>
xrpl::STAmount::STAmount ( A const &  asset,
std::uint64_t  mantissa = 0,
int  exponent = 0,
bool  negative = false 
)

Definition at line 112 of file STAmount.h.

◆ STAmount() [10/16]

template<AssetType A>
xrpl::STAmount::STAmount ( A const &  asset,
std::uint32_t  mantissa,
int  exponent = 0,
bool  negative = false 
)

Definition at line 364 of file STAmount.h.

◆ STAmount() [11/16]

template<AssetType A>
xrpl::STAmount::STAmount ( A const &  asset,
std::int64_t  mantissa,
int  exponent = 0 
)

Definition at line 356 of file STAmount.h.

◆ STAmount() [12/16]

template<AssetType A>
xrpl::STAmount::STAmount ( A const &  asset,
int  mantissa,
int  exponent = 0 
)

Definition at line 374 of file STAmount.h.

◆ STAmount() [13/16]

template<AssetType A>
xrpl::STAmount::STAmount ( A const &  asset,
Number const &  number 
)

Definition at line 140 of file STAmount.h.

◆ STAmount() [14/16]

xrpl::STAmount::STAmount ( IOUAmount const &  amount,
Issue const &  issue 
)

Definition at line 380 of file STAmount.h.

◆ STAmount() [15/16]

xrpl::STAmount::STAmount ( XRPAmount const &  amount)

Definition at line 229 of file STAmount.cpp.

◆ STAmount() [16/16]

xrpl::STAmount::STAmount ( MPTAmount const &  amount,
MPTIssue const &  mptIssue 
)

Definition at line 393 of file STAmount.h.

Member Function Documentation

◆ operator Number()

xrpl::STAmount::operator Number ( ) const

Definition at line 522 of file STAmount.h.

◆ exponent()

int xrpl::STAmount::exponent ( ) const
noexcept

Definition at line 438 of file STAmount.h.

◆ integral()

bool xrpl::STAmount::integral ( ) const
noexcept

Definition at line 444 of file STAmount.h.

◆ native()

bool xrpl::STAmount::native ( ) const
noexcept

Definition at line 450 of file STAmount.h.

◆ holds()

template<ValidIssueType TIss>
constexpr bool xrpl::STAmount::holds ( ) const
constexprnoexcept

Definition at line 457 of file STAmount.h.

◆ negative()

bool xrpl::STAmount::negative ( ) const
noexcept

Definition at line 463 of file STAmount.h.

◆ mantissa()

std::uint64_t xrpl::STAmount::mantissa ( ) const
noexcept

Definition at line 469 of file STAmount.h.

◆ asset()

Asset const & xrpl::STAmount::asset ( ) const

Definition at line 475 of file STAmount.h.

◆ get() [1/2]

template<ValidIssueType TIss>
constexpr TIss const & xrpl::STAmount::get ( ) const
constexpr

◆ issue()

Issue const & xrpl::STAmount::issue ( ) const

Definition at line 488 of file STAmount.h.

◆ getCurrency()

Currency const & xrpl::STAmount::getCurrency ( ) const

Definition at line 494 of file STAmount.h.

◆ getIssuer()

AccountID const & xrpl::STAmount::getIssuer ( ) const

Definition at line 500 of file STAmount.h.

◆ signum()

int xrpl::STAmount::signum ( ) const
noexcept

Definition at line 506 of file STAmount.h.

◆ zeroed()

STAmount xrpl::STAmount::zeroed ( ) const

Returns a zero value with the same issuer and currency.

Definition at line 512 of file STAmount.h.

◆ setJson()

void xrpl::STAmount::setJson ( Json::Value elem) const

Definition at line 623 of file STAmount.cpp.

◆ value()

STAmount const & xrpl::STAmount::value ( ) const
noexcept

Definition at line 586 of file STAmount.h.

◆ operator bool()

xrpl::STAmount::operator bool ( ) const
explicitnoexcept

Definition at line 517 of file STAmount.h.

◆ operator+=()

STAmount & xrpl::STAmount::operator+= ( STAmount const &  a)

Definition at line 330 of file STAmount.cpp.

◆ operator-=()

STAmount & xrpl::STAmount::operator-= ( STAmount const &  a)

Definition at line 337 of file STAmount.cpp.

◆ operator=() [1/4]

STAmount & xrpl::STAmount::operator= ( beast::Zero  )

Definition at line 532 of file STAmount.h.

◆ operator=() [2/4]

STAmount & xrpl::STAmount::operator= ( XRPAmount const &  amount)

Definition at line 539 of file STAmount.h.

◆ operator=() [3/4]

STAmount & xrpl::STAmount::operator= ( Number const &  number)

Definition at line 546 of file STAmount.h.

◆ negate()

void xrpl::STAmount::negate ( )

Definition at line 556 of file STAmount.h.

◆ clear() [1/2]

void xrpl::STAmount::clear ( )

Definition at line 563 of file STAmount.h.

◆ clear() [2/2]

void xrpl::STAmount::clear ( Asset const &  asset)

Definition at line 573 of file STAmount.h.

◆ setIssuer()

void xrpl::STAmount::setIssuer ( AccountID const &  uIssuer)

Definition at line 580 of file STAmount.h.

◆ setIssue()

void xrpl::STAmount::setIssue ( Asset const &  asset)

Set the Issue for this amount.

Definition at line 428 of file STAmount.cpp.

◆ getSType()

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

Reimplemented from xrpl::STBase.

Definition at line 647 of file STAmount.cpp.

◆ getFullText()

std::string xrpl::STAmount::getFullText ( ) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 653 of file STAmount.cpp.

◆ getText()

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

Reimplemented from xrpl::STBase.

Definition at line 663 of file STAmount.cpp.

◆ getJson()

Json::Value xrpl::STAmount::getJson ( JsonOptions  = JsonOptions::none) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 751 of file STAmount.cpp.

◆ add()

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

Reimplemented from xrpl::STBase.

Definition at line 759 of file STAmount.cpp.

◆ isEquivalent()

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

Reimplemented from xrpl::STBase.

Definition at line 798 of file STAmount.cpp.

◆ isDefault()

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

Reimplemented from xrpl::STBase.

Definition at line 805 of file STAmount.cpp.

◆ xrp()

XRPAmount xrpl::STAmount::xrp ( ) const

Definition at line 264 of file STAmount.cpp.

◆ iou()

IOUAmount xrpl::STAmount::iou ( ) const

Definition at line 280 of file STAmount.cpp.

◆ mpt()

MPTAmount xrpl::STAmount::mpt ( ) const

Definition at line 295 of file STAmount.cpp.

◆ construct()

std::unique_ptr< STAmount > xrpl::STAmount::construct ( SerialIter sit,
SField const &  name 
)
staticprivate

Definition at line 241 of file STAmount.cpp.

◆ set()

void xrpl::STAmount::set ( std::int64_t  v)
private

Definition at line 948 of file STAmount.cpp.

◆ canonicalize()

void xrpl::STAmount::canonicalize ( )
private

Definition at line 829 of file STAmount.cpp.

◆ copy()

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

Reimplemented from xrpl::STBase.

Definition at line 247 of file STAmount.cpp.

◆ move()

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

Reimplemented from xrpl::STBase.

Definition at line 253 of file STAmount.cpp.

◆ operator=() [4/4]

STAmount & xrpl::STAmount::operator= ( IOUAmount const &  iou)
private

Definition at line 310 of file STAmount.cpp.

◆ get() [2/2]

template<ValidIssueType TIss>
constexpr TIss const & xrpl::STAmount::get ( ) const
constexpr

Definition at line 482 of file STAmount.h.

◆ 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 194 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 204 of file STBase.h.

◆ setFName()

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

A STBase is a field.

This sets the name.

Definition at line 117 of file STBase.cpp.

◆ getFName()

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

Definition at line 124 of file STBase.cpp.

◆ addFieldID()

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

Definition at line 130 of file STBase.cpp.

◆ emplace()

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

Definition at line 214 of file STBase.h.

◆ getCounter()

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

Definition at line 110 of file CountedObject.h.

Friends And Related Symbol Documentation

◆ detail::STVar

friend class detail::STVar
friend

Definition at line 301 of file STAmount.h.

◆ operator+

STAmount operator+ ( STAmount const &  v1,
STAmount const &  v2 
)
friend

Definition at line 344 of file STAmount.cpp.

Member Data Documentation

◆ mAsset

Asset xrpl::STAmount::mAsset
private

Definition at line 38 of file STAmount.h.

◆ mValue

mantissa_type xrpl::STAmount::mValue
private

Definition at line 39 of file STAmount.h.

◆ mOffset

exponent_type xrpl::STAmount::mOffset
private

Definition at line 40 of file STAmount.h.

◆ mIsNegative

bool xrpl::STAmount::mIsNegative
private

Definition at line 41 of file STAmount.h.

◆ cMinOffset

int const xrpl::STAmount::cMinOffset = -96
static

Definition at line 46 of file STAmount.h.

◆ cMaxOffset

int const xrpl::STAmount::cMaxOffset = 80
static

Definition at line 47 of file STAmount.h.

◆ cMinValue

constexpr std::uint64_t xrpl::STAmount::cMinValue = 1'000'000'000'000'000ull
staticconstexpr

Definition at line 50 of file STAmount.h.

◆ cMaxValue

constexpr std::uint64_t xrpl::STAmount::cMaxValue = cMinValue * 10 - 1
staticconstexpr

Definition at line 52 of file STAmount.h.

◆ cMaxNative

constexpr std::uint64_t xrpl::STAmount::cMaxNative = 9'000'000'000'000'000'000ull
staticconstexpr

Definition at line 54 of file STAmount.h.

◆ cMaxNativeN

constexpr std::uint64_t xrpl::STAmount::cMaxNativeN = 100'000'000'000'000'000ull
staticconstexpr

Definition at line 57 of file STAmount.h.

◆ cIssuedCurrency

constexpr std::uint64_t xrpl::STAmount::cIssuedCurrency = 0x8'000'000'000'000'000ull
staticconstexpr

Definition at line 58 of file STAmount.h.

◆ cPositive

constexpr std::uint64_t xrpl::STAmount::cPositive = 0x4'000'000'000'000'000ull
staticconstexpr

Definition at line 59 of file STAmount.h.

◆ cMPToken

constexpr std::uint64_t xrpl::STAmount::cMPToken = 0x2'000'000'000'000'000ull
staticconstexpr

Definition at line 60 of file STAmount.h.

◆ cValueMask

constexpr std::uint64_t xrpl::STAmount::cValueMask = ~(cPositive | cMPToken)
staticconstexpr

Definition at line 61 of file STAmount.h.

◆ uRateOne

std::uint64_t const xrpl::STAmount::uRateOne = getRate(STAmount(1), STAmount(1))
static

Definition at line 63 of file STAmount.h.

◆ fName

SField const* xrpl::STBase::fName
privateinherited

Definition at line 117 of file STBase.h.