Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to implement a converter

Conversion from one data type to another is performed by a class derived from the abstract CConverterBase2 class. Conversions can be performed between files, specified by filenames, or between objects which support the stream interfaces, e.g. stream stores, memory streams and the clipboard.

The key CConverterBase2 functions to implement are:

The approach of an initial preparatory step followed by a sequence of further incremental steps allows the client thread to stay responsive while a potentially lengthy conversion process is taking place.

CConverterBase2 also defines two functions which do the complete conversion in one function call: ConvertL() and ConvertObjectL(). CConverterBase2 supplies default implementations of these functions which perform their tasks by calling ConvertAL()/ConvertObjectAL() once and DoConvertL() in a loop until complete.

A converter must also implement :

Example

This is an example declaration of a converter class:

class CExampleConverter : public CConverterBase2 
    {
public: static CConverterBase2* NewL();
    CExampleConverter();
    ~CExampleConverter();
    // from CConverterBase2
    void ConvertObjectAL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL);
    TBool DoConvertL();
    TUid Uid();
    TInt Capabilities();
    void CancelConvert();
private:
    RReadStream* iReadStream;
    RWriteStream* iWriteStream;
    };

Note

The MConverterUiObserver observer pointer can be NULL, so check for this before calling its functions.