IMPSengine/messageencoder/wbxml/inc/impsxmlutils.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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: 
       
    15 *       Provides the methods for pureData handling.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef CImpsXmlUtils_H
       
    22 #define CImpsXmlUtils_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include "ImpsDataAccessorApi.h"
       
    26 
       
    27 // CLASS DECLARATION
       
    28 class CImpsXmlUtils :public CBase
       
    29     {
       
    30     public:  
       
    31         
       
    32         /**
       
    33         * Method encodes TransactionContent to the
       
    34         * XML format and stores to the data structure 
       
    35         * @param aImpsData data structure containing the data
       
    36         */
       
    37         void TransactionContentToXmlL( MImpsDataAccessor& aImpsData );
       
    38          /**
       
    39         * Method decodes TransactionContent from the
       
    40         * XML format and stores data to the data structure 
       
    41         * @param aImpsData data structure containing the data
       
    42         * @return primitive or KErrNotFound
       
    43         */
       
    44         TInt XmlToTransactionContentL( MImpsDataAccessor& aImpsData );
       
    45 
       
    46         /**
       
    47         * Method writes xml element start tag to the buffer
       
    48         * @param aTag name of the tag.
       
    49         */
       
    50         void StartElementL( const TDesC8& aTag, const TDesC8& aAttribute );
       
    51 
       
    52         /**
       
    53         * Method writes xml element end tag to the buffer
       
    54         * @param aTag name of the tag.
       
    55         */
       
    56         void EndElementL( const TDesC8& aTag );
       
    57         
       
    58         /**
       
    59         * Method writes data to the encode buffer
       
    60         * @param aData pointer to the data 
       
    61         */
       
    62         void WriteToBufferL( const TDesC8& aData );
       
    63         
       
    64         void StorePureDataL( MImpsDataAccessor& aImpsData, TInt aIndex, TInt aMessageType );
       
    65         
       
    66         void ResetL( );
       
    67 
       
    68         TPtrC8 EscapeXmlL ( const TDesC8& aDes );
       
    69         /**
       
    70         * Two-phased constructor.
       
    71         */
       
    72         static CImpsXmlUtils* NewL( );
       
    73         
       
    74         /**
       
    75         * Destructor.
       
    76         */
       
    77         virtual ~CImpsXmlUtils( );
       
    78 
       
    79     private:
       
    80         /**
       
    81         * C++ default constructor.
       
    82         */
       
    83         CImpsXmlUtils( );
       
    84         /**
       
    85         * By default constructor is private.
       
    86         */
       
    87         void ConstructL( );
       
    88         /**
       
    89         * Method maps strings to the enumerated values
       
    90         * @param aName name of the element
       
    91         * @return enumerated value
       
    92         */
       
    93         TImpsContent NameToKeyPresencePrimitives( TDesC8* aName );
       
    94         /**
       
    95         * Method maps strings to the enumerated values
       
    96         * @param aName name of the element
       
    97         * @return enumerated value
       
    98         */
       
    99         TImpsPresenceContent NameToKeyPresenceElements( TDesC8* aName );
       
   100         /*
       
   101         * Method converts integer to the string format
       
   102         * @param aInteger integer to be converted 
       
   103         */
       
   104 //        TPtrC8 ConvertIntToPtr( TInt aInteger );
       
   105         /**
       
   106         * Method converts 8-bit data to the enumerated value
       
   107         * @param aData
       
   108         * @return converted integer
       
   109         */
       
   110         TInt ConvertToIntL( TDesC8* aData, TInt aKey );
       
   111         /**
       
   112         * Method converts 16-bit descriptor to the 8-bit format
       
   113         * @param aDes descriptor to be converted 
       
   114         * @return pointer to the converted descriptor
       
   115         */
       
   116 //        TPtrC8 Convert16To8L( TDesC* aDes );
       
   117         /**
       
   118         * Method converts boolean to the character format
       
   119         * @param aBool boolean to be converted
       
   120         * @return pointer to the converted descriptor
       
   121         */
       
   122 //        TPtrC8 ConvertBooleanToChar( TBool aBool );
       
   123         /**
       
   124         * Method converts 8-bit data to the boolean
       
   125         * @param aData data buffer
       
   126         * @return the converted boolean
       
   127         */
       
   128         TBool ConvertToBoolean( TDesC8* aData );
       
   129         /**
       
   130         * Method writes empty xml element to the buffer
       
   131         * @param aTag name of the tag.
       
   132         */
       
   133         void WriteEmptyElementL( const TDesC8& aTag );
       
   134         /**
       
   135         * Method restores desc type element and writes it to the buffer
       
   136         * If the descriptor's length is zero, the 
       
   137         * encoder will write empty string
       
   138         * @param aKey key to be restored
       
   139         * @param aElementName name of the element
       
   140         * @param aKeyType type of the key, default value is EImpsKeyTypeIM
       
   141         */
       
   142 //        void EncodeDescL( TInt aKey, 
       
   143 //                          TPtrC8 aElementName, 
       
   144 //                          enum TImpsKeyType = EImpsKeyTypeIM );
       
   145         /**
       
   146         * Method restores desc type elements and writes them to the buffer
       
   147         * @param aKey key to be restored
       
   148         * @param aElementName name of the element
       
   149         * @param aKeyType type of the key
       
   150         */
       
   151 //        void EncodeMultipleDescsL( TInt aKey, 
       
   152 //                                   TPtrC8 aElementName, 
       
   153 //                                   enum TImpsKeyType = EImpsKeyTypeIM );
       
   154         /**
       
   155         * Method restores integer type element and writes it to the buffer
       
   156         * @param aKey key to be restored
       
   157         * @param aElementName name of the element
       
   158         * @param aKeyType type of the key, default value is EImpsKeyTypeIM
       
   159         */
       
   160 //        void EncodeIntegerL( TInt aKey, 
       
   161 //                             TPtrC8 aElementName, 
       
   162 //                             enum TImpsKeyType = EImpsKeyTypeIM );
       
   163         /**
       
   164         * Method restores boolean type element and writes it to the buffer
       
   165         * @param aKey key to be restored
       
   166         * @param aElementName name of the element
       
   167         * @param aKeyType type of the key, default value is EImpsKeyTypeIM
       
   168         */
       
   169 //        void EncodeBooleanL( TInt aKey, 
       
   170 //                             TPtrC8 aElementName, 
       
   171 //                             enum TImpsKeyType = EImpsKeyTypeIM );
       
   172 //                
       
   173         /**
       
   174         * Helping methods for parsing. 
       
   175         */
       
   176         void DoParseL( );
       
   177         void ParseElementsL( );
       
   178         void UpdatePosition( TInt aLength );
       
   179         TInt FindNextTag( );
       
   180         TInt CreateKeyL( TInt aLength );
       
   181         /**
       
   182         * Save data to the internal data structure.
       
   183         */
       
   184         void SaveDataL( TDesC8* aData, TInt aKe) ;
       
   185         /**
       
   186         * Actual encoding 
       
   187         */
       
   188         void DoEncodeL( MImpsDataAccessor& aImpsDat);
       
   189         void EncodePresencePrimitiveL( MImpsKey* aKey, 
       
   190                                        MImpsDataAccessor& aImpsData );
       
   191         void UnescapeL ( );
       
   192 
       
   193     private:    // Data
       
   194 
       
   195         enum TImpsParseState
       
   196             {
       
   197             EImpsUndefined = 0,
       
   198             EImpsStartElement,
       
   199             EImpsEndElement,
       
   200             EImpsEmptyElement
       
   201             };
       
   202 
       
   203         CBufFlat*               iEncodeBuffer;
       
   204         HBufC8*                 iElementValue;
       
   205         HBufC*                  iElementData;
       
   206         HBufC8*                 iIntegerValue;
       
   207         MImpsDataAccessor*      iImpsData;
       
   208         MImpsKey*               iAccessKey;
       
   209         TInt                    iPosition;
       
   210         TInt                    iBufSize;
       
   211         TInt                    iEncodeBufferSize;
       
   212         TInt                    iPrimitive;
       
   213         TPtrC8                  iData;
       
   214         TBool                   iContinue;
       
   215 
       
   216     };
       
   217 
       
   218 #endif      
       
   219             
       
   220 // End of File