Current stable version: 1.0.1 (README)
Current test version: 1.1 beta 1 (README)
What is it?
A library for packing and unpacking binary data, not unlike lhf's lpack
or Roberto's struct library. It sacrifices performance for flexibility
and portability.
What's changed since 1.0?
- parser was completely rewritten. This is unlikely to make much difference
to most users.
- bitpack support (eg, multiple 4-bit ints packed into one larger one) added
- read and write buffering are now performed where possible, drastically
improving performance when operating on files
- source for generated pack/unpack functions is now available to the caller
- an actual interface for adding new pack/unpack formats
Why use it?
- read and write support for signed and unsigned integers, fixed point
rationals, fixed-length, null-terminated, null-padded & counted strings,
skipping and padding, booleans, floats, bitmasks, and bitfields
- unpack/pack from/to strings, files, or anything that supports
file-like :read/:write/:seek operations
- any type can be any byte-aligned width - 24-bit integers? booleans
stored as uint32_ts? 128-bit masks? No problem.
- supports naming, grouping and repetition of fields (and groups, nested
arbitrarily deep). You can specify the structure of the data in the
format string and get back a table with conveniently named fields (and
possibly subtables); and then you can unpack an array of 10,000 of them
just by putting "10000 *" on the front - and pass the same table to pack()
to write it back to disk.
- written entirely in Lua, and thus very portable and easy to extend.
Why NOT use it?
- written entirely in Lua, and thus slower and more memory-hungry than C
equivalents