|
1 /* |
|
2 * Copyright (c) 2007-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 * CmdLineHandler class declaration. |
|
16 * @internalComponent |
|
17 * @released |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef CMDLINEHANDLER_H |
|
23 #define CMDLINEHANDLER_H |
|
24 |
|
25 #include "common.h" |
|
26 #include "exceptionreporter.h" |
|
27 #include "version.h" |
|
28 #include "hash.h" |
|
29 #include <map> |
|
30 #include <vector> |
|
31 |
|
32 /** |
|
33 Tydefs used in this class. |
|
34 |
|
35 @internalComponent |
|
36 @released |
|
37 */ |
|
38 |
|
39 typedef std::map<String,unsigned int> OptionsMap; |
|
40 typedef std::map<String,unsigned int> SuppressionsMap; |
|
41 typedef std::vector<char*> ArgumentList; |
|
42 |
|
43 |
|
44 /** |
|
45 Long options will be intialized into an MAP, this data is used later to |
|
46 validate the received command line arguments. |
|
47 |
|
48 @internalComponent |
|
49 @released |
|
50 */ |
|
51 const String KLongHelpOption("--help"); |
|
52 const String KLongXmlOption("--xml"); |
|
53 const String KLongQuietOption("--quiet"); |
|
54 const String KLongAllOption("--all"); |
|
55 const String KLongOutputOption("--output"); |
|
56 const String KLongVerboseOption("--verbose"); |
|
57 const String KLongSuppressOption("--suppress"); |
|
58 const String KLongVidValOption("--vidlist"); |
|
59 const String KLongSidAllOption("--sidall"); |
|
60 const String KLongE32InputOption("--e32input"); |
|
61 |
|
62 /** |
|
63 Short options will be intialized into an MAP, this data is used later to |
|
64 validate the received command line arguments. |
|
65 |
|
66 @internalComponent |
|
67 @released |
|
68 */ |
|
69 const String KShortHelpOption("-h"); |
|
70 const String KShortXmlOption("-x"); |
|
71 const String KShortQuietOption("-q"); |
|
72 const String KShortAllOption("-a"); |
|
73 const String KShortOutputOption("-o"); |
|
74 const String KShortVerboseOption("-v"); |
|
75 const String KShortSuppressOption("-s"); |
|
76 const String KShortNoCheck("-n"); |
|
77 |
|
78 /** |
|
79 options to enable required Validation |
|
80 |
|
81 @internalComponent |
|
82 @released |
|
83 */ |
|
84 const String KLongEnableDepCheck("--dep"); |
|
85 const String KLongEnableSidCheck("--sid"); |
|
86 const String KLongEnableVidCheck("--vid"); |
|
87 const String KLongEnableDbgFlagCheck("--dbg"); |
|
88 const String KLongNoCheck("--nocheck"); |
|
89 |
|
90 /** |
|
91 option values to disable specific Validation. |
|
92 |
|
93 @internalComponent |
|
94 @released |
|
95 */ |
|
96 const String KSuppressDependency("dep"); |
|
97 const String KSuppressSid("sid"); |
|
98 const String KSuppressVid("vid"); |
|
99 |
|
100 /** |
|
101 To mark whether validaition is enabled or not |
|
102 |
|
103 @internalComponent |
|
104 @released |
|
105 */ |
|
106 const unsigned int KMarkEnable = 0x80000000; |
|
107 |
|
108 /** |
|
109 VID value size |
|
110 |
|
111 @internalComponent |
|
112 @released |
|
113 */ |
|
114 const unsigned int KHexEightByte = 8; |
|
115 const unsigned int KDecHighValue = 0xFFFFFFFF; |
|
116 |
|
117 /** |
|
118 Applicable values of option suppress or -s, allocate each bit for every Validation. |
|
119 |
|
120 @internalComponent |
|
121 @released |
|
122 */ |
|
123 typedef enum Suppress |
|
124 { |
|
125 EDep = 0x1, |
|
126 ESid = 0x2, |
|
127 EVid = 0x4, |
|
128 EDbg = 0x8, |
|
129 //While including more checks, define the constants here; |
|
130 EAllValidation = EDep | ESid | EVid //Add the new check over here. |
|
131 }; |
|
132 |
|
133 /** |
|
134 Constants to define number of values. |
|
135 |
|
136 @internalComponent |
|
137 @released |
|
138 */ |
|
139 typedef enum NumberOfValue |
|
140 { |
|
141 ENone = 0x0, |
|
142 ESingle = 0x1, |
|
143 //Include new number of values here |
|
144 EMultiple = 0x2, |
|
145 EOptional |
|
146 }; |
|
147 |
|
148 /** |
|
149 Prefix to the short option |
|
150 |
|
151 @internalComponent |
|
152 @released |
|
153 */ |
|
154 const char KShortOptionPrefix = '-'; |
|
155 |
|
156 /** |
|
157 XML file extension, if the extension is not provided as part of report name, |
|
158 this string is appended. |
|
159 |
|
160 @internalComponent |
|
161 @released |
|
162 */ |
|
163 const String KXmlExtension(".xml"); |
|
164 |
|
165 /** |
|
166 Default XML report name, used if the output report name is not passed through |
|
167 command line. |
|
168 |
|
169 @internalComponent |
|
170 @released |
|
171 */ |
|
172 const String GXmlFileName("imgcheckreport.xml"); |
|
173 |
|
174 /** |
|
175 Tool name |
|
176 |
|
177 @internalComponent |
|
178 @released |
|
179 */ |
|
180 const String KToolName("imgcheck"); |
|
181 |
|
182 /** |
|
183 Constants used validate the input Decimal or Hexadecimal values |
|
184 |
|
185 @internalComponent |
|
186 @released |
|
187 */ |
|
188 const String KHexNumber("0123456789abcdef"); |
|
189 const String KDecNumber("0123456789"); |
|
190 |
|
191 /** |
|
192 class command line handler |
|
193 |
|
194 @internalComponent |
|
195 @released |
|
196 */ |
|
197 class CmdLineHandler |
|
198 { |
|
199 public: |
|
200 CmdLineHandler(void); |
|
201 ~CmdLineHandler(void); |
|
202 void Usage(void); |
|
203 void Version(void); |
|
204 const String& PrintUsage(void) const; |
|
205 const String& PrintVersion(void) const; |
|
206 String NextImageName(void); |
|
207 unsigned int NoOfImages(void) const; |
|
208 const unsigned int ReportFlag(void) const; |
|
209 const String& XmlReportName(void) const; |
|
210 ReturnType ProcessCommandLine(unsigned int aArgc, char* aArgv[]); |
|
211 void ValidateArguments(void) const; |
|
212 const unsigned int EnabledValidations(void) const; |
|
213 UnIntList& VidValueList(void); |
|
214 const String& Command(void) const; |
|
215 bool DebuggableFlagVal(void); |
|
216 void ValidateImageNameList(void); |
|
217 void ValidateE32NoCheckArguments(void); |
|
218 |
|
219 private: |
|
220 bool IsOption(const String& aName, int& aLongOptionFlag); |
|
221 bool Validate(const String& aName, bool aOptionValue, unsigned int aNoOfVal); |
|
222 void NormaliseName(void); |
|
223 void ParseOption(const String& aFullName, String& aOptionName, StringList& aOptionValues, bool& aOptionValue); |
|
224 void HandleImage(const String& aImageName); |
|
225 void StringListToUnIntList(StringList& aStrList, UnIntList& aUnIntList); |
|
226 bool AlreadyReceived(String& aName); |
|
227 |
|
228 private: |
|
229 StringList iImageNameList; |
|
230 OptionsMap iOptionMap; |
|
231 SuppressionsMap iSuppressVal; |
|
232 UnIntList iVidValList; |
|
233 bool iDebuggableFlagVal; |
|
234 String iInputCommand; |
|
235 String iXmlFileName; |
|
236 bool iNoImage; |
|
237 unsigned int iCommmandFlag; |
|
238 unsigned int iValidations; |
|
239 unsigned int iSuppressions; |
|
240 String iVersion; |
|
241 String iUsage; |
|
242 }; |
|
243 |
|
244 #endif //CMDLINEHANDLER_H |