Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWMoney<T>



Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/money/money.h>
RWMoney<double> m(1.25, "CAD");

Related Java Class

com.roguewave.money.currency.v1_0.Money

Description

Class RWMoney<T> provides a mapping between an amount and a currency, by encapsulating a decimal value and referencing a currency. The C++ and Java versions of this class differ. In C++, the value is an arbitrary decimal type specified as a template parameter. In Java, the value is either a double or a BigDecimal.

When RWMoney objects are used in arithmetic operations, all operands must be the same currency. If the currencies for RWMoney operands used in the same equation differ, the operator (or method, in Java) will throw an exception. Similarly, all assignments to RWMoney objects must have the same currency as the original object. If not, an exception is thrown.

Operations between monies of different currencies may be performed using class RWMoneyCalculator<T>.

Here is an example assignment and some arithmetic calculations:

Example

Public Constructors

RWMoney();
RWMoney(const RWMoney<T>& m);
RWMoney(const T& amount, const RWCString currencyMnemonic);
RWMoney(const RWCString currencyMnemonic);

Public Member Operators

RWMoney<T>& 
operator=(const RWMoney<T>& rhs);
RWMoney<T>& 
operator+=(const RWMoney<T>& rhs);
RWMoney<T>& 
operator-=(const RWMoney<T>& rhs);
RWMoney<T>& 
operator*=(const T& rhs);
RWMoney<T>& 
operator/=(const T& rhs);
RWMoney<T> 
operator-();

Public Member Functions

T 
amount() const;
RWCString 
currency() const;
void 
restoreFrom(RWFile&);
void 
restoreFrom(RWvistream&);
void 
saveOn(RWFile&) const;
void 
saveOn(RWvostream&) const;
void 
setAmount(const T& amt);
void 
setCurrency(const RWCString& currencyMnemonic);

Related Global Operators

RWMoney<T> 
operator+(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWMoney<T> 
operator-(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWMoney<T> 
operator*(const RWMoney<T>& lhs, const T& rhs);
RWMoney<T> 
operator*(const T& lhs, const RWMoney<T>& rhs);
RWMoney<T> 
operator/(const RWMoney<T>& lhs, const T& rhs);
RWBoolean 
operator<(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWBoolean 
operator<=(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWBoolean 
operator>(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWBoolean 
operator>=(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWBoolean 
operator==(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWBoolean 
operator!=(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
RWvostream& 
operator<<(RWvostream& strm, const RWMoney<T>& c);
RWFile& 
operator<<(RWFile& file, const RWMoney<T>& c);
RWvistream& 
operator>>(RWvistream& strm, const RWMoney<T>& c);
RWFile& 
operator>>(RWFile& strm, const RWMoney<T>& c);
RWMoney<T>
round(const RWMoney<T>& m, unsigned int places);


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.