-
Notifications
You must be signed in to change notification settings - Fork 2
Getting Started
Spiff needs for you to have three things - a binary file to parse, a description of the file format, and some classes that will ultimately represent the contents of the file.
File formats are described in an .adf file (adf = Arbitrary Data Format). The formal grammar of the file is described in AdfGrammar. The .adf extension is a convention rather than a necessity.
The most basic things you can do are to specify a list of datatypes, in the order in which they occur in the file, followed by a name to give to that field. The primitive datatypes map directly to Java primitives:
byte (1 byte) short (2 bytes) int (4 bytes) long (8 bytes) double (4 bytes) float (8 bytes)
There are also unsigned equivalents for integers:
ubyte ushort uint ulong
For instance, the file header of a bitmap file looks like this:
short bfType int bfSize short bfReserved1 short bfReserved2 int bfOffBits