#include <MamaPrice.h>
Name | |
---|---|
MamaPrice() | |
MamaPrice(double value, mamaPricePrecision precision =MAMA_PRICE_PREC_100) | |
MamaPrice(const MamaPrice & copy) | |
~MamaPrice() | |
MamaPrice & | operator=(const MamaPrice & rhs) |
MamaPrice & | operator+=(const MamaPrice & rhs) |
MamaPrice & | operator-=(const MamaPrice & rhs) |
bool | operator==(const MamaPrice & rhs) const |
bool | operator==(double rhs) const |
bool | operator!=(const MamaPrice & rhs) const |
bool | operator!=(double rhs) const |
bool | operator<(const MamaPrice & rhs) const |
bool | operator<(double rhs) const |
bool | operator>(const MamaPrice & rhs) const |
bool | operator>(double rhs) const |
MamaPrice | operator-(const MamaPrice & rhs) const |
MamaPrice | operator-(double rhs) const |
MamaPrice | operator-() const |
MamaPrice | operator+(const MamaPrice & rhs) const |
MamaPrice | operator+(double rhs) const |
double | compare(const MamaPrice & rhs) const |
void | clear() |
void | set(double priceValue, mamaPriceHints hints =0) |
void | setValue(double value) |
void | setPrecision(mamaPricePrecision precision) |
void | setHints(mamaPriceHints hints) |
void | setIsValidPrice(bool valid) |
double | getValue() const |
mamaPricePrecision | getPrecision() const |
mamaPriceHints | getHints() const |
bool | getIsValidPrice() const |
void | setFromString(const char * str) |
void | getAsString(char * result, mama_size_t maxLen) const |
const char * | getAsString() const |
void | negate() |
bool | isZero() const |
mamaPrice | getCValue() |
const mamaPrice | getCValue() const |
mamaPricePrecision | decimals2Precision(mama_i32_t places) |
mamaPricePrecision | denom2Precision(mama_i32_t denominator) |
mama_i32_t | precision2Decimals(mamaPricePrecision precision) |
mama_i32_t | precision2Denom(mamaPricePrecision precision) |
class Wombat::MamaPrice;
MamaPrice is a special data type for representing floating point numbers that often require special formatting for display purposes, such as prices. MamaPrice contains the 64-bit (double precision) floating point value and an optional display hint. The set of display hints includes hints for:
MamaPrice()
MamaPrice(
double value,
mamaPricePrecision precision =MAMA_PRICE_PREC_100
)
MamaPrice(
const MamaPrice & copy
)
~MamaPrice()
MamaPrice & operator=(
const MamaPrice & rhs
)
MamaPrice & operator+=(
const MamaPrice & rhs
)
MamaPrice & operator-=(
const MamaPrice & rhs
)
bool operator==(
const MamaPrice & rhs
) const
bool operator==(
double rhs
) const
inline bool operator!=(
const MamaPrice & rhs
) const
inline bool operator!=(
double rhs
) const
bool operator<(
const MamaPrice & rhs
) const
bool operator<(
double rhs
) const
bool operator>(
const MamaPrice & rhs
) const
bool operator>(
double rhs
) const
inline MamaPrice operator-(
const MamaPrice & rhs
) const
Subtraction operator. Note: this operator creates a temporary object.
inline MamaPrice operator-(
double rhs
) const
Subtraction operator for double. Note: this operator creates a temporary object.
inline MamaPrice operator-() const
Negation operator. Note: this operator creates a temporary object.
inline MamaPrice operator+(
const MamaPrice & rhs
) const
Addition operator. Note: this operator creates a temporary object.
inline MamaPrice operator+(
double rhs
) const
Addition operator for double. Note: this operator creates a temporary object.
double compare(
const MamaPrice & rhs
) const
void clear()
void set(
double priceValue,
mamaPriceHints hints =0
)
void setValue(
double value
)
void setPrecision(
mamaPricePrecision precision
)
void setHints(
mamaPriceHints hints
)
void setIsValidPrice(
bool valid
)
double getValue() const
mamaPricePrecision getPrecision() const
mamaPriceHints getHints() const
bool getIsValidPrice() const
void setFromString(
const char * str
)
void getAsString(
char * result,
mama_size_t maxLen
) const
const char * getAsString() const
Return a string representation of the price. Note that the alternative getAsString() method is more efficient because this method must allocate a temporary buffer (automatically destroyed upon object destruction).
void negate()
Negate the price value. Hints and precisions are not affected.
bool isZero() const
Return whether the price has a value equivalent to zero. It may not be exactly 0.0, but we check against +/- epsilon.
mamaPrice getCValue()
const mamaPrice getCValue() const
static mamaPricePrecision decimals2Precision(
mama_i32_t places
)
Return the appropriate precision code for a given number of decimal places.
static mamaPricePrecision denom2Precision(
mama_i32_t denominator
)
Return the appropriate precision code for a given fractional denominator.
static mama_i32_t precision2Decimals(
mamaPricePrecision precision
)
Return the number of decimal places for a given precision code.
static mama_i32_t precision2Denom(
mamaPricePrecision precision
)
Return the fractional denominator for a given precision code.
Updated on 2023-03-31 at 15:29:25 +0100