BeeSchema 0.9.0
See the version list below for details.
dotnet add package BeeSchema --version 0.9.0
NuGet\Install-Package BeeSchema -Version 0.9.0
<PackageReference Include="BeeSchema" Version="0.9.0" />
paket add BeeSchema --version 0.9.0
#r "nuget: BeeSchema, 0.9.0"
// Install BeeSchema as a Cake Addin #addin nuget:?package=BeeSchema&version=0.9.0 // Install BeeSchema as a Cake Tool #tool nuget:?package=BeeSchema&version=0.9.0
BeeSchema
Binary Schema Library
BeeSchema allows you to define the structure of a binary file using a simple schema (*.bee) file, then read the file in a much more human way. No more BinaryReader or manually reading data from Streams.
NOTE: BeeSchema is still in development, so things may change and other things might not be too optimised. Also, BeeSchema was designed as a replacement for the limited structure definition support in Ostara. As such, some features that you require may not be supported.
Schema Files
The structure of a binary file to be parsed by BeeSchema is defined in a simple text file (usually with the extension *.bee) that uses a custom language designed specifically for this purpose. These schemas can then be loaded by BeeSchema, and later used to parse binary files and turn them into more human-readable data. The basic structure of any schema file consists of optional custom data types and a schema block that represents the entry point of the schema file. This block is where BeeSchema will begin its parsing of binary files. For example, a schema file for a simple binary file that consists of a 32-bit integer followed by an 8-bit integer might look like this:
schema {
first_var : Int;
next_var : Byte;
}
Example Schema File
Here's an example schema file that demonstrates all of the current features of BeeSchema:
# We can include external files so that we can use types defined in them
include somefile.bee;
# This is a single-line comment
##
This is a
multi-line
comment.
##
struct SomeStruct {
a_bool : bool;
a_byte : byte;
an_sbyte : sbyte;
a_ushort : ushort;
a_short : short;
an_int : int;
a_uint : uint;
a_long : long;
a_ulong : ulong
a_float : float;
a_double : double;
a_string : string;
an_ip : ipaddress;
a_timestamp : epoch
}
# Enum and bitfield definitions require a base type
enum SomeEnum : byte {
SomeValue1,
SomeValue2,
AnotherValue = 10,
YetAnotherValue
}
bitfield SomeBitfield : byte {
first_bit : 1;
next_3_bits : 3;
last_4_bits : 4;
}
schema {
a_struct : SomeStruct; # Variables can be annotated by using a comment
an_enum : SomeEnum;
a_bitfield : SomeBitfield;
length : Int;
an_array : Char[length];
an_array2 : Int[4 * 2];
an_array3 : Byte[@size - @pos - 32];
int_1,
int_2,
int_3 : Int; # Multiple variables of the same type can be declared by separating them with a comma
until(@eof) {
some_var : Float;
another_var : Epoch;
}
}
Using BeeSchema
To use BeeSchema, create an instance of the Schema class using the static FromFile() or FromText() methods. You can then parse a binary file by passing the filename, a byte array, or a Stream object to the instance's Parse() method. Please see the Example project for a simple example on how to use BeeSchema and the resulting parsed data.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.5.2
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.