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
ripple::STAmount Class Referencefinal

#include <STAmount.h>

Inheritance diagram for ripple::STAmount:
Inheritance graph
[legend]
Collaboration diagram for ripple::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 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 std::uint64_t const cMinValue = 1000000000000000ull
 
static std::uint64_t const cMaxValue = 9999999999999999ull
 
static std::uint64_t const cMaxNative = 9000000000000000000ull
 
static std::uint64_t const cMaxNativeN = 100000000000000000ull
 
static std::uint64_t const cIssuedCurrency = 0x8000000000000000ull
 
static std::uint64_t const cPositive = 0x4000000000000000ull
 
static std::uint64_t const cMPToken = 0x2000000000000000ull
 
static std::uint64_t const 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 49 of file STAmount.h.

Member Typedef Documentation

◆ mantissa_type

Definition at line 52 of file STAmount.h.

◆ exponent_type

Definition at line 53 of file STAmount.h.

◆ rep

Definition at line 54 of file STAmount.h.

◆ value_type

Definition at line 63 of file STAmount.h.

Constructor & Destructor Documentation

◆ STAmount() [1/16]

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

Definition at line 120 of file STAmount.cpp.

◆ STAmount() [2/16]

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

Definition at line 322 of file STAmount.h.

◆ STAmount() [3/16]

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

Definition at line 338 of file STAmount.h.

◆ STAmount() [4/16]

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

Definition at line 349 of file STAmount.h.

◆ STAmount() [5/16]

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

Definition at line 202 of file STAmount.cpp.

◆ STAmount() [6/16]

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

Definition at line 208 of file STAmount.cpp.

◆ STAmount() [7/16]

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

Definition at line 236 of file STAmount.cpp.

◆ STAmount() [8/16]

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

Definition at line 221 of file STAmount.cpp.

◆ STAmount() [9/16]

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

Definition at line 129 of file STAmount.h.

◆ STAmount() [10/16]

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

Definition at line 378 of file STAmount.h.

◆ STAmount() [11/16]

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

Definition at line 370 of file STAmount.h.

◆ STAmount() [12/16]

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

Definition at line 388 of file STAmount.h.

◆ STAmount() [13/16]

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

Definition at line 157 of file STAmount.h.

◆ STAmount() [14/16]

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

Definition at line 394 of file STAmount.h.

◆ STAmount() [15/16]

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

Definition at line 248 of file STAmount.cpp.

◆ STAmount() [16/16]

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

Definition at line 407 of file STAmount.h.

Member Function Documentation

◆ operator Number()

ripple::STAmount::operator Number ( ) const

Definition at line 530 of file STAmount.h.

◆ exponent()

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

Definition at line 452 of file STAmount.h.

◆ native()

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

Definition at line 458 of file STAmount.h.

◆ holds()

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

Definition at line 465 of file STAmount.h.

◆ negative()

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

Definition at line 471 of file STAmount.h.

◆ mantissa()

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

Definition at line 477 of file STAmount.h.

◆ asset()

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

Definition at line 483 of file STAmount.h.

◆ get() [1/2]

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

◆ issue()

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

Definition at line 496 of file STAmount.h.

◆ getCurrency()

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

Definition at line 502 of file STAmount.h.

◆ getIssuer()

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

Definition at line 508 of file STAmount.h.

◆ signum()

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

Definition at line 514 of file STAmount.h.

◆ zeroed()

STAmount ripple::STAmount::zeroed ( ) const

Returns a zero value with the same issuer and currency.

Definition at line 520 of file STAmount.h.

◆ setJson()

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

Definition at line 643 of file STAmount.cpp.

◆ value()

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

Definition at line 594 of file STAmount.h.

◆ operator bool()

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

Definition at line 525 of file STAmount.h.

◆ operator+=()

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

Definition at line 350 of file STAmount.cpp.

◆ operator-=()

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

Definition at line 357 of file STAmount.cpp.

◆ operator=() [1/4]

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

Definition at line 540 of file STAmount.h.

◆ operator=() [2/4]

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

Definition at line 547 of file STAmount.h.

◆ operator=() [3/4]

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

Definition at line 554 of file STAmount.h.

◆ negate()

void ripple::STAmount::negate ( )

Definition at line 564 of file STAmount.h.

◆ clear() [1/2]

void ripple::STAmount::clear ( )

Definition at line 571 of file STAmount.h.

◆ clear() [2/2]

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

Definition at line 581 of file STAmount.h.

◆ setIssuer()

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

Definition at line 588 of file STAmount.h.

◆ setIssue()

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

Set the Issue for this amount.

Definition at line 448 of file STAmount.cpp.

◆ getSType()

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

Reimplemented from ripple::STBase.

Definition at line 667 of file STAmount.cpp.

◆ getFullText()

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

Reimplemented from ripple::STBase.

