コード例 #1
0
ファイル: gnc-recurrence-sql.c プロジェクト: 573/gnucash
/*@ 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;
}
コード例 #2
0
ファイル: gnc-recurrence-sql.c プロジェクト: 573/gnucash
/*@ 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;
}
コード例 #3
0
ファイル: gnc-recurrence-sql.cpp プロジェクト: Bob-IT/gnucash
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;
}
コード例 #4
0
ファイル: gnc-recurrence-sql.cpp プロジェクト: Bob-IT/gnucash
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;
}