bitfield Field
Last updated
Was this helpful?
Last updated
Was this helpful?
The <bitfield> is a container field, which allows wrapped member fields to be serialized using limited number of bits (instead of bytes). The supported fields, that can be members of the <bitfield>, are:
Since v2 of the specification it is also allowed to use field, which references one of the field types above.
The <bitfield> field has all the properties as well as extra properties and elements described below.
Member fields need to be listed as children XML elements of the <bitfield>. Every such member is expected to use bitLength property to specify its serialization length in bits. If it is not specified, then length in bits is calculated automatically as length in bytes multiplied by 8.
NOTE that summary of all the lengths in bits of all the members must be divisible by 8 and mustn't exceed 64 bits, otherwise the code generator must report an error.
The members of <bitfield> must be listed in order starting from the least significant bit. In the example above SomeIntMember occupies bits [0 - 2], SomeSetMember occupies bits [3 - 5], and SomeEnumMember occupies bits [6 -7].
If there is any other defined as XML child of the <bitfield>, then all the members must be wrapped in <members> XML element for separation.
When serializing, the <bitfield> object needs to combine the values of all the members into single unsigned raw value of appropriate length, and write the received value using appropriate endian. By default endian of the is used, unless it is overridden using extra endian property of the <bitfield> field.
Use for future references.