SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Encapsulates a source currency, a target currency, and a conversion factor, which is, by convention, a multiplicative conversion factor. More...
#include <rw/currency/exchgrate.h>
Public Member Functions | |
RWExchangeRate () | |
RWExchangeRate (const RWExchangeRate &r) | |
RWExchangeRate (const RWCString &sourceMnemonic, const RWCString &targetMnemonic, double rate) | |
double | conversionFactor () const |
RWExchangeRate & | operator= (const RWExchangeRate &r) |
void | restoreFrom (RWvistream &) |
void | restoreFrom (RWFile &) |
void | saveOn (RWvostream &) const |
void | saveOn (RWFile &) const |
void | setConversionFactor (double factor) |
void | setSource (const RWCString &mnemonic) |
void | setTarget (const RWCString &mnemonic) |
RWCString | source () const |
RWCString | target () const |
Related Functions | |
(Note that these are not member functions.) | |
RWvostream & | operator<< (RWvostream &s, const RWExchangeRate &r) |
RWFile & | operator<< (RWFile &f, const RWExchangeRate &r) |
bool | operator== (const RWExchangeRate &a, const RWExchangeRate &b) |
RWvistream & | operator>> (RWvistream &s, RWExchangeRate &r) |
RWFile & | operator>> (RWFile &f, RWExchangeRate &r) |
Class RWExchangeRate encapsulates a source currency, a target currency, and a conversion factor, which is, by convention, a multiplicative conversion factor. This means that the source currency amount is multiplied by the conversion factor to obtain the equivalent amount in the target currency. Source and target currencies are stored by their mnemonics and the conversion factor is stored as a double precision floating point number.
|
inline |
Default constructor. The source and target are set to null strings and the rate is set to zero.
RWExchangeRate::RWExchangeRate | ( | const RWExchangeRate & | r | ) |
Copy constructor. Contents of r are copied to self.
RWExchangeRate::RWExchangeRate | ( | const RWCString & | sourceMnemonic, |
const RWCString & | targetMnemonic, | ||
double | rate | ||
) |
Constructs an exchange rate object with the given information. The source currency mnemonic is contained in sourceMnemonic, the target mnemonic is contained in targetMnemonic, and the multiplicative conversion factor is contained in rate.
|
inline |
Returns the multiplicative conversion factor for converting money from source currency to target currency.
RWExchangeRate& RWExchangeRate::operator= | ( | const RWExchangeRate & | r | ) |
Assignment operator. Assigns contents of r to self.
void RWExchangeRate::restoreFrom | ( | RWvistream & | ) |
Restore from a virtual stream.
void RWExchangeRate::saveOn | ( | RWvostream & | ) | const |
Persist to a virtual stream.
|
inline |
Sets the multiplicative conversion factor for converting money from source currency to target currency to factor.
|
inline |
Sets the source mnemonic to mnemonic.
|
inline |
Sets the target mnemonic to mnemonic.
|
inline |
Returns the mnemonic for the source currency.
|
inline |
Returns the mnemonic for the target currency.
|
related |
Saves the object to a virtual stream.
|
related |
Saves the object to a RWFile.
|
friend |
Returns true
if a and b have the same source mnemonic, target mnemonic, and conversion factor. Returns false
if not. The comparison of the source and target mnemonics is case insensitive.
|
related |
Restores a object from a virtual stream.
|
related |
Restores a object from a RWFile.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |