presadap12/Parser2/SrcXmlParser/CPEngXMLParser.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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:  XML Parser implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGXMLPARSER_H
       
    19 #define __CPENGXMLPARSER_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <badesca.h>
       
    23 #include <nw_cXML_Parser.h>
       
    24 #include "MPEngXMLParser.h"
       
    25 
       
    26 
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CPEngParserStack;
       
    30 
       
    31 /**
       
    32  *  The parser class for decoding XML
       
    33  */
       
    34 class CPEngXMLParser : public CBase,
       
    35             public MPEngXMLParser
       
    36     {
       
    37     public:  // Constructors and destructor
       
    38 
       
    39         /**
       
    40          * Two-phased constructor.
       
    41          */
       
    42         IMPORT_C static CPEngXMLParser* NewLC();
       
    43 
       
    44         /**
       
    45          * Destructor.
       
    46          */
       
    47         ~CPEngXMLParser();
       
    48 
       
    49 
       
    50     private:  // Constructors
       
    51 
       
    52         /**
       
    53          * C++ default constructor.
       
    54          */
       
    55         CPEngXMLParser();
       
    56 
       
    57 
       
    58         /**
       
    59          * By default Symbian OS constructor is private.
       
    60          */
       
    61         void ConstructL();
       
    62 
       
    63 
       
    64 
       
    65     public: // Functions from MPEngXMLParser
       
    66 
       
    67         /**
       
    68          * @See MPEngXMLParser
       
    69          */
       
    70         TBool DecodeL( const TDesC8& aBuffer,
       
    71                        const TDesC8& aString,
       
    72                        TBool aTags,
       
    73                        TInt aLevel = 0 );
       
    74 
       
    75         TInt Count();
       
    76         TPtrC8 ResultL( TInt aIndex = 0 );
       
    77 
       
    78 
       
    79         HBufC8* ResultAsNarrowTextL( TInt aIndex = 0 );
       
    80         HBufC16* ResultAsUnicodeTextL( TInt aIndex = 0 );
       
    81         HBufC16* ResultAsWVAddressL( TInt aIndex = 0 );
       
    82         HBufC8* ResultAsBase64DecodedL( TInt aIndex = 0 );
       
    83 
       
    84         TInt ParseResultL( const TDesC8& aBuffer,
       
    85                            TInt aOperationID,
       
    86                            MPEngAdvTransactionStatus2& aStatus,
       
    87                            TBool& aResultRequired );
       
    88 
       
    89         TInt ParseResultL( const TDesC8& aBuffer,
       
    90                            TInt aOperationID,
       
    91                            MPEngAdvTransactionStatus2& aStatus );
       
    92 
       
    93         TInt ParseContactListResultL( const TDesC8& aBuffer,
       
    94                                       TInt aOperationID,
       
    95                                       const TDesC& aContactList,
       
    96                                       MPEngAdvTransactionStatus2& aStatus );
       
    97         void Close();
       
    98 
       
    99 
       
   100 
       
   101 
       
   102 
       
   103     private: //Private helpers
       
   104 
       
   105         void ResetResults();
       
   106         HBufC16* DoWVAddressUnescapeL( const TDesC16& aSrc );
       
   107         HBufC8* DoXMLUnEscapingL( const TDesC8& aSrc );
       
   108 
       
   109         TInt DoParseResultL( const TDesC8& aBuffer,
       
   110                              MPEngAdvTransactionStatus2& aStatus,
       
   111                              TInt aOperationID,
       
   112                              const TUint32* aAttributeTypeID,
       
   113                              const TDesC* aContactListID,
       
   114                              TBool& aResultRequired );
       
   115 
       
   116         void DoParseDetailedResultsL( const TDesC8& aBuffer,
       
   117                                       MPEngAdvTransactionStatus2& aStatus,
       
   118                                       TInt aOperationID,
       
   119                                       const TUint32* aAttributeTypeID,
       
   120                                       const TDesC* aContactListID );
       
   121 
       
   122         void DoParseOneDetailedResultL( const TDesC8& aDetailedResult,
       
   123                                         MPEngAdvTransactionStatus2& aStatus,
       
   124                                         TInt aOperationID,
       
   125                                         const TUint32* aAttributeTypeID,
       
   126                                         const TDesC* aContactListID );
       
   127         void SetError( TInt aError );
       
   128 
       
   129 
       
   130     private: // The callback functions for the XML parser
       
   131 
       
   132         static NW_Status_t StartDocument_CB( NW_XML_Reader_t*, void* );
       
   133         static NW_Status_t EndDocument_CB( NW_XML_Reader_t*, void* );
       
   134         static NW_Status_t Tag_Start_CB( NW_XML_Reader_t* aReader,
       
   135                                          const NW_XML_Reader_Interval_t* aName,
       
   136                                          void* aParser );
       
   137 
       
   138         static NW_Status_t Tag_End_CB( NW_XML_Reader_t* aReader,
       
   139                                        const NW_XML_Reader_Interval_t* aName,
       
   140                                        NW_Uint32 emptyTagFlag,
       
   141                                        void* aParser );
       
   142 
       
   143         static NW_Status_t Attr_Start_CB( NW_XML_Reader_t*,
       
   144                                           const NW_XML_Reader_Interval_t* pI_name,
       
   145                                           void* );
       
   146 
       
   147         static NW_Status_t Attr_VarVal_CB( NW_XML_Reader_t*,
       
   148                                            const NW_XML_Reader_Interval_t* pI_name,
       
   149                                            const NW_XML_Reader_Interval_t* pI_value,
       
   150                                            void* );
       
   151 
       
   152         static NW_Status_t Attributes_End_CB( NW_XML_Reader_t*,
       
   153                                               NW_Uint32 attributeCount,
       
   154                                               void* );
       
   155 
       
   156         static NW_Status_t Attr_Entity_VarVal_CB ( NW_XML_Reader_t* pT,
       
   157                                                    const NW_XML_Reader_Interval_t* pI_name,
       
   158                                                    NW_Uint8* pValue,
       
   159                                                    NW_Uint32 valueByteLength,
       
   160                                                    void* pV );
       
   161 
       
   162         static NW_Status_t Exception_CB( NW_XML_Reader_t*, void* );
       
   163 
       
   164 
       
   165 
       
   166 
       
   167     private:    // Data
       
   168 
       
   169         //OWN: an array to hold the parsing results
       
   170         RArray<TPtrC8> iResults;
       
   171 
       
   172         //REF: the incoming xml data to be parsed
       
   173         TPtrC8 iData;
       
   174 
       
   175         //REF: the string (token) to be searched
       
   176         TPtrC8 iSearchable;
       
   177 
       
   178         //OWN:  holds the result intervals
       
   179         CPEngParserStack* iIntervals;
       
   180 
       
   181         //OWN: a boolean to tell if the tags will be taken into the result
       
   182         TBool iIncludeTags;
       
   183 
       
   184         //OWN: current parsing level
       
   185         TInt iParsingLevel;
       
   186 
       
   187         //OWN: restriction to the level we are parsing
       
   188         TInt iMaxParseLevel;
       
   189 
       
   190         //OWN: callback object for the xml parser
       
   191         NW_XML_Parser_EventCallbacks_s iCallBacks;
       
   192 
       
   193         //OWN:  xml toolkits xml reader object
       
   194         NW_XML_Reader_t iReader;
       
   195 
       
   196         //OWN: Error
       
   197         TInt    iError;
       
   198     };
       
   199 
       
   200 #endif      // __CPENGXMLPARSER_H
       
   201 
       
   202 //  End of File
       
   203