Definition at line 673 of file STAmount.cpp.

◆ getText()

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

Reimplemented from ripple::STBase.

Definition at line 683 of file STAmount.cpp.

◆ getJson()

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

Reimplemented from ripple::STBase.

Definition at line 772 of file STAmount.cpp.

◆ add()

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

Reimplemented from ripple::STBase.

Definition at line 780 of file STAmount.cpp.

◆ isEquivalent()

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

Reimplemented from ripple::STBase.

Definition at line 819 of file STAmount.cpp.

◆ isDefault()

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

Reimplemented from ripple::STBase.

Definition at line 826 of file STAmount.cpp.

◆ xrp()

XRPAmount ripple::STAmount::xrp ( ) const

Definition at line 283 of file STAmount.cpp.

◆ iou()

IOUAmount ripple::STAmount::iou ( ) const

Definition at line 299 of file STAmount.cpp.

◆ mpt()

MPTAmount ripple::STAmount::mpt ( ) const

Definition at line 314 of file STAmount.cpp.

◆ construct()

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

Definition at line 260 of file STAmount.cpp.

◆ set()

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

Definition at line 967 of file STAmount.cpp.

◆ canonicalize()

void ripple::STAmount::canonicalize ( )
private

Definition at line 850 of file STAmount.cpp.

◆ copy()

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

Reimplemented from ripple::STBase.

Definition at line 266 of file STAmount.cpp.

◆ move()

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

Reimplemented from ripple::STBase.

Definition at line 272 of file STAmount.cpp.

◆ operator=() [4/4]

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

Definition at line 329 of file STAmount.cpp.

◆ get() [2/2]

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

Definition at line 490 of file STAmount.h.

◆ operator==()

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

Definition at line 51 of file STBase.cpp.

◆ operator!=()

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

Definition at line 57 of file STBase.cpp.

◆ downcast() [1/3]

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

Definition at line 213 of file STBase.h.

◆ downcast() [2/3]

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

◆ downcast() [3/3]

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

Definition at line 223 of file STBase.h.

◆ setFName()

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

A STBase is a field.

This sets the name.

Definition at line 136 of file STBase.cpp.

◆ getFName()

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

Definition at line 143 of file STBase.cpp.

◆ addFieldID()

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

Definition at line 149 of file STBase.cpp.

◆ emplace()

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

Definition at line 233 of file STBase.h.

◆ getCounter()

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

Definition at line 129 of file CountedObject.h.

Friends And Related Symbol Documentation

◆ detail::STVar

friend class detail::STVar
friend

Definition at line 315 of file STAmount.h.

◆ operator+

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

Definition at line 364 of file STAmount.cpp.

Member Data Documentation

◆ mAsset

Asset ripple::STAmount::mAsset
private

Definition at line 57 of file STAmount.h.

◆ mValue

mantissa_type ripple::STAmount::mValue
private

Definition at line 58 of file STAmount.h.

◆ mOffset

exponent_type ripple::STAmount::mOffset
private

Definition at line 59 of file STAmount.h.

◆ mIsNegative

bool ripple::STAmount::mIsNegative
private

Definition at line 60 of file STAmount.h.

◆ cMinOffset

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

Definition at line 65 of file STAmount.h.

◆ cMaxOffset

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

Definition at line 66 of file STAmount.h.

◆ cMinValue

std::uint64_t const ripple::STAmount::cMinValue = 1000000000000000ull
static

Definition at line 69 of file STAmount.h.

◆ cMaxValue

std::uint64_t const ripple::STAmount::cMaxValue = 9999999999999999ull
static

Definition at line 70 of file STAmount.h.

◆ cMaxNative

std::uint64_t const ripple::STAmount::cMaxNative = 9000000000000000000ull
static

Definition at line 71 of file STAmount.h.

◆ cMaxNativeN

std::uint64_t const ripple::STAmount::cMaxNativeN = 100000000000000000ull
static

Definition at line 74 of file STAmount.h.

◆ cIssuedCurrency

std::uint64_t const ripple::STAmount::cIssuedCurrency = 0x8000000000000000ull
static

Definition at line 75 of file STAmount.h.

◆ cPositive

std::uint64_t const ripple::STAmount::cPositive = 0x4000000000000000ull
static

Definition at line 76 of file STAmount.h.

◆ cMPToken

std::uint64_t const ripple::STAmount::cMPToken = 0x2000000000000000ull
static

Definition at line 77 of file STAmount.h.

◆ cValueMask

std::uint64_t const ripple::STAmount::cValueMask = ~(cPositive | cMPToken)
static

Definition at line 78 of file STAmount.h.

◆ uRateOne

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

Definition at line 80 of file STAmount.h.

◆ fName

SField const* ripple::STBase::fName
privateinherited

Definition at line 136 of file STBase.h.