Example #1
0
void
gnc_sql_slots_load( GncSqlBackend* be, QofInstance* inst )
{
    slot_info_t info = { NULL, NULL, TRUE, NULL, 0, NULL, FRAME, NULL, g_string_new('\0') };
    g_return_if_fail( be != NULL );
    g_return_if_fail( inst != NULL );

    info.be = be;
    info.guid = qof_instance_get_guid( inst );
    info.pKvpFrame = qof_instance_get_slots( inst );
    info.context = NONE;

    slots_load_info( &info );
}
Example #2
0
void
gnc_sql_slots_load (GncSqlBackend* sql_be, QofInstance* inst)
{
    slot_info_t info = { NULL, NULL, TRUE, NULL, KvpValue::Type::INVALID,
                         NULL, FRAME, NULL, "" };
    g_return_if_fail (sql_be != NULL);
    g_return_if_fail (inst != NULL);

    info.be = sql_be;
    info.guid = qof_instance_get_guid (inst);
    info.pKvpFrame = qof_instance_get_slots (inst);
    info.context = NONE;

    slots_load_info (&info);
}
Example #3
0
static void
set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
    slot_info_t* pInfo = (slot_info_t*)pObject;

    g_return_if_fail( pObject != NULL );
    if ( pValue == NULL ) return;

    switch ( pInfo->value_type)
    {
    case KVP_TYPE_GUID:
    {
        KvpValue *value = kvp_value_new_guid( (GncGUID*)pValue );
        set_slot_from_value( pInfo, value );
        break;
    }
    case KVP_TYPE_GLIST:
    {
        slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue );
        kvp_value *pValue = NULL;
        gchar *key = get_key_from_path( pInfo->path );

        newInfo->context = LIST;

        slots_load_info( newInfo );
        pValue = kvp_value_new_glist_nc( newInfo->pList );
        kvp_frame_set_slot_nc(pInfo->pKvpFrame, key, pValue);
        g_string_free( newInfo->path, TRUE );
        g_slice_free( slot_info_t, newInfo );
        g_free( key );
        break;
    }
    case KVP_TYPE_FRAME:
    {
        slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue ) ;
        KvpFrame *newFrame = kvp_frame_new();
        newInfo->pKvpFrame = newFrame;

        switch ( pInfo->context )
        {
        case LIST:
        {
            KvpValue *value = kvp_value_new_frame_nc( newFrame );
            gchar *key = get_key_from_path( pInfo->path );
            newInfo->path = g_string_assign( newInfo->path, key );
            pInfo->pList = g_list_append( pInfo->pList, value );
            g_free( key );
            break;
        }
        case FRAME:
        default:
        {
            gchar *key = get_key_from_path( pInfo->path );
            kvp_frame_set_frame_nc( pInfo->pKvpFrame, key, newFrame );
            g_free( key );
            break;
        }
        }

        newInfo->context = FRAME;
        slots_load_info ( newInfo );
        g_string_free( newInfo->path, TRUE );
        g_slice_free( slot_info_t, newInfo );
        break;
    }
    default:
        break;
    }
}
Example #4
0
static void
set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
    slot_info_t* pInfo = (slot_info_t*)pObject;

    g_return_if_fail( pObject != NULL );
    if ( pValue == NULL ) return;

    switch ( pInfo->value_type)
    {
    case KvpValue::Type::GUID:
    {
        auto new_guid = guid_copy(static_cast<GncGUID*>(pValue));
        set_slot_from_value(pInfo, new KvpValue{new_guid});
        break;
    }
    case KvpValue::Type::GLIST:
    {
        slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue );
        KvpValue *pValue = NULL;
        gchar *key = get_key_from_path( pInfo->path );

        newInfo->context = LIST;

        slots_load_info( newInfo );
        pValue = new KvpValue{newInfo->pList};
        pInfo->pKvpFrame->set(key, pValue);
        g_string_free( newInfo->path, TRUE );
        g_slice_free( slot_info_t, newInfo );
        g_free( key );
        break;
    }
    case KvpValue::Type::FRAME:
    {
        slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue ) ;
        auto newFrame = new KvpFrame;
        newInfo->pKvpFrame = newFrame;

        switch ( pInfo->context )
        {
        case LIST:
        {
            auto value = new KvpValue{newFrame};
            gchar *key = get_key_from_path( pInfo->path );
            newInfo->path = g_string_assign( newInfo->path, key );
            pInfo->pList = g_list_append( pInfo->pList, value );
            g_free( key );
            break;
        }
        case FRAME:
        default:
        {
            gchar *key = get_key_from_path( pInfo->path );
            pInfo->pKvpFrame->set(key, new KvpValue{newFrame});
            g_free( key );
            break;
        }
        }

        newInfo->context = FRAME;
        slots_load_info ( newInfo );
        g_string_free( newInfo->path, TRUE );
        g_slice_free( slot_info_t, newInfo );
        break;
    }
    default:
        break;
    }
}