[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using librec
From: |
Jose E. Marchesi |
Subject: |
Re: Using librec |
Date: |
Thu, 06 May 2021 17:57:07 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Cool, thanks!
>
> So after doing the commands in your first email, I'd have to create an
> mset, adapt the code in your second email, and then write to disk?
You will need to create a db, get its mset, add the record created below
to it, and write, yes :)
>
>
> On Thu, 6 May 2021, 13:25 Jose E. Marchesi, <jemarch@gnu.org> wrote:
>
>>
>> > Thanks for your quick response! If you don't mind, could you give me an
>> > example usage of creating a multi-set/record? Some functions need typedef
>> > function pointers, which I can't make heads or tails of.
>>
>> This is how you would create a rec_record_t with the following record:
>>
>> Foo: bar
>> # this is a comment
>> Bar: baz
>>
>> The code:
>>
>> rec_field_t f1 = rec_field_new ("Foo", "bar");
>> rec_comment_t c = rec_comment_new ("this is a comment");
>> rec_field_t f2 = rec_field_new ("Bar", "baz");
>>
>> rec_record_t rec = rec_record_new ();
>> rec_mset_t rec_elements = rec_record_mset (rec):
>>
>> rec_mset_append (rec_elements, MSET_FIELD, f1, MSET_ANY);
>> rec_mset_append (rec_elements, MSET_COMMENT, c, MSET_ANY);
>> rec_mset_append (rec_elements, MSET_FIELD, f2, MSET_ANY);
>>
>> Working with record sets is similar: they also have a mset that contains
>> MSET_RECORD or MSET_COMMENT elements.
>>
>
> --
> Student Account