rippled
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
ripple::unit::ValueUnit< UnitTag, T > Class Template Reference

#include <Units.h>

Inheritance diagram for ripple::unit::ValueUnit< UnitTag, T >:
Inheritance graph
[legend]
Collaboration diagram for ripple::unit::ValueUnit< UnitTag, T >:
Collaboration graph
[legend]

Public Types

using unit_type = UnitTag
 
using value_type = T
 

Public Member Functions

 ValueUnit ()=default
 
constexpr ValueUnit (ValueUnit const &other)=default
 
constexpr ValueUnitoperator= (ValueUnit const &other)=default
 
constexpr ValueUnit (beast::Zero)
 
constexpr ValueUnitoperator= (beast::Zero)
 
constexpr ValueUnit (value_type value)
 
constexpr ValueUnitoperator= (value_type value)
 
template<Compatible< ValueUnit > Other>
requires SafeToCast<Other, value_type>
constexpr ValueUnit (ValueUnit< unit_type, Other > const &value)
 Instances with the same unit, and a type that is "safe" to convert to this one can be converted implicitly.
 
constexpr ValueUnit operator+ (value_type const &rhs) const
 
constexpr ValueUnit operator- (value_type const &rhs) const
 
constexpr ValueUnit operator* (value_type const &rhs) const
 
constexpr value_type operator/ (ValueUnit const &rhs) const
 
ValueUnitoperator+= (ValueUnit const &other)
 
ValueUnitoperator-= (ValueUnit const &other)
 
ValueUnitoperator++ ()
 
ValueUnitoperator-- ()
 
ValueUnitoperator*= (value_type const &rhs)
 
ValueUnitoperator/= (value_type const &rhs)
 
template<Integral transparent = value_type>
ValueUnitoperator%= (value_type const &rhs)
 
ValueUnit operator- () const
 
constexpr bool operator== (ValueUnit const &other) const
 
template<Compatible< ValueUnit > Other>
constexpr bool operator== (ValueUnit< unit_type, Other > const &other) const
 
constexpr bool operator== (value_type other) const
 
template<Compatible< ValueUnit > Other>
constexpr bool operator!= (ValueUnit< unit_type, Other > const &other) const
 
constexpr bool operator< (ValueUnit const &other) const
 
constexpr operator bool () const noexcept
 Returns true if the amount is not zero.
 
constexpr int signum () const noexcept
 Return the sign of the amount.
 
constexpr value_type fee () const
 Returns the number of drops.
 
template<class Other >
constexpr double decimalFromReference (ValueUnit< unit_type, Other > reference) const
 
Json::Value jsonClipped () const
 
constexpr value_type value () const
 Returns the underlying value.
 

Private Attributes

value_type value_
 

Friends

constexpr ValueUnit operator+ (value_type lhs, ValueUnit const &rhs)
 
constexpr ValueUnit operator- (value_type lhs, ValueUnit const &rhs)
 
constexpr ValueUnit operator* (value_type lhs, ValueUnit const &rhs)
 
std::istreamoperator>> (std::istream &s, ValueUnit &val)
 

Detailed Description

template<class UnitTag, class T>
class ripple::unit::ValueUnit< UnitTag, T >

Definition at line 91 of file Units.h.

Member Typedef Documentation

◆ unit_type

template<class UnitTag , class T >
using ripple::unit::ValueUnit< UnitTag, T >::unit_type = UnitTag

Definition at line 99 of file Units.h.

◆ value_type

template<class UnitTag , class T >
using ripple::unit::ValueUnit< UnitTag, T >::value_type = T

Definition at line 100 of file Units.h.

Constructor & Destructor Documentation

◆ ValueUnit() [1/5]

template<class UnitTag , class T >
ripple::unit::ValueUnit< UnitTag, T >::ValueUnit ( )
default

◆ ValueUnit() [2/5]

