omaprovisioning/provisioning/ProvisioningParser/Inc/CWPWbxmlParser.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:  CWPWbxmlParser parses WBXML data with builder pattern
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CWPWBXMLPARSER_H
       
    20 #define CWPWBXMLPARSER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 // DATA TYPES
       
    25 typedef struct NW_TinyTree_Node_s NW_TinyTree_Node_t;
       
    26 typedef NW_TinyTree_Node_t NW_DOM_DocumentNode_t;
       
    27 typedef NW_TinyTree_Node_t NW_DOM_Node_t;
       
    28 typedef NW_DOM_Node_t NW_DOM_ElementNode_t;
       
    29 typedef struct NW_DOM_AttributeHandle_s NW_DOM_AttributeHandle_t;
       
    30 
       
    31 typedef struct NW_TinyDom_Handle_s NW_TinyDom_Handle_t;
       
    32 
       
    33 typedef struct NW_String_String_s NW_String_String_t;
       
    34 typedef struct NW_String_String_s NW_String_t;
       
    35 
       
    36 typedef struct NW_String_UCS2Buff_s NW_String_UCS2Buff_t;
       
    37 
       
    38 typedef unsigned long	NW_Uint32;
       
    39 typedef signed   long   NW_Int32;
       
    40 typedef unsigned short	NW_Uint16;
       
    41 typedef unsigned char	NW_Byte; 
       
    42 typedef unsigned short	NW_Ucs2; 
       
    43 
       
    44 typedef struct NW_WBXML_Dictionary_s NW_WBXML_Dictionary_t;
       
    45 
       
    46 typedef NW_TinyTree_Node_t NW_DOM_DocumentNode_t;
       
    47 
       
    48 // FORWARD DECLARATIONS
       
    49 class MWPBuilder;
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 /**
       
    54 *  Class CWPNameValuePair for passing attribute name and value
       
    55 *  @lib ProvisioningParser
       
    56 *  @since 2.0
       
    57 */
       
    58 class CWPNameValuePair : public CBase
       
    59 	{
       
    60 	public:
       
    61         /**
       
    62         * C++ default constructor.
       
    63         */
       
    64 		CWPNameValuePair();
       
    65 
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69 		~CWPNameValuePair();
       
    70 
       
    71 	public:
       
    72 		/**
       
    73 		* Sets the values for a string pair.
       
    74 		* @param aValue The value of the string
       
    75 		*/
       
    76 		void SetValue( HBufC* aValue );
       
    77 		/**
       
    78 		* Gets the value of a string pair.
       
    79 		* @param aValue The value of the string
       
    80 		*/
       
    81 		const TDesC& Value() const;
       
    82 
       
    83 
       
    84 	private:
       
    85 		// The value of the pair. Owns.
       
    86 		HBufC* iValue;
       
    87 	};
       
    88 
       
    89 /**
       
    90 *  Class CWPWbxmlParser parses wbxml data received from ProvisioningEngine
       
    91 *  Parsed data is built back into ProvisioningEngine.
       
    92 *
       
    93 *  @lib ProvisioningParser
       
    94 *  @since 2.0
       
    95 */
       
    96 class CWPWbxmlParser : public CBase
       
    97 	{
       
    98 	public:  // Constructors and destructor
       
    99 
       
   100         /**
       
   101         * Two-phased constructor.
       
   102         */
       
   103 		IMPORT_C static CWPWbxmlParser* NewL();
       
   104 
       
   105 		/**
       
   106         * Destructor.
       
   107         */
       
   108 		virtual ~CWPWbxmlParser();
       
   109 
       
   110 	public:	  // New functions
       
   111 
       
   112 		/**
       
   113         * Parses WBXML document and builds data model
       
   114         * @since 2.0
       
   115         * @param aDocument Reference a wbxml document
       
   116 		* @param aRoot Pointing to data model builder 
       
   117         */
       
   118 		IMPORT_C void ParseL(const TDesC8& aDocument, MWPBuilder& aRoot );
       
   119 
       
   120 
       
   121 	private:  
       
   122 
       
   123         /**
       
   124         * C++ default constructor.
       
   125         */
       
   126 		CWPWbxmlParser();
       
   127 
       
   128         /**
       
   129         * By default Symbian 2nd phase constructor is private.
       
   130         */
       
   131 		void ConstructL();
       
   132 
       
   133 		/* 
       
   134 		*	Cleanup parser handle 
       
   135 		*/		
       
   136 		static void Cleanup( TAny *aPtr );
       
   137 
       
   138 		/**
       
   139         * Parses WBXML document
       
   140         * @since 2.0
       
   141         * @param aDocument Pointer to a document node
       
   142         * @param aRoot Reference to a document builder
       
   143         * @return parser status
       
   144         */
       
   145 		NW_Uint16 ParseDocumentL( NW_DOM_DocumentNode_t* aDocument,
       
   146 							MWPBuilder& aRoot );
       
   147 		/**
       
   148         * Parses node in DOM tree
       
   149         * @since 2.0
       
   150         * @param aNode Pointing to DOM tree node
       
   151 		* @param aEncoding Wbxml document encoding ( UTF8 )
       
   152 		* @param aRoot Pointing to data model builder 
       
   153         * @return parser status
       
   154         */
       
   155 		NW_Uint16 ParseNodeL( NW_DOM_Node_t* aNode, NW_Uint32 aEncoding,
       
   156 						MWPBuilder& aRoot );
       
   157 		/**
       
   158         * Parses XML Element
       
   159         * @since 2.0
       
   160         * @param aElement Pointing to DOM tree element
       
   161 		* @param aEncoding Wbxml document encoding ( UTF8 )
       
   162 		* @param aRoot Pointing to data model builder 
       
   163         * @return parser status
       
   164         */
       
   165 		void ParseElementL( NW_DOM_ElementNode_t* aElement,
       
   166 							NW_Uint32 aEncoding, MWPBuilder& aRoot );
       
   167 		/**
       
   168         * Parses XML Element attributes
       
   169         * @since 2.0
       
   170         * @param aAttrHandle Pointing to a handle to the attribute
       
   171 		* @param aEncoding Wbxml document encoding ( UTF8 )
       
   172 		* @param aPair for passing attribute name and value
       
   173         * @return attribute token or error code
       
   174         */
       
   175 		NW_Uint16 ParseAttributeL( NW_DOM_AttributeHandle_t* aAttrHandle,
       
   176 									NW_Uint32 aEncoding,
       
   177 									 CWPNameValuePair& aPair );
       
   178 
       
   179 		/**
       
   180         * Processes attribute string and returns the value in HBuFC
       
   181         * @since 2.0
       
   182         * @param aString Source string
       
   183 		* @param aEncoding Wbxml document encoding ( UTF8 )
       
   184 		* @param aStatus Current processing status
       
   185         * @return HBufC containing the source string, ownership is transferred
       
   186         */
       
   187 		HBufC* ProcessAttributePartL( NW_String_t* aString,											
       
   188 														NW_Uint32 aEncoding,
       
   189 														NW_Uint16 aStatus );
       
   190 
       
   191 	private: // member variables
       
   192 		NW_WBXML_Dictionary_t* iDictionary[1]; // single dictionary, owned
       
   193 		NW_DOM_DocumentNode_t* iDocNode;	// used
       
   194 		TInt iRecursionDepth;
       
   195 		TInt iErrCode;
       
   196 		HBufC* iParameterName;
       
   197 	
       
   198 
       
   199 	};
       
   200 
       
   201 #endif	// CWPWBXMLPARSER_H
       
   202             
       
   203 // End of File