ncdengine/provider/protocol/inc/ncdsubparser.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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:   CNcdSubParser declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NcdSUBPARSER_H
       
    20 #define NcdSUBPARSER_H
       
    21 
       
    22 #include <xml/parser.h>
       
    23 #include <xml/contenthandler.h>
       
    24 #include <xml/documentparameters.h>
       
    25 #include <xml/taginfo.h>
       
    26 #include <xml/attribute.h>
       
    27 
       
    28 #include "ncdparser.h"
       
    29 
       
    30 /**
       
    31  * Subparser observer.
       
    32  */
       
    33 class MNcdSubParserObserver
       
    34     {
       
    35 public:
       
    36     virtual ~MNcdSubParserObserver() {}
       
    37     /**
       
    38      * This is called when the subparser is finished parsing its data.
       
    39      * @param aSubParserTag The tag which was parsed by the parser
       
    40      * @param aErrorCode Error code in case of parse errors
       
    41      */
       
    42     virtual void SubParserFinishedL( const TDesC8& aSubParserTag, TInt aErrorCode ) = 0;
       
    43     };
       
    44 
       
    45 /**
       
    46  * Subparser base clas.
       
    47  */
       
    48 class CNcdSubParser : public CBase,
       
    49                       public Xml::MContentHandler,
       
    50                       public MNcdSubParserObserver
       
    51     {
       
    52 public:
       
    53     enum TType
       
    54         {
       
    55         EParserDefaultType,
       
    56         EParserUnknown,
       
    57         EParserProtocolResponse,
       
    58         EParserEntityRef,
       
    59         EParserEntityData
       
    60         };
       
    61 
       
    62 public:
       
    63     CNcdSubParser( MNcdParserObserverBundle& aObservers,
       
    64                    MNcdSubParserObserver& aSubParserObserver,
       
    65                    TInt aDepth,
       
    66                    TType aType = EParserDefaultType );
       
    67     virtual ~CNcdSubParser();
       
    68 
       
    69 public:
       
    70     TType Type() const;
       
    71     const TDesC8& Tag() const;
       
    72     TInt Depth() const;
       
    73     // return KNullDesC8 if not found
       
    74     static const TDesC8& AttributeValue( const TDesC8& aAttributeName,
       
    75                                          const Xml::RAttributeArray& aAttributes );
       
    76     static const TDesC8& AttributePrefix( const TDesC8& aAttributeName,
       
    77                                           const Xml::RAttributeArray& aAttributes );
       
    78 
       
    79 
       
    80 
       
    81 public: // From Xml::MContentHandler
       
    82 
       
    83     /**
       
    84      * @see Xml::MContentHandler::OnStartDocumentL
       
    85      * @note this parent class implementation of OnStartDocumentL
       
    86      *  must be called by overriding child class implementations of the function. 
       
    87      * 
       
    88      */
       
    89     virtual void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode) ;
       
    90     virtual void OnEndDocumentL(TInt aErrorCode) ;
       
    91     virtual void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, 
       
    92                                  TInt aErrorCode) ;
       
    93     virtual void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode) ;
       
    94     virtual void OnContentL(const TDesC8& aBytes, TInt aErrorCode) ;
       
    95     virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, 
       
    96                                        TInt aErrorCode) ;
       
    97     virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode) ;
       
    98     virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode) ;
       
    99     virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode) ;
       
   100     virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, 
       
   101                                           TInt aErrorCode) ;
       
   102     virtual void OnError(TInt aErrorCode);
       
   103     virtual TAny* GetExtendedInterface(const TInt32 aUid);
       
   104 
       
   105 public: // From MNcdSubParserObserver
       
   106 
       
   107     virtual void SubParserFinishedL( const TDesC8& aTag, TInt aErrorCode );
       
   108 
       
   109 protected:
       
   110     void ConstructL( const Xml::RTagInfo& aElement );
       
   111 protected:
       
   112     TType iType;
       
   113     TInt iDepth;
       
   114     HBufC8* iTag;
       
   115     HBufC8* iBuffer;
       
   116     MNcdParserObserverBundle* iObservers;
       
   117     MNcdSubParserObserver* iSubParserObserver;
       
   118     CNcdSubParser* iSubParser;
       
   119     };
       
   120 
       
   121 #endif