rippled
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
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)
 
 STAmount (SField const &name, Issue const &issue, mantissa_type mantissa, exponent_type exponent, bool native, bool negative, unchecked)
 
 STAmount (Issue const &issue, mantissa_type mantissa, exponent_type exponent, bool native, bool negative, unchecked)
 
 STAmount (SField const &name, Issue const &issue, mantissa_type mantissa, exponent_type exponent, bool native, bool negative)
 
 STAmount (SField const &name, std::int64_t mantissa)
 
 STAmount (SField const &name, std::uint64_t mantissa=0, bool negative=false)
 
 STAmount (SField const &name, Issue const &issue, std::uint64_t mantissa=0, int exponent=0, bool negative=false)
 
 STAmount (std::uint64_t mantissa=0, bool negative=false)
 
 STAmount (Issue const &issue, std::uint64_t mantissa=0, int exponent=0, bool negative=false)
 
 STAmount (Issue const &issue, std::uint32_t mantissa, int exponent=0, bool negative=false)
 
 STAmount (Issue const &issue, std::int64_t mantissa, int exponent=0)
 
 STAmount (Issue const &issue, int mantissa, int exponent=0)
 
 STAmount (IOUAmount const &amount, Issue const &issue)
 
 STAmount (XRPAmount const &amount)
 
 operator Number () const
 
int exponent () const noexcept
 
bool native () const noexcept
 
bool negative () const noexcept
 
std::uint64_t mantissa () const noexcept
 
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. More...
 
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)
 
void negate ()
 
void clear ()
 
void clear (STAmount const &saTmpl)
 
void clear (Issue const &issue)
 
void setIssuer (AccountID const &uIssuer)
 
void setIssue (Issue const &issue)
 Set the Issue for this amount and update mIsNative. More...
 
SerializedTypeID getSType () const override
 
std::string getFullText () const override
 
std::string getText () const override
 
Json::Value getJson (JsonOptions) const override
 
void add (Serializer &s) const override
 
bool isEquivalent (const STBase &t) const override
 
bool isDefault () const override
 
XRPAmount xrp () const
 
IOUAmount iou () const
 
bool operator== (const STBase &t) const
 
bool operator!= (const STBase &t) const
 
template<class D >
D & downcast ()
 
template<class D >
D const & downcast () const
 
void setFName (SField const &n)
 A STBase is a field. More...
 
SField const & getFName () const
 
void addFieldID (Serializer &s) const
 

Static Public Attributes

static const int cMinOffset = -96
 
static const int cMaxOffset = 80
 
static const std::uint64_t cMinValue = 1000000000000000ull
 
static const std::uint64_t cMaxValue = 9999999999999999ull
 
static const std::uint64_t cMaxNative = 9000000000000000000ull
 
static const std::uint64_t cMaxNativeN = 100000000000000000ull
 
static const std::uint64_t cNotNative = 0x8000000000000000ull
 
static const std::uint64_t cPosNative = 0x4000000000000000ull
 
static const std::uint64_t 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

Issue mIssue
 
mantissa_type mValue
 
exponent_type mOffset
 
bool mIsNative
 
bool mIsNegative
 
SField const * fName
 

Friends

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

Detailed Description

Definition at line 45 of file STAmount.h.

Member Typedef Documentation

◆ mantissa_type

Definition at line 48 of file STAmount.h.

◆ exponent_type

Definition at line 49 of file STAmount.h.

◆ rep

Definition at line 50 of file STAmount.h.

◆ value_type

Definition at line 60 of file STAmount.h.

Constructor & Destructor Documentation

◆ STAmount() [1/14]

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

Definition at line 88 of file STAmount.cpp.

◆ STAmount() [2/14]

ripple::STAmount::STAmount ( SField const &  name,
Issue const &  issue,
mantissa_type  mantissa,
exponent_type  exponent,
bool  native,
bool  negative,
unchecked   
)

Definition at line 161 of file STAmount.cpp.

◆ STAmount() [3/14]

ripple::STAmount::STAmount ( Issue const &  issue,
mantissa_type  mantissa,
exponent_type  exponent,
bool  native,
bool  negative,
unchecked   
)

Definition at line 178 of file STAmount.cpp.

◆ STAmount() [4/14]

ripple::STAmount::STAmount ( SField const &  name,
Issue const &  issue,
mantissa_type  mantissa,
exponent_type  exponent,
bool  native,
bool  negative 
)

Definition at line 193 of file STAmount.cpp.

◆ STAmount() [5/14]

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

Definition at line 210 of file STAmount.cpp.

◆ STAmount() [6/14]

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

Definition at line 216 of file STAmount.cpp.

◆ STAmount() [7/14]

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

Definition at line 226 of file STAmount.cpp.

◆ STAmount() [8/14]

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

Definition at line 244 of file STAmount.cpp.

◆ STAmount() [9/14]

ripple::STAmount::STAmount ( Issue const &  issue,
std::uint64_t  mantissa = 0,
int  exponent = 0,
bool  negative = false 
)

Definition at line 253 of file STAmount.cpp.

◆ STAmount() [10/14]

ripple::STAmount::STAmount ( Issue const &  issue,
std::uint32_t  mantissa,
int  exponent = 0,
bool  negative = false 
)

Definition at line 270 of file STAmount.cpp.

◆ STAmount() [11/14]

ripple::STAmount::STAmount ( Issue const &  issue,
std::int64_t  mantissa,
int  exponent = 0 
)

Definition at line 263 of file STAmount.cpp.

◆ STAmount() [12/14]

ripple::STAmount::STAmount ( Issue const &  issue,
int  mantissa,
int  exponent = 0 
)

Definition at line 279 of file STAmount.cpp.

◆ STAmount() [13/14]

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

Definition at line 285 of file STAmount.cpp.

◆ STAmount() [14/14]

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

Definition at line 299 of file STAmount.cpp.

Member Function Documentation

◆ operator Number()

ripple::STAmount::operator Number ( ) const

Definition at line 381 of file STAmount.h.

◆ exponent()

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

Definition at line 323 of file STAmount.h.

◆ native()

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

Definition at line 329 of file STAmount.h.

◆ negative()

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

Definition at line 335 of file STAmount.h.

◆ mantissa()

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

Definition at line 341 of file STAmount.h.

◆ issue()

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

Definition at line 347 of file STAmount.h.

◆ getCurrency()

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

Definition at line 353 of file STAmount.h.

◆ getIssuer()

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

Definition at line 359 of file STAmount.h.

◆ signum()

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

Definition at line 365 of file STAmount.h.

◆ zeroed()

STAmount ripple::STAmount::zeroed ( ) const

Returns a zero value with the same issuer and currency.

Definition at line 371 of file STAmount.h.

◆ setJson()

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

Definition at line 517 of file STAmount.cpp.

◆ value()

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

Definition at line 440 of file STAmount.h.

◆ operator bool()

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

Definition at line 376 of file STAmount.h.

◆ operator+=()

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

Definition at line 383 of file STAmount.cpp.

◆ operator-=()

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

Definition at line 390 of file STAmount.cpp.

◆ operator=() [1/3]

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

Definition at line 388 of file STAmount.h.

◆ operator=() [2/3]

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

Definition at line 395 of file STAmount.h.

◆ negate()

void ripple::STAmount::negate ( )

Definition at line 402 of file STAmount.h.

◆ clear() [1/3]

void ripple::STAmount::clear ( )

Definition at line 409 of file STAmount.h.

◆ clear() [2/3]

void ripple::STAmount::clear ( STAmount const &  saTmpl)

Definition at line 420 of file STAmount.h.

◆ clear() [3/3]

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

Definition at line 426 of file STAmount.h.

◆ setIssuer()

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

Definition at line 433 of file STAmount.h.

◆ setIssue()

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

Set the Issue for this amount and update mIsNative.

Definition at line 479 of file STAmount.cpp.

◆ getSType()

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

Reimplemented from ripple::STBase.

Definition at line 542 of file STAmount.cpp.

◆ getFullText()

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

Reimplemented from ripple::STBase.

Definition at line 548 of file STAmount.cpp.

◆ getText()

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

Reimplemented from ripple::STBase.

Definition at line 571 of file STAmount.cpp.

◆ getJson()

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

Reimplemented from ripple::STBase.

Definition at line 655 of file STAmount.cpp.

◆ add()

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

Reimplemented from ripple::STBase.

Definition at line 663 of file STAmount.cpp.

◆ isEquivalent()

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

Reimplemented from ripple::STBase.

Definition at line 694 of file STAmount.cpp.

◆ isDefault()

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

Reimplemented from ripple::STBase.

Definition at line 701 of file STAmount.cpp.

◆ xrp()

XRPAmount ripple::STAmount::xrp ( ) const

Definition at line 334 of file STAmount.cpp.

◆ iou()

IOUAmount ripple::STAmount::iou ( ) const

Definition at line 349 of file STAmount.cpp.

◆ construct()

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

Definition at line 311 of file STAmount.cpp.

◆ set()

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

Definition at line 835 of file STAmount.cpp.

◆ canonicalize()

void ripple::STAmount::canonicalize ( )
private

Definition at line 725 of file STAmount.cpp.

◆ copy()

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

Reimplemented from ripple::STBase.

Definition at line 317 of file STAmount.cpp.

◆ move()

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

Reimplemented from ripple::STBase.

Definition at line 323 of file STAmount.cpp.

◆ operator=() [3/3]

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

Definition at line 364 of file STAmount.cpp.

◆ operator==()

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

Definition at line 45 of file STBase.cpp.

◆ operator!=()

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

Definition at line 51 of file STBase.cpp.

◆ downcast() [1/2]

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

Definition at line 145 of file STBase.h.

◆ downcast() [2/2]

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

Definition at line 155 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 125 of file STBase.cpp.

◆ getFName()

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

Definition at line 132 of file STBase.cpp.

◆ addFieldID()

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

Definition at line 138 of file STBase.cpp.

◆ emplace()

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

Definition at line 165 of file STBase.h.

◆ getCounter()

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

Definition at line 128 of file CountedObject.h.

Friends And Related Function Documentation

◆ detail::STVar

friend class detail::STVar
friend

Definition at line 283 of file STAmount.h.

◆ operator+

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

Definition at line 397 of file STAmount.cpp.

Member Data Documentation

◆ mIssue

Issue ripple::STAmount::mIssue
private

Definition at line 53 of file STAmount.h.

◆ mValue

mantissa_type ripple::STAmount::mValue
private

Definition at line 54 of file STAmount.h.

◆ mOffset

exponent_type ripple::STAmount::mOffset
private

Definition at line 55 of file STAmount.h.

◆ mIsNative

bool ripple::STAmount::mIsNative
private

Definition at line 56 of file STAmount.h.

◆ mIsNegative

bool ripple::STAmount::mIsNegative
private

Definition at line 57 of file STAmount.h.

◆ cMinOffset

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

Definition at line 62 of file STAmount.h.

◆ cMaxOffset

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

Definition at line 63 of file STAmount.h.

◆ cMinValue

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

Definition at line 66 of file STAmount.h.

◆ cMaxValue

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

Definition at line 67 of file STAmount.h.

◆ cMaxNative

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

Definition at line 68 of file STAmount.h.

◆ cMaxNativeN

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

Definition at line 71 of file STAmount.h.

◆ cNotNative

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

Definition at line 72 of file STAmount.h.

◆ cPosNative

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

Definition at line 73 of file STAmount.h.

◆ uRateOne

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

Definition at line 75 of file STAmount.h.

◆ fName

SField const* ripple::STBase::fName
privateinherited

Definition at line 68 of file STBase.h.