ledger-core
Public Member Functions | Static Public Member Functions | List of all members
ledger::core::api::Amount Class Referenceabstract

#include <Amount.hpp>

+ Inheritance diagram for ledger::core::api::Amount:

Public Member Functions

virtual std::shared_ptr< BigInttoBigInt ()=0
 
virtual Currency getCurrency ()=0
 
virtual CurrencyUnit getUnit ()=0
 
virtual std::shared_ptr< AmounttoUnit (const CurrencyUnit &unit)=0
 
virtual std::shared_ptr< AmounttoMagnitude (int32_t magnitude)=0
 
virtual std::string toString ()=0
 
virtual int64_t toLong ()=0
 
virtual double toDouble ()=0
 
virtual std::string format (const Locale &locale, const std::experimental::optional< FormatRules > &rules)=0
 

Static Public Member Functions

static std::shared_ptr< AmountfromHex (const Currency &currency, const std::string &hex)
 
static std::shared_ptr< AmountfromLong (const Currency &currency, int64_t value)
 

Detailed Description

Class representing amount of transaction, output, inputs…

Member Function Documentation

◆ format()

virtual std::string ledger::core::api::Amount::format ( const Locale locale,
const std::experimental::optional< FormatRules > &  rules 
)
pure virtual

Format an amount with a locale and some formatting rules.

◆ fromHex()

std::shared_ptr< api::Amount > ledger::core::api::Amount::fromHex ( const Currency currency,
const std::string &  hex 
)
static

Transform an hexadecimal string into an amount (expressed in the given currency).

◆ fromLong()

std::shared_ptr< api::Amount > ledger::core::api::Amount::fromLong ( const Currency currency,
int64_t  value 
)
static

Transform a 64-bit number into an amount (expressed in the given currency).

◆ getCurrency()

virtual Currency ledger::core::api::Amount::getCurrency ( )
pure virtual

Get currency in which amount was computed.

Returns
Currency object

Implemented in ledger::core::Amount.

◆ getUnit()

virtual CurrencyUnit ledger::core::api::Amount::getUnit ( )
pure virtual

Get currency unit in which amount was computed.

Returns
CurrencyUnit object

Implemented in ledger::core::Amount.

◆ toBigInt()

virtual std::shared_ptr<BigInt> ledger::core::api::Amount::toBigInt ( )
pure virtual

Get amount as a BigInt.

Returns
BigInt

Implemented in ledger::core::Amount.

◆ toDouble()

virtual double ledger::core::api::Amount::toDouble ( )
pure virtual

Get amount as double

Returns
double

Implemented in ledger::core::Amount.

◆ toLong()

virtual int64_t ledger::core::api::Amount::toLong ( )
pure virtual

Get amount as long

Returns
64 bits integer

Implemented in ledger::core::Amount.

◆ toMagnitude()

virtual std::shared_ptr<Amount> ledger::core::api::Amount::toMagnitude ( int32_t  magnitude)
pure virtual

Get an amount that is equal to the given magnitude in the units system.

Implemented in ledger::core::Amount.

◆ toString()

virtual std::string ledger::core::api::Amount::toString ( )
pure virtual

Get amount as string

Returns
string

Implemented in ledger::core::Amount.

◆ toUnit()

virtual std::shared_ptr<Amount> ledger::core::api::Amount::toUnit ( const CurrencyUnit unit)
pure virtual

Convert amount in another currency unit.

Parameters
CurrencyUnitobject, target currency unit
Returns
Amount object, amount in target currency unit

Implemented in ledger::core::Amount.


The documentation for this class was generated from the following files: