GomSorting: Gom Reference Manual

## GomSorting GomSorting |

## Functions

#define | GOM_SORTING_CONST()
gchar * | gom_sorting_get_sql ()
GomSorting * | gom_sorting_new ()
void | gom_sorting_add ()

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GomSorting

## Description

## Functions

### GOM_SORTING_CONST()

    #define GOM_SORTING_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOM_TYPE_SORTING, GomSorting const))

### gom_sorting_get_sql ()

    gchar *
    gom_sorting_get_sql (GomSorting *sorting,
                         GHashTable *table_map);

#### Parameters

sorting | A GomSorting. | [in]
table_map | A GHashTable. | [in]

#### Returns

A string containing the SQL query corresponding to this `sorting` .

[transfer full]

### gom_sorting_new ()

    GomSorting *
    gom_sorting_new (GType first_resource_type,
                     const gchar *first_property_name,
                     GomSortingMode first_sorting_mode,
                     ...);

Creates a new GomSorting to instance.

This is useful to sort query results, as GomSorting knows how to return the proper "ORDER BY" SQL statements.

Example:

    1
    2
    3
    4
    5
    6
    GomSorting *sorting = gom_sorting_new(EPISODE_TYPE_RESOURCE,
                                          "season-number",
                                          GOM_SORTING_DESCENDING,
                                          EPISODE_TYPE_RESOURCE,
                                          "episode-number",
                                          GOM_SORTING_ASCENDING);

The above example maps to the following SQL statement:

    1
    ORDER BY 'episodes'.'season-number' DESC, 'episodes'.'episode-number'

[constructor]

#### Parameters

first_resource_type | A subclass of GomResource. |
first_property_name | A string. |
first_sorting_mode | A GomSortingMode. |
... | Additional triples of resource_type/property_name/sorting_mode, followed by `NULL`. |

#### Returns

A GomSorting.

[transfer full]

### gom_sorting_add ()

    void
    gom_sorting_add (GomSorting *sorting,
                     GType resource_type,
                     const gchar *property_name,
                     GomSortingMode sorting_mode);

Add a new ORDER BY clause to the sorting object.

This allows chaining ORDER BY clauses, adding them one at a time, rather than passing them all to the constructor.

Example:

    1
    2
    3
    4
    5
    GomSorting *sorting = g_object_new (GOM_TYPE_SORTING, NULL);
    gom_sorting_add (sorting, EPISODE_TYPE_RESOURCE, "season-number",
                     GOM_SORTING_DESCENDING);
    gom_sorting_add (sorting, EPISODE_TYPE_RESOURCE, "episode-number",
                     GOM_SORTING_ASCENDING);

The above example maps to the following SQL statement:

    1
    ORDER BY 'episodes'.'season-number' DESC, 'episodes'.'episode-number'

#### Parameters

sorting | A GomSorting. |
resource_type | A subclass of GomResource. |
property_name | A string. |
sorting_mode | A GomSortingMode. |

## Types and Values