Pecunia 0.9.0-alpha.22
Library using the ISO-4217 currency standard & a fixed monetary unit size
|
Represents a monetary value in minor units, with associated currency code and sign/affinity. More...
#include <Money.hpp>
Public Member Functions | |
Minor () | |
Minor (const Currency &code, const MajorUnit minor=0u, const MinorUnit subMinor=0u) | |
Full initialisation constructor for a currency that requires a minor value. | |
Minor (const Currency &code, const std::optional< MajorUnit > minor, const MinorUnit subMinor=0u) | |
Full initialisation constructor representing a monetary value in its associated currency with minor (when supported) and sub-minor units. | |
Minor (const MajorUnit subMinor, const Currency &code) | |
Sub-minor initialisation constructor. This is largely useful for currencies that do not support minor currencies and need to have a negative sub-minor value. | |
Sign | affinity () const noexcept |
An accessor to the sign/affinity of the minor currency. | |
Currency | code () const noexcept |
Retrieves the currency code associated with the monetary value. | |
std::optional< MinorUnit > | minorOnly () const noexcept |
Retrieves the minor unit representation of the monetary value, if available. | |
MajorUnit | minorWithSub () const noexcept |
Computes the total monetary value in minor units, including any sub-minor adjustments, based on the stored amount, currency code, and affinity (sign). | |
MinorUnit | subMinor () const noexcept |
Returns the sub-minor unit representation of the monetary value. This value represents finer resolution units beneath the primary minor unit of currency. | |
Public Attributes | |
enum PECUNIA_EXPORT | Neither |
The minor value is neither positive nor negative, i.e. zero. | |
enum PECUNIA_EXPORT | Positive |
The minor value is positive. | |
enum PECUNIA_EXPORT | Sign: std::uint8_t { Negative |
When working only with minor units, this represents the positivity or negativity of a minor value. | |
Represents a monetary value in minor units, with associated currency code and sign/affinity.
pecunia::Minor::Minor | ( | ) |
Default unknown currency constructor.
pecunia::Minor::Minor | ( | const MajorUnit | subMinor, |
const Currency & | code ) |
Sub-minor initialisation constructor. This is largely useful for currencies that do not support minor currencies and need to have a negative sub-minor value.
subMinor | Specifies the value for the sub-minor portion of the minor unit. |
code | Represents the currency code associated with the monetary value. |
|
explicit |
Full initialisation constructor for a currency that requires a minor value.
InvalidArgument | Thrown if the `minor` value is provided while the currency does not support minor digits. |
InvalidArgument | Thrown if the `minor` value is /not/ provided while the currency does support minor digits. |
OverflowError | Thrown if the `minor` value exceeds the maximum allowable value for the given currency’s minor digits. |
OverflowError | Thrown if the `subMinor` value exceeds the maximum allowable sub-minor value. |
code | The currency associated with this instance. |
minor | A value representing the minor unit of the monetary value. |
subMinor | A value representing the sub-minor unit of the monetary value. |
pecunia::Minor::Minor | ( | const Currency & | code, |
const std::optional< MajorUnit > | minor, | ||
const MinorUnit | subMinor = 0u ) |
Full initialisation constructor representing a monetary value in its associated currency with minor (when supported) and sub-minor units.
InvalidArgument | Thrown if the `minor` value is provided while the currency does not support minor digits. |
InvalidArgument | Thrown if the `minor` value is /not/ provided while the currency does support minor digits. |
OverflowError | Thrown if the `minor` value exceeds the maximum allowable value for the given currency’s minor digits. |
OverflowError | Thrown if the `subMinor` value exceeds the maximum allowable sub-minor value. |
code | The currency associated with this instance. |
minor | An optional value representing the minor unit of the monetary value. |
subMinor | A value representing the sub-minor unit of the monetary value. |
|
nodiscardnoexcept |
An accessor to the sign/affinity of the minor currency.
|
nodiscardnoexcept |
Retrieves the currency code associated with the monetary value.
|
nodiscardnoexcept |
Retrieves the minor unit representation of the monetary value, if available.
|
nodiscardnoexcept |
Computes the total monetary value in minor units, including any sub-minor adjustments, based on the stored amount, currency code, and affinity (sign).
|
nodiscardnoexcept |
Returns the sub-minor unit representation of the monetary value. This value represents finer resolution units beneath the primary minor unit of currency.
enum PECUNIA_EXPORT pecunia::Minor::Neither |
The minor value is neither positive nor negative, i.e. zero.
enum PECUNIA_EXPORT pecunia::Minor::Positive |
The minor value is positive.
|
strong |
When working only with minor units, this represents the positivity or negativity of a minor value.