GtkDataFormat

## GtkDataFormat GtkDataFormat — a data formatting library |

## Synopsis

    #include <gtkextra.h>

    gchar *             gtk_data_format                     (const gchar *str,
                                                             const gchar *dataformat);
    gchar *             gtk_data_format_remove              (const gchar *str,
                                                             const gchar *dataformat);

## Description

the widget property 'dataformat' may contain formatting instructions for the field contents. Any unrecognized formatting instruction is silently skipped.

The formatting process should always be reversible. Thus formatting can be applied when input focus leaves a field and removed again when the focus enters a field, without the need of an additional content buffer.

the library can be easily extended by adding more instructions to the list above.

## Details

### gtk_data_format ()

    gchar *             gtk_data_format                     (const gchar *str,
                                                             const gchar *dataformat);

format `str` according to `dataformat`.

formatting instructions:

'' (the empty string) does no formatting at all.

'int8' is formatted as a singed 8-bit integer value with optional '-' sign.

'int16' is formatted as a signed 16-bit integer with optional '-' sign.

'int32' is formatted as a signed 32-bit integer with optional '-' sign.

'money' is formatted as a double float value with 2 decimal digits and 1000s-separators

'float,N' is formatted as a double float value with N decimal digits and 1000s-separators

'bit' is formatted as a boolean value [0,1].

`str` : | the string to be formatted
`dataformat` : | formatting instructions
Returns : | a pointer to an internal static buffer, with the formatted data

### gtk_data_format_remove ()

    gchar *             gtk_data_format_remove              (const gchar *str,
                                                             const gchar *dataformat);

reverse the effect of gtk_data_format, i.e. remove all formatting characters, apply trailing dash

`str` : | the string to be unformatted
`dataformat` : | formatting instructions
Returns : | a pointer to an internal static buffer, with the unformatted data