]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src-isv/spec/Binary Format.mediawiki
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src-isv / spec / Binary Format.mediawiki
index d97fa149f1c9aed09a587cec51ef5b109d7a17f5..b9e50304b2f8c96c676652e03a70992baa9d7208 100644 (file)
-=Binary Format=\r
-''Binary serialization'' is used in files and network communication.\r
-This document gives a specification how Datatypes and Datavalues are written in binary format. \r
-\r
-All numeric values are in [http://en.wikipedia.org/wiki/Endianness Big Endian] order, aka Network byte order.\r
-\r
-===Boolean===\r
-Boolean is an <code>UINT8</code>, with one of the following values.\r
-\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Value'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>0</code>\r
-|false\r
-|-\r
-|<code>1</code>\r
-|true\r
-|- style="background-color: #f9f9f9;"\r
-|<code>2..255</code>\r
-|''Invalid value''\r
-|}\r
-\r
-===Numbers===\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Type'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|Byte\r
-|Int8\r
-|-\r
-|Integer\r
-|Int32\r
-|- style="background-color: #f9f9f9;"\r
-|Long\r
-|Int64\r
-|-\r
-|Float\r
-|Float\r
-|- style="background-color: #f9f9f9;"\r
-|Double\r
-|Double\r
-|}\r
-\r
-===Optional===\r
-There is a Boolean that describes whether there is an actual value.\r
-If false no data follows, true the content ensues.\r
-\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>hasValue : Boolean</code>\r
-|Tells whether there is a ''value''\r
-|-\r
-|''value''\r
-|The actual value, available only if hasValue == true.\r
-|}\r
-\r
-===String===\r
-String is a series of bytes encoded as [http://download.oracle.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8 Modified-UTF-8]. \r
-\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>length : Length</code>\r
-|Describes the number of bytes in the string using packed integer encoding (1-5 bytes).\r
-|-\r
-|''data''\r
-|Modified-UTF-8 encoded String.  \r
-|}\r
-\r
-The length is encoded as UInt32 of 1 to 5 bytes. \r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Value'''\r
-|'''Encoding'''\r
-|- style="background-color: #f9f9f9;"\r
-| <code>0x00000000..0x0000007F</code>\r
-| ''value'' (1 byte)\r
-|-\r
-| <code>0x00000080..0x00003FFF</code>\r
-| ''value & 0x3f | 0x80'', ''value>>6 & 0xff'' (2 bytes)\r
-|- style="background-color: #f9f9f9;"\r
-| <code>0x00004000..0x001FFFFF</code>\r
-| ''value & 0x1f | 0xC0'', ''value>>5 & 0xff'', ''value>>13 & 0xff'' (3 bytes)\r
-|-\r
-| <code>0x02000000..0x0FFFFFFF</code>\r
-| ''value & 0x1f | 0xE0'', ''value>>3 & 0xff'', ''value>>12 & 0xff'', ''value>>20 & 0xff'' (4 bytes)\r
-|- style="background-color: #f9f9f9;"\r
-| <code>0x10000000..0xFFFFFFFF</code>\r
-| ''value & 0x07 | 0xF0'', ''value>>3 & 0xff'', ''value>>11 & 0xff'', ''value>>19 & 0xff'', ''value>>27 & 0xff'' (5 bytes)\r
-|}\r
-\r
-\r
-\r
-===Array===\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>length : UInt32</code>\r
-|Describes the number of elements as unsigned integer. This field is omited if the range is constant.\r
-|-\r
-|''&lt;elements&gt;''\r
-|Array elements\r
-|}\r
-\r
-===Generic Record===\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|''&lt;fields&gt;''\r
-|Component fields in the order specified in datatype.\r
-|}\r
-\r
-===Referable Record===\r
-Referable records are objects that are referenced else where in the datavalue. The way they are serialized is that, when a record is serialized the first time, a 0 is written and then the actual record value. The serializer object gives it a next id number and takes a note of it. Id is not written, it is implicit and only interpretable by reading the stream. When a refereable record the second time, or afterwards, only it's id number is written, not the whole content.\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>recordId : Integer</code>\r
-|Identity that refers in this serialiation to this instance.\r
-|-\r
-|''&lt;fields&gt;''\r
-|Component fields in the order specified in datatype.\r
-|}\r
-\r
-===Generic Union===\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>tag : Byte, Short or Integer</code>\r
-|Number that indicates that type in the UnionType's ''components'' array. Type depends on the number of cases.\r
-|-\r
-|''value''\r
-|The value of the component type.\r
-|}\r
-\r
-===Variant===\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>type : DataType</code>\r
-|Describes the datatype of the following value.\r
-|-\r
-|''value''\r
-|The value serialized according to the type\r
-|}\r
-\r
-===Map===\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Field'''\r
-|'''Description'''\r
-|- style="background-color: #f9f9f9;"\r
-|<code>length : UInt32</code>\r
-|Describes the number of entries in the map using integer encoding.\r
-|-\r
-|''&lt;entries&gt;''\r
-|Map Entries\r
-|- style="background-color: #f9f9f9;"\r
-|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>key : K</code>\r
-|The key serializes according to the Key type\r
-|-\r
-|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>value : V</code>\r
-|The value serialized according to the Value type\r
-|}\r
-Entries are written in ascending of the key (See [[typesystem.html#Comparison]])\r
-\r
-\r
-=File types=\r
-{| border="1" cellpadding="3" cellspacing="0" align="center"\r
-|'''Extension'''\r
-|'''Description'''\r
-|- \r
-|<tt>.dbb</tt> ||Databoard Binary File. Concatenation of Datatype + value\r
-|}\r
+=Binary Format=
+''Binary serialization'' is used in files and network communication.
+This document gives a specification how Datatypes and Datavalues are written in binary format. 
+
+All numeric values are in [http://en.wikipedia.org/wiki/Endianness Big Endian] order, aka Network byte order.
+
+===Boolean===
+Boolean is an <code>UINT8</code>, with one of the following values.
+
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Value'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>0</code>
+|false
+|-
+|<code>1</code>
+|true
+|- style="background-color: #f9f9f9;"
+|<code>2..255</code>
+|''Invalid value''
+|}
+
+===Numbers===
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Type'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|Byte
+|Int8
+|-
+|Integer
+|Int32
+|- style="background-color: #f9f9f9;"
+|Long
+|Int64
+|-
+|Float
+|Float
+|- style="background-color: #f9f9f9;"
+|Double
+|Double
+|}
+
+===Optional===
+There is a Boolean that describes whether there is an actual value.
+If false no data follows, true the content ensues.
+
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>hasValue : Boolean</code>
+|Tells whether there is a ''value''
+|-
+|''value''
+|The actual value, available only if hasValue == true.
+|}
+
+===String===
+String is a series of bytes encoded as [http://download.oracle.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8 Modified-UTF-8]. 
+
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>length : Length</code>
+|Describes the number of bytes in the string using packed integer encoding (1-5 bytes).
+|-
+|''data''
+|Modified-UTF-8 encoded String.  
+|}
+
+The length is encoded as UInt32 of 1 to 5 bytes. 
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Value'''
+|'''Encoding'''
+|- style="background-color: #f9f9f9;"
+| <code>0x00000000..0x0000007F</code>
+| ''value'' (1 byte)
+|-
+| <code>0x00000080..0x00003FFF</code>
+| ''value & 0x3f | 0x80'', ''value>>6 & 0xff'' (2 bytes)
+|- style="background-color: #f9f9f9;"
+| <code>0x00004000..0x001FFFFF</code>
+| ''value & 0x1f | 0xC0'', ''value>>5 & 0xff'', ''value>>13 & 0xff'' (3 bytes)
+|-
+| <code>0x02000000..0x0FFFFFFF</code>
+| ''value & 0x1f | 0xE0'', ''value>>3 & 0xff'', ''value>>12 & 0xff'', ''value>>20 & 0xff'' (4 bytes)
+|- style="background-color: #f9f9f9;"
+| <code>0x10000000..0xFFFFFFFF</code>
+| ''value & 0x07 | 0xF0'', ''value>>3 & 0xff'', ''value>>11 & 0xff'', ''value>>19 & 0xff'', ''value>>27 & 0xff'' (5 bytes)
+|}
+
+
+
+===Array===
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>length : UInt32</code>
+|Describes the number of elements as unsigned integer. This field is omited if the range is constant.
+|-
+|''&lt;elements&gt;''
+|Array elements
+|}
+
+===Generic Record===
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|''&lt;fields&gt;''
+|Component fields in the order specified in datatype.
+|}
+
+===Referable Record===
+Referable records are objects that are referenced else where in the datavalue. The way they are serialized is that, when a record is serialized the first time, a 0 is written and then the actual record value. The serializer object gives it a next id number and takes a note of it. Id is not written, it is implicit and only interpretable by reading the stream. When a refereable record the second time, or afterwards, only it's id number is written, not the whole content.
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>recordId : Integer</code>
+|Identity that refers in this serialiation to this instance.
+|-
+|''&lt;fields&gt;''
+|Component fields in the order specified in datatype.
+|}
+
+===Generic Union===
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>tag : Byte, Short or Integer</code>
+|Number that indicates that type in the UnionType's ''components'' array. Type depends on the number of cases.
+|-
+|''value''
+|The value of the component type.
+|}
+
+===Variant===
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>type : DataType</code>
+|Describes the datatype of the following value.
+|-
+|''value''
+|The value serialized according to the type
+|}
+
+===Map===
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Field'''
+|'''Description'''
+|- style="background-color: #f9f9f9;"
+|<code>length : UInt32</code>
+|Describes the number of entries in the map using integer encoding.
+|-
+|''&lt;entries&gt;''
+|Map Entries
+|- style="background-color: #f9f9f9;"
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>key : K</code>
+|The key serializes according to the Key type
+|-
+|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>value : V</code>
+|The value serialized according to the Value type
+|}
+Entries are written in ascending of the key (See [[typesystem.html#Comparison]])
+
+
+=File types=
+{| border="1" cellpadding="3" cellspacing="0" align="center"
+|'''Extension'''
+|'''Description'''
+|- 
+|<tt>.dbb</tt> ||Databoard Binary File. Concatenation of Datatype + value
+|}