A buffer descriptor provides a fixed length buffer to contain and access data. The data is part of the descriptor object.
A buffer descriptor object is an instance of a templated class, where the template parameter is an integer value that defines the size of the descriptor's data area.
A buffer descriptor comes in two forms:
a non-modifiable buffer descriptor.
a modifiable buffer descriptor.
The data contained in a non-modifiable buffer descriptor can be accessed, but not changed, through this descriptor. The data can, however, be completely replaced using the assignment operators.
Data is accessed through functions provided by the base class.
A non-modifiable buffer descriptor is supplied in two variants:
the 16 bit variant, a TBufC16<TInt>
, to contain Unicode strings.
the 8 bit variant, a TBufC8<TInt>
, to contain non-Unicode strings and binary data.
There is also a build independent type, TBufC<TInt>
. This is the type which is most commonly used in program code; the appropriate variant is selected at build time.
An explicit 8 bit variant is chosen for binary data. The explicit 16 bit variant is rarely used.
The base class, TDesC
, contains a data member which holds the length of the data. The following drawing shows the layout of a TBufC<5>
object initialised with the string of five characters representing the English word "Hello".
The data contained in a modifiable buffer descriptor can be both accessed and changed through this descriptor.
The template parameter, as well as determining the size of the data area created as part of the descriptor object, also defines the maximum length of the descriptor.
The length of the data can vary between zero and the maximum length. When the length of the data is less than the maximum, a portion of the data area within the descriptor is unused.
Data is accessed and modified through functions provided by the base classes.
A modifiable buffer descriptor is supplied in two variants:
the 16 bit variant, a TBuf16<TInt>
, to contain Unicode strings.
the 8 bit variant, a TBuf8<TInt>
, to contain non-Unicode strings and binary data.
There is also a build independent type, TBuf<TInt>
. This is the type which is most commonly used in program code; the appropriate variant is selected at build time.
An explicit 8 bit variant is chosen for binary data. The explicit 16 bit variant is rarely used.
The base class TDesC
, contains a data member that holds the length of the data. The base class TDes
, contains a data member that holds the maximum length of the data. The following drawing shows the layout of a TBuf<12>
object initialised with the string of five characters representing the English word "Hello".