rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWExchangeRate Class Reference
[Currency Conversions]

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>

List of all members.

Public Member Functions

 RWExchangeRate ()
 RWExchangeRate (const RWExchangeRate &r)
 RWExchangeRate (const RWCString &sourceMnemonic, const RWCString &targetMnemonic, double rate)
RWCString source () const
RWCString target () const
double conversionFactor () const
void setSource (const RWCString &mnemonic)
void setTarget (const RWCString &mnemonic)
void setConversionFactor (double factor)
void saveOn (RWvostream &) const
void saveOn (RWFile &) const
void restoreFrom (RWvistream &)
void restoreFrom (RWFile &)
RWExchangeRateoperator= (const RWExchangeRate &r)

Related Functions

(Note that these are not member functions.)



bool operator== (const RWExchangeRate &a, const RWExchangeRate &b)
RWvostreamoperator<< (RWvostream &s, const RWExchangeRate &r)
RWFileoperator<< (RWFile &f, const RWExchangeRate &r)
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 ( RWFile  ) 

Restore from an RWFile.

void RWExchangeRate::restoreFrom ( RWvistream  ) 

Restore from a virtual stream.

void RWExchangeRate::saveOn ( RWFile  )  const

Persist to an RWFile.

void RWExchangeRate::saveOn ( RWvostream  )  const

Persist to a virtual stream.

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

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

Saves the object to a RWFile.

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

Saves the object to a virtual stream.

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.

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

Restores a object from a RWFile.

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

Restores a object from a virtual stream.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.