SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Stores RWCurrency objects in which each is identified by a unique mnemonic. More...
#include <rw/currency/currbook.h>
Public Member Functions | |
RWCurrencyBook () | |
RWCurrencyBook (const RWCurrencyBook &) | |
void | clear () |
bool | contains (const RWCString &mnemonic) const |
size_t | entries () const |
bool | find (const RWCString &mnemonic, RWCurrency ¤cy) const |
RWTValSlist< RWCurrency > | getAllCurrencies () const |
RWTValSlist< RWCString > | getAllCurrencyMnemonics () const |
bool | initialize (std::istream &strm) |
bool | insert (const RWCurrency ¤cy) |
RWCurrencyBook & | operator= (const RWCurrencyBook &) |
bool | remove (const RWCString &mnemonic) |
void | restoreFrom (RWFile &) |
void | restoreFrom (RWvistream &) |
void | saveOn (RWFile &) const |
void | saveOn (RWvostream &) const |
Static Public Attributes | |
static const RWCString | beginToken |
static const RWCString | codeTag |
static const RWCString | endToken |
static const RWCString | expDateTag |
static const RWCString | fractionNameTag |
static const RWCString | introDateTag |
static const RWCString | mnemonicTag |
static const RWCString | nameTag |
static const RWCString | wholeToFractionTag |
Friends | |
std::ostream & | operator<< (std::ostream &strm, const RWCurrencyBook &b) |
Related Symbols | |
(Note that these are not member symbols.) | |
std::istream & | operator>> (std::istream &strm, RWCurrencyBook &b) |
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. The Currency Module includes a file <installdir>/examples/currency/currency_book
.in that can be used to initialize an RWCurrencyBook through an std::ifstream. Refer to this file for the currencies supported and their mnemonics. The Currency Module User Guide contains information on how to add currency definitions to this file.
RWCurrencyBook::RWCurrencyBook | ( | ) |
Default constructor. Creates an empty currency book.
RWCurrencyBook::RWCurrencyBook | ( | const RWCurrencyBook & | ) |
Copy constructor.
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.
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:
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:
bool RWCurrencyBook::insert | ( | const RWCurrency & | currency | ) |
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 | ( | RWvistream & | ) |
Restores the currency book from a virtual stream.
void RWCurrencyBook::saveOn | ( | RWvostream & | ) | const |
Persists the currency book to a virtual stream.
|
friend |
Outputs the RWCurrencyBook to a stream in the same format shown in the initialize() function.
|
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.
|
static |
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().
|
static |
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().
|
static |
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().
|
static |
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().
|
static |
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().
|
static |
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().
|
static |
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().
|
static |
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().
|
static |
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().
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |