|
1 /* |
|
2 ============================================================================ |
|
3 Name : NPRStoryXmlParser.h |
|
4 Author : John Kern |
|
5 |
|
6 Copyright (c) 2009 Symbian Foundation Ltd |
|
7 This component and the accompanying materials are made available |
|
8 under the terms of the License "Eclipse Public License v1.0" |
|
9 which accompanies this distribution, and is available |
|
10 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
11 |
|
12 Initial Contributors: |
|
13 - Symbian Foundation Ltd - initial contribution |
|
14 - Symsource |
|
15 |
|
16 Contributors: |
|
17 - John Kern |
|
18 - Symsource |
|
19 |
|
20 Description : Story xml parser |
|
21 ============================================================================ |
|
22 */ |
|
23 |
|
24 #ifndef __NPR_STORY_XML_PARSER_H__ |
|
25 #define __NPR_STORY_XML_PARSER_H__ |
|
26 |
|
27 // INCLUDES |
|
28 #include <Xml/ContentHandler.h> |
|
29 #include <Xml/Parser.h> |
|
30 |
|
31 #include "NPRStory.h" |
|
32 |
|
33 using namespace Xml; |
|
34 |
|
35 /** |
|
36 * CNPRStoryXmlParser |
|
37 * The SAX parser will use this handler and associated enums to create story objects. |
|
38 */ |
|
39 |
|
40 // used by SAX parser. States of the XML response from NPR server. |
|
41 enum TNPRNewsState |
|
42 { |
|
43 ENPRNewsStateIdle = 0, |
|
44 ENPRNewsStateStory, |
|
45 ENPRNewsStateTitle, |
|
46 ENPRNewsStateTeaser, |
|
47 ENPRNewsStateThumbnail, |
|
48 ENPRNewsStateMedium, |
|
49 ENPRNewsStateText, |
|
50 ENPRNewsStateParagraph, |
|
51 ENPRNewsStateDate, |
|
52 ENPRNewsStateAudio, |
|
53 ENPRNewsStateAudioMp3, |
|
54 ENPRNewsStateAudioReal, |
|
55 ENPRNewsStateAudioWM, |
|
56 }; |
|
57 |
|
58 class CNPRStoryXmlParser : public CBase, public MContentHandler |
|
59 { |
|
60 public: |
|
61 static CNPRStoryXmlParser* NewL(RPointerArray<CNPRStory>* aStoryArray); |
|
62 static CNPRStoryXmlParser* NewLC(RPointerArray<CNPRStory>* aStoryArray); |
|
63 ~CNPRStoryXmlParser(); |
|
64 |
|
65 public: |
|
66 void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); |
|
67 void OnEndDocumentL(TInt aErrorCode); |
|
68 void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode); |
|
69 void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); |
|
70 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
71 void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode); |
|
72 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
73 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
74 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
75 void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode); |
|
76 void OnError(TInt aErrorCode); |
|
77 TAny* GetExtendedInterface(const TInt32 aUid) ; |
|
78 |
|
79 private: |
|
80 // Constructors and destructor |
|
81 HBufC* Copy8To16LC(const TDesC8& aDes); |
|
82 |
|
83 private: |
|
84 CNPRStoryXmlParser(RPointerArray<CNPRStory>* aStoryArray); |
|
85 void ConstructL(); |
|
86 |
|
87 private: |
|
88 CNPRStory* iCurrentStory; |
|
89 TNPRNewsState iState; |
|
90 RPointerArray<CNPRStory>* iStoryArray; //it doesn't take ownership, do not delete |
|
91 HBufC8* iTagName; |
|
92 TBool iStory; |
|
93 }; |
|
94 |
|
95 #endif // __NPR_STORY_XML_PARSER_H__ |