|
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: XML parser |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __XMLPARSER_H__ |
|
20 #define __XMLPARSER_H__ |
|
21 |
|
22 // ------------------------------------------------------------------------------------------------ |
|
23 // Includes |
|
24 // ------------------------------------------------------------------------------------------------ |
|
25 #include <e32base.h> |
|
26 #include <s32strm.h> |
|
27 |
|
28 #include "WBXMLDefs.h" |
|
29 #include "WBXMLHandler.h" |
|
30 #include "WBXMLParserError.h" |
|
31 |
|
32 // ------------------------------------------------------------------------------------------------ |
|
33 // Constants |
|
34 // ------------------------------------------------------------------------------------------------ |
|
35 _LIT(KXMLNoExtHandler, "No extension handler"); |
|
36 _LIT(KXMLNoDocHandler, "No document handler"); |
|
37 |
|
38 _LIT8(KXMLNull, "\0x00"); |
|
39 |
|
40 // ------------------------------------------------------------------------------------------------ |
|
41 // Forwards |
|
42 // ------------------------------------------------------------------------------------------------ |
|
43 class CXMLAttributes; |
|
44 |
|
45 // ------------------------------------------------------------------------------------------------ |
|
46 // TXMLStackItem |
|
47 // ------------------------------------------------------------------------------------------------ |
|
48 struct TXMLStackItem |
|
49 { |
|
50 public: |
|
51 inline TXMLStackItem( TUint8 aTag, TUint8 aCodePage ); |
|
52 inline TUint8 Tag() const; |
|
53 inline TUint8 CodePage() const; |
|
54 |
|
55 private: |
|
56 TUint8 iTag; |
|
57 TUint8 iCodePage; |
|
58 }; |
|
59 |
|
60 inline TXMLStackItem::TXMLStackItem( TUint8 aTag, TUint8 aCodePage ) : iTag(aTag), iCodePage(aCodePage) |
|
61 { |
|
62 } |
|
63 |
|
64 inline TUint8 TXMLStackItem::Tag() const |
|
65 { |
|
66 return iTag; |
|
67 } |
|
68 |
|
69 inline TUint8 TXMLStackItem::CodePage() const |
|
70 { |
|
71 return iCodePage; |
|
72 } |
|
73 |
|
74 // ------------------------------------------------------------------------------------------------ |
|
75 // CXMLParser |
|
76 // ------------------------------------------------------------------------------------------------ |
|
77 class CXMLParser : public CBase |
|
78 { |
|
79 public: |
|
80 IMPORT_C static CXMLParser* NewL(); |
|
81 IMPORT_C ~CXMLParser(); |
|
82 IMPORT_C void SetDocumentHandler( MWBXMLDocumentHandler* aHandler ); |
|
83 IMPORT_C void SetExtensionHandler( MWBXMLExtensionHandler* aHandler ); |
|
84 |
|
85 IMPORT_C void SetDocumentL( RReadStream& aInput ); |
|
86 IMPORT_C TWBXMLParserError ParseL(); |
|
87 |
|
88 protected: |
|
89 TWBXMLParserError doParseDocumentHeaderL(); |
|
90 TWBXMLParserError doParseDocumentBodyL(); |
|
91 |
|
92 TUint32 readMUint32L(); |
|
93 TUint8 readUint8L(); |
|
94 TPtrC8 readStrIL(); |
|
95 TPtrC8 readOpaqueL(); |
|
96 TPtrC8 stringTableString( TUint32 aIndex ); |
|
97 void readAttributesL( CWBXMLAttributes* aAttributes ); |
|
98 void readStringTableL(); |
|
99 void handleExtensionsL( TUint8 aId ); |
|
100 void handleElementL( TUint8 aId ); |
|
101 |
|
102 private: |
|
103 void ConstructL(); |
|
104 |
|
105 private: |
|
106 MWBXMLDocumentHandler* iDocHandler; |
|
107 MWBXMLExtensionHandler* iExtHandler; |
|
108 HBufC8* iStringTable; |
|
109 RReadStream iInput; |
|
110 RArray<TXMLStackItem> iStack; |
|
111 CBufBase* iBuffer; |
|
112 TUint8 iCodePage; |
|
113 TBool iDocHdrParsed; |
|
114 }; |
|
115 |
|
116 #endif // __XMLPARSER_H__ |