1 /* |
|
2 * Copyright (c) 2005-2007 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: ConML parser/generator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _SCONCONMLHANDLER_H |
|
20 #define _SCONCONMLHANDLER_H |
|
21 |
|
22 // ----------------------------------------------------------------------------- |
|
23 // Includes |
|
24 // ----------------------------------------------------------------------------- |
|
25 #include "sconconmlgenerator.h" |
|
26 #include "sconwbxmldefs.h" |
|
27 #include "sconconmlhandlererror.h" |
|
28 #include "sconconmldtd.h" |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // Definitions and constants |
|
32 // ----------------------------------------------------------------------------- |
|
33 |
|
34 _LIT8(KWBXMLNull, "\x00"); |
|
35 |
|
36 const TInt KSConBufferGranularity( 32 ); |
|
37 const TInt KSConDefaultDocumentSize( 2048 ); |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // TWBXMLStackItem |
|
41 // ----------------------------------------------------------------------------- |
|
42 NONSHARABLE_STRUCT( TWBXMLStackItem ) |
|
43 { |
|
44 public: |
|
45 inline TWBXMLStackItem( TUint8 aTag ); |
|
46 inline TUint8 Tag() const; |
|
47 |
|
48 private: |
|
49 TUint8 iTag; |
|
50 }; |
|
51 |
|
52 #include "sconwbxmlparser.inl" |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSConConMLHandler - WBXML parsing |
|
56 // ----------------------------------------------------------------------------- |
|
57 class CSConConMLHandler : public CBase |
|
58 { |
|
59 public: |
|
60 static CSConConMLHandler* NewL(); |
|
61 ~CSConConMLHandler(); |
|
62 |
|
63 /** |
|
64 * Starts the parsing of a WBXML document |
|
65 * @param aInput - the WBXML document to be parsed |
|
66 * @param aCallback - Call back function to call |
|
67 * after the document is parsed |
|
68 * @return An error code |
|
69 */ |
|
70 virtual TInt ParseDocumentL( CBufFlat& aInput, |
|
71 MWBXMLConMLCallback* aCallback ); |
|
72 |
|
73 /** |
|
74 * Starts the generating of a WBXML and XML document |
|
75 * @param aContent - the data to be generated into the document |
|
76 * @return An error code |
|
77 */ |
|
78 virtual TInt GenerateDocument( ConML_ConMLPtr_t aContent ); |
|
79 |
|
80 /** |
|
81 * Returns the generated document in XML -format |
|
82 * @param none |
|
83 * @return The document as TPtrC8 |
|
84 */ |
|
85 virtual TPtrC8 XMLDocument(); |
|
86 |
|
87 /** |
|
88 * Returns the generated document in WBXML -format |
|
89 * @param none |
|
90 * @return The document as TPtrC8 |
|
91 */ |
|
92 virtual TPtrC8 WBXMLDocument(); |
|
93 |
|
94 private: |
|
95 CSConConMLHandler(); |
|
96 void ConstructL(); |
|
97 |
|
98 TInt ParseL(); |
|
99 TConMLParserError DoParseDocumentHeaderL(); |
|
100 TConMLParserError DoParseDocumentBodyL(); |
|
101 TUint8 ReadUint8L(); |
|
102 TUint32 ReadMUint32L(); |
|
103 TPtrC8 ReadStrIL(); |
|
104 TPtrC8 StringTableString( TUint32 aIndex ); |
|
105 void ReadStringTableL(); |
|
106 TPtrC8 ReadOpaqueL(); |
|
107 void HandleElementL( TUint8 aId ); |
|
108 |
|
109 private: |
|
110 CSConConMLGenerator* iGenerator; |
|
111 HBufC8* iStringTable; |
|
112 CBufBase* iBuffer; |
|
113 TBool iHeaderParsed; |
|
114 RArray< TUint > iElemStack; |
|
115 TInt iPos; |
|
116 CBufFlat* iParseBuffer; |
|
117 MWBXMLConMLCallback* iCallback; |
|
118 }; |
|
119 |
|
120 IMPORT_C CSConConMLHandler* CreateCSConConMLHandlerL(); |
|
121 typedef CSConConMLHandler* (*TSConCreateCSConConMLHandlerFunc) (); |
|
122 |
|
123 #endif |
|