Descriptors can be externalised in one of two ways:
using the WriteL() member functions of the RWriteStream class.
using the templated stream operator<<
The WriteL() member functions of RWriteStream write only the content of a descriptor to the stream; they do not write any length information.
The operator<< is implemented by the Store framework to write both the length of the descriptor content and the content itself to the stream.
Use of the operator<< is preferred because descriptors can then be internalised using either the corresponding operator>> or the variants of HBufC::NewL() or HBufC::NewLC() that take a read stream.
Descriptors can be internalised in one of three ways:
using the ReadL() member functions of the RReadStream class.
using the templated stream operator>>
using the variants of HBufC::NewL() or HBufC::NewLC() that take a read stream.
The ReadL() member functions of RReadStream assume that the stream contains only the content of a descriptor.
Note that the specific variant, ReadL(TDes& aDes), assumes that the length of data to be read from the stream is the same as the maximum length of the target descriptor.
The templated stream operator>> is implemented by the Store framework to read both the length of the descriptor content and the content itself and assumes that the descriptor was originally externalised using the templated operator<<.
The NewLC() and NewL() member functions of HBufC heap descriptors allocate the heap descriptor before internalising from the stream and also assume that the descriptor was originally externalised using the operator<<.