rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWCurrencyBook Class Reference
[Currencies]

Stores RWCurrency objects in which each is identified by a unique mnemonic. More...

#include <rw/currency/currbook.h>

List of all members.

Public Member Functions

 RWCurrencyBook ()
 RWCurrencyBook (const RWCurrencyBook &)
bool initialize (std::istream &strm)
RWTValSlist< RWCurrencygetAllCurrencies () const
RWTValSlist< RWCStringgetAllCurrencyMnemonics () const
bool find (const RWCString &mnemonic, RWCurrency &currency) const
bool contains (const RWCString &mnemonic) const
size_t entries () const
bool insert (const RWCurrency &currency)
bool remove (const RWCString &mnemonic)
void clear ()
void saveOn (RWvostream &) const
void saveOn (RWFile &) const
void restoreFrom (RWvistream &)
void restoreFrom (RWFile &)
RWCurrencyBookoperator= (const RWCurrencyBook &)

Static Public Attributes

static const RWCString mnemonicTag
static const RWCString codeTag
static const RWCString nameTag
static const RWCString fractionNameTag
static const RWCString wholeToFractionTag
static const RWCString introDateTag
static const RWCString expDateTag
static const RWCString beginToken
static const RWCString endToken

Friends

std::ostream & operator<< (std::ostream &, const RWCurrencyBook &)

Related Functions

(Note that these are not member functions.)



std::istream & operator>> (std::istream &strm, RWCurrencyBook &b)

Detailed Description

Class RWCurrencyBook stores RWCurrency objects. Each currency in the currency book is identified by a unique mnemonic. A currency's mnemonic can only appear once--duplicates are not allowed.

Class RWCurrencyBook can be initialized from an std::istream. Currency Module includes a file that can be used to initialize an RWCurrencyBook through an std::ifstream. Appendix B lists the countries and the currency mnemonics in the provided file.

Synopsis

 #include <rw/currency/currbook.h>
 std::ifstream strm("currency_book.txt");
 RWCurrencyBook b;
 b.initialize(strm);

Constructor & Destructor Documentation

RWCurrencyBook::RWCurrencyBook (  ) 

Default constructor. Creates an empty currency book.

RWCurrencyBook::RWCurrencyBook ( const RWCurrencyBook  ) 

Copy constructor.


Member Function Documentation

void RWCurrencyBook::clear (  ) 

Removes all currencies.

bool RWCurrencyBook::contains ( const RWCString mnemonic  )  const

Returns true if the currency book contains the currency with the given mnemonic.

size_t RWCurrencyBook::entries (  )  const

Returns the number of currencies currently in the book.

bool RWCurrencyBook::find ( const RWCString mnemonic,
RWCurrency currency 
) const

Finds the currency indicated by mnemonic, places it in currency and returns true. If no such currency exists, c is unchanged and the function returns false.

RWTValSlist<RWCurrency> RWCurrencyBook::getAllCurrencies (  )  const

Returns a collection of all the currencies in the currency book.

RWTValSlist<RWCString> RWCurrencyBook::getAllCurrencyMnemonics (  )  const

Returns the mnemonics of all the currencies in the currency book.

bool RWCurrencyBook::initialize ( std::istream &  strm  ) 

Initializes a currency book with currencies from strm. This method returns false if there is an error in the stream format, or if one or more of the currencies is missing a mnemonic.

Note:
The previous contents of self are deleted when this function is invoked.

A currency specification begins with the token BEGIN_CURRENCY, on a line by itself. Each attribute of the currency is specified as a name/value pair, one per line. The name/value separator is the equal sign `='. The end of a currency specification is indicated by the token END_CURRENCY. Comment lines start with a # character and are automatically skipped. For example:

 #Kenya
 BEGIN_CURRENCY
 mnemonic=KES
 ratio =.01
 name=shilling
 fraction=cents
 code=404
 introduced=
 expires=
 END_CURRENCY

Name matching is case-insensitive and the only required value is mnemonic. The initialize() function returns false if one or more of the currencies is missing a mnemonic.

Valid names are:

 mnemonic
 ratio
 name
 fraction
 code
 introduced
 expires
bool RWCurrencyBook::insert ( const RWCurrency currency  ) 

Adds the given currency to the currency book. If the currency book already contains an entry that matches currency, insert() does not add currency, and it returns false. Otherwise, insert() adds currency to the currency book and returns true.

RWCurrencyBook& RWCurrencyBook::operator= ( const RWCurrencyBook  ) 

Assignment operator.

bool RWCurrencyBook::remove ( const RWCString mnemonic  ) 

Removes the currency indicated by mnemonic if it exists in the currency book, and returns true. If mnemonic does not exist, returns false.

void RWCurrencyBook::restoreFrom ( RWFile  ) 

Restores the currency book from an RWFile.

void RWCurrencyBook::restoreFrom ( RWvistream  ) 

Restores the currency book from a virtual stream.

void RWCurrencyBook::saveOn ( RWFile  )  const

Persists the currency book to an RWFile.

void RWCurrencyBook::saveOn ( RWvostream  )  const

Persists the currency book to a virtual stream.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  strm,
const RWCurrencyBook b 
) [friend]

Outputs the RWCurrencyBook to a stream in the same format shown in the initialize() function.

std::istream & operator>> ( std::istream &  strm,
RWCurrencyBook b 
) [related]

Replaces the contents of the currency book with the contents of the stream. The format of the stream is the same as that described in the initialize() member function.


Member Data Documentation

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

The following static data members define the strings that provide names for the name/value pairs used when initializing from a stream. They are initialized to the valid names described in RWCurrencyBook::initialize().

 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.