Data Types | ||
noExpirationDate |
noIntroductionDate |
#include<rw/money/currency.h> RWCurrency USDollars("USD", 840, "dollar", "cents", 0.01);
com.roguewave.money.currency.v1_0.Currency
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.
static const RWDate noExpirationDate; static const RWDate noIntroductionDate;
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
RWCurrency();
Default constructor.
RWCurrency(const RWCurrency& c);
Copy constructor.
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(const RWCString& mnemonic, int code, const RWCString& name, const RWCString& fractionName, double wholeToFractRatio, const RWDate& intro, constRWDate& expire);
Constructs an RWCurrency with the given information.
RWCurrency& operator=(const RWCurrency& c);
Assignment operator.
int code() const;
Returns the currency's numeric code.
RWDate expirationDate() const;
Returns a currency's expiration date. A return value of RWCurrency::noExpirationDate indicates there is no expiration date.
RWCString fractionName() const;
Returns the currency's fraction name.
RWBoolean hasExpired() const;
Returns TRUE if today's date is beyond the currency's expiration date.
RWDate introductionDate() const;
Returns a currency's introduction date. A return value of RWCurrency::noIntroductionDate indicates there is no introduction date.
RWBoolean isActive() const;
Returns TRUE if today's date lies between the introduction date and the expiration date.
RWCString mnemonic() const;
Returns the currency's mnemonic.
RWCString name() const;
Returns the currency's name.
void restoreFrom(RWFile&);
Restores the currency from an RWFile.
void restoreFrom(RWvistream&);
Restores the currency from a virtual stream.
void setCode(int code);
Sets the currency's numeric code to code.
RWDate setExpirationDate(const RWDate& d);
Sets a currency's expiration date. Note that this can be a date in the past.
RWDate setIntroductionDate(const RWDate& d);
Sets a currency's introduction date. Note that this can be a date in the past.
void saveOn(RWFile&) const;
Persists the currency to an RWFile.
void saveOn(RWvostream&) const;
Persists the currency to a virtual stream.
void setFractionName(const RWCString& name);
Sets the currency's fraction name to name.
void setName(const RWCString& name);
Sets the currency's name to name.
void setMnemonic(const RWCString& mnemonic);
Sets the currency's mnemonic to mnemonic.
void setWholeToFractionRatio(double ratio);
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 ratio.
RWCString wholeToFractionRatio() const;
Returns the ratio between one unit of the whole part of the currency and the smallest unit of the fractional part of the currency
RWBoolean operator==(const RWCurrency& lhs, const RWCurrency& rhs);
Returns TRUE if and only if all data members are equal.
RWvostream& operator<<(RWvostream& strm, const RWCurrency& c); RWFile& operator<<(RWFile& file, const RWCurrency& c);
Saves the currency object to a virtual stream or RWFile, respectively.
RWvistream& operator>>(RWvistream& strm, const RWCurrency& c); RWFile& operator>>(RWFile& strm, const RWCurrency& c);
Restores a currency object from a virtual stream or RWFile, respectively.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.