Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Currency Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWMoneyCalculator<T>

Module:  Currency   Group:  Money Calculator


Does not inherit

Local Index

Members

Synopsis

#include <rw/currency/moneycalc.h>
RWMoneyCalculator<double>
           calc(RWMoneyCalculator<double>::plain, 2u);

Description

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.

Conversion Policies

Four conversion policies are available:

Conversions are carried out through the RWExchangeFactory object that is associated with the particular calculator object.

Rounding Policies

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:

Public Enumerations

enum ConversionType {noConversion, base, target, source}
enum RoundMethod {noRounding, up, down, plain, bankers}

Public Constructors

RWMoneyCalculator();
RWMoneyCalculator(const RWMoneyCalculator<T>&);
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);

Public Member Operators

RWMoneyCalculator<T>& 
operator=(const RWMoneyCalculator<T>& c);

Public Member Functions

RWMoney<T>
abs(const RWMoney& money) const;
unsigned int 
accuracy() const;
RWMoney<T> 
add(const RWMoney<T>& opnd1, const RWMoney<T>& opnd2) const;
RWCString
baseCurrency() const;
RWMoneyCalculator<T>::ConversionType 
conversionType() const;
RWMoney<T>
divide(const RWMoney<T>& opnd1, const T& opnd2) const;
bool
equal(const RWMoney<T>& lhs, RWMoney<T>& rhs)const;
RWExchangeFactory<T> 
exchangeFactory() const;
RWExchangeFactory<T>& 
exchangeFactory();
bool
greaterThan(const RWMoney<T>& lhs, RWMoney<T>& rhs)const;
bool 
greaterThanOrEqual(const RWMoney<T>& lhs, 
                   RWMoney<T>& rhs)const;
bool 
greaterThanZero(const RWMoney<T>& money)const;
bool 
isZero(const RWMoney<T>& money)const;
bool 
lessThan(const RWMoney<T>& lhs, RWMoney<T>& rhs)const;
bool 
lessThanOrEqual(const RWMoney<T>& lhs, 
                RWMoney<T>& rhs)const;
bool 
lessThanZero(const RWMoney<T>& money)const;
RWMoney<T> 
multiply(const RWMoney<T>& opnd1, const T& opnd2) const;
RWMoney<T>
multiply(const T& opnd1, const RWMoney<T>& opnd2) const;
RWMoney<T>
round(const RWMoney& money) const;
unsigned int 
roundDigit() const;
RWMoneyCalculator<T>::RoundMethod 
roundMethod() const;
bool 
sameCurrency(const RWMoney<T>& opnd1,RWMoney<T>& opnd2)const;
void 
setaccuracy(unsigned int accuracy);
void 
setConversionType(RWMoneyCalculator<T>::ConversionType 
                    conversionType);
void
setExchangeFactory(const RWExchangeFactory<T>& f);
void 
setRoundDigit(unsigned int roundDigit);
void 
setRoundingMethod(RWMoneyCalculator<T>::RoundMethod method);
RWMoney<T> 
subtract(const RWMoney<T>& opnd1,
         const RWMoney<T>& opnd2) const;


Previous fileTop of DocumentContentsIndex pageNext file

© 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.