Generic FileFormat Data Types: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
 
Line 14: Line 14:
|-
|-
|align="left"|byte||align="left"| 8 bit (1 byte)
|align="left"|byte||align="left"| 8 bit (1 byte)
|-
|align="middle"|tbool||align="left"| byte (0 = false).
|-
|-
|align="middle"|short||align="left"| 16 bit signed short (2 bytes)
|align="middle"|short||align="left"| 16 bit signed short (2 bytes)
|-
|-
|align="middle"|ushort||align="left"| 16 bit '''unsigned''' short (2 bytes)
|align="middle"|ushort||align="left"| 16 bit '''unsigned''' short (2 bytes)
|-
|align="middle"|long||align="left"| 32 bit signed integer (4 bytes)
|-
|-
|align="middle"|ulong||align="left"| 32 bit '''unsigned''' integer (4 bytes)
|align="middle"|ulong||align="left"| 32 bit '''unsigned''' integer (4 bytes)
Line 31: Line 35:
|-
|-
|}
|}
====XYZTriplet====
XYZTriplet
{
  float    x,y,z;
}


 
:Note that 'int' is not used in this documentation for the following reasons:
Note that the use of the word 'int' is bad policy. An int is machine and compiler and language dependent. BI use floats to represent signed values unsigned integers for indexes and string counts.
:*an 'int' is machine and compiler and language dependent. It is an arbitrary size SIGNED value.
:*with exceptions, BI use floats when requiring negative values.
:*almost all references to 'integers' in BI file formats are either positive-only offsets into memory, zero based indexes, and counts.
:the incidence of true shorts and true integers in BI is quite rare. Exception -1 is a favourite, to indicate default

Revision as of 06:29, 3 August 2009

Intro

This is a generic list of data types encountered in all file formats. Not all of which will be used in a specific file format.

They are listed here, rather than repetitive typing in each of file format's documentation.

Endian

Little endian byte order, lsb first for numeric values, text is stored in Big endian byte order.

Data Types

Type Description
byte 8 bit (1 byte)
tbool byte (0 = false).
short 16 bit signed short (2 bytes)
ushort 16 bit unsigned short (2 bytes)
long 32 bit signed integer (4 bytes)
ulong 32 bit unsigned integer (4 bytes)
float 32 bit signed single precision floating point value (4 bytes)
double 64 bit signed single precision floating point value (8 bytes)
asciiz Null terminated (0x00) variable length ascii string
ascii fixed length ascii string(UTF-8)

XYZTriplet

XYZTriplet
{
 float    x,y,z;
}
Note that 'int' is not used in this documentation for the following reasons:
  • an 'int' is machine and compiler and language dependent. It is an arbitrary size SIGNED value.
  • with exceptions, BI use floats when requiring negative values.
  • almost all references to 'integers' in BI file formats are either positive-only offsets into memory, zero based indexes, and counts.
the incidence of true shorts and true integers in BI is quite rare. Exception -1 is a favourite, to indicate default