#include <value.h>
Public Methods | |
Value () | |
Value (double value, const string ¤cy) | |
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) |
|
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. |
|
Construct a value by giving an amount and a currency.
|
|
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".
|
|
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.
|
|
Returns the currency of this value as ISO-4217 string.
|
|
Returns the amount of this value.
|
|
Check whether this value is an empty value, which occurs if it has been constructed by the default empty constructor. Returns true otherwise.
|
|
Returns a user-readable string representation of this value. This has the format e.g. "1234.56 EUR".
|
|
Returns a HBCI-conforming string representation of this value. See the documentation of the constructor for more on this.
|