ifx_gl_convert_money - Convert a money string to an internal representation.
SYNOPSIS
#include <ifxgls.h>
int ifx_gl_convert_money(mi_money *money, char *monstr, char *format)
DESCRIPTION
This function converts the money string stored in monstr into
an internal representation. The internal representation is stored in
the mi_money structure pointed to by money in the format specified
by format.
If format is NULL, then the format is
determined from the DBMONEY environment variable
and the LC_MONEY settings in the current GLS locale.
If format is not NULL, then it must point to a character
string which adheres to the description in the FORMAT section below.
FORMAT
The format may contain the following:
1. one or more white-space character as specified in ifx_gl_ismspace()
2. One or more ordinary characters (neither % nor white-space character)
3. one conversion specification
One or more white-spaces in format causes skipping over one or more
white-spaces in monstr, up to the first non-white-space
character (which remains unscanned), or until no more characters can
be scanned.
Each ordinary character in format is compared with that in
monstr. Any mismatch is reported as error. The differing and
subsequent characters in monstr remain unscanned.
A conversion specification consists of a % character and a terminating
conversion character that determins the type of conversion required.
There may be optional modifiers between the % and conversion characters.
The following conversion specifications are supported.
- %i
-
Matches a monetary representation formatted according to the
locale's international currency format. The corresponding argument
should be a (double *).
- %n
-
Matches a monetary representation formatted according to the
locale's national currency format. The corresponding argument
should be a (double *).
- %%
-
Matches a % character. No corrsponding argument is needed.
Modifiers
Modifiers may immediately follow the initial % of a directive in the
following format:
['][-][<max-width>]
If a (') exists, the field is assumed to follow the grouping rule
specified in the locale.
If a minus (-) exists, the field is assumed to be left justified.
The first character of monstr is expected to be the first character of
the value to be converted. Whitespace in monstr won't be skipped, but
reported as error.
If no - exists, the field is assumed to be right justified. Whitespaces
will be skipped.
<max-width> is a decimal number which specifies the maximum number of
characters to be read from monstr.
Locale Information
The LC_MONETARY category of the program's locale affects the behavior
of this function including the monetary radix character (which may be
different from the numeric radix character affected by the LC_NUMERIC
category), the grouping separator, the currency symbols, positive,
negative signs and the order of currency symbol, sign and value.
The international currency symbol should be conformant with the ISO
4217:1987 standard.
RETURN VALUES
On success, this function returns 0.
On failure, this function returns -1.
ERRORS
If an error has occurred, this function returns -1 and
ifx_gl_lc_errno() returns,
- [IFX_GL_INVALIDFMT]
- bad format string
- [IFX_GL_ENOMEM]
- memory allocation failure
SEE ALSO
ifx_gl_format_money(),
ACKNOWLEDGEMENT
Portions of this description were derived from the X/Open CAE
Specification: "System Interfaces and Headers, Issue 4"; X/Open
Document Number: C202; ISBN: 1-872630-47-2; Published by X/Open Company
Ltd., U.K.