|
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: Generic WBXML parser class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __WBXMLPARSER_H__ |
|
20 #define __WBXMLPARSER_H__ |
|
21 |
|
22 // ------------------------------------------------------------------------------------------------ |
|
23 // Includes |
|
24 // ------------------------------------------------------------------------------------------------ |
|
25 #include <e32base.h> |
|
26 #include <s32strm.h> |
|
27 |
|
28 #include "WBXMLHandler.h" |
|
29 #include "WBXMLDefs.h" |
|
30 #include "WBXMLParserError.h" |
|
31 |
|
32 // ------------------------------------------------------------------------------------------------ |
|
33 // Constants |
|
34 // ------------------------------------------------------------------------------------------------ |
|
35 _LIT(KWBXMLNoExtHandler, "No extension handler"); |
|
36 _LIT(KWBXMLNoDocHandler, "No document handler"); |
|
37 |
|
38 _LIT8(KWBXMLNull, "\x00"); |
|
39 |
|
40 // ------------------------------------------------------------------------------------------------ |
|
41 // Forwards |
|
42 // ------------------------------------------------------------------------------------------------ |
|
43 class CWBXMLAttributes; |
|
44 |
|
45 // ------------------------------------------------------------------------------------------------ |
|
46 // TWBXMLStackItem |
|
47 // ------------------------------------------------------------------------------------------------ |
|
48 struct TWBXMLStackItem |
|
49 { |
|
50 public: |
|
51 inline TWBXMLStackItem( TUint8 aTag, TUint8 aCodePage ); |
|
52 inline TUint8 Tag() const; |
|
53 inline TUint8 CodePage() const; |
|
54 |
|
55 private: |
|
56 TUint8 iTag; |
|
57 TUint8 iCodePage; |
|
58 TUint16 iDummy; |
|
59 }; |
|
60 |
|
61 #include "WBXMLParser.inl" |
|
62 |
|
63 // ------------------------------------------------------------------------------------------------ |
|
64 // CWBXMLParser |
|
65 // ------------------------------------------------------------------------------------------------ |
|
66 class CWBXMLParser : public CBase |
|
67 { |
|
68 public: |
|
69 IMPORT_C static CWBXMLParser* NewL(); |
|
70 IMPORT_C ~CWBXMLParser(); |
|
71 IMPORT_C void SetDocumentHandler( MWBXMLDocumentHandler* aHandler ); |
|
72 IMPORT_C void SetExtensionHandler( MWBXMLExtensionHandler* aHandler ); |
|
73 |
|
74 IMPORT_C void SetDocumentL( RReadStream& aInput ); |
|
75 IMPORT_C TWBXMLParserError ParseL(); |
|
76 |
|
77 private: |
|
78 TWBXMLParserError DoParseDocumentHeaderL(); |
|
79 TWBXMLParserError DoParseDocumentBodyL(); |
|
80 |
|
81 TUint32 ReadMUint32L(); |
|
82 TUint8 ReadUint8L(); |
|
83 TPtrC8 ReadStrIL(); |
|
84 TPtrC8 ReadOpaqueL(); |
|
85 TPtrC8 StringTableString( TUint32 aIndex ); |
|
86 void ReadAttributesL( CWBXMLAttributes* aAttributes ); |
|
87 void ReadStringTableL(); |
|
88 void HandleExtensionsL( TUint8 aId ); |
|
89 void HandleElementL( TUint8 aId ); |
|
90 |
|
91 void ConstructL(); |
|
92 |
|
93 private: |
|
94 MWBXMLDocumentHandler* iDocHandler; |
|
95 MWBXMLExtensionHandler* iExtHandler; |
|
96 HBufC8* iStringTable; |
|
97 RReadStream iInput; |
|
98 RArray<TWBXMLStackItem> iStack; |
|
99 CBufBase* iBuffer; |
|
100 TUint8 iCodePage; |
|
101 TBool iDocHdrParsed; |
|
102 }; |
|
103 |
|
104 #endif // __WBXMLPARSER_H__ |