ncdengine/provider/server/inc/ncdconfigurationparser.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:   CNcdConfigurationParser declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCDCONFIGURATIONPARSER_H
       
    20 #define C_NCDCONFIGURATIONPARSER_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 /**
       
    29  * Observer interface for a configuration observer
       
    30  */ 
       
    31 class MNcdConfigurationParserObserver
       
    32     {
       
    33 public:
       
    34    
       
    35     /**
       
    36      * Called when starting to parse a new element
       
    37      *
       
    38      * @param aElement Name of the element
       
    39      */ 
       
    40     virtual void ConfigurationElementStartL(
       
    41         const TDesC8& aElement ) 
       
    42         {
       
    43         (void) aElement;
       
    44         }
       
    45 
       
    46 
       
    47     /**
       
    48      * Called after an element has been parsed
       
    49      *
       
    50      * @param aElement Name of the parsed element
       
    51      * @param aData Data included in the element
       
    52      */    
       
    53     virtual void ConfigurationElementEndL( 
       
    54         const TDesC8& aElement, 
       
    55         const TDesC8& aData ) = 0;
       
    56 
       
    57     /**
       
    58      * Called for each attribute in an element
       
    59      *
       
    60      * @param aElement Element that is being parsed
       
    61      * @param aAttribute Name of the attribute
       
    62      * @param aValue Value of the attribute
       
    63      */
       
    64     virtual void ConfigurationAttributeL( 
       
    65         const TDesC8& aElement, 
       
    66         const TDesC8& aAttribute, 
       
    67         const TDesC8& aValue ) = 0;
       
    68     
       
    69     /**
       
    70      * Called when a parse error occurs
       
    71      */    
       
    72     virtual void ConfigurationError( TInt aError ) = 0;
       
    73 
       
    74 protected:
       
    75 
       
    76     /**
       
    77      * Destructor
       
    78      */
       
    79     virtual ~MNcdConfigurationParserObserver()
       
    80         {
       
    81         }
       
    82     };
       
    83 
       
    84 
       
    85 /**
       
    86  * Provider configuration parser
       
    87  */
       
    88 class CNcdConfigurationParser : public CBase,
       
    89                                 public Xml::MContentHandler
       
    90     {
       
    91 public:
       
    92 
       
    93     /**
       
    94      * NewL
       
    95      * @param aObserver Observer for parsing events
       
    96      */
       
    97     static CNcdConfigurationParser* NewL( 
       
    98         MNcdConfigurationParserObserver& aObserver );
       
    99 
       
   100 
       
   101     /**
       
   102      * NewLC
       
   103      * @param aObserver Observer for parsing events
       
   104      */
       
   105     static CNcdConfigurationParser* NewLC( 
       
   106         MNcdConfigurationParserObserver& aObserver );
       
   107     
       
   108     /**
       
   109      * Destructor
       
   110      */
       
   111     virtual ~CNcdConfigurationParser();
       
   112     
       
   113 public: // New methods
       
   114 
       
   115     /**
       
   116      * Parses given data
       
   117      *
       
   118      * @param aData Data to parse
       
   119      */
       
   120     void ParseL( const TDesC16& aData );    
       
   121 
       
   122 
       
   123     /**
       
   124      * Parses given data
       
   125      *
       
   126      * @param aData Data to parse
       
   127      */
       
   128     void ParseL( const TDesC8& aData );    
       
   129         
       
   130 public: // From Xml::MContentHandler
       
   131 
       
   132     void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, 
       
   133         TInt aErrorCode);
       
   134         
       
   135     void OnEndDocumentL(TInt aErrorCode);
       
   136     
       
   137     void OnStartElementL(const Xml::RTagInfo& aElement, 
       
   138         const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
       
   139         
       
   140     void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
       
   141     
       
   142     void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
   143     
       
   144     void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, 
       
   145         TInt aErrorCode) ;
       
   146     
       
   147     void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
   148     
       
   149     void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
       
   150     
       
   151     void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
   152     
       
   153     void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, 
       
   154         TInt aErrorCode);
       
   155     
       
   156     void OnError(TInt aErrorCode);
       
   157     
       
   158     TAny* GetExtendedInterface(const TInt32 aUid);
       
   159 
       
   160     
       
   161 private:
       
   162     CNcdConfigurationParser( MNcdConfigurationParserObserver& aObserver );                        
       
   163                         
       
   164     void ConstructL();
       
   165 
       
   166 private:
       
   167 
       
   168     MNcdConfigurationParserObserver& iObserver;
       
   169     Xml::CParser* iXmlParser;
       
   170     HBufC8* iBuffer;
       
   171     };
       
   172 
       
   173 #endif // C_NCDCONFIGURATIONPARSER_H