Ejemplo n.º 1
0
/*@ null @*/ GList*
gnc_sql_recurrence_load_list( GncSqlBackend* be, const GncGUID* guid )
{
    GncSqlResult* result;
    GList* list = NULL;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( guid != NULL, NULL );

    result = gnc_sql_set_recurrences_from_db( be, guid );
    if ( result != NULL )
    {
        GncSqlRow* row = gnc_sql_result_get_first_row( result );

        while ( row != NULL )
        {
            Recurrence* pRecurrence = g_new0( Recurrence, 1 );
            g_assert( pRecurrence != NULL );
            load_recurrence( be, row, pRecurrence );
            list = g_list_append( list, pRecurrence );
            row = gnc_sql_result_get_next_row( result );
        }
        gnc_sql_result_dispose( result );
    }

    return list;
}
Ejemplo n.º 2
0
/*@ null @*/ Recurrence*
gnc_sql_recurrence_load( GncSqlBackend* be, const GncGUID* guid )
{
    GncSqlResult* result;
    Recurrence* r = NULL;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( guid != NULL, NULL );

    result = gnc_sql_set_recurrences_from_db( be, guid );
    if ( result != NULL )
    {
        guint numRows = gnc_sql_result_get_num_rows( result );

        if ( numRows > 0 )
        {
            if ( numRows > 1 )
            {
                g_warning( "More than 1 recurrence found: first one used" );
            }
            r = g_new0( Recurrence, 1 );
            g_assert( r != NULL );
            load_recurrence( be, gnc_sql_result_get_first_row( result ), r );
        }
        else
        {
            g_warning( "No recurrences found" );
        }
        gnc_sql_result_dispose( result );
    }

    return r;
}
Ejemplo n.º 3
0
GList*
gnc_sql_recurrence_load_list (GncSqlBackend* sql_be, const GncGUID* guid)
{
    GList* list = NULL;

    g_return_val_if_fail (sql_be != NULL, NULL);
    g_return_val_if_fail (guid != NULL, NULL);

    auto result = gnc_sql_set_recurrences_from_db (sql_be, guid);
    for (auto row : *result)
    {
        Recurrence* pRecurrence = g_new0 (Recurrence, 1);
        g_assert (pRecurrence != NULL);
        load_recurrence (sql_be, row, pRecurrence);
        list = g_list_append (list, pRecurrence);
    }

    return list;
}
Ejemplo n.º 4
0
Recurrence*
gnc_sql_recurrence_load (GncSqlBackend* sql_be, const GncGUID* guid)
{
    Recurrence* r = NULL;

    g_return_val_if_fail (sql_be != NULL, NULL);
    g_return_val_if_fail (guid != NULL, NULL);

    auto result = gnc_sql_set_recurrences_from_db (sql_be, guid);
    auto row = result->begin();
    if (row == nullptr)
    {
        g_warning ("No recurrences found");
        return r;
    }
    r = g_new0 (Recurrence, 1);
    g_assert (r != NULL);
    load_recurrence (sql_be, *(result->begin()), r);

    if (++row != nullptr)
        g_warning ("More than 1 recurrence found: first one used");

    return r;
}