## toolOptions toolOptions — A convienent wrapper around GHashTable that can support types. |

## Synopsis

    struct              Option_stuct;
    typedef             Option;
    typedef             OptionTable;
    enum                OptionTypes;
    Option*             toolOptionsNew_optionBoolean        (const gchar *name,
                                                             const gchar *label);
    Option*             toolOptionsNew_optionFloat          (const gchar *name,
                                                             const gchar *label);
    Option*             toolOptionsNew_optionInteger        (const gchar *name,
                                                             const gchar *label);
    #define             toolOptionsNew_table                ()
    void                toolOptionsFree_option              (gpointer option);
    #define             toolOptionsFree_table               (table)
    #define             toolOptionsAdd_optionToTable        (table, option)
    gchar*              toolOptionsGet_label                (Option *option);
    gchar*              toolOptionsGet_name                 (Option *option);
    #define             toolOptionsGet_optionFromTable      (table, option)
    OptionTypes         toolOptionsGet_type                 (Option *option);
    gchar*              toolOptionsGet_valueAndLabel        (Option *option);
    gboolean            toolOptionsGet_valueBoolean         (Option *option,
                                                             gboolean *value);
    gboolean            toolOptionsGet_valueFloat           (Option *option,
                                                             float *value);
    gboolean            toolOptionsGet_valueInteger         (Option *option,
                                                             int *value);
    void                toolOptionsSet_valueBoolean         (Option *option,
                                                             gboolean value);
    void                toolOptionsSet_valueFloat           (Option *option,
                                                             float value);
    void                toolOptionsSet_valueInteger         (Option *option,
                                                             int value);

## Description

This wrapper is a simple way to store integers, floating point values or booleans in a table, accessing with a string key and remembering their types.

## Details

### struct Option_stuct

    struct Option_stuct;

Opaque structure to store values, their ranges...

### Option

    typedef struct Option_stuct Option;

Short way to address Option_stuct.

### OptionTable

    typedef GHashTable OptionTable;

This hashtable is used to specificaly bind strings to Option elements.

### enum OptionTypes

    typedef enum
      {
        OPTION_BOOLEAN,
        OPTION_INTEGER,
        OPTION_FLOAT,
        NB_OPTION_TYPES
      } OptionTypes;

These are types supported in the OptionTable.

`OPTION_BOOLEAN` | a boolean value ;
`OPTION_INTEGER` | an integer value ;
`OPTION_FLOAT` | a floating point value ;
`NB_OPTION_TYPES` | number of suppoted types.

### toolOptionsNew_optionBoolean ()

    Option*             toolOptionsNew_optionBoolean        (const gchar *name,
                                                             const gchar *label);

Create a new Option using the name as identifier.

`name` : | a string identifying the option ;
`label` : | a string describing shortly the option (must be in UTF-8).
Returns : | a newly created option, use `toolOptionsFree_option()` to free it.

### toolOptionsNew_optionFloat ()

    Option*             toolOptionsNew_optionFloat          (const gchar *name,
                                                             const gchar *label);

Create a new Option using the name as identifier.

`name` : | a string identifying the option ;
`label` : | a string describing shortly the option (must be in UTF-8).
Returns : | a newly created option, use `toolOptionsFree_option()` to free it.

### toolOptionsNew_optionInteger ()

    Option*             toolOptionsNew_optionInteger        (const gchar *name,
                                                             const gchar *label);

Create a new Option using the name as identifier.

`name` : | a string identifying the option ;
`label` : | a string describing shortly the option (must be in UTF-8).
Returns : | a newly created option, use `toolOptionsFree_option()` to free it.

### toolOptionsNew_table()

    #define             toolOptionsNew_table()

Create a new table of options. Strings are used as keys and elements are Option.

Returns : | a newly created table. Use `toolOptionsFree_table()` to destroy it.

### toolOptionsFree_option ()

    void                toolOptionsFree_option              (gpointer option);

Free the memory used by the `option`.

`option` : | the Option to free.

### toolOptionsFree_table()

    #define toolOptionsFree_table(table) g_hash_table_destroy((GHashTable*)table)

Free all memory used by a table of options, and free also its elements.

`table` : | the table to free.

### toolOptionsAdd_optionToTable()

    #define             toolOptionsAdd_optionToTable(table, option)

Add the given `option` to the table, using its name as key.

`table` : | the table to add the option to ;
`option` : | an Option to be added.

### toolOptionsGet_label ()

    gchar*              toolOptionsGet_label                (Option *option);

Get the label of the option.

`option` : | the Option to get the label of.
Returns : | a string owned by V_Sim, should not be freed.

### toolOptionsGet_name ()

    gchar*              toolOptionsGet_name                 (Option *option);

Get the name of the option.

`option` : | the Option to get the name of.
Returns : | a string owned by V_Sim, should not be freed.

### toolOptionsGet_optionFromTable()

    #define             toolOptionsGet_optionFromTable(table, option)

Look in `table` to find `option`. If no option with this name is found, then it returns NULL.

`table` : | the table to look in ;
`option` : | a string being the option name.

### toolOptionsGet_type ()

    OptionTypes         toolOptionsGet_type                 (Option *option);

Get the type of the option.

`option` : | the Option to get the type of.
Returns : | a OptionTypes value.

### toolOptionsGet_valueAndLabel ()

    gchar*              toolOptionsGet_valueAndLabel        (Option *option);

This method returns a string with the value followed by the label in parenthesis and with Pango markup for smaller font.

`option` : | the Option to get the value from.
Returns : | a newly created markup string.

### toolOptionsGet_valueBoolean ()

    gboolean            toolOptionsGet_valueBoolean         (Option *option,
                                                             gboolean *value);

Read the value of one option.

`option` : | the Option to get the value from ;
`value` : | a location to store the value.
Returns : | FALSE if the value is currently unset.

### toolOptionsGet_valueFloat ()

    gboolean            toolOptionsGet_valueFloat           (Option *option,
                                                             float *value);

Read the value of one option.

`option` : | the Option to get the value from ;
`value` : | a location to store the value.
Returns : | FALSE if the value is currently unset.

### toolOptionsGet_valueInteger ()

    gboolean            toolOptionsGet_valueInteger         (Option *option,
                                                             int *value);

Read the value of one option.

`option` : | the Option to get the value from ;
`value` : | a location to store the value.
Returns : | FALSE if the value is currently unset.

### toolOptionsSet_valueBoolean ()

    void                toolOptionsSet_valueBoolean         (Option *option,
                                                             gboolean value);

Change or set (if not set yet) the value of one option.

`option` : | the Option to set the value of ;
`value` : | the new value.

### toolOptionsSet_valueFloat ()

    void                toolOptionsSet_valueFloat           (Option *option,
                                                             float value);

Change or set (if not set yet) the value of one option.

`option` : | the Option to set the value of ;
`value` : | the new value.

### toolOptionsSet_valueInteger ()

    void                toolOptionsSet_valueInteger         (Option *option,
                                                             int value);

Change or set (if not set yet) the value of one option.

`option` : | the Option to set the value of ;
`value` : | the new value.