Skip to Content.
Sympa Menu

freetds - Re: [freetds] a better libtds

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] a better libtds
  • Date: Mon, 22 Aug 2011 11:43:22 -0400

On Mon, 22 Aug 2011 10:53:02 -0400
Brian Bruns <brian AT bruns.com> wrote:

> If I'm understanding you correctly, you want a structure with an enum
> and essentially an array of void * to all the elements and then to use
> it you need to cast the void * back depending on the value of the
> attached datatype?

Yes, it's an array of aliases to the members of the struct. And,
because void*, they'd have to be cast.

> struct {
> uint16 flags;
> uint16 unknown;
> uint32 rowcount;
> } tds_done_inproc;
>
> tds_member_t done_in_proc_reader[] = {
> {
> offsetof(tds_done_inproc, flags),
> tds_read_uint16
> },
> {
> offsetof(tds_done_inproc, unknown),
> tds_read_uint16
> },
> {
> offsetof(tds_done_inproc, rowcount),
> tds_read_uint32
> },
> };
>
> The nice part is this is easily generated from a table of grammars,
> and you get a nice usable structure on the other end (as opposed to a
> nameless array of elements if I'm understanding you correctly), no
> casting from void * necessary. Do the same in reverse for
> writing..things like XOR key password could be a function and you just
> pass the plain text and the function pointer handles the ugly bits.

Thank you. Yes, that's the kind of thing I hope to get from the
formal grammar. Not having ever actually used a parser-generator, I
had in mind a more brute-force method. I agree the above is more
attractive.

The key is to be able to iterate over the struct elements, for both
input and output.

Regards,

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page