SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Static Public Attributes | Friends | Related Functions
RWCurrency Class Reference

A repository for currency information. More...

#include <rw/currency/currency.h>

Public Member Functions

 RWCurrency ()
 
 RWCurrency (const RWCurrency &)
 
 RWCurrency (const RWCString &mnemonic, int code, const RWCString &name, const RWCString &fractionName, double wholeToFractRatio)
 
 RWCurrency (const RWCString &mnemonic, int code, const RWCString &name, const RWCString &fractionName, double wholeToFractRatio, const RWDate &introDate, const RWDate &expDate)
 
int code () const
 
RWDate expirationDate () const
 
RWCString fractionName () const
 
bool hasExpired () const
 
RWDate introductionDate () const
 
bool isActive () const
 
RWCString mnemonic () const
 
RWCString name () const
 
RWCurrencyoperator= (const RWCurrency &)
 
void restoreFrom (RWvistream &)
 
void restoreFrom (RWFile &)
 
void saveOn (RWvostream &) const
 
void saveOn (RWFile &) const
 
void setCode (int c)
 
void setExpirationDate (const RWDate &d)
 
void setFractionName (const RWCString &fn)
 
void setIntroductionDate (const RWDate &d)
 
void setMnemonic (const RWCString &m)
 
void setName (const RWCString &n)
 
void setWholeToFractionRatio (double r)
 
double wholeToFractionRatio () const
 

Static Public Attributes

static const RWDate noExpirationDate
 
static const RWDate noIntroductionDate
 

Friends

bool operator== (const RWCurrency &a, const RWCurrency &b)
 

Related Functions

(Note that these are not member functions.)

RWvostreamoperator<< (RWvostream &s, const RWCurrency &c)
 
RWFileoperator<< (RWFile &f, const RWCurrency &c)
 
RWvistreamoperator>> (RWvistream &s, RWCurrency &c)
 
RWFileoperator>> (RWFile &f, RWCurrency &c)
 

Detailed Description

The RWCurrency class provides a repository for the following currency information:

If you omit the introduction date and the expiration date when constructing an RWCurrency object, the constructor assigns them values of the public static data members RWCurrency::noIntroductionDate and RWCurrency::noExpirationDate, respectively.

Synopsis
#include <rw/currency/currency.h>
RWCurrency USDollars("USD", 840, "dollar", "cents", 0.01);

Constructor & Destructor Documentation

RWCurrency::RWCurrency ( )

Default constructor.

RWCurrency::RWCurrency ( const RWCurrency )

Copy constructor.

RWCurrency::RWCurrency ( const RWCString mnemonic,
int  code,
const RWCString name,
const RWCString fractionName,
double  wholeToFractRatio 
)

Constructs an RWCurrency with the given information. The introduction and expiration dates are assigned RWCurrency::noIntroductionDate and RWCurrency::noExpirationDate, respectively.

RWCurrency::RWCurrency ( const RWCString mnemonic,
int  code,
const RWCString name,
const RWCString fractionName,
double  wholeToFractRatio,
const RWDate introDate,
const RWDate expDate 
)

Constructs an RWCurrency with the given information.

Member Function Documentation

int RWCurrency::code ( ) const
inline

Returns the currency's numeric code.

RWDate RWCurrency::expirationDate ( ) const
inline

Returns a currency's expiration date. A return value of RWCurrency::noExpirationDate indicates there is no expiration date.

RWCString RWCurrency::fractionName ( ) const
inline

Returns the currency's fraction name.

bool RWCurrency::hasExpired ( ) const

Returns true if today's date is beyond the currency's expiration date.

RWDate RWCurrency::introductionDate ( ) const
inline

Returns a currency's introduction date. A return value of RWCurrency::noIntroductionDate indicates there is no introduction date.

bool RWCurrency::isActive ( ) const

Returns true if today's date lies between the introduction date and the expiration date.

RWCString RWCurrency::mnemonic ( ) const
inline

Returns the currency's mnemonic.

RWCString RWCurrency::name ( ) const
inline

Returns the currency's name.

RWCurrency& RWCurrency::operator= ( const RWCurrency )

Assignment operator.

void RWCurrency::restoreFrom ( RWvistream )

Restores the currency from a virtual stream.

void RWCurrency::restoreFrom ( RWFile )

Restores the currency from an RWFile.

void RWCurrency::saveOn ( RWvostream ) const

Persists the currency to a virtual stream.

void RWCurrency::saveOn ( RWFile ) const

Persists the currency to an RWFile.

void RWCurrency::setCode ( int  c)
inline

Sets the currency's numeric code to c.

void RWCurrency::setExpirationDate ( const RWDate d)
inline

Sets a currency's expiration date. Note that this can be a date in the past.

void RWCurrency::setFractionName ( const RWCString fn)
inline

Sets the currency's fraction name to fn.

void RWCurrency::setIntroductionDate ( const RWDate d)
inline

Sets a currency's introduction date. Note that this can be a date in the past.

void RWCurrency::setMnemonic ( const RWCString m)
inline

Sets the currency's mnemonic to m.

void RWCurrency::setName ( const RWCString n)
inline

Sets the currency's name to n.

void RWCurrency::setWholeToFractionRatio ( double  r)
inline

Sets the ratio between one unit of the whole part of the currency and the smallest unit of the fractional part of the currency to r.

double RWCurrency::wholeToFractionRatio ( ) const
inline

Returns the ratio between one unit of the whole part of the currency and the smallest unit of the fractional part of the currency

Friends And Related Function Documentation

RWvostream & operator<< ( RWvostream s,
const RWCurrency c 
)
related

Saves the currency object to a virtual stream.

RWFile & operator<< ( RWFile f,
const RWCurrency c 
)
related

Saves the currency object to an RWFile.

bool operator== ( const RWCurrency a,
const RWCurrency b 
)
friend

Returns true if and only if all data members are equal.

RWvistream & operator>> ( RWvistream s,
RWCurrency c 
)
related

Restores a currency object from a virtual stream.

RWFile & operator>> ( RWFile f,
RWCurrency c 
)
related

Restores a currency object from an RWFile.

Member Data Documentation

const RWDate RWCurrency::noExpirationDate
static

These data members provide a way to deal with currencies that do not have introduction or expiration dates. The data member noIntroductionDate represents a date that is "before the beginning of time." Similarly, noExpirationDate represents a date that is "after the end of time." If you omit the introduction date and the expiration date when constructing an RWCurrency object, the constructor assigns these values. You can also use them in applications to determine whether specific introduction or expiration dates occur. The following example shows how they are used:

const RWDate RWCurrency::noIntroductionDate
static

These data members provide a way to deal with currencies that do not have introduction or expiration dates. The data member noIntroductionDate represents a date that is "before the beginning of time." Similarly, noExpirationDate represents a date that is "after the end of time." If you omit the introduction date and the expiration date when constructing an RWCurrency object, the constructor assigns these values. You can also use them in applications to determine whether specific introduction or expiration dates occur. The following example shows how they are used:

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