inc/NPRStationXmlParser.h
changeset 0 0049171ecffb
equal deleted inserted replaced
-1:000000000000 0:0049171ecffb
       
     1 /*
       
     2  ============================================================================
       
     3  Name	: NPRStationXmlParser.h
       
     4  Author	: Symsource
       
     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  - Symsource
       
    14  
       
    15  Contributors:
       
    16  - Symsource
       
    17  
       
    18  Description : Station xml parser
       
    19  ============================================================================
       
    20  */
       
    21 
       
    22 #ifndef __NPR_STATION_XML_PARSER_H__
       
    23 #define __NPR_STATION_XML_PARSER_H__
       
    24 
       
    25 // INCLUDES
       
    26 #include <Xml/ContentHandler.h>
       
    27 
       
    28 #include "NPRStation.h"
       
    29 
       
    30 using namespace Xml;
       
    31 // CLASS DECLARATION
       
    32 
       
    33 /**
       
    34  *  CNPRStationXmlParser
       
    35  * The SAX parser will use this handler and associated enums to create story objects.  
       
    36  */
       
    37 
       
    38 // used by SAX parser. States of the XML response from NPR server. 
       
    39 enum TNPRStationParserState
       
    40 		{
       
    41         ENPRStationStateIdle = 0,
       
    42         ENPRStationStateStation,
       
    43         ENPRStationStateStationEnd,
       
    44         ENPRStationStateName,
       
    45         ENPRStationStateNameEnd,
       
    46         ENPRStationStateFrequency,
       
    47         ENPRStationStateFrequencyEnd,
       
    48         ENPRStationStateMarketCity,
       
    49         ENPRStationStateMarketCityEnd
       
    50 		};
       
    51 
       
    52 class CNPRStationXmlParser : public CBase, public MContentHandler
       
    53 	{
       
    54 public:
       
    55 	static CNPRStationXmlParser* NewL(RPointerArray<CNPRStation>* aStationArray);
       
    56 	static CNPRStationXmlParser* NewLC(RPointerArray<CNPRStation>* aStationArray);
       
    57 	~CNPRStationXmlParser();
       
    58 
       
    59 public:
       
    60 	void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); 
       
    61 	void OnEndDocumentL(TInt aErrorCode); 
       
    62 	void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode);
       
    63 	void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
       
    64 	void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
    65 	void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
       
    66 	void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
    67 	void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
       
    68 	void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
    69 	void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
       
    70 	void OnError(TInt aErrorCode);
       
    71 	TAny* GetExtendedInterface(const TInt32 aUid);
       
    72 
       
    73 private:
       
    74 	HBufC* Copy8To16LC(const TDesC8& aDes);
       
    75 	
       
    76 private:
       
    77 	CNPRStationXmlParser(RPointerArray<CNPRStation>* aStationArray);
       
    78 	void ConstructL();
       
    79 
       
    80 private:
       
    81 	CNPRStation 				*iCurrentStation; 
       
    82 	TNPRStationParserState		iState;
       
    83 	RPointerArray<CNPRStation>* iStationArray; //it doesn't take ownership, do not delete
       
    84 	};
       
    85 
       
    86 #endif // __NPR_STATION_XML_PARSER_H__