Descriptors

Descriptors are self-describing strings that can be used to store binary data and text. Each descriptor object holds the length of the string as well as its type which identifies the underlying memory layout of the data it holds. For more information on different descriptor classes, see Using Descriptors.

There are modifiable and non-modifiable descriptors, the latter type is identified by a "C" suffix in the class name. The length of a non-modifiable descriptor is defined when compiling an application, and the length of a modifiable descriptor can vary within the limits set by iMaxLength. Nonmodifiable descriptors are more secure, as their length is checked during compilation. The following figure shows the differences between these types.

Figure 1. Differences between modifiable, nonmodifiable, and pointer descriptors

When designing applications, avoid using fixed-length buffers as parameters and use base classes (preferably constant base type TDesC) instead. Descriptor objects provide a flexible interface for manipulating the contained string, including size and length checks. Take advantage of these when possible.

For more information and examples, see the Descriptors Overview topic.