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

HBCI::Value Class Reference

Represents a monetary value in HBCI. More...

#include <value.h>

List of all members.

Public Methods

 Value ()
 Value (double value, const string &currency)
 Value (const string &strvalue)
bool isValid () const
double getValue () const
const string & getCurrency () const
string toString () const
string toReadableString () const

Static Public Methods

unsigned int currencyPrecision (const string &c)


Detailed Description

Represents a monetary value in HBCI.

Author:
fabian kaiser


Constructor & Destructor Documentation

HBCI::Value::Value  
 

Default constructor.

Creates an empty, invalid value. This is used as a placeholder value where a valid value will be filled in later.

Note that simply initializing an empty value with zero doesn't do the job, since a value needs to have a currency, too, and this one can't be left empty. Also, initializing it with zero makes a placeholder value indistinguishable from actual zero value. Hence, you have to check values whether they are valid before using it.

HBCI::Value::Value double    value,
const string &    currency
 

Construct a value by giving an amount and a currency.

Parameters:
value  the amount
currency  the currency as ISO-4217 string, e.g. "EUR" for Euro

HBCI::Value::Value const string &    strvalue
 

Construct a value by parsing an HBCI-conforming value-string.

See HBCI-Spec chapter II.5.3.1 on the exact format. This implementation accepts the following:

"<float>[:<CUR>]" where <float> is a floating point literal and <CUR> is the three-character ISI-4217 currency string, separated from the float literal by a colon ":".

According to HBCI, <float> is of format "<digits>,[<digits>]": No leading minus sign; at least one digit left of the decimal delimiter; comma (not point!) as decimal delimiter; comma is mandatory (!); only as many digits after the comma as ISO-4217 says for the given currency; total length not more than 15 characters.

This implementation is a little bit less restrictive about the format and accepts also the following "[-]<digits>[<,.>[<digits>]]": Optional leading minus sign; at least one digit left of decimal delimiter; comma or point as decimal delimiter; if there are no digits on the right of the decimal delimiter, it can be omitted. The numeric range is limited to approx. +-10^17, after which the value will be rounded according to ordinary floating point rules.

If there is a format error (esp. if both comma and point or more than one of each appear in the float literal), a HBCI::Error is thrown.

The <CUR> currency string is simply truncated to three characters; if you errorneously specified "Euro", you won't notice that until your bank complains about an unknown currency. FIXME: should we throw an error if there are more than three characters after the colon? I don't think so.

Examples: HBCI-conforming: "4567,89:EUR", "100,2:EUR", "0,:EUR"; not HBCI-conforming, but also accepted here: "-4567,89:EUR", "100.20:EUR", "0:EUR".

Parameters:
strvalue  string representation of the value
Exceptions:
HBCI::Error  is the string is malformed


Member Function Documentation

unsigned int HBCI::Value::currencyPrecision const string &    c [static]
 

Returns the standarized floating-point precision of a given currency, according to ISO-4217. The returned number are the number of digits after the decimal point (comma).

For most currencies this is 2 (e.g. "EUR"), but for some it is 0 (e.g. Japan's Yen, "JPY"), and for even less others it might be totally different.

Only the currencies mentioned in the HBCI-spec, chapter VIII.11, are implemented currently. For unimplemented currencies, 2 is returned, and a warning message is printed on stderr.

Author:
Christian Stimming <stimming@tuhh.de>
Returns :
The standarized precision for this currency

const string& HBCI::Value::getCurrency   const [inline]
 

Returns the currency of this value as ISO-4217 string.

Returns :
The currency.

double HBCI::Value::getValue   const [inline]
 

Returns the amount of this value.

Returns :
The amount.

bool HBCI::Value::isValid   const [inline]
 

Check whether this value is an empty value, which occurs if it has been constructed by the default empty constructor. Returns true otherwise.

Returns :
false if invalid/empty value, true if valid value.
Author:
Mathias Kettner <mk@quara.de>

string HBCI::Value::toReadableString   const
 

Returns a user-readable string representation of this value.

This has the format e.g. "1234.56 EUR".

Returns :
The string representation.

string HBCI::Value::toString   const
 

Returns a HBCI-conforming string representation of this value.

See the documentation of the constructor for more on this.

Returns :
The string representation.


The documentation for this class was generated from the following file:
Generated on Mon Jun 23 13:41:18 2003 for openhbci by doxygen1.2.17