SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Performs algebraic operations when the money operands in an equation are not of the same currency. More...
#include <rw/currency/moneycalc.h>
Public Types | |
enum | ConversionType { noConversion , base , target , source } |
enum | RoundMethod { noRounding , up , down , plain , bankers } |
Public Member Functions | |
RWMoneyCalculator () | |
RWMoneyCalculator (const RWExchangeFactory< T > &ef, ConversionType ct, const RWCString &baseCurr="", RoundMethod rm=noRounding, unsigned int accuracy=2, unsigned int roundDigit=5) | |
RWMoneyCalculator (const RWExchangeRateTable &ert, ConversionType ct, const RWCString &baseCurr="", RoundMethod rm=noRounding, unsigned int accuracy=2, unsigned int roundDigit=5) | |
RWMoneyCalculator (const RWMoneyCalculator< T > &calc) | |
RWMoneyCalculator (RoundMethod rm, unsigned int accuracy, unsigned int roundDigit=5) | |
RWMoney< T > | abs (const RWMoney< T > &x) const |
unsigned int | accuracy () const |
RWMoney< T > | add (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
RWCString | baseCurrency () const |
ConversionType | conversionType () const |
RWMoney< T > | divide (const RWMoney< T > &lhs, const T &rhs) const |
bool | equal (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
RWExchangeFactory< T > & | exchangeFactory () |
RWExchangeFactory< T > | exchangeFactory () const |
bool | greaterThan (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
bool | greaterThanOrEqual (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
bool | greaterThanZero (const RWMoney< T > &x) const |
bool | isZero (const RWMoney< T > &x) const |
bool | lessThan (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
bool | lessThanOrEqual (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
bool | lessThanZero (const RWMoney< T > &x) const |
RWMoney< T > | multiply (const RWMoney< T > &lhs, const T &rhs) const |
RWMoney< T > | multiply (const T &lhs, const RWMoney< T > &rhs) const |
RWMoneyCalculator< T > & | operator= (const RWMoneyCalculator< T > &) |
RWMoney< T > | round (const RWMoney< T > &) const |
unsigned int | roundDigit () const |
RoundMethod | roundMethod () const |
bool | sameCurrency (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
void | setAccuracy (unsigned int a) |
void | setConversionType (ConversionType ct) |
void | setExchangeFactory (const RWExchangeFactory< T > &f) |
void | setRoundDigit (unsigned int rd) |
void | setRoundMethod (RoundMethod rm) |
RWMoney< T > | subtract (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
Class RWMoneyCalculator can perform algebraic operations when the money operands in the equation are not of the same currency. Because some conversion from one currency to another must occur before such an operation can be carried out, RWMoneyCalculator lets you specify a conversion policy for calculator objects.
Four conversion policies are available:
Conversions are carried out through the RWExchangeFactory object that is associated with the particular calculator object.
In addition to setting the conversion policy, you must set a rounding policy and an accuracy for the calculator. The accuracy specifies how many digits to the right of the decimal points should be reported. Rounding a negative number is equivalent to rounding the absolute value of the negative number, then multiplying the result by negative one. Briefly, the available rounding policies available for RWMoneyCalculator are:
enum RWMoneyCalculator::ConversionType |
enum RWMoneyCalculator::RoundMethod |
RWMoneyCalculator< T >::RWMoneyCalculator | ( | ) |
Constructs a calculator object that does no rounding or currency conversion.
RWMoneyCalculator< T >::RWMoneyCalculator | ( | const RWMoneyCalculator< T > & | calc | ) |
Copy constructor.
|
inline |
Construct a calculator that does rounding, but does not do currency conversion.
|
inline |
Construct a calculator that does currency conversion and rounding, if other than the default RoundMethod is provided.
|
inline |
Same as above, except use the given exchange rate table to construct the exchange factory argument.
|
inline |
Returns the absolute value of the parameter.
|
inline |
Returns the accuracy for this RWMoneyCalculator object.
RWMoney< T > RWMoneyCalculator< T >::add | ( | const RWMoney< T > & | lhs, |
const RWMoney< T > & | rhs ) const |
|
inline |
Returns the currency that is used when the conversion type is set to base.
|
inline |
Returns the current conversion type for this RWMoneyCalculator object.
|
inline |
Divides the first operand by the second and returns the result.
|
inline |
|
inline |
Returns the exchange factory that is being used by the calculator. This version may be used to modify the exchange factory.
|
inline |
Returns the exchange factory that is being used by the calculator.
|
inline |
|
inline |
|
inline |
Tests whether the indicated value is greater than zero.
|
inline |
Tests whether the indicated value is equal to zero.
|
inline |
|
inline |
|
inline |
Tests whether the indicated value is less than zero.
|
inline |
Multiplies the first operand by the second and returns the result.
|
inline |
Multiplies the first operand by the second and returns the result.
RWMoneyCalculator< T > & RWMoneyCalculator< T >::operator= | ( | const RWMoneyCalculator< T > & | ) |
Assignment operator.
RWMoney< T > RWMoneyCalculator< T >::round | ( | const RWMoney< T > & | ) | const |
Rounds the provided RWMoney value according to the current rounding method and accuracy for RWMoneyCalculator.
|
inline |
Returns the current value for the round digit.
|
inline |
Returns the rounding method for this RWMoneyCalculator object.
|
inline |
Compares whether the given values have the same currency type.
|
inline |
Sets the accuracy value for this RWMoneyCalculator object.
|
inline |
Sets the conversion type for this RWMoneyCalculator object.
|
inline |
Sets the exchange factory used by the calculator.
|
inline |
Sets the value for the rounding digit. The default value is 5.
|
inline |
Sets the rounding method for the calculator.
RWMoney< T > RWMoneyCalculator< T >::subtract | ( | const RWMoney< T > & | lhs, |
const RWMoney< T > & | rhs ) const |
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |