Pecunia 0.9.0-alpha.22
Library using the ISO-4217 currency standard & a fixed monetary unit size
|
Represents the components of a monetary value separated into major, minor, sub-minor units and its associated currency. More...
#include <MoneyParts.hpp>
Public Member Functions | |
PECUNIA_EXPORT | MoneyParts () |
Constructs an empty object with default initialised values. | |
PECUNIA_EXPORT | MoneyParts (const Currency code, const MajorUnit major, const std::optional< MinorUnit > minorOnly, const MinorUnit subMinor=0) |
Full initialisation constructor that fully initialises the object. | |
PECUNIA_EXPORT const Currency & | code () const noexcept |
Retrieves the currency code of the monetary value. | |
PECUNIA_EXPORT const MajorUnit & | full () const noexcept |
Retrieves the full monetary value represented in its major unit including all minor components. | |
PECUNIA_EXPORT const MajorUnit & | major () const noexcept |
Retrieves the major unit part of the monetary value. | |
PECUNIA_EXPORT const std::optional< MinorUnit > & | minorOnly () const noexcept |
Retrieves the minor-only part of a monetary value, excluding other components. | |
PECUNIA_EXPORT const MinorUnit & | minorWithSub () const noexcept |
Retrieves the combined value of the minor and sub-minor units. | |
PECUNIA_EXPORT const MinorUnit & | subMinor () const noexcept |
Retrieves the sub-minor unit associated with the monetary value. This provides fine-grained detail of the monetary amount, particularly when precision to the smallest unit (e.g., fractional cents) is required. | |
Friends | |
class | Money |
Represents the components of a monetary value separated into major, minor, sub-minor units and its associated currency.
It is designed to facilitate the manipulation and representation of complex monetary values by providing segmented access to the major, minor, and sub-minor components, along with the currency. It is primarily used for scenarios requiring precise control and interpretation of monetary values, formatting, etc.
PECUNIA_EXPORT pecunia::MoneyParts::MoneyParts | ( | ) |
Constructs an empty object with default initialised values.
This constructor is primarily used to create an instance with zero values for all its member properties, and a default currency code of XXX, usually as a placeholder or initial state.
PECUNIA_EXPORT pecunia::MoneyParts::MoneyParts | ( | const Currency | code, |
const MajorUnit | major, | ||
const std::optional< MinorUnit > | minorOnly, | ||
const MinorUnit | subMinor = 0 ) |
Full initialisation constructor that fully initialises the object.
InvalidArgument | When the monetary value does not support minor units and minor units are supplied. |
code | The currency of the monetary value. |
major | The major monetary value. |
minorOnly | The minor monetary value, if the currency supports it. |
subMinor | The sub-minor monetary value. |
|
nodiscardnoexcept |
Retrieves the currency code of the monetary value.
|
nodiscardnoexcept |
Retrieves the full monetary value represented in its major unit including all minor components.
This method provides access to the total monetary value as represented in the major unit of the currency, incorporating all minor and sub-minor units.
|
nodiscardnoexcept |
Retrieves the major unit part of the monetary value.
This method is used to extract only the integral, major unit component of a monetary value, excluding any minor or sub-minor parts.
|
nodiscardnoexcept |
Retrieves the minor-only part of a monetary value, excluding other components.
|
nodiscardnoexcept |
Retrieves the combined value of the minor and sub-minor units.
This method provides access to the aggregated minor and sub-minor components of a monetary value.
|
nodiscardnoexcept |
Retrieves the sub-minor unit associated with the monetary value. This provides fine-grained detail of the monetary amount, particularly when precision to the smallest unit (e.g., fractional cents) is required.
|
friend |