Re: New to D: parse a binary file

2011-02-06 Thread scottrick
Thanks, your post was very helpful.  Two more questions (probably
related):

Where is the function 'format' defined?  Also, what is that 'unittest'
block?  It compiles fine as is, but if I refer to format outside of
unittest, it will not compile.  Also, if I compile and run your
example, it doesn't do anything, since main() is empty?

Thanks again,


New to D: parse a binary file

2011-02-05 Thread scottrick
Hi,

I am new to D.  I am trying to write a binary file parser for a
project of mine and I thought it would be fun to try and learn a new
language at the same time.  So I chose D!  :D  I have been
struggling however and have not been able to find very many good
examples, so I am posting this message.

I think I'm supposed to be using std.stdio, but I'm not 100% sure.
Could somebody post a short example of how to parse a couple of
characters and ints or whatever from a file?  Or how to read, say,
the next however many bytes into a struct?

Also, looking at the documentation, I am confused by this method
signature:

T[] rawRead(T)(T[] buffer);

I understand that T is generic type, but I am not sure of the
meaning of the (T) after the method name.

Thanks,