SourcePro® 2023.1 |
SourcePro® API Reference Guide |
Represents a specified amount of money in a specified currency. More...
#include <rw/currency/money.h>
Public Member Functions | |
RWMoney () | |
RWMoney (const RWMoney< T > &m) | |
RWMoney (const T &amount, const RWCString ¤cyMnemonic) | |
RWMoney (const RWCString ¤cyMnemonic) | |
T | amount () const |
RWCString | currency () const |
RWMoney< T > & | operator*= (const T &rhs) |
RWMoney< T > & | operator+= (const RWMoney< T > &rhs) |
RWMoney< T > & | operator- () |
RWMoney< T > & | operator-= (const RWMoney< T > &rhs) |
RWMoney< T > & | operator/= (const T &rhs) |
RWMoney< T > & | operator= (const RWMoney< T > &rhs) |
void | restoreFrom (RWvistream &) |
void | restoreFrom (RWFile &) |
void | saveOn (RWvostream &) const |
void | saveOn (RWFile &) const |
void | setAmount (const T &amount) |
void | setCurrency (const RWCString ¤cyMnemonic) |
Related Functions | |
(Note that these are not member functions.) | |
template<class T > | |
bool | operator!= (const RWMoney< T > &lhs, const RWMoney< T > &rhs) |
template<class T > | |
RWMoney< T > | operator* (const RWMoney< T > &lhs, const T &rhs) |
template<class T > | |
RWMoney< T > | operator* (const T &lhs, const RWMoney< T > &rhs) |
template<class T > | |
RWMoney< T > | operator+ (const RWMoney< T > &lhs, const RWMoney< T > &rhs) |
template<class T > | |
RWMoney< T > | operator- (const RWMoney< T > &lhs, const RWMoney< T > &rhs) |
template<class T > | |
RWMoney< T > | operator/ (const RWMoney< T > &lhs, const T &rhs) |
template<class T > | |
bool | operator< (const RWMoney< T > &l, const RWMoney< T > &r) |
template<class T > | |
RWvostream & | operator<< (RWvostream &strm, const RWMoney< T > &n) |
template<class T > | |
RWFile & | operator<< (RWFile &f, const RWMoney< T > &n) |
template<class T > | |
bool | operator<= (const RWMoney< T > &lhs, const RWMoney< T > &rhs) |
template<class T > | |
bool | operator== (const RWMoney< T > &l, const RWMoney< T > &r) |
template<class T > | |
bool | operator> (const RWMoney< T > &lhs, const RWMoney< T > &rhs) |
template<class T > | |
bool | operator>= (const RWMoney< T > &lhs, const RWMoney< T > &rhs) |
template<class T > | |
RWvistream & | operator>> (RWvistream &strm, RWMoney< T > &n) |
template<class T > | |
RWFile & | operator>> (RWFile &f, RWMoney< T > &n) |
template<class T > | |
RWMoney< T > | round (const RWMoney< T > &x, unsigned int places) |
Class RWMoney 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.
Here is an example assignment and some arithmetic calculations:
Constructs a money object with the given amount and currency.
Constructs a money object with the given currency and amount equal to zero.
|
inline |
Returns the amount.
Returns the currency's mnemonic
Sets contents of self to self times rhs.
Sets contents of self to self plus rhs.
Returns negation of self. Returned money object will have the same currency as self, but amount will be the negative of self.
Sets contents of self to self minus rhs.
Sets contents of self to self divided by rhs.
Sets contents of self to rhs.
void RWMoney< T >::restoreFrom | ( | RWvistream & | ) |
Restore from a virtual stream.
void RWMoney< T >::saveOn | ( | RWvostream & | ) | const |
Persist to a virtual stream.
|
inline |
Sets the amount.
Sets the currency mnemonic
Inequality operator.
Multiplication operator.
Multiplication operator.
|
related |
Addition operator.
|
related |
Subtraction operator.
Division operator.
Less than operator.
|
related |
Saves the object to a virtual stream.
Saves the object to an RWFile.
Less than or equal to operator.
Equality operator.
Greater than operator.
Greater than or equal to operator.
|
related |
Restores a object from a virtual stream.
Restores a object from an RWFile.
Rounds the amount to the indicated number of decimal places. See the description of class RWMoneyCalculator for a discussion of the available rounding methods.
Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |