|
1 /* |
|
2 * Copyright (c) 2010 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: Declaration of XML parser class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef POSREVGEOCODEXMLPARSER_H |
|
19 #define POSREVGEOCODEXMLPARSER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <xml/contenthandler.h> |
|
23 #include <xml/parser.h> |
|
24 using namespace Xml; |
|
25 |
|
26 // Forward declarations |
|
27 class CPosLandmark; |
|
28 |
|
29 /** |
|
30 * MPosRevGeoCodeXmlObserver, an observer to CXmlHandler class. |
|
31 */ |
|
32 class MPosRevGeoCodeXmlObserver |
|
33 { |
|
34 public: |
|
35 /* |
|
36 * Signyfys the completion of parsing of the output data. |
|
37 * |
|
38 * @param aError error status of parsing part. |
|
39 */ |
|
40 virtual void OnParseCompletedL( TInt aError ) = 0; |
|
41 }; |
|
42 |
|
43 /** |
|
44 * This class parses XML script and fills the information into landmarks structure. |
|
45 */ |
|
46 class CPosRevGeoCodeXmlParser : public CBase, |
|
47 public MContentHandler |
|
48 { |
|
49 /* |
|
50 * Category of the address information. This is used for |
|
51 * internal parsing procedure. |
|
52 */ |
|
53 enum TLocationInfoType |
|
54 { |
|
55 ENone = 0, |
|
56 ECountryName, |
|
57 EState, |
|
58 ECity, |
|
59 EDistrict, |
|
60 EPostalCode, |
|
61 EThoroughfareName, |
|
62 EThoroughfareNumber |
|
63 }; |
|
64 public: |
|
65 /** |
|
66 * Factory function to create the instance of CPosRevGeoCodeXmlParser object. |
|
67 */ |
|
68 static CPosRevGeoCodeXmlParser* NewL( MPosRevGeoCodeXmlObserver& aObserver ); |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 */ |
|
73 virtual ~CPosRevGeoCodeXmlParser(); |
|
74 |
|
75 public: |
|
76 /** |
|
77 * Starts parsing XML provided through buffer. |
|
78 */ |
|
79 void StartParsingL( HBufC8* aXmlInfo,CPosLandmark* aLandmarkInfo ); |
|
80 |
|
81 private: |
|
82 /** |
|
83 * Constructor |
|
84 */ |
|
85 CPosRevGeoCodeXmlParser( MPosRevGeoCodeXmlObserver& aObserver ); |
|
86 |
|
87 /** |
|
88 * Symbian 2nd phase constructor. |
|
89 */ |
|
90 void ConstructL(); |
|
91 |
|
92 private: // from MContentHandler |
|
93 void OnStartDocumentL( const RDocumentParameters &aDocParam, TInt aErrorCode ); |
|
94 void OnEndDocumentL( TInt aErrorCode ); |
|
95 void OnStartElementL( const RTagInfo &aElement, const RAttributeArray &aAttributes, TInt aErrorCode ); |
|
96 void OnEndElementL( const RTagInfo &aElement, TInt aErrorCode ); |
|
97 void OnContentL( const TDesC8 &aBytes, TInt aErrorCode ); |
|
98 void OnStartPrefixMappingL( const RString &aPrefix, const RString &aUri, TInt aErrorCode ); |
|
99 void OnEndPrefixMappingL( const RString &aPrefix, TInt aErrorCode ); |
|
100 void OnIgnorableWhiteSpaceL( const TDesC8 &aBytes, TInt aErrorCode ); |
|
101 void OnSkippedEntityL( const RString &aName, TInt aErrorCode ); |
|
102 void OnProcessingInstructionL( const TDesC8 &aTarget, const TDesC8 &aData, TInt aErrorCode); |
|
103 void OnError( TInt aErrorCode ); |
|
104 |
|
105 TAny *GetExtendedInterface( const TInt32 aUid ); |
|
106 |
|
107 private://Data members |
|
108 /** |
|
109 * Reference to XML observer |
|
110 */ |
|
111 MPosRevGeoCodeXmlObserver& iObserver; |
|
112 |
|
113 /** |
|
114 * Pointer to parser |
|
115 * Own |
|
116 */ |
|
117 CParser* iParser; |
|
118 |
|
119 /** |
|
120 * Buffer the contain XML to parsed |
|
121 */ |
|
122 HBufC8* iBuffer; |
|
123 |
|
124 /** |
|
125 * Pointer to client's landmarks object. |
|
126 */ |
|
127 CPosLandmark* iClientLandmark; |
|
128 |
|
129 /** |
|
130 * Current parsing element |
|
131 */ |
|
132 TLocationInfoType iCurrentElement; |
|
133 |
|
134 /** |
|
135 * Boolean to represent thoroughfare. |
|
136 */ |
|
137 TBool iThoroughfare; |
|
138 }; |
|
139 |
|
140 #endif /* POSREVGEOCODEXMLPARSER_H */ |