这是伞形仓库,各组件以 submodule 形式存在,修改组件需 fork 对应子仓库而非本仓库;使用生成的解析器还需额外引入对应语言的 KS 运行时库;README 未给出具体安装命令,需到 kaitai.io 查看下载说明
kaitai_struct
kaitai-io活跃维护用声明式语言描述二进制文件格式,自动生成 C++、Go、Java、Python 等多语言解析器,省去手写解析代码的麻烦。
Kaitai Struct: declarative language to generate binary data parsers in C++ / C# / Go / Java / JavaScript / Lua / Nim / Perl / PHP / Python / Ruby / Rust
README 里没有找到可直接复制的安装命令,请到 README 或官方文档查看安装方式。
README 未说明
用声明式语言描述二进制格式,一次编写即可生成多语言解析器
用声明式语言描述二进制文件格式,自动生成 C++、Go、Java、Python 等多语言解析器,省去手写解析代码的麻烦。
核心能力
- 用 .ksy 文件声明式描述二进制文件或网络包格式
- 通过 ksc 编译器生成 C++、Java、Python、Rust 等十余种语言源码
- 生成的解析器提供易读易用的 API 访问数据字段
- 配套 Web IDE 与 ksv 可视化工具调试格式解析
- 内置格式描述集合仓库可直接复用
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Kaitai Struct
[!NOTE] If you want to make changes to the project, do not fork this
kaitai_structrepository. Instead, choose the component you want to modify in the file tree above and fork that individual component instead.This is an umbrella repository, containing the components only as submodules to make it easier to check out the entire project. Unless you want to modify this README, it is not the repo where you can make edits.
What is Kaitai Struct?
Kaitai Struct (KS) is a declarative language used to describe various binary data structures, laid out in files or in memory: i.e. binary file formats, network stream packet formats, etc.
The main idea is that a particular format is described in Kaitai
Struct language (.ksy file) only once and then can be compiled with
kaitai-struct-compiler (or ksc for short) into source files in one
of the supported programming languages. These modules will include
generated code for a parser that can read the described data structure
from a file or stream and provide access to it in a nice,
easy-to-comprehend API.
What is it used for?
Have you ever found yourself writing repetitive, error-prone and hard-to-debug code that reads binary data structures from file / network stream and somehow represents them in memory for easier access?
Kaitai Struct tries to make this job easier — you only have to describe the binary format once and then everybody can use it from their programming languages — cross-language, cross-platform.
Kaitai Struct includes a growing collection of format descriptions, available in formats submodule repository.
Using KS in your project
Typically, using formats described in KS in your project involves the following steps:
- Describe the format — i.e. create a
.ksyfile - Use a visualizer to debug the format and ensure that it parses data properly (official visualizers are Web IDE and the console visualizer ksv)
- Compile the
.ksyfile into a target language source file and include that file in your project - Add the KS runtime library for your particular language to your project (don't worry, it's small and it's there mostly to ensure readability of generated code)
- Use the generated class(es) to parse your binary file or stream and access its components
To see an example, a list of supported languages, download instructions and licensing information, visit https://kaitai.io/.