Skip to content

sunveil/dataformats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TAIGA raw data formats specification

Kaitai Struct

Kaitai Struct is a declarative language used for describe various binary data structures, laid out in files or in memory: i.e. binary file formats, network stream packet formats, etc.

Supported languages

Official Kaitai Struct [compiler] now supports compiling .ksy into source modules for the following languages:

  • C++
  • C#
  • Java
  • JavaScript
  • Lua
  • Perl
  • Php
  • Python
  • Ruby
  • and additional DOT format

How to use

Example for Java

To use reader you need to include Hiscore.java to project. If you use maven include this in pom file:

    <dependencies>
        <dependency>
            <groupId>io.kaitai</groupId>
            <artifactId>kaitai-struct-runtime</artifactId>
            <version>0.8</version>
        </dependency>
    </dependencies>

Alternatively, you can just copy whole source code to one’s project: the library is intentionally kept as only 5 .java files, so it should be easy enough as well.

Parsing a structure directly from a local file:

    Hiscore hiscore = Hiscore.fromFile(anExampleHiscoreFile);

Parsing a structure from a byte array (byte[]):

    Hiscore hiscore = new Hiscore(new KaitaiStream(byteArray));

The hiscore file is array of packages. The file itself starts with two blocks: first comes header and then comes data_block.

    Hiscore hiscore = Hiscore.fromFile(anExampleHiscoreFile);

Parsing a structure from a byte array (byte[]):

    Hiscore hiscore = new Hiscore(new KaitaiStream(byteArray));

The hiscore file is array of packages. The file itself starts with two blocks: first comes header and then comes data_block.

	// get package
	Hiscore.Package package = hiscore.packages().get(0);
	// read package size in bytes
	System.out.println("Size: " + package.hdr().sz());
	// read event number
    System.out.println("Event number: " + package.hdr().eventNumber());

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published