SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
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 | RoundMethod { noRounding, up, down, plain, bankers } |
enum | ConversionType { noConversion, base, target, source } |
Public Member Functions | |
RWMoneyCalculator () | |
RWMoneyCalculator (const RWMoneyCalculator< T > &calc) | |
RWMoneyCalculator (RoundMethod rm, unsigned int accuracy, unsigned int roundDigit=5) | |
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) | |
unsigned int | roundDigit () const |
unsigned int | accuracy () const |
ConversionType | conversionType () const |
RoundMethod | roundMethod () const |
RWExchangeFactory< T > | exchangeFactory () const |
RWExchangeFactory< T > & | exchangeFactory () |
RWCString | baseCurrency () const |
void | setRoundDigit (unsigned int rd) |
void | setAccuracy (unsigned int a) |
void | setConversionType (ConversionType ct) |
void | setRoundMethod (RoundMethod rm) |
void | setExchangeFactory (const RWExchangeFactory< T > &f) |
RWMoney< T > | round (const RWMoney< T > &) const |
RWMoney< T > | add (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
RWMoney< T > | subtract (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
RWMoney< T > | multiply (const RWMoney< T > &lhs, const T &rhs) const |
RWMoney< T > | multiply (const T &lhs, const RWMoney< T > &rhs) const |
RWMoney< T > | divide (const RWMoney< T > &lhs, const T &rhs) const |
RWMoney< T > | abs (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 | greaterThan (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
bool | greaterThanOrEqual (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
bool | equal (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
bool | greaterThanZero (const RWMoney< T > &x) const |
bool | lessThanZero (const RWMoney< T > &x) const |
bool | isZero (const RWMoney< T > &x) const |
bool | sameCurrency (const RWMoney< T > &lhs, const RWMoney< T > &rhs) const |
RWMoneyCalculator< T > & | operator= (const RWMoneyCalculator< T > &) |
Class RWMoneyCalculator<T> 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<T> lets you specify a conversion policy for calculator objects.
#include <rw/currency/moneycalc.h> RWMoneyCalculator<double> calc(RWMoneyCalculator<double>::plain, 2u);
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<T> are:
enum RWMoneyCalculator::ConversionType |
Enumeration for the currency conversion policy. For details see the Conversion Policies.
enum RWMoneyCalculator::RoundMethod |
Enumeration for rounding method. For details see Rounding Policies.
RWMoneyCalculator< T >::RWMoneyCalculator | ( | ) |
Constructs a calculator object that does no rounding or currency conversion.
RWMoneyCalculator< T >::RWMoneyCalculator | ( | const RWMoneyCalculator< T > & | calc | ) |
Copy constructor.
RWMoneyCalculator< T >::RWMoneyCalculator | ( | RoundMethod | rm, | |
unsigned int | accuracy, | |||
unsigned int | roundDigit = 5 | |||
) | [inline] |
Construct a calculator that does rounding, but does not do currency conversion.
RWMoneyCalculator< T >::RWMoneyCalculator | ( | const RWExchangeFactory< T > & | ef, | |
ConversionType | ct, | |||
const RWCString & | baseCurr = "" , |
|||
RoundMethod | rm = noRounding , |
|||
unsigned int | accuracy = 2 , |
|||
unsigned int | roundDigit = 5 | |||
) | [inline] |
Construct a calculator that does currency conversion and rounding, if other than the default RoundMethod is provided.
RWMoneyCalculator< T >::RWMoneyCalculator | ( | const RWExchangeRateTable & | ert, | |
ConversionType | ct, | |||
const RWCString & | baseCurr = "" , |
|||
RoundMethod | rm = noRounding , |
|||
unsigned int | accuracy = 2 , |
|||
unsigned int | roundDigit = 5 | |||
) | [inline] |
Same as above, except use the given exchange rate table to construct the exchange factory argument.
RWMoney< T > RWMoneyCalculator< T >::abs | ( | const RWMoney< T > & | x | ) | const [inline] |
Returns the absolute value of the parameter.
unsigned int RWMoneyCalculator< T >::accuracy | ( | ) | const [inline] |
Returns the accuracy for this RWMoneyCalculator<T> object.
RWMoney<T> RWMoneyCalculator< T >::add | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const |
Adds the two RWMoney<T> operands and returns the result.
Addition and subtraction are allowed on monies of different currency types if the conversion type for the calculator object is set to base, target, or source.
RWCString RWMoneyCalculator< T >::baseCurrency | ( | ) | const [inline] |
Returns the currency that is used when the conversion type is set to base.
ConversionType RWMoneyCalculator< T >::conversionType | ( | ) | const [inline] |
Returns the current conversion type for this RWMoneyCalculator<T> object.
RWMoney< T > RWMoneyCalculator< T >::divide | ( | const RWMoney< T > & | lhs, | |
const T & | rhs | |||
) | const [inline] |
Divides the first operand by the second and returns the result.
bool RWMoneyCalculator< T >::equal | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const [inline] |
RWExchangeFactory<T>& RWMoneyCalculator< T >::exchangeFactory | ( | ) | [inline] |
Returns the exchange factory that is being used by the calculator. This version may be used to modify the exchange factory.
RWExchangeFactory<T> RWMoneyCalculator< T >::exchangeFactory | ( | ) | const [inline] |
Returns the exchange factory that is being used by the calculator.
bool RWMoneyCalculator< T >::greaterThan | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const [inline] |
bool RWMoneyCalculator< T >::greaterThanOrEqual | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const [inline] |
bool RWMoneyCalculator< T >::greaterThanZero | ( | const RWMoney< T > & | x | ) | const [inline] |
Tests whether the indicated value is greater than zero.
bool RWMoneyCalculator< T >::isZero | ( | const RWMoney< T > & | x | ) | const [inline] |
Tests whether the indicated value is equal to zero.
bool RWMoneyCalculator< T >::lessThan | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const [inline] |
bool RWMoneyCalculator< T >::lessThanOrEqual | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const [inline] |
bool RWMoneyCalculator< T >::lessThanZero | ( | const RWMoney< T > & | x | ) | const [inline] |
Tests whether the indicated value is less than zero.
RWMoney< T > RWMoneyCalculator< T >::multiply | ( | const T & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const [inline] |
Multiplies the first operand by the second and returns the result.
RWMoney< T > RWMoneyCalculator< T >::multiply | ( | const RWMoney< T > & | lhs, | |
const T & | rhs | |||
) | const [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<T> value according to the current rounding method and accuracy for RWMoneyCalculator<T> .
unsigned int RWMoneyCalculator< T >::roundDigit | ( | ) | const [inline] |
Returns the current value for the round digit.
RoundMethod RWMoneyCalculator< T >::roundMethod | ( | ) | const [inline] |
Returns the rounding method for this RWMoneyCalculator<T> object.
bool RWMoneyCalculator< T >::sameCurrency | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const [inline] |
Compares whether the given values have the same currency type.
void RWMoneyCalculator< T >::setAccuracy | ( | unsigned int | a | ) | [inline] |
Sets the accuracy value for this RWMoneyCalculator<T> object.
void RWMoneyCalculator< T >::setConversionType | ( | ConversionType | ct | ) | [inline] |
Sets the conversion type for this RWMoneyCalculator<T> object.
void RWMoneyCalculator< T >::setExchangeFactory | ( | const RWExchangeFactory< T > & | f | ) | [inline] |
Sets the exchange factory used by the calculator.
void RWMoneyCalculator< T >::setRoundDigit | ( | unsigned int | rd | ) | [inline] |
Sets the value for the rounding digit. The default value is 5.
void RWMoneyCalculator< T >::setRoundMethod | ( | RoundMethod | rm | ) | [inline] |
Sets the rounding method for the calculator.
RWMoney<T> RWMoneyCalculator< T >::subtract | ( | const RWMoney< T > & | lhs, | |
const RWMoney< T > & | rhs | |||
) | const |
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.