preon

Java or C++ equivalents to Preon?

纵饮孤独 提交于 2020-01-12 07:32:39
问题 Preon is a Java library meant for creating binary codecs: you simply place annotations in a class' data members regarding their correspondence with bit fields (e.g. number of bits to use for certain field) and, based on such class, the library builds a Codec object that is able to create instances of the class reading their data from a binary input stream. Due to licensing issues (it is distributed under GPL), I cannot use it. Are there any libraries with equivalent or similar functionality,

Parsing variable record lengths in Preon

故事扮演 提交于 2019-12-24 18:56:24
问题 I'm trying to use Preon to parse binary files, which are structured as a sequence of variable length records. For each record, there's a number which specifies the record length (in bytes). Here's a simplified version of what I'm trying to do: package test.preon; import nl.flotsam.preon.annotation.BoundList; import nl.flotsam.preon.annotation.BoundNumber; import java.util.List; public class BinFile { @BoundNumber(size="16") int numberOfRecords; @BoundList(type=Record.class, size=

Preon decode and then encode doesn't return the same byte array

自古美人都是妖i 提交于 2019-12-08 22:50:32
I am using Preon to encode enum fields in a byte array. The fields of the first byte (example-byte: 0xf7=1111 01 11) are set up as this: @BoundNumber(size="2") //Corresponds to 11 private byte b1_1_notUsed; @BoundNumber(size="2") //Corresponds to 01 private ParkingBrakeSwitch parkingBrakeSwitch; @BoundNumber(size="4") private byte b1_3_notUsed; //Corresponds to 1111 Decoding works fine, thus I expect encoding the decoded object back to a byte array will yield the same byte array that I had from the beginning. This is not the case however. Instead the bits in the first byte are encoded like

Preon decode and then encode doesn't return the same byte array

懵懂的女人 提交于 2019-12-08 07:46:56
问题 I am using Preon to encode enum fields in a byte array. The fields of the first byte (example-byte: 0xf7=1111 01 11) are set up as this: @BoundNumber(size="2") //Corresponds to 11 private byte b1_1_notUsed; @BoundNumber(size="2") //Corresponds to 01 private ParkingBrakeSwitch parkingBrakeSwitch; @BoundNumber(size="4") private byte b1_3_notUsed; //Corresponds to 1111 Decoding works fine, thus I expect encoding the decoded object back to a byte array will yield the same byte array that I had