|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CREATORRANDOMDATAPARSER_H_ |
|
21 #define CREATORRANDOMDATAPARSER_H_ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <badesca.h> |
|
25 #include <xml/contenthandler.h> |
|
26 #include <xml/parser.h> |
|
27 |
|
28 //using namespace Xml; |
|
29 |
|
30 class CCreatorRandomDataParser : public CBase, public Xml::MContentHandler |
|
31 { |
|
32 |
|
33 public: |
|
34 enum TRandomDataType |
|
35 { |
|
36 EFirstName, |
|
37 ESurname, |
|
38 ECompany, |
|
39 EAddress, |
|
40 EJobTitle, |
|
41 EPhoneNumber, |
|
42 EGroupName, |
|
43 EMeetingReason, |
|
44 EMeetingPlace, |
|
45 EMemoText, |
|
46 EAnniversaryReason, |
|
47 EToDoText, |
|
48 EReminderText, |
|
49 EMessageSubject, |
|
50 EMessageText, |
|
51 ECity, |
|
52 ECountry, |
|
53 EPostcode, |
|
54 EState, |
|
55 EPobox, |
|
56 EPrefix, |
|
57 ESuffix, |
|
58 ELandmarkName, |
|
59 ELandmarkDescription |
|
60 }; |
|
61 |
|
62 public: |
|
63 |
|
64 virtual ~CCreatorRandomDataParser(); |
|
65 static CCreatorRandomDataParser* NewL(); |
|
66 static CCreatorRandomDataParser* NewLC(); |
|
67 CDesCArrayFlat* ParseL(const TDesC& aFileName, const TRandomDataType aDataType); |
|
68 |
|
69 TInt GetError() const; |
|
70 |
|
71 private: |
|
72 |
|
73 CCreatorRandomDataParser(); |
|
74 void ConstructL(); |
|
75 |
|
76 /** |
|
77 * Converts 8 bit descriptor to 16 bit descriptor |
|
78 * @param aDes 8 bit descriptor to be converted |
|
79 * @return Pointer to the new 16 bit descriptor |
|
80 */ |
|
81 HBufC* Convert8BitTo16BitLC(const TDesC8& aInput); |
|
82 void GetTextFileMode(RFile& aFile, TInt& aFileSize); |
|
83 |
|
84 |
|
85 public: |
|
86 // From MContentHandler: |
|
87 void OnStartDocumentL(const Xml::RDocumentParameters &aDocParam, TInt aErrorCode); |
|
88 void OnEndDocumentL(TInt aErrorCode); |
|
89 void OnStartElementL(const Xml::RTagInfo& aElement, |
|
90 const Xml::RAttributeArray& aAttributes, |
|
91 TInt aErrorCode); |
|
92 void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode); |
|
93 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
94 void OnStartPrefixMappingL(const RString& aPrefix, |
|
95 const RString& aUri, |
|
96 TInt aErrorCode); |
|
97 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
98 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
99 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
100 void OnProcessingInstructionL(const TDesC8& aTarget, |
|
101 const TDesC8& aData, |
|
102 TInt aErrorCode); |
|
103 void OnError(TInt aErrorCode); |
|
104 TAny* GetExtendedInterface(const TInt32 aUid); |
|
105 |
|
106 private: |
|
107 TRandomDataType iDataType; |
|
108 CDesCArray* iElementNameArray; |
|
109 HBufC* iContentData; |
|
110 TBool iInsideRootElement; |
|
111 TBool iContentParsingActive; |
|
112 |
|
113 CDesCArrayFlat* iResultArray; |
|
114 |
|
115 enum TFileFormat |
|
116 { |
|
117 EFormatANSIASCII, |
|
118 EFormatUTF8, |
|
119 EFormatUTF16LE, |
|
120 EFormatUTF16BE |
|
121 }; |
|
122 |
|
123 // XML parser |
|
124 Xml::CParser* iParser; |
|
125 |
|
126 TFileFormat iScriptTextFormat; |
|
127 TInt iLastError; |
|
128 }; |
|
129 |
|
130 #endif /*CREATORRANDOMDATAPARSER_H_*/ |