SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 RWCString &sourceMnemonic, const RWCString &targetMnemonic, double rate)
 
 RWExchangeRate (const RWExchangeRate &r)
 
double conversionFactor () const
 
RWExchangeRateoperator= (const RWExchangeRate &r)
 
void restoreFrom (RWFile &)
 
void restoreFrom (RWvistream &)
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) const
 
void setConversionFactor (double factor)
 
void setSource (const RWCString &mnemonic)
 
void setTarget (const RWCString &mnemonic)
 
RWCString source () const
 
RWCString target () const
 

Related Symbols

(Note that these are not member symbols.)

RWFileoperator<< (RWFile &f, const RWExchangeRate &r)
 
RWvostreamoperator<< (RWvostream &s, const RWExchangeRate &r)
 
bool operator== (const RWExchangeRate &a, const RWExchangeRate &b)
 
RWFileoperator>> (RWFile &f, RWExchangeRate &r)
 
RWvistreamoperator>> (RWvistream &s, 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);
Encapsulates a source currency, a target currency, and a conversion factor, which is,...
Definition exchgrate.h:52

Constructor & Destructor Documentation

◆ RWExchangeRate() [1/3]

RWExchangeRate::RWExchangeRate ( )
inline

Default constructor. The source and target are set to null strings and the rate is set to zero.

◆ RWExchangeRate() [2/3]

RWExchangeRate::RWExchangeRate ( const RWExchangeRate & r)

Copy constructor. Contents of r are copied to self.

◆ RWExchangeRate() [3/3]

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

◆ conversionFactor()

double RWExchangeRate::conversionFactor ( ) const
inline

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

◆ operator=()

RWExchangeRate & RWExchangeRate::operator= ( const RWExchangeRate & r)

Assignment operator. Assigns contents of r to self.

◆ restoreFrom() [1/2]

void RWExchangeRate::restoreFrom ( RWFile & )

Restore from an RWFile.

◆ restoreFrom() [2/2]

void RWExchangeRate::restoreFrom ( RWvistream & )

Restore from a virtual stream.

◆ saveOn() [1/2]

void RWExchangeRate::saveOn ( RWFile & ) const

Persist to an RWFile.

◆ saveOn() [2/2]

void RWExchangeRate::saveOn ( RWvostream & ) const

Persist to a virtual stream.

◆ setConversionFactor()

void RWExchangeRate::setConversionFactor ( double factor)
inline

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

◆ setSource()

void RWExchangeRate::setSource ( const RWCString & mnemonic)
inline

Sets the source mnemonic to mnemonic.

◆ setTarget()

void RWExchangeRate::setTarget ( const RWCString & mnemonic)
inline

Sets the target mnemonic to mnemonic.

◆ source()

RWCString RWExchangeRate::source ( ) const
inline

Returns the mnemonic for the source currency.

◆ target()

RWCString RWExchangeRate::target ( ) const
inline

Returns the mnemonic for the target currency.

Friends And Related Symbol Documentation

◆ operator<<() [1/2]

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

Saves the object to a RWFile.

◆ operator<<() [2/2]

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

Saves the object to a virtual stream.

◆ operator==

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.

◆ operator>>() [1/2]

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

Restores a object from a RWFile.

◆ operator>>() [2/2]

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

Restores a object from a virtual stream.

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