rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWCurrency Class Reference
[Currencies]

A repository for currency information. More...

#include <rw/currency/currency.h>

List of all members.

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)
void setMnemonic (const RWCString &m)
void setName (const RWCString &n)
void setCode (int c)
void setFractionName (const RWCString &fn)
void setWholeToFractionRatio (double r)
void setIntroductionDate (const RWDate &d)
void setExpirationDate (const RWDate &d)
RWCString mnemonic () const
RWCString name () const
int code () const
RWCString fractionName () const
double wholeToFractionRatio () const
RWDate introductionDate () const
RWDate expirationDate () const
bool hasExpired () const
bool isActive () const
void saveOn (RWvostream &) const
void saveOn (RWFile &) const
void restoreFrom (RWvistream &)
void restoreFrom (RWFile &)
RWCurrencyoperator= (const RWCurrency &)

Static Public Attributes

static const RWDate noIntroductionDate
static const RWDate noExpirationDate

Friends

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

Related Functions

(Note that these are not member functions.)



RWvostreamoperator<< (RWvostream &s, const RWCurrency &c)
RWvistreamoperator>> (RWvistream &s, RWCurrency &c)
RWFileoperator<< (RWFile &f, const 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 ( RWFile  ) 

Restores the currency from an RWFile.

void RWCurrency::restoreFrom ( RWvistream  ) 

Restores the currency from a virtual stream.

void RWCurrency::saveOn ( RWFile  )  const

Persists the currency to an RWFile.

void RWCurrency::saveOn ( RWvostream  )  const

Persists the currency to a virtual stream.

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

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

Saves the currency object to an RWFile.

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

Saves the currency object to a virtual stream.

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

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

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

Restores a currency object from an RWFile.

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

Restores a currency object from a virtual stream.


Member Data Documentation

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:

 RWCurrency C;
 .
 .
 .
 if(C.expirationDate==RWCurrency::noExpirationDate)
 {
 .
 .
 .
 }
 RWDate d;
 if(d<=RWCurrency::noExpirationDate)
 //Always true
 if(d>=RWCurrency::noIntroductionDate)
 //Always true

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:

 RWCurrency C;
 .
 .
 .
 if(C.expirationDate==RWCurrency::noExpirationDate)
 {
 .
 .
 .
 }
 RWDate d;
 if(d<=RWCurrency::noExpirationDate)
 //Always true
 if(d>=RWCurrency::noIntroductionDate)
 //Always true
 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.