Initializing a Currency Book
RWCurrencyBook provides two restoreFrom() member functions, and two right shift operators, operator >>(), to restore the currency book from an RWFile or a virtual stream. Similarly, it provides two saveOn() member functions and two left shift operators, operator <<(), to persist a currency book to an RWFile or a virtual stream.
The class also provides an initialize() member function that lets you initialize from an istream. The following code shows how to use initialize() to populate an RWCurrencyBook, myBook from the file currency_book.in:
 
#include <rw/currency/currbook.h>
ifstream strm("currency_book.in");
RWCurrencyBook myBook;
b.initialize(strm);
Each entry in the currency book is a different currency. 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
name=shilling
fraction=cents
ratio=.01
mnemonic=KES
code=404
END_CURRENCY
Name matching is case-insensitive and the only required field for each currency in a currency book is the mnemonic.