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 73 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 81 of file Units.h.

◆ value_type

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

Definition at line 82 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 93 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 104 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 119 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 98 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 109 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 126 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 139 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 153 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 166 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 172 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 179 of file Units.h.

◆ operator++()

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

Definition at line 186 of file Units.h.

◆ operator--()

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

Definition at line 193 of file Units.h.

◆ operator*=()

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

Definition at line 200 of file Units.h.

◆ operator/=()

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

Definition at line 207 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 215 of file Units.h.

◆ operator-() [2/2]

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

Definition at line 222 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 230 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 237 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 243 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 250 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 255 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 263 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 270 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 278 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 285 of file Units.h.

◆ jsonClipped()

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

Definition at line 295 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 325 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 132 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 145 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 159 of file Units.h.

◆ operator>>

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

Definition at line 331 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 85 of file Units.h.