2.1.4 Record
A record is the basic building block used to store information about features in a workbook. Each binary record is a variable-length sequence of bytes. A binary record consists of three components: a record type, a record size, and the record data that is specific to that record type.
The record type is an integer that specifies what type of information is specified by the record and how the structure of the record data specific to this record is ordered and structured. Each valid record type is listed in Record Enumeration (section 2.3). The record type MUST be either one or two bytes. The record type MUST be two bytes if and only if the high bit in the low byte is equal to 1; otherwise, the record type MUST be one byte. If the record type is two bytes, the value consists of seven low bits of the high byte combined with the seven low bits of the low byte. This value MUST be greater than or equal to 128 and less than 16384. For performance reasons, one-byte record types are reserved for commonly used records. Record type values MUST be a value from Record Enumeration (section 2.3) or the record MUST make use of the future record (section 2.1.6) architecture.
The record size specifies the count of bytes that specifies the total size of the record data. This value MUST be one to four bytes. This value MUST be one byte if the high bit in the low byte is equal to 0; otherwise, this value MUST be greater than one byte. If the count of bytes is greater than one byte, the high bit in each successive byte specifies whether an additional byte is used. If the high bit of the second byte is equal to 1, then this value MUST use an additional third byte. If the high bit of the third byte is equal to 1, then this value MUST use an additional fourth byte. The high bit of the fourth byte MUST be ignored. The value consists of the seven low bits of each byte combined. The low, least significant bits are contained within the first byte, and each successive byte contains higher order bits than the previous byte.
The record data component contains fields that correspond to a particular record type and comprise the remainder of the record. The order and structure of the fields for a given record type listed in Record Enumeration (section 2.3) are specified in the corresponding section for that record type in Records (section 2.4). The total size of the record data component MUST be equal to the record size. Fields in the record data component can contain simple values, arrays of values, structures of several fields, arrays of fields, and arrays of structures.
For example, the following record type and record size specify a BrtCommentText (section 2.4.338) record with a size of 200 bytes:
-
11111101 00000100 11001000 00000001 [Record Fields]
The first byte is 11111101, specifying a low value of 125 and that the record type requires a second byte. The second byte is 00000100, specifying a high value of 4 * 128, which equals 512. The record type value is 125 + 512, or 637, which corresponds to a BrtCommentText (section 2.4.338) record type. The next byte is 11001000, specifying a low value of 72 and that the record size requires a second byte. The second byte is 00000001, specifying a higher value of 1 * 128 and that the record size does not require an additional byte. The record size is 72 + 128, or 200, which specifies the total size, in bytes, of the record data component. The fields in the record data component are specified by BrtCommentText (section 2.4.338).