Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/serenity4/binaryparsingtools.jl
A collection of tools to parse binary data
https://github.com/serenity4/binaryparsingtools.jl
Last synced: 6 days ago
JSON representation
A collection of tools to parse binary data
- Host: GitHub
- URL: https://github.com/serenity4/binaryparsingtools.jl
- Owner: serenity4
- License: mit
- Created: 2024-06-05T18:53:08.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-18T10:37:52.000Z (about 2 months ago)
- Last Synced: 2024-09-18T14:13:58.684Z (about 2 months ago)
- Language: Julia
- Homepage:
- Size: 278 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BinaryParsingTools
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://serenity4.github.io/BinaryParsingTools.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://serenity4.github.io/BinaryParsingTools.jl/dev/)
[![Build Status](https://github.com/serenity4/BinaryParsingTools.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/serenity4/BinaryParsingTools.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/serenity4/BinaryParsingTools.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/serenity4/BinaryParsingTools.jl)Provides a set of tools for working with binary data formats.
This library uses a `BinaryIO`, to be extended for any `Base.read` operations on
your types. Under the hood, this is an alias to `SwapStreams.SwapStream` which will
make sure you read in the correct endianness. To determine whether endianness should be changed, see `BinaryParsingTools.swap_endianness`.Then, read any binary data using `read_binary` which will create the create the appropriate `BinaryIO` and dispatch to `Base.read(::BinaryIO, ::Type{MyType})`.
```julia
using BinaryParsingToolsBinaryParsingTools.swap_endianness(io::IO, ::Type{MyType}) = false
function Base.read(::BinaryIO, ::Type{MyType})
# ...
endopen(io -> read_binary(io, MyType), "data.bin")
```A `@serializable` macro is furthermore provided to automate the parsing of structs, as so:
```julia
@serializable struct MyType
x::UInt32
name::String << String([read(io, UInt8) for _ in 1:32])
end
```which will automatically define `read(io::IO, ::Type{MyType})` (see the reference documentation for more details on how it works).