|
1 /* |
|
2 * Copyright (c) 2004-2009 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @released |
|
23 */ |
|
24 |
|
25 #ifndef __PARSEHANDLERBASE_H__ |
|
26 #define __PARSEHANDLERBASE_H__ |
|
27 |
|
28 #include <xml/contenthandler.h> |
|
29 #include <e32base.h> |
|
30 |
|
31 #include <flogger.h> |
|
32 _LIT(KRtaLogDir, "rta"); |
|
33 _LIT(KRtaLogName, "rta.log"); |
|
34 |
|
35 namespace ReferenceTestAgent |
|
36 { |
|
37 /** Provides an MContentHandler inteface that has a virtual destructor and implements |
|
38 default behavior for parsers which can be overriden by derived parsers as required |
|
39 */ |
|
40 class CParseHandlerBase : public CBase, public Xml::MContentHandler |
|
41 { |
|
42 public: |
|
43 virtual ~CParseHandlerBase(); |
|
44 |
|
45 // Overridden as required by derived classes |
|
46 virtual void ParseStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes); |
|
47 virtual void ParseEndElementL(const Xml::RTagInfo& aElement); |
|
48 virtual void ParseContentL(const TDesC8& aBytes); |
|
49 |
|
50 |
|
51 // From MContentHandler |
|
52 virtual void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode); |
|
53 virtual void OnEndDocumentL(TInt aErrorCode); |
|
54 virtual void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode); |
|
55 virtual void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode); |
|
56 virtual void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
57 virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode); |
|
58 virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
59 virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
60 virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
61 virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode); |
|
62 virtual void OnError(TInt aErrorCode); |
|
63 virtual TAny* GetExtendedInterface(const TInt32 aUid); |
|
64 static const TDesC8& GetTagAttributeL(const Xml::RAttributeArray& aAttributes, const TDesC8& aTag); |
|
65 static HBufC* ConvertDes8ToDes16L(const TDesC8& aString); |
|
66 |
|
67 #ifdef _DEBUG |
|
68 |
|
69 static void LogL(const TDesC& aMessage); |
|
70 static void LogL(const TDesC& aMessage, const TDesC8& aParam); |
|
71 static void LogL(const TDesC& aMessage, TInt aParam); |
|
72 |
|
73 #endif |
|
74 |
|
75 protected: |
|
76 void StartChildParserL(CParseHandlerBase* aChildParser, const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes); |
|
77 |
|
78 private: |
|
79 CParseHandlerBase* iChildParser; // delete when depth = 0 |
|
80 TInt iChildDepth; // when this is zero we process the tags, otherwise child does. |
|
81 }; |
|
82 } |
|
83 |
|
84 #endif |