On Sun, Aug 16, 2009 at 2:01 AM, Carsten Haitzler<ras...@rasterman.com> wrote:
> On Sun, 16 Aug 2009 01:48:26 -0300 Raphael Kubo da Costa <k...@profusion.mobi>
> said:
>
> whats the data descriptor for it? i assume you have at least 2 (one for the
> base struct with the list, one for the list item struct?)
Apparently my attachment wasn't being sent correctly, sorry. I guess
you can see the code now :)

-- 
Raphael Kubo da Costa
ProFUSION embedded systems
http://profusion.mobi
#include <Eina.h>
#include <Eet.h>
#include <stdio.h>

typedef struct {
    int i;
} Entry;

typedef struct {
    Eina_List *entry_list;
} Db;

int main(int argc, char *argv[])
{
    Eet_Data_Descriptor *entry_edd = NULL;
    Eet_Data_Descriptor *db_edd = NULL;
    Eet_Data_Descriptor_Class eddc;
    Eet_File *db_file;
    Db *db;
    Entry *entry = NULL;

    eina_init();
    eet_init();

    EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Entry);
    entry_edd = eet_data_descriptor_stream_new(&eddc);
    EET_DATA_DESCRIPTOR_ADD_BASIC(entry_edd, Entry, "i", i, EET_T_INT);

    EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Db);
    db_edd = eet_data_descriptor_stream_new(&eddc);
    EET_DATA_DESCRIPTOR_ADD_LIST(db_edd, Db, "entry_list", entry_list, entry_edd);

    db_file = eet_open("eet.file", EET_FILE_MODE_READ_WRITE);
    db = eet_data_read(db_file, db_edd, "data");
    if (!db) {
        db = (Db*)malloc(sizeof(Db));
        db->entry_list = NULL;
    }

    if (argc > 1 && atoi(argv[1])) {
        entry = (Entry*)malloc(sizeof(Entry));
        entry->i = 42;
        db->entry_list = eina_list_append(db->entry_list, entry);
    }

    printf("%d\n", eet_data_write(db_file, db_edd, "data", db, 1));

    eet_data_descriptor_free(entry_edd); 
    eet_data_descriptor_free(db_edd); 
    eet_close(db_file);

    if (entry)
        free(entry);
    free(db);

    eet_shutdown();
    eina_shutdown();

    return 0;
}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to