SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWCurrency Class Reference

A repository for currency information. More...

#include <rw/currency/currency.h>

Public Member Functions

 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)
 
 RWCurrency (const RWCurrency &)
 
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 (RWFile &)
 
void restoreFrom (RWvistream &)
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) 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 Symbols

(Note that these are not member symbols.)

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

Detailed Description

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

  • Mnemonic. Defined in the ISO 4217:1995 standard. The mnemonic uniquely identifies a currency.
  • Numeric Code. Defined in the ISO 4217:1995 standard. The numeric code uniquely identifies a currency.
  • Name. Defined in the ISO 4217:1995 standard. The name uniquely identifies a currency.
  • Fraction Name. The name of the fractional portion of a currency. For example "Cents" is the fractional name of the United States dollar, and "Pence" is the fractional name for the United Kingdom pound.
  • Ratio of Whole to Fraction. Ratio between one unit of the whole part of a currency and the smallest unit of the fractional part of that currency. For example, for United States Dollars the ratio is one dollar to one penny which is 0.01.
  • Introduction Date. Date upon which the currency was, or will be, introduced.
  • Expiration Date. Date upon which the currency is, or was, no longer valid.

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);
A repository for currency information.
Definition currency.h:74

Constructor & Destructor Documentation

◆ RWCurrency() [1/4]

RWCurrency::RWCurrency ( )

Default constructor.

◆ RWCurrency() [2/4]

RWCurrency::RWCurrency ( const RWCurrency & )

Copy constructor.

◆ RWCurrency() [3/4]

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() [4/4]

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

◆ code()

int RWCurrency::code ( ) const
inline

Returns the currency's numeric code.

◆ expirationDate()

RWDate RWCurrency::expirationDate ( ) const
inline

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

◆ fractionName()

RWCString RWCurrency::fractionName ( ) const
inline

Returns the currency's fraction name.

◆ hasExpired()

bool RWCurrency::hasExpired ( ) const

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

◆ introductionDate()

RWDate RWCurrency::introductionDate ( ) const
inline

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

◆ isActive()

bool RWCurrency::isActive ( ) const

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

◆ mnemonic()

RWCString RWCurrency::mnemonic ( ) const
inline

Returns the currency's mnemonic.

◆ name()

RWCString RWCurrency::name ( ) const
inline

Returns the currency's name.

◆ operator=()

RWCurrency & RWCurrency::operator= ( const RWCurrency & )

Assignment operator.

◆ restoreFrom() [1/2]

void RWCurrency::restoreFrom ( RWFile & )

Restores the currency from an RWFile.

◆ restoreFrom() [2/2]

void RWCurrency::restoreFrom ( RWvistream & )

Restores the currency from a virtual stream.

◆ saveOn() [1/2]

void RWCurrency::saveOn ( RWFile & ) const

Persists the currency to an RWFile.

◆ saveOn() [2/2]

void RWCurrency::saveOn ( RWvostream & ) const

Persists the currency to a virtual stream.

◆ setCode()

void RWCurrency::setCode ( int c)
inline

Sets the currency's numeric code to c.

◆ setExpirationDate()

void RWCurrency::setExpirationDate ( const RWDate & d)
inline

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

◆ setFractionName()

void RWCurrency::setFractionName ( const RWCString & fn)
inline

Sets the currency's fraction name to fn.

◆ setIntroductionDate()

void RWCurrency::setIntroductionDate ( const RWDate & d)
inline

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

◆ setMnemonic()

void RWCurrency::setMnemonic ( const RWCString & m)
inline

Sets the currency's mnemonic to m.

◆ setName()

void RWCurrency::setName ( const RWCString & n)
inline

Sets the currency's name to n.

◆ setWholeToFractionRatio()

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.

◆ wholeToFractionRatio()

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 Symbol Documentation

◆ operator<<() [1/2]

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

Saves the currency object to an RWFile.

◆ operator<<() [2/2]

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

Saves the currency object to a virtual stream.

◆ operator==

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

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

◆ operator>>() [1/2]

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

Restores a currency object from an RWFile.

◆ operator>>() [2/2]

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

Restores a currency object from a virtual stream.

Member Data Documentation

◆ noExpirationDate

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:

if (C.expirationDate() == RWCurrency::noExpirationDate) {
// ...
}
// Always true
}
// Always true
}
static const RWDate noExpirationDate
Definition currency.h:109
static const RWDate noIntroductionDate
Definition currency.h:104
Represents a date stored as a Julian day number.
Definition rwdate.h:112

◆ noIntroductionDate

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:

if (C.expirationDate() == RWCurrency::noExpirationDate) {
// ...
}
// Always true
}
// Always true
}

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