Introduction To CDR

Overview

 

CDR is a data-encapsulation format, mapping from data types defined in OMG IDL to a platform-neutral byte-level representation suitable for sending data over a network or storing it in a file.

CDR has the following features:

  • Variable byte ordering - Machines with a common byte order may exchange messages without byte swapping. When communicating machines have different byte order, the message originator determines the message byte order, and the receiver is responsible for swapping bytes to match its native ordering. 
  • Aligned primitive types - Primitive OMG IDL data types are aligned on their natural boundaries, permitting data to be handled efficiently by architectures that enforce data alignment in memory.
  • Complete OMG IDL Mapping - CDR describes representations for all OMG IDL data types.

 

Primitive Types

 

Primitive data types are specified for both big-endian and little-endian orderings. Primitive data types are encoded in multiples of octets. An octet is an 8-bit value.

 

Alignment

 

In order to allow primitive data to be moved into and out of octet streams with instructions specifically designed for those primitive data types, in CDR all primitive data types must be aligned on their natural boundaries (i.e., the alignment boundary of a primitive datum is equal to the size of the datum in octets). Any primitive of size n octets must start at an octet stream index that is a multiple of n. In CDR, n is one of 1,2, 4, or 8.

Where necessary, an alignment gap precedes the representation of a primitive datum. The value of octets in alignment gaps is undefined. A gap must be the minimum size necessary to align the following primitive. Table 15-1 gives alignment boundaries for CDR/OMG-IDL primitive types.

Alignment is defined above as being relative to the beginning of an octet stream. The first octet of the stream is octet index zero (0); any data type may be stored starting at this index.

 

Integer Data Types

CDR defines the encapsulation of integer values of 8. 16, 32, and 64 bits in length. Both in its signed and unsigned versions.

 

 

Floating Point data Types

 

CDR defines the encapsulation of floating point values of 32, 64, and 128 bits in length.

 

 

Octet

CDR defines the encaosulation of opaque octets

 

 

Boolean

CDR Encapsulates boolean types using one byte

 

 

Character Types

 

CDR Defines the encapsulation of character and wide character types

 

 

 

Constructed Types

 

Constructed types are built from OMG IDL’s data types using facilities defined by the OMG IDL language.

 

Alignment

 

 

Struct

 

 

Union

 

 

Array

 

 

Sequence

 

 

Enum

 

 

Strings and Wide Strings

 

 

Fixed Point Decimal Type

 

 

Value Types