SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Related Functions
RWExchangeRate Class Reference

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
 
RWExchangeRateoperator= (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.)

RWvostreamoperator<< (RWvostream &s, const RWExchangeRate &r)
 
RWFileoperator<< (RWFile &f, const RWExchangeRate &r)
 
bool operator== (const RWExchangeRate &a, const RWExchangeRate &b)
 
RWvistreamoperator>> (RWvistream &s, RWExchangeRate &r)
 
RWFileoperator>> (RWFile &f, RWExchangeRate &r)
 

Detailed Description

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.

Synopsis
#include <rw/currency/exchgrate.h>
RWExchangeRate r("USD", "INR",42.254);

Constructor & Destructor Documentation

RWExchangeRate::RWExchangeRate ( )
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.

Member Function Documentation

double RWExchangeRate::conversionFactor ( ) const
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::restoreFrom ( RWFile )

Restore from an RWFile.

void RWExchangeRate::saveOn ( RWvostream ) const

Persist to a virtual stream.

void RWExchangeRate::saveOn ( RWFile ) const

Persist to an RWFile.

void RWExchangeRate::setConversionFactor ( double  factor)
inline

Sets the multiplicative conversion factor for converting money from source currency to target currency to factor.

void RWExchangeRate::setSource ( const RWCString mnemonic)
inline

Sets the source mnemonic to mnemonic.

void RWExchangeRate::setTarget ( const RWCString mnemonic)
inline

Sets the target mnemonic to mnemonic.

RWCString RWExchangeRate::source ( ) const
inline

Returns the mnemonic for the source currency.

RWCString RWExchangeRate::target ( ) const
inline

Returns the mnemonic for the target currency.

Friends And Related Function Documentation

RWvostream & operator<< ( RWvostream s,
const RWExchangeRate r 
)
related

Saves the object to a virtual stream.

RWFile & operator<< ( RWFile f,
const RWExchangeRate r 
)
related

Saves the object to a RWFile.

bool operator== ( const RWExchangeRate a,
const RWExchangeRate b 
)
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.

RWvistream & operator>> ( RWvistream s,
RWExchangeRate r 
)
related

Restores a object from a virtual stream.

RWFile & operator>> ( RWFile f,
RWExchangeRate r 
)
related

Restores a object from a RWFile.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.