Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CurrencyDB Class Reference

class to manipulate the currency database. More...

#include <CurrencyDB.h>

Inheritance diagram for CurrencyDB:

Database< currencyStructure, packedCurrencyStructure > GenericDB Collaboration diagram for CurrencyDB:

Collaboration graph
[legend]
List of all members.

Public Methods

void unpackRecord (currencyStructure *currency, packedCurrencyStructure *packed_currency) DB_SECTION1
 unpacks a currency record. More...

void packRecord (currencyStructure *currency, MemHandle db_entry) DB_SECTION1
 packs a currency record. More...

 CurrencyDB () DB_SECTION1
 initialize the database. More...

UInt16 newRecord (currencyStructure *c) DB_SECTION1
 creates a new record; if this is the only currency the default currency for the application is automatically set to the uid for this new record; the exchange rate is automatically set to 1. More...

bool deleteRecord (UInt16 id) DB_SECTION1
 deletes a currency, given its id. More...

bool checkCurrencyDependency (UInt16 id) DB_SECTION1
 check whether there is any kind of dependency on the given currency. More...

bool checkForExistingCode (Char *code, UInt32 ignore_uid=0) DB_SECTION1
 checks if a given code already exists in the database. More...

double getExchangeRate (UInt32 currency1, UInt32 currency2) DB_SECTION1
 This method can be used to obtain the exchange rate between any two currencies. More...

void adjustExchangeRate (UInt32 src_currency, UInt32 dest_currency, double rate) DB_SECTION1
 modifies the exchange rate in between the given currency to match some given rate. More...

void newDefaultCurrency (UInt32 currency) DB_SECTION1
 Update all exchange rates so that they correspond to a new given default currency. More...

void getDescriptionTruncLeftToFit (UInt32 uid, Int16 width, Char *buffer) DB_SECTION1
 creates a description for a given currency and puts it in a (preallocated) buffer. More...


Static Public Methods

Int16 compareRecords (packedCurrencyStructure *rec1, packedCurrencyStructure *rec2, Int16 other, SortRecordInfoPtr sr1, SortRecordInfoPtr sr2, MemHandle app_info) DB_SECTION1
 Compares two packed currency structures. More...


Detailed Description

class to manipulate the currency database.

Definition at line 50 of file CurrencyDB.h.


Constructor & Destructor Documentation

CurrencyDB::CurrencyDB  
 

initialize the database.


Member Function Documentation

void CurrencyDB::adjustExchangeRate UInt32    src_currency,
UInt32    dest_currency,
double    rate
 

modifies the exchange rate in between the given currency to match some given rate.

Note:
the operation fails if none of the given currencies is the default currency. This is because we would have to set the exchange rate of both give currencies w.r.t. the default currency. We cannot do this without more information
Parameters:
src_currency  UID for the source currency
dest_currency  UID for the destination currency
rate  new exchange rate between src_currency and dest_currency

bool CurrencyDB::checkCurrencyDependency UInt16    id
 

check whether there is any kind of dependency on the given currency.

Returns:
true if there is such a dependency, false otherwise

bool CurrencyDB::checkForExistingCode Char *    code,
UInt32    ignore_uid = 0
 

checks if a given code already exists in the database.

Returns:
true if a currency with the given code exists in the database, false othewise
Parameters:
code  currency code to look for
ignore_uid  if not 0 (default value) the given uid is going to be ignored in the search. This is useful when updating an existing record

Int16 CurrencyDB::compareRecords packedCurrencyStructure   rec1,
packedCurrencyStructure   rec2,
Int16    other,
SortRecordInfoPtr    sr1,
SortRecordInfoPtr    sr2,
MemHandle    app_info
[static]
 

Compares two packed currency structures.

The currency database is sorted by code For parameters see the PalmOS reference

bool CurrencyDB::deleteRecord UInt16    id [virtual]
 

deletes a currency, given its id.

The process fails if the given currency is set as default, or if there are any accounts which use the currency

Parameters:
id  the id of the record to be deleted

Reimplemented from GenericDB.

void CurrencyDB::getDescriptionTruncLeftToFit UInt32    uid,
Int16    width,
Char *    buffer
 

creates a description for a given currency and puts it in a (preallocated) buffer.

Parameters:
uid  the uid of the currency to be described
width  maximum width of generated text (if generated text is longer will be truncated)
buffer  buffer where the new text is going to be generated

double CurrencyDB::getExchangeRate UInt32    currency1,
UInt32    currency2
 

This method can be used to obtain the exchange rate between any two currencies.

The calculation will make use of the exchange rate w.r.t the default currency

Parameters:
currency1  UID of the first currency (source currency)
currency2  UID of the destination currency
Returns:
a fraction x such that: one unit of currency1 * x = value of 1 unit currency1 in currency2

void CurrencyDB::newDefaultCurrency UInt32    currency
 

Update all exchange rates so that they correspond to a new given default currency.

Parameters:
currency  the UID of the new default currency
Note:
this method does not change the actual currency, as it is stored in the application preferences

UInt16 CurrencyDB::newRecord currencyStructure   c [virtual]
 

creates a new record; if this is the only currency the default currency for the application is automatically set to the uid for this new record; the exchange rate is automatically set to 1.

Otherwise the record is simply created without any further manipulation The code names have to be unique, so giving an existing code name will result in a warning a refusal to create

Parameters:
c  pointer to the structure containing the currency data
Returns:
id of the newly created record

Reimplemented from Database< currencyStructure, packedCurrencyStructure >.

void CurrencyDB::packRecord currencyStructure   currency,
MemHandle    db_entry
[virtual]
 

packs a currency record.

Implements Database< currencyStructure, packedCurrencyStructure >.

void CurrencyDB::unpackRecord currencyStructure   currency,
packedCurrencyStructure   packed_currency
[virtual]
 

unpacks a currency record.

Implements Database< currencyStructure, packedCurrencyStructure >.


The documentation for this class was generated from the following file:
Generated on Thu Jan 16 23:11:14 2003 for FreeCoins by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002