syncmlfw/common/wbxml/inc/WBXMLGenerator.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Generic WBXML generator.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __WBXMLGENERATOR_H__
       
    20 #define __WBXMLGENERATOR_H__
       
    21 
       
    22 // ------------------------------------------------------------------------------------------------
       
    23 // Includes
       
    24 // ------------------------------------------------------------------------------------------------
       
    25 #include <e32base.h>
       
    26 
       
    27 #include "WBXMLAttributes.h"
       
    28 
       
    29 // ------------------------------------------------------------------------------------------------
       
    30 // Class forwards
       
    31 // ------------------------------------------------------------------------------------------------
       
    32 
       
    33 class CXMLWorkspace;
       
    34 
       
    35 // ------------------------------------------------------------------------------------------------
       
    36 // TWBXMLContentFormat
       
    37 // ------------------------------------------------------------------------------------------------
       
    38 enum TWBXMLContentFormat
       
    39 	{
       
    40 	EWBXMLContentFormatOpaque,
       
    41 	EWBXMLContentFormatInlineString
       
    42 	};
       
    43 
       
    44 // ------------------------------------------------------------------------------------------------
       
    45 // CWBXMLGenerator
       
    46 // ------------------------------------------------------------------------------------------------
       
    47 class CWBXMLGenerator : public CBase
       
    48 	{
       
    49 public:
       
    50 	IMPORT_C TPtrC8 Document();
       
    51 	IMPORT_C void Reset();
       
    52 
       
    53 protected:
       
    54 	IMPORT_C CWBXMLGenerator();
       
    55 	IMPORT_C virtual ~CWBXMLGenerator();
       
    56 
       
    57 	IMPORT_C void CreateStaticWorkspaceL( TInt aBufferSize );
       
    58 	IMPORT_C void CreateDynamicWorkspaceL();
       
    59 
       
    60 	IMPORT_C CXMLWorkspace* Workspace() const;
       
    61 	IMPORT_C void SetWorkspace( CXMLWorkspace* aBuffer, TBool aTakeOwnership = EFalse );
       
    62 
       
    63 	// WBXML
       
    64 	IMPORT_C void BeginDocumentL( TUint8 aVersion, TInt32 aPublicId, TUint32 aCharset, const TDesC8& aStringTbl = TPtrC8() ); // Negative PublicId = offset to string table
       
    65 
       
    66 	IMPORT_C void BeginElementL( TUint8 aElement, TBool aHasContent = EFalse, TBool aHasAttributes = EFalse );
       
    67 	IMPORT_C void EndElementL();
       
    68 
       
    69 	IMPORT_C void AddElementL( TUint8 aElement, const TDesC8& aContent, const TWBXMLContentFormat aFormat = EWBXMLContentFormatOpaque );
       
    70 	IMPORT_C void AddElementL( TUint8 aElement, const TDesC8& aContent, const CWBXMLAttributes& aAttributes, const TWBXMLContentFormat aFormat = EWBXMLContentFormatOpaque );
       
    71 
       
    72 	IMPORT_C void AddEntityL( TUint32 aEntity );
       
    73 
       
    74 	IMPORT_C void AddExt_IL( TInt aExtNum, const TDesC8& aContent );
       
    75 	IMPORT_C void AddExt_TL( TInt aExtNum, TUint32 aContent );
       
    76 	IMPORT_C void AddExtL( TInt aExtNum );
       
    77 
       
    78 	IMPORT_C void SwitchCodePageL( TUint8 aNewCodePage );
       
    79 
       
    80 	IMPORT_C TInt HandleResult( TInt aResult, TInt aTreshold = 0 );
       
    81 
       
    82 private:
       
    83 	void WriteMUint32L( TUint32 aValue );
       
    84 	void WriteOpaqueDataL( const TDesC8& aData );
       
    85 	void WriteInlineStringL( const TDesC8& aData );
       
    86 	void FreeWorkspace();
       
    87 
       
    88 private:
       
    89 	CXMLWorkspace* iWorkspace;
       
    90 	TBool iOwnsWorkspace;
       
    91 	};
       
    92 
       
    93 #endif // __WBXMLGENERATOR_H__