Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Using TDesC


Usage in a function interface

Interfaces which take narrow or wide (Unicode) text, depending on the build variant, use descriptors in their specification.

An interface which needs access to either narrow text or wide (Unicode) text, depending on the build variant, but which does not need to change that data in any way, can use a TDesC as the argument type. All build independent concrete descriptors are derived from TDesC which means that the interface can accept any build independent descriptor.

The following code fragment shows the most common function prototype pattern.

void ClassX::foo(const TDesC& anArg);

The use of TDesC ensures that the data cannot be modified through the descriptor; const is an extra guarantee that the data cannot be changed.

If the interface is to handle explicit 8 bit or explicit 16 bit data, regardless of the build variant, then use TDesC8 or TDesC16 instead.

See also