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