template<class UnitTag , class T >
constexpr ripple::unit::ValueUnit< UnitTag, T >::ValueUnit ( ValueUnit< UnitTag, T > const &  other)
constexprdefault

◆ ValueUnit() [3/5]

template<class UnitTag , class T >
constexpr ripple::unit::ValueUnit< UnitTag, T >::ValueUnit ( beast::Zero  )
explicitconstexpr

Definition at line 111 of file Units.h.

◆ ValueUnit() [4/5]

template<class UnitTag , class T >
constexpr ripple::unit::ValueUnit< UnitTag, T >::ValueUnit ( value_type  value)
explicitconstexpr

Definition at line 122 of file Units.h.

◆ ValueUnit() [5/5]

template<class UnitTag , class T >
template<Compatible< ValueUnit > Other>
requires SafeToCast<Other, value_type>
constexpr ripple::unit::ValueUnit< UnitTag, T >::ValueUnit ( ValueUnit< unit_type, Other > const &  value)
constexpr

Instances with the same unit, and a type that is "safe" to convert to this one can be converted implicitly.

Definition at line 137 of file Units.h.

Member Function Documentation

◆ operator=() [1/3]

template<class UnitTag , class T >
constexpr ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator= ( ValueUnit< UnitTag, T > const &  other)
constexprdefault

◆ operator=() [2/3]

template<class UnitTag , class T >
constexpr ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator= ( beast::Zero  )
constexpr

Definition at line 116 of file Units.h.

◆ operator=() [3/3]

template<class UnitTag , class T >
constexpr ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator= ( value_type  value)
constexpr

Definition at line 127 of file Units.h.

◆ operator+()

template<class UnitTag , class T >
constexpr ValueUnit ripple::unit::ValueUnit< UnitTag, T >::operator+ ( value_type const &  rhs) const
constexpr

Definition at line 144 of file Units.h.

◆ operator-() [1/2]

template<class UnitTag , class T >
constexpr ValueUnit ripple::unit::ValueUnit< UnitTag, T >::operator- ( value_type const &  rhs) const
constexpr

Definition at line 157 of file Units.h.

◆ operator*()

template<class UnitTag , class T >
constexpr ValueUnit ripple::unit::ValueUnit< UnitTag, T >::operator* ( value_type const &  rhs) const
constexpr

Definition at line 171 of file Units.h.

◆ operator/()

template<class UnitTag , class T >
constexpr value_type ripple::unit::ValueUnit< UnitTag, T >::operator/ ( ValueUnit< UnitTag, T > const &  rhs) const
constexpr

Definition at line 184 of file Units.h.

◆ operator+=()

template<class UnitTag , class T >
ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator+= ( ValueUnit< UnitTag, T > const &  other)

Definition at line 190 of file Units.h.

◆ operator-=()

template<class UnitTag , class T >
ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator-= ( ValueUnit< UnitTag, T > const &  other)

Definition at line 197 of file Units.h.

◆ operator++()

template<class UnitTag , class T >
ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator++ ( )

Definition at line 204 of file Units.h.

◆ operator--()

template<class UnitTag , class T >
ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator-- ( )

Definition at line 211 of file Units.h.

◆ operator*=()

template<class UnitTag , class T >
ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator*= ( value_type const &  rhs)

Definition at line 218 of file Units.h.

◆ operator/=()

template<class UnitTag , class T >
ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator/= ( value_type const &  rhs)

Definition at line 225 of file Units.h.

◆ operator%=()

template<class UnitTag , class T >
template<Integral transparent = value_type>
ValueUnit & ripple::unit::ValueUnit< UnitTag, T >::operator%= ( value_type const &  rhs)

Definition at line 233 of file Units.h.

◆ operator-() [2/2]

template<class UnitTag , class T >
ValueUnit ripple::unit::ValueUnit< UnitTag, T >::operator- ( ) const

Definition at line 240 of file Units.h.

◆ operator==() [1/3]

template<class UnitTag , class T >
constexpr bool ripple::unit::ValueUnit< UnitTag, T >::operator== ( ValueUnit< UnitTag, T > const &  other) const
constexpr

Definition at line 248 of file Units.h.

◆ operator==() [2/3]

template<class UnitTag , class T >
template<Compatible< ValueUnit > Other>
constexpr bool ripple::unit::ValueUnit< UnitTag, T >::operator== ( ValueUnit< unit_type, Other > const &  other) const
constexpr

Definition at line 255 of file Units.h.

◆ operator==() [3/3]

template<class UnitTag , class T >
constexpr bool ripple::unit::ValueUnit< UnitTag, T >::operator== ( value_type  other) const
constexpr

Definition at line 261 of file Units.h.

◆ operator!=()

template<class UnitTag , class T >
template<Compatible< ValueUnit > Other>
constexpr bool ripple::unit::ValueUnit< UnitTag, T >::operator!= ( ValueUnit< unit_type, Other > const &  other) const
constexpr

Definition at line 268 of file Units.h.

◆ operator<()

template<class UnitTag , class T >
constexpr bool ripple::unit::ValueUnit< UnitTag, T >::operator< ( ValueUnit< UnitTag, T > const &  other) const
constexpr

Definition at line 273 of file Units.h.

◆ operator bool()

template<class UnitTag , class T >
constexpr ripple::unit::ValueUnit< UnitTag, T >::operator bool ( ) const
explicitconstexprnoexcept

Returns true if the amount is not zero.

Definition at line 281 of file Units.h.

◆ signum()

template<class UnitTag , class T >
constexpr int ripple::unit::ValueUnit< UnitTag, T >::signum ( ) const
constexprnoexcept

Return the sign of the amount.

Definition at line 288 of file Units.h.

◆ fee()

template<class UnitTag , class T >
constexpr value_type ripple::unit::ValueUnit< UnitTag, T >::fee ( ) const
constexpr

Returns the number of drops.

Definition at line 296 of file Units.h.

◆ decimalFromReference()

template<class UnitTag , class T >
template<class Other >
constexpr double ripple::unit::ValueUnit< UnitTag, T >::decimalFromReference ( ValueUnit< unit_type, Other >  reference) const
constexpr

Definition at line 303 of file Units.h.

◆ jsonClipped()

template<class UnitTag , class T >
Json::Value ripple::unit::ValueUnit< UnitTag, T >::jsonClipped ( ) const

Definition at line 313 of file Units.h.

◆ value()

template<class UnitTag , class T >
constexpr value_type ripple::unit::ValueUnit< UnitTag, T >::value ( ) const
constexpr

Returns the underlying value.

Code SHOULD NOT call this function unless the type has been abstracted away, e.g. in a templated function.

Definition at line 343 of file Units.h.

Friends And Related Symbol Documentation

◆ operator+

template<class UnitTag , class T >
constexpr ValueUnit operator+ ( value_type  lhs,
ValueUnit< UnitTag, T > const &  rhs 
)
friend

Definition at line 150 of file Units.h.

◆ operator-

template<class UnitTag , class T >
constexpr ValueUnit operator- ( value_type  lhs,
ValueUnit< UnitTag, T > const &  rhs 
)
friend

Definition at line 163 of file Units.h.

◆ operator*

template<class UnitTag , class T >
constexpr ValueUnit operator* ( value_type  lhs,
ValueUnit< UnitTag, T > const &  rhs 
)
friend

Definition at line 177 of file Units.h.

◆ operator>>

template<class UnitTag , class T >
std::istream & operator>> ( std::istream s,
ValueUnit< UnitTag, T > &  val 
)
friend

Definition at line 349 of file Units.h.

Member Data Documentation

◆ value_

template<class UnitTag , class T >
value_type ripple::unit::ValueUnit< UnitTag, T >::value_
private

Definition at line 103 of file Units.h.