connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlhandler.h
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:20:56 +0100
branchRCL_3
changeset 20 4a793f564d72
parent 0 d0791faffa3f
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201032 Kit: 201035

/*
* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  ConML parser/generator
*
*/


#ifndef _SCONCONMLHANDLER_H
#define _SCONCONMLHANDLER_H

// -----------------------------------------------------------------------------
// Includes
// -----------------------------------------------------------------------------
#include "sconconmlgenerator.h"
#include "sconwbxmldefs.h"
#include "sconconmlhandlererror.h"
#include "sconconmldtd.h"

// -----------------------------------------------------------------------------
// Definitions and constants
// -----------------------------------------------------------------------------

_LIT8(KWBXMLNull, "\x00");

const TInt KSConBufferGranularity( 32 );
const TInt KSConDefaultDocumentSize( 2048 );

// -----------------------------------------------------------------------------
// TWBXMLStackItem
// -----------------------------------------------------------------------------
NONSHARABLE_STRUCT( TWBXMLStackItem )
    {
public:
    inline TWBXMLStackItem( TUint8 aTag );
    inline TUint8 Tag() const;

private:
    TUint8 iTag;
    };

#include "sconwbxmlparser.inl"

// -----------------------------------------------------------------------------
// CSConConMLHandler - WBXML parsing
// -----------------------------------------------------------------------------
class CSConConMLHandler : public CBase
    {
public:
    static CSConConMLHandler* NewL();
    ~CSConConMLHandler();
    
    /**
    * Starts the parsing of a WBXML document
    * @param aInput - the WBXML document to be parsed
    * @param aCallback - Call back function to call 
    * after the document is parsed
    * @return An error code
    */
    virtual TInt ParseDocumentL( CBufFlat& aInput,  
        MWBXMLConMLCallback* aCallback  );
    
    /**
    * Starts the generating of a WBXML and XML document
    * @param aContent - the data to be generated into the document
    * @return An error code
    */
    virtual TInt GenerateDocument( ConML_ConMLPtr_t aContent );
    
    /**
    * Returns the generated document in XML -format
    * @param none
    * @return The document as TPtrC8
    */
    virtual TPtrC8 XMLDocument();
    
    /**
    * Returns the generated document in WBXML -format
    * @param none
    * @return The document as TPtrC8
    */
    virtual TPtrC8 WBXMLDocument();
    
private:
    CSConConMLHandler();
    void ConstructL();
    
    TInt ParseL();
    TConMLParserError DoParseDocumentHeaderL();
    TConMLParserError DoParseDocumentBodyL();
    TUint8 ReadUint8L();
    TUint32 ReadMUint32L();
    TPtrC8 ReadStrIL();
    TPtrC8 StringTableString( TUint32 aIndex );
    void ReadStringTableL();    
    TPtrC8 ReadOpaqueL();
    void HandleElementL( TUint8 aId );
    
private:
    CSConConMLGenerator* iGenerator;
    HBufC8* iStringTable;
    CBufBase* iBuffer;
    TBool iHeaderParsed;
    RArray< TUint > iElemStack;
    TInt iPos;
    CBufFlat* iParseBuffer;
    MWBXMLConMLCallback* iCallback;
    };

    IMPORT_C CSConConMLHandler* CreateCSConConMLHandlerL();
    typedef CSConConMLHandler* (*TSConCreateCSConConMLHandlerFunc) (); 
    
#endif