Generic Binary Keyed Format (*.gbkf)
This format is a generic solution for reading and writing data in a binary mode. It is designed to reduce the data size between server and clients, and also to be simple to use and flexible for layering additional specifications.
Work in progress, the first version is not yet released.
Core Structure
The data must start with a header, be followed by zero or more Keyed-Values, and end with a SHA256 sum.
Main Header
-
gbkf:
- Type: ASCII character sequence
- Encoding: 1 byte per character using 7-bit ASCII (ISO 646)
- Length: 4 bytes, 1 byte per letter.
-
gbkf Version:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 1 byte
-
Values:
- Min: 0
- Max: 255
- Default: 0, and once the first gbkf format be finished, will be set to 1.
- 0: means Undefined
-
Specification ID:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 4 bytes
-
Values:
- Min: 0
- Max: 4,294,967,295
- Default: 0
- 0: means Undefined
-
Specification Version:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 2 bytes
-
Values:
- Min: 0
- Max: 65,535
- Default: 0
- 0: means Undefined
-
Keys Length:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 1 byte
-
Values:
- Min: 1
- Max: 255
- Default: 1
-
Number of Keyed-Values:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 4 bytes
-
Values:
- Min: 0
- Max: 4,294,967,295
- Default: 0
Keyed-Values
Each Keyed-Value starts with a common header, followed by type-specific data, and then, depending on each type, additional fields may be added before adding the list of values.
Header
-
Key:
- Type: ASCII character sequence
- Encoding: 1 byte per character using 7-bit ASCII (ISO 646)
- Length: <Keys Length> This value is defined in the Main Header.
-
Instance ID:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 4 Bytes
-
Values:
- Min: 0
- Max: 4,294,967,295
- Default: 0
-
Number of Values:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 4 Bytes
-
Values:
- Min: 0
- Max: 4,294,967,295
- Default: 0
- Values Type:
Type Undefined
In progress...
Type Integer
-
Integers Length:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: 1 byte
-
Values:
- 1: for uint8
- 2: for uint16
- 4: for uint32
- 8: for uint64
- Default: 1
-
Values:
- Type: Unsigned Integer
- Encoding: Big-endian
- Length: <Integers Length>
-
Values:
- Min: 0
- Max: 18,446,744,073,709,551,615
Type Single
The single values are read and written using IEEE 754 single-precision, and only finite normalized values are supported.
-
Values:
- Type: Single
- Encoding: Big-endian
- Length: 4 Bytes
-
Values:
- Min: -3.4028235e+38
- Max: 3.4028235e+38
Type Double
The double values are read and written using IEEE 754 double-precision, and only finite normalized values are supported.
-
Values:
- Type: double
- Encoding: Big-endian
- Length: 8 Bytes
-
Values:
- Min: -1.7976931348623157e+308
- Max: 1.7976931348623157e+308
SHA 256
In order to verify the file integrity, it must end with an SHA-256 (32 bytes) that hashes the header and the keyed-values.