Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 21:21, Ellery Newcomer wrote: struct Rec2{ ushort index; ushort nparams; ushort options; NoLength!(Parameter[], "nparams") params; } ... foreach(i,m; rec2.tupleof){ static if(isNoLength!(typeof(m))){ auto len = lenField!(rec2, typeof(m)); ... }else{ ... } } The other thing is, once I

Re: structs, templates, alias

2010-04-25 Thread Ellery Newcomer
On 04/25/2010 02:50 PM, Robert Clipsham wrote: On 25/04/10 20:32, Ellery Newcomer wrote: Hmm. Either I'm not understanding you or I didn't explain something clearly. something like this struct Rec2{ ushort index; ushort nparams; ushort options; ushort[] params; // this has nparams elements }

Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 20:32, Ellery Newcomer wrote: Hmm. Either I'm not understanding you or I didn't explain something clearly. something like this struct Rec2{ ushort index; ushort nparams; ushort options; ushort[] params; // this has nparams elements } Rec2 rec2 = {index:1, nparams:2, options:~0, par

Re: structs, templates, alias

2010-04-25 Thread Ellery Newcomer
On 04/25/2010 02:10 PM, Robert Clipsham wrote: On 25/04/10 19:15, Ellery Newcomer wrote: Yeah, that's about what I do. The trouble is getting blit to know which field is the length field. I suppose you could pass an index into the tuple to the substructure. That still wouldn't fix the substructu

Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 19:15, Ellery Newcomer wrote: Yeah, that's about what I do. The trouble is getting blit to know which field is the length field. I suppose you could pass an index into the tuple to the substructure. That still wouldn't fix the substructure being able to modify the field length. I do

Re: structs, templates, alias

2010-04-25 Thread Ellery Newcomer
On 04/25/2010 12:26 PM, Robert Clipsham wrote: On 25/04/10 16:04, Ellery Newcomer wrote: Does anyone have any ideas regarding this problem? I haven't looked into this fully, but for the "the length field and the array/structure are separated by one or more fields" issue, something like this sh

Re: structs, templates, alias

2010-04-25 Thread Robert Clipsham
On 25/04/10 16:04, Ellery Newcomer wrote: Does anyone have any ideas regarding this problem? I haven't looked into this fully, but for the "the length field and the array/structure are separated by one or more fields" issue, something like this should help: foreach( m; MyStruct.tupleof

structs, templates, alias

2010-04-25 Thread Ellery Newcomer
Hello. I have a bunch of disparate binary record types that I need to be able to read and write to/from a binary stream. Currently, the way I do this is just by drumming out a struct declaration and relying on the tupleof property to specify how to read/write. Ex: struct Rec0{ ushort inde