CBOT Operation Codes

Overview

Operation codes are single-character instructions that control the deserialization process. They are categorized as follows:

Native Codes

Native codes define primitive data types that can be directly represented in the protocol.

Boolean Codes

Boolean codes represent true/false values used with the boolean native code.

Summary of supported codes

Operation Codes

Code Name Category Description
0 PVER Control Protocol version
1 MCSM Control Model checksum
2 MCSU Control Model upgrade checksum
3 - Reserved Reserved for future use
4 - Reserved Reserved for future use
5 - Reserved Reserved for future use
6 - Reserved Reserved for future use
7 - Reserved Reserved for future use
8 - Reserved Reserved for future use
9 - Reserved Reserved for future use
A DEFN Property Define key-ID mapping
B ASGV Property Assign value to property
C ARRB Structural Array begin
D ARRE Structural Array end
E OBJB Structural Object begin
F OBJE Structural Object end
G PNTR Value Pointer type (not used)
H NULL Value Null value
I NATV Value Native value
J STRN String String value
K SSTR String Simple string
L STBG String String builder begin
M STEN String String end
N STPA String String part without newline
O STNL String String part ending with newline
P ENCM Value Encoded model
Q SRZP Value Serialized property (not used)
R MAPB Structural Map begin
S MAPE Structural Map end
T MAPK Structural Map entry key
U MAPV Structural Map entry value
V SETB Structural Set begin
W SETE Structural Set end
X BARB Binary Byte array begin
Y BARE Binary Byte array end
Z BARP Binary Byte array part
[ UPGR Control Upgraded property indicator

Native Codes

Code Name Category Description
a INT32 Number 32-bit signed integer
b INT64 Number 64-bit signed integer
c FLOAT32 Number 32-bit float
d FLOAT64 Number 64-bit float
e BOOLEAN Boolean Boolean value
f BIG_INTEGER Number Big integer
g BIG_DECIMAL Number Big decimal
h ZONED_DATETIME Date/Time ISO 8601 zoned datetime
i LOCAL_DATETIME Date/Time ISO 8601 local datetime
j LOCAL_DATE Date/Time ISO 8601 Local date
k LOCAL_TIME Date/Time ISO 8601 Local Time
l UTC_DATETIME Date/Time ISO 8601 utc datetime

Boolean Codes

Code Name Description
t TRUE True value
f FALSE False value

Operation Code Specifications

Operation Codes

PVER - Protocol Version

Specifies the CBOT protocol version being used. This code is used to verify that protocol is understood by both parties in the same manner. Currently not used since Model Checksum already contains embedded version information.

Format: 0<version>

Parameters: - <version>: Protocol version string (e.g., "0.903")

MCSM - Model Checksum

Provides a checksum for the base model configuration. It:

Format: 1<checksum>

Description:

Parameters: - <checksum>: 8-character hexadecimal checksum

MCSU - Model Upgrade Checksum

Provides a checksum for a specific model upgrade. It:

Format: 2<id><checksum>

Parameters: - <id>: Upgrade id - <checksum>: 8-character hexadecimal checksum

DEFN - Definition

Creates a mapping between a string (key) and an ID. In essence, a key can be any simple string that might be repeated multiple times. It is mainly used to define property names that are encountered for the first time during serialization, but it is also used to map other strings when needed.

Format: A<id><key>

Parameters: - <id>: 4-character ID - <key>: Property name string

ASGV - Assign Value

Assigns a value to a property identified by ID.

Format: B<id><value>

Parameters: - <id>: 4-character ID referencing a key - <value>: Value encoding (varies by type)

ARRB - Array Begin

Marks the beginning of an array.

Format: C

ARRE - Array End

Marks the end of an array.

Format: D

OBJB - Object Begin

Marks the beginning of an object. Operation has an optional id that is used by model to decide what kind of type should be used. If id is not given, then implementation must choose a type that suits best for the situation. For instance in JavaScript this means a plain object.

Format: E | E<id>

Parameters: - <id>: Optional 4-character object type ID

OBJE - Object End

Marks the end of an object.

Format: F

PNTR - Pointer

Reserved for the use of pointers in the future

Format: G

NULL - Null Value

Represents a null value.

Format: H

NATV - Native Value

Format: I<type><value>

Description: Indicates a native type value.

Parameters: - <type>: Native type code - <value>: Type-specific value representation

STRN - String

Begins a string value. The protocol supports two kinds of strings: simple strings, and complex strings containing newlines.

Format: J<type><value>

Description:

Parameters: - <type>: String type code - <value>: String content or parts

SSTR - Simple String

Represents a simple string which does not contain any newlines and is sufficiently short.

Format: K<text>

Parameters: - <text>: String content

STBG - String Builder Begin

Begins a string builder for long strings, which may contain newlines.

Format: L

STEN - String End

Finalizes a string builder.

Format: M

STPA - String Part

Defines a fragment of a string which does not contain any newlines.

Format: N<text>

Parameters: - <text>: String fragment

STNL - String Newline

Defines a fragment of a string which ends with a newline. The newline itself is not included in the fragment.

Format: O<text>

Parameters: - <text>: String fragment (newline implied)

ENCM - Encoded Model

Represents an encoded model value with a specific ID.

Format: P<id><value>

Parameters: - <id>: 4-character ID - <value>: Encoded model value

SRZP - Serialized Property

Represents a custom serialized property value. Reserved for future use.

Format: Q<value>

Parameters: - <value>: Serialized property value

MAPB - Map Begin

Marks the beginning of a map structure.

Format: R

MAPE - Map End

Marks the end of a map structure.

Format: S

MAPK - Map Entry Key

Defines the key part of a map entry.

Format: T<value>

Parameters: - <value>: Key value

MAPV - Map Entry Value

Defines the value part of a map entry.

Format: U<value>

Parameters: - <value>: Value content

SETB - Set Begin

Marks the beginning of a set structure.

Format: V

SETE - Set End

Marks the end of a set structure.

Format: W

BARB - Byte Array Begin

Marks the beginning of a byte array.

Format: X<size>

Parameters: - <size>: Size of the byte array as native 64-bit integer

BARE - Byte Array End

Marks the end of a byte array.

Format: Y

BARP - Byte Array Part

Defines a part of a byte array.

Format: Z<value>

Parameters: - <value>: Byte array part in base64 format

UPGR - Upgrade

Indicates an upgraded property.

Format: [<id>

Parameters: - <id>: Upgrade ID

4. Native Code Specifications

INT32 - 32-bit Signed Integer

Represents a 32-bit signed integer value.

Format: a<value>

Parameters: - <value>: 32-bit signed integer value

Range: -2,147,483,648 to 2,147,483,647

INT64 - 64-bit Signed Integer

Represents a 64-bit signed integer value.

Format: b<value>

Parameters: - <value>: 64-bit signed integer value

Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

FLOAT32 - 32-bit Float

Represents a 32-bit floating-point number.

Format: c<value>

Parameters: - <value>: 32-bit floating-point value

Precision: Approximately 7 decimal digits

FLOAT64 - 64-bit Float

Represents a 64-bit floating-point number.

Format: d<value>

Parameters: - <value>: 64-bit floating-point value

Precision: Approximately 15-17 decimal digits

BOOLEAN - Boolean Value

Represents a boolean value using boolean codes.

Format: e<boolean_code>

Parameters: - <boolean_code>: Boolean code ('t' for true, 'f' for false)

Boolean Codes: - t: True value - f: False value

BIG_INTEGER - Big Integer

Represents an arbitrary-precision integer.

Format: f<value>

Parameters: - <value>: String representation of big integer

Pattern: ^[+-]?\d+$

BIG_DECIMAL - Big Decimal

Represents an arbitrary-precision decimal number.

Format: g<value>

Parameters: - <value>: String representation of big decimal

Pattern: ^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$

ZONED_DATETIME - ISO 8601 Zoned Datetime

Represents a zoned datetime in ISO 8601 format.

Format: h<value>

Parameters: - <value>: ISO 8601 zoned datetime string

Pattern: YYYY-MM-DDTHH:MM:SS.sss[zoneid]

LOCAL_DATETIME - ISO 8601 Local Datetime

Represents a local datetime in ISO 8601 format.

Format: i<value>

Parameters: - <value>: ISO 8601 local datetime string

Pattern: YYYY-MM-DDTHH:MM:SS.sss

LOCAL_DATE - ISO 8601 Local Date

Represents a local date in ISO 8601 format.

Format: j<value>

Parameters: - <value>: ISO 8601 local date string

Pattern: YYYY-MM-DD

LOCAL_TIME - ISO 8601 Local Time

Represents a local time in ISO 8601 format.

Format: k<value>

Parameters: - <value>: ISO 8601 local time string

Pattern: HH:MM:SS.sss

UTC_DATETIME - UTC 8601 Date Time

Represents a utc datetime in ISO 8601 format.

Format: l<value>

Parameters: - <value>: ISO 8601 datetime string

Pattern: YYYY-MM-DDTHH:MM:SS.sssZ