| The Casbah Project: APIs and Reference Manual: Developer's Release 1 | ||
|---|---|---|
| Prev | Self-Describing Binary Data Representation for LDO (LDO-Binary) | Next |
The binary encoding format is described by the following grammar:
stream := magic version item*
magic := #x89 'C' 'B' 'F'
version := VERSION Major Minor
item := define-id? attributes? ( atomic | list | dictionary | reference )
atomic := ( INTEGER-N | INTEGER-P ) Integer
| ( FLOAT-NN | FLOAT-NP | FLOAT-PN | FLOAT-PP ) Mantissa Exponent
| FLOAT-INF
| FLOAT-NAN
| OPAQUE Length String
| NULL
reference := REFERENCE Id
define-id := DEFINE-REFERENCE Id
attributes := ATTRIBUTES ( REFERENCE Id | define-id? dictionary )
list := LIST Length item*
dictionary := DICTIONARY Length (item, item)*The terminals Major, Minor, Length, Id, Integer, Mantissa, and Exponent are BER encoded integers.
String is an 8bit-clean value and can be used for any plain text or binary value.
The length of String is the number of octets contained in the string. The length of a list is the count of the number of items in the list. The length of a dictionary is the count of the number of key/value pairs in the dictionary.
Id values start at one (1) and increase sequentially.
The octets of a BER compressed integer represent an unsigned integer in base 128, most significant digit first, with as few digits as possible. Bit eight (the high bit) is set on each byte except the last.
The explicit field types are defined as follows:
VERSION := #x01 INTEGER-N := #x02 INTEGER-P := #x03 FLOAT-NN := #x04 FLOAT-NP := #x05 FLOAT-PN := #x06 FLOAT-PP := #x07 FLOAT-INF := #x08 FLOAT-NAN := #x09 OPAQUE := #x0A NULL := #x0B LIST := #x0C DICTIONARY := #x0D DEFINE-REFERENCE := #x0E REFERENCE := #x0F ATTRIBUTES := #x10