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 of usage and flexible for adding on-top specifications.

Work in progress, the first version is not yet released.

Core Structure

Header 16 Bytes
...Keyed-Values...
SHA 256 32 Bytes

The data must start with a header, be followed by zero or multiple of Keyed-Values, and end with a SHA256 sum.

*The most significant byte is at the beginning of the byte array

Header

gbkf 4 Bytes
gbkf Version 1 Byte = uint 8
Specification ID 4 Bytes = uint 32
Specification Version 2 Bytes = uint 16
Keys Length 1 Byte = uint 8
Keyed-Values Nb 4 Bytes = uint 32
  1. gbkf:
    • Type: ASCII
    • Length: 4 bytes, 1 byte per letter.
  2. gbkf Version:
    • Type: Unsigned Integer
    • 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
  3. Specification ID:
    • Type: Unsigned Integer
    • Length: 4 bytes
    • Values:
      • Min: 0
      • Max: 4,294,967,295
      • Default: 0
      • 0: means Undefined
  4. Specification Version:
    • Type: Unsigned Integer
    • Length: 2 bytes
    • Values:
      • Min: 0
      • Max: 65,535
      • Default: 0
      • 0: means Undefined
  5. Keys Length:
    • Type: Unsigned Integer
    • Length: 1 byte
    • Values:
      • Min: 1
      • Max: 255
      • Default: 1
  6. Keyed-Values Nb:
    • Type: Unsigned Integer
    • Length: 4 bytes
    • Values:
      • Min: 1
      • Max: 4,294,967,295
      • Default: 0

Keyed-Values

Keyed-Value's Header

Key 1 to 255 Bytes
Instance ID 4 Bytes = uint 32
Values Nb 4 Bytes = uint 32
Values Type 1 Byte = uint 8
...Type Data...
  1. Key:
    • Type: ASCII
    • Length: <Keys Length>
  2. Instance ID:
    • Type: Unsigned Integer
    • Length: 4 Bytes
    • Values:
      • Min: 0
      • Max: 4,294,967,295
      • Default: 0
  3. Values Nb:
    • Type: Unsigned Integer
    • Length: 4 Bytes
    • Values:
      • Min: 0
      • Max: 4,294,967,295
      • Default: 0
  4. Values Type:

Keyed-Value's of type Undefined

In progress...

Keyed-Value's of type Integer

Integers Length 1 Byte = uint 8
...Values... 1 to 8 Bytes
  1. Integers Length:
    • Type: Unsigned Integer
    • Length: 1 byte
    • Values:
      • 1: for int 8
      • 2: for int 16
      • 4: for int 32
      • 8: for int 64
      • Default: 1
  2. Values:
    • Type: Unsigned Integer
    • Length: <Integers Length>
    • Values:
      • Min: 0
      • Max: 18,446,744,073,709,551,615

Keyed-Value's of Double

...Values... 8 Bytes

The double values are read and written using IEEE 754 double-precision

  1. Values:
    • Type: Double
    • Length: 4 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.