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

RWMoney<T>

Module:  Currency   Group:  Money


Does not inherit

Local Index

Members

Non-Members

Synopsis

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

Description

Class RWMoney<T> provides a mapping between an amount and a currency, by encapsulating a decimal value and referencing a currency. In C++, the value is an arbitrary decimal type specified as a template parameter.

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 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);
bool 
operator<(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
bool 
operator<=(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
bool 
operator>(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
bool 
operator>=(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
bool 
operator==(const RWMoney<T>& lhs, const RWMoney<T>& rhs);
bool 
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 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.