Kaitai project is happy to announce release of new major version of Kaitai Struct, declarative markup language to describe various binary data structures — binary file formats, network stream packets, etc.
The basic idea of Kaitai Struct is that a
particular format can be described using
Kaitai Struct language (in a .ksy
file), which then can be compiled
using ksc
into source files in
one of the supported programming
languages. These modules will include a
generated code for a parser that can read
described data structure from a file / stream
and provide access to its contents in a nice,
easy-to-comprehend API.
Note that this release is dedicated to FOSDEM 2017 conference. If you happen to be there, don't miss a talk on Kaitai Struct on Sunday, February, 5th in room K.3.401 (Open Media devroom). Even if you aren't at FOSDEM in person, you can still view the real-time video broadcast.
type: b12
to parse 12 bits as integer from a stream (obviously, one can use b1
, b2
, b3
, etc)b1
is parsed as a boolean valuebXX
are chained in a sequence, can be used to parse bit masks/fieldsu1
, s4
, str
, etc) starts parsing normally, aligning to next bytedoc
for docstrings is allowed on type levelmeta
can now include:
title
(to give proper full title for type)license
(to specify work licensing)ks-version
(to specify minimal version of Kaitai Struct compiler that must be used to process a .ksy - i.e. 0.6
)ks-debug
(to enforce generation of classes as if --debug
mode was specified in command line)meta
is non-global now, but can be used on multiple levels and inherited from closest one-key
syntax: for example, Web IDE uses -webide-representation
key which is ignored by the compiler, but useful for clearer debuggingenum: XXX
specifications are not just strings, but proper references to declared enums, thus they're checked for validity, can reference upper level nested enums from lower levels, etc - this fixes majority of existing enum namespacing problems in JavaScript, Python, PHP and Perlid
in seq
elements in now optional: it can be useful for quick exploration mapping (one can always assign identifiers later), or for unused ("reserved for later use") attributes - such attributes would be assigned numbered IDs automaticallyif
and enum
123_456_789
or 0b0101_0011
nowto_s
method for integer types to convert them to stringsif
condition) and "not yet calculated" results - introduced _is_null_XXX()
method for check for true null result in generated APIensure_fixed_contents
no longer requires both expected byte array and its length, only array is requiredIOException
type
, array types, and type combining on switching / ternary operators