blob: 909718d3e79fa404c273541d4db89455176821e9 [file] [log] [blame]
scroggo@google.com161e1ba2013-03-04 16:41:06 +00001/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
scroggo@google.comd9ba9a02013-03-21 19:43:15 +00008#ifndef SK_COMMAND_LINE_FLAGS_H
9#define SK_COMMAND_LINE_FLAGS_H
scroggo@google.com161e1ba2013-03-04 16:41:06 +000010
11#include "SkString.h"
scroggo@google.comb7dbf632013-04-23 15:38:09 +000012#include "SkTArray.h"
sglez@google.com586db932013-07-24 17:24:23 +000013#include "SkTDArray.h"
scroggo@google.com161e1ba2013-03-04 16:41:06 +000014
15/**
scroggo@google.comd9ba9a02013-03-21 19:43:15 +000016 * Including this file (and compiling SkCommandLineFlags.cpp) provides command line
scroggo@google.com161e1ba2013-03-04 16:41:06 +000017 * parsing. In order to use it, use the following macros in global
18 * namespace:
19 *
20 * DEFINE_bool(name, defaultValue, helpString);
21 * DEFINE_string(name, defaultValue, helpString);
22 * DEFINE_int32(name, defaultValue, helpString);
23 * DEFINE_double(name, defaultValue, helpString);
24 *
scroggo@google.comd9ba9a02013-03-21 19:43:15 +000025 * Then, in main, call SkCommandLineFlags::SetUsage() to describe usage and call
26 * SkCommandLineFlags::Parse() to parse the flags. Henceforth, each flag can
scroggo@google.com161e1ba2013-03-04 16:41:06 +000027 * be referenced using
28 *
29 * FLAGS_name
30 *
31 * For example, the line
32 *
33 * DEFINE_bool(boolean, false, "The variable boolean does such and such");
34 *
35 * will create the following variable:
36 *
37 * bool FLAGS_boolean;
38 *
39 * which will initially be set to false, and can be set to true by using the
40 * flag "--boolean" on the commandline. "--noboolean" will set FLAGS_boolean
scroggo@google.com5dc4ca12013-03-21 13:10:59 +000041 * to false. FLAGS_boolean can also be set using "--boolean=true" or
42 * "--boolean true" (where "true" can be replaced by "false", "TRUE", "FALSE",
43 * "1" or "0").
44 *
scroggo@google.com5dc4ca12013-03-21 13:10:59 +000045 * The helpString will be printed if the help flag (-h or -help) is used.
scroggo@google.com161e1ba2013-03-04 16:41:06 +000046 *
47 * Similarly, the line
48 *
49 * DEFINE_int32(integer, .., ..);
50 *
51 * will create
52 *
53 * int32_t FLAGS_integer;
54 *
55 * and
56 *
57 * DEFINE_double(real, .., ..);
58 *
59 * will create
60 *
61 * double FLAGS_real;
62 *
63 * These flags can be set by specifying, for example, "--integer 7" and
64 * "--real 3.14" on the command line.
65 *
66 * Unlike the others, the line
67 *
68 * DEFINE_string(args, .., ..);
69 *
70 * creates an array:
71 *
scroggo@google.comb7dbf632013-04-23 15:38:09 +000072 * SkCommandLineFlags::StringArray FLAGS_args;
scroggo@google.com161e1ba2013-03-04 16:41:06 +000073 *
74 * If the default value is the empty string, FLAGS_args will default to a size
75 * of zero. Otherwise it will default to a size of 1 with the default string
76 * as its value. All strings that follow the flag on the command line (until
77 * a string that begins with '-') will be entries in the array.
78 *
kkinnunen9ebc3f02015-12-21 23:48:13 -080079 * DEFINE_extended_string(args, .., .., extendedHelpString);
80 *
81 * creates a similar string array flag as DEFINE_string. The flag will have extended help text
82 * (extendedHelpString) that can the user can see with '--help <args>' flag.
83 *
scroggo@google.com161e1ba2013-03-04 16:41:06 +000084 * Any flag can be referenced from another file after using the following:
85 *
86 * DECLARE_x(name);
87 *
88 * (where 'x' is the type specified in the DEFINE).
89 *
90 * Inspired by gflags (https://code.google.com/p/gflags/). Is not quite as
91 * robust as gflags, but suits our purposes. For example, allows creating
scroggo@google.comd9ba9a02013-03-21 19:43:15 +000092 * a flag -h or -help which will never be used, since SkCommandLineFlags handles it.
93 * SkCommandLineFlags will also allow creating --flag and --noflag. Uses the same input
scroggo@google.com161e1ba2013-03-04 16:41:06 +000094 * format as gflags and creates similarly named variables (i.e. FLAGS_name).
95 * Strings are handled differently (resulting variable will be an array of
96 * strings) so that a flag can be followed by multiple parameters.
97 */
98
scroggo@google.com161e1ba2013-03-04 16:41:06 +000099class SkFlagInfo;
100
scroggo@google.comd9ba9a02013-03-21 19:43:15 +0000101class SkCommandLineFlags {
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000102
103public:
104 /**
105 * Call to set the help message to be displayed. Should be called before
scroggo@google.comd9ba9a02013-03-21 19:43:15 +0000106 * Parse.
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000107 */
108 static void SetUsage(const char* usage);
109
110 /**
111 * Call at the beginning of main to parse flags created by DEFINE_x, above.
112 * Must only be called once.
113 */
scroggo@google.comd9ba9a02013-03-21 19:43:15 +0000114 static void Parse(int argc, char** argv);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000115
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000116 /**
117 * Custom class for holding the arguments for a string flag.
118 * Publicly only has accessors so the strings cannot be modified.
119 */
120 class StringArray {
121 public:
kkinnunen9ebc3f02015-12-21 23:48:13 -0800122 StringArray() { }
123 explicit StringArray(const SkTArray<SkString>& strings)
124 : fStrings(strings) {
125 }
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000126 const char* operator[](int i) const {
127 SkASSERT(i >= 0 && i < fStrings.count());
128 return fStrings[i].c_str();
129 }
130
131 int count() const {
132 return fStrings.count();
133 }
134
135 bool isEmpty() const { return this->count() == 0; }
136
epoger@google.comdefc4872013-09-19 06:18:27 +0000137 /**
138 * Returns true iff string is equal to one of the strings in this array.
139 */
140 bool contains(const char* string) const {
141 for (int i = 0; i < fStrings.count(); i++) {
142 if (fStrings[i].equals(string)) {
143 return true;
144 }
145 }
146 return false;
147 }
148
caryclark936b7342014-07-11 12:14:51 -0700149 void set(int i, const char* str) {
150 fStrings[i].set(str);
151 }
152
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000153 private:
154 void reset() { fStrings.reset(); }
155
156 void append(const char* string) {
157 fStrings.push_back().set(string);
158 }
159
scroggo@google.com58104a92013-04-24 19:25:26 +0000160 void append(const char* string, size_t length) {
161 fStrings.push_back().set(string, length);
162 }
163
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000164 SkTArray<SkString> fStrings;
165
166 friend class SkFlagInfo;
167 };
168
commit-bot@chromium.orga6f37e72013-08-30 15:52:46 +0000169 /* Takes a list of the form [~][^]match[$]
170 ~ causes a matching test to always be skipped
171 ^ requires the start of the test to match
172 $ requires the end of the test to match
173 ^ and $ requires an exact match
174 If a test does not match any list entry, it is skipped unless some list entry starts with ~
175 */
176 static bool ShouldSkip(const SkTDArray<const char*>& strings, const char* name);
177 static bool ShouldSkip(const StringArray& strings, const char* name);
178
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000179private:
180 static SkFlagInfo* gHead;
181 static SkString gUsage;
182
183 // For access to gHead.
184 friend class SkFlagInfo;
185};
186
187#define TO_STRING2(s) #s
188#define TO_STRING(s) TO_STRING2(s)
189
190#define DEFINE_bool(name, defaultValue, helpString) \
191bool FLAGS_##name; \
fmalita523beb72015-06-10 10:46:50 -0700192SK_UNUSED static bool unused_##name = SkFlagInfo::CreateBoolFlag(TO_STRING(name), \
halcanary96fcdcc2015-08-27 07:41:13 -0700193 nullptr, \
fmalita523beb72015-06-10 10:46:50 -0700194 &FLAGS_##name, \
195 defaultValue, \
196 helpString)
scroggo@google.com09fd4d22013-03-20 14:20:18 +0000197
198// bool 2 allows specifying a short name. No check is done to ensure that shortName
199// is actually shorter than name.
200#define DEFINE_bool2(name, shortName, defaultValue, helpString) \
201bool FLAGS_##name; \
fmalita523beb72015-06-10 10:46:50 -0700202SK_UNUSED static bool unused_##name = SkFlagInfo::CreateBoolFlag(TO_STRING(name), \
203 TO_STRING(shortName),\
204 &FLAGS_##name, \
205 defaultValue, \
206 helpString)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000207
208#define DECLARE_bool(name) extern bool FLAGS_##name;
209
210#define DEFINE_string(name, defaultValue, helpString) \
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000211SkCommandLineFlags::StringArray FLAGS_##name; \
fmalita523beb72015-06-10 10:46:50 -0700212SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
halcanary96fcdcc2015-08-27 07:41:13 -0700213 nullptr, \
fmalita523beb72015-06-10 10:46:50 -0700214 &FLAGS_##name, \
215 defaultValue, \
kkinnunen9ebc3f02015-12-21 23:48:13 -0800216 helpString, nullptr)
217#define DEFINE_extended_string(name, defaultValue, helpString, extendedHelpString) \
218SkCommandLineFlags::StringArray FLAGS_##name; \
219SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
220 nullptr, \
221 &FLAGS_##name, \
222 defaultValue, \
223 helpString, \
224 extendedHelpString)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000225
scroggo@google.com604e0c22013-04-09 21:25:46 +0000226// string2 allows specifying a short name. There is an assert that shortName
227// is only 1 character.
scroggo@google.com09fd4d22013-03-20 14:20:18 +0000228#define DEFINE_string2(name, shortName, defaultValue, helpString) \
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000229SkCommandLineFlags::StringArray FLAGS_##name; \
fmalita523beb72015-06-10 10:46:50 -0700230SK_UNUSED static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
231 TO_STRING(shortName), \
232 &FLAGS_##name, \
233 defaultValue, \
kkinnunen9ebc3f02015-12-21 23:48:13 -0800234 helpString, nullptr)
scroggo@google.com09fd4d22013-03-20 14:20:18 +0000235
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000236#define DECLARE_string(name) extern SkCommandLineFlags::StringArray FLAGS_##name;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000237
robertphillips5ce341f2015-09-18 09:04:43 -0700238
239
240
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000241#define DEFINE_int32(name, defaultValue, helpString) \
242int32_t FLAGS_##name; \
fmalita523beb72015-06-10 10:46:50 -0700243SK_UNUSED static bool unused_##name = SkFlagInfo::CreateIntFlag(TO_STRING(name), \
244 &FLAGS_##name, \
245 defaultValue, \
246 helpString)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000247
robertphillips5ce341f2015-09-18 09:04:43 -0700248#define DEFINE_int32_2(name, shortName, defaultValue, helpString) \
249int32_t FLAGS_##name; \
250SK_UNUSED static bool unused_##name = SkFlagInfo::CreateIntFlag(TO_STRING(name), \
251 TO_STRING(shortName), \
252 &FLAGS_##name, \
253 defaultValue, \
254 helpString)
255
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000256#define DECLARE_int32(name) extern int32_t FLAGS_##name;
257
258#define DEFINE_double(name, defaultValue, helpString) \
259double FLAGS_##name; \
fmalita523beb72015-06-10 10:46:50 -0700260SK_UNUSED static bool unused_##name = SkFlagInfo::CreateDoubleFlag(TO_STRING(name), \
261 &FLAGS_##name, \
262 defaultValue, \
263 helpString)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000264
265#define DECLARE_double(name) extern double FLAGS_##name;
266
267class SkFlagInfo {
268
269public:
270 enum FlagTypes {
271 kBool_FlagType,
272 kString_FlagType,
273 kInt_FlagType,
274 kDouble_FlagType,
275 };
276
scroggo@google.com58104a92013-04-24 19:25:26 +0000277 /**
278 * Each Create<Type>Flag function creates an SkFlagInfo of the specified type. The SkFlagInfo
279 * object is appended to a list, which is deleted when SkCommandLineFlags::Parse is called.
280 * Therefore, each call should be made before the call to ::Parse. They are not intended
281 * to be called directly. Instead, use the macros described above.
282 * @param name Long version (at least 2 characters) of the name of the flag. This name can
283 * be referenced on the command line as "--name" to set the value of this flag.
284 * @param shortName Short version (one character) of the name of the flag. This name can
285 * be referenced on the command line as "-shortName" to set the value of this flag.
286 * @param p<Type> Pointer to a global variable which holds the value set by SkCommandLineFlags.
287 * @param defaultValue The default value of this flag. The variable pointed to by p<Type> will
288 * be set to this value initially. This is also displayed as part of the help output.
289 * @param helpString Explanation of what this flag changes in the program.
290 */
scroggo@google.com09fd4d22013-03-20 14:20:18 +0000291 static bool CreateBoolFlag(const char* name, const char* shortName, bool* pBool,
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000292 bool defaultValue, const char* helpString) {
kkinnunen9ebc3f02015-12-21 23:48:13 -0800293 SkFlagInfo* info = new SkFlagInfo(name, shortName, kBool_FlagType, helpString, nullptr);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000294 info->fBoolValue = pBool;
295 *info->fBoolValue = info->fDefaultBool = defaultValue;
296 return true;
297 }
298
scroggo@google.com58104a92013-04-24 19:25:26 +0000299 /**
300 * See comments for CreateBoolFlag.
301 * @param pStrings Unlike the others, this is a pointer to an array of values.
302 * @param defaultValue Thise default will be parsed so that strings separated by spaces
303 * will be added to pStrings.
304 */
scroggo@google.com09fd4d22013-03-20 14:20:18 +0000305 static bool CreateStringFlag(const char* name, const char* shortName,
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000306 SkCommandLineFlags::StringArray* pStrings,
kkinnunen9ebc3f02015-12-21 23:48:13 -0800307 const char* defaultValue, const char* helpString,
308 const char* extendedHelpString);
skia.committer@gmail.com075b0892013-03-05 07:09:08 +0000309
scroggo@google.com58104a92013-04-24 19:25:26 +0000310 /**
311 * See comments for CreateBoolFlag.
312 */
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000313 static bool CreateIntFlag(const char* name, int32_t* pInt,
314 int32_t defaultValue, const char* helpString) {
kkinnunen9ebc3f02015-12-21 23:48:13 -0800315 SkFlagInfo* info = new SkFlagInfo(name, nullptr, kInt_FlagType, helpString, nullptr);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000316 info->fIntValue = pInt;
317 *info->fIntValue = info->fDefaultInt = defaultValue;
318 return true;
319 }
320
robertphillips5ce341f2015-09-18 09:04:43 -0700321 static bool CreateIntFlag(const char* name, const char* shortName, int32_t* pInt,
322 int32_t defaultValue, const char* helpString) {
kkinnunen9ebc3f02015-12-21 23:48:13 -0800323 SkFlagInfo* info = new SkFlagInfo(name, shortName, kInt_FlagType, helpString, nullptr);
robertphillips5ce341f2015-09-18 09:04:43 -0700324 info->fIntValue = pInt;
325 *info->fIntValue = info->fDefaultInt = defaultValue;
326 return true;
327 }
328
scroggo@google.com58104a92013-04-24 19:25:26 +0000329 /**
330 * See comments for CreateBoolFlag.
331 */
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000332 static bool CreateDoubleFlag(const char* name, double* pDouble,
333 double defaultValue, const char* helpString) {
kkinnunen9ebc3f02015-12-21 23:48:13 -0800334 SkFlagInfo* info = new SkFlagInfo(name, nullptr, kDouble_FlagType, helpString, nullptr);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000335 info->fDoubleValue = pDouble;
336 *info->fDoubleValue = info->fDefaultDouble = defaultValue;
337 return true;
338 }
339
340 /**
scroggo@google.com5dc4ca12013-03-21 13:10:59 +0000341 * Returns true if the string matches this flag.
342 * For a boolean flag, also sets the value, since a boolean flag can be set in a number of ways
343 * without looking at the following string:
344 * --name
345 * --noname
346 * --name=true
347 * --name=false
348 * --name=1
349 * --name=0
350 * --name=TRUE
351 * --name=FALSE
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000352 */
scroggo@google.com5dc4ca12013-03-21 13:10:59 +0000353 bool match(const char* string);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000354
355 FlagTypes getFlagType() const { return fFlagType; }
356
357 void resetStrings() {
358 if (kString_FlagType == fFlagType) {
359 fStrings->reset();
360 } else {
mtklein@google.com330313a2013-08-22 15:37:26 +0000361 SkDEBUGFAIL("Can only call resetStrings on kString_FlagType");
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000362 }
363 }
364
365 void append(const char* string) {
366 if (kString_FlagType == fFlagType) {
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000367 fStrings->append(string);
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000368 } else {
mtklein@google.com330313a2013-08-22 15:37:26 +0000369 SkDEBUGFAIL("Can only append to kString_FlagType");
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000370 }
371 }
372
373 void setInt(int32_t value) {
374 if (kInt_FlagType == fFlagType) {
375 *fIntValue = value;
376 } else {
mtklein@google.com330313a2013-08-22 15:37:26 +0000377 SkDEBUGFAIL("Can only call setInt on kInt_FlagType");
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000378 }
379 }
380
381 void setDouble(double value) {
382 if (kDouble_FlagType == fFlagType) {
383 *fDoubleValue = value;
384 } else {
mtklein@google.com330313a2013-08-22 15:37:26 +0000385 SkDEBUGFAIL("Can only call setDouble on kDouble_FlagType");
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000386 }
387 }
388
scroggo@google.com5dc4ca12013-03-21 13:10:59 +0000389 void setBool(bool value) {
390 if (kBool_FlagType == fFlagType) {
391 *fBoolValue = value;
392 } else {
mtklein@google.com330313a2013-08-22 15:37:26 +0000393 SkDEBUGFAIL("Can only call setBool on kBool_FlagType");
scroggo@google.com5dc4ca12013-03-21 13:10:59 +0000394 }
395 }
396
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000397 SkFlagInfo* next() { return fNext; }
398
399 const SkString& name() const { return fName; }
400
scroggo@google.com8366df02013-03-20 19:50:41 +0000401 const SkString& shortName() const { return fShortName; }
402
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000403 const SkString& help() const { return fHelpString; }
kkinnunen9ebc3f02015-12-21 23:48:13 -0800404 const SkString& extendedHelp() const { return fExtendedHelpString; }
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000405
406 SkString defaultValue() const {
407 SkString result;
408 switch (fFlagType) {
409 case SkFlagInfo::kBool_FlagType:
410 result.printf("%s", fDefaultBool ? "true" : "false");
411 break;
412 case SkFlagInfo::kString_FlagType:
413 return fDefaultString;
414 case SkFlagInfo::kInt_FlagType:
415 result.printf("%i", fDefaultInt);
416 break;
417 case SkFlagInfo::kDouble_FlagType:
418 result.printf("%2.2f", fDefaultDouble);
419 break;
420 default:
mtklein@google.com330313a2013-08-22 15:37:26 +0000421 SkDEBUGFAIL("Invalid flag type");
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000422 }
423 return result;
424 }
425
426 SkString typeAsString() const {
427 switch (fFlagType) {
428 case SkFlagInfo::kBool_FlagType:
429 return SkString("bool");
430 case SkFlagInfo::kString_FlagType:
431 return SkString("string");
432 case SkFlagInfo::kInt_FlagType:
433 return SkString("int");
434 case SkFlagInfo::kDouble_FlagType:
435 return SkString("double");
436 default:
mtklein@google.com330313a2013-08-22 15:37:26 +0000437 SkDEBUGFAIL("Invalid flag type");
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000438 return SkString();
439 }
440 }
441
442private:
kkinnunen9ebc3f02015-12-21 23:48:13 -0800443 SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const char* helpString,
444 const char* extendedHelpString)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000445 : fName(name)
scroggo@google.com604e0c22013-04-09 21:25:46 +0000446 , fShortName(shortName)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000447 , fFlagType(type)
448 , fHelpString(helpString)
kkinnunen9ebc3f02015-12-21 23:48:13 -0800449 , fExtendedHelpString(extendedHelpString)
halcanary96fcdcc2015-08-27 07:41:13 -0700450 , fBoolValue(nullptr)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000451 , fDefaultBool(false)
halcanary96fcdcc2015-08-27 07:41:13 -0700452 , fIntValue(nullptr)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000453 , fDefaultInt(0)
halcanary96fcdcc2015-08-27 07:41:13 -0700454 , fDoubleValue(nullptr)
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000455 , fDefaultDouble(0)
halcanary96fcdcc2015-08-27 07:41:13 -0700456 , fStrings(nullptr) {
scroggo@google.comd9ba9a02013-03-21 19:43:15 +0000457 fNext = SkCommandLineFlags::gHead;
458 SkCommandLineFlags::gHead = this;
bsalomon49f085d2014-09-05 13:34:00 -0700459 SkASSERT(name && strlen(name) > 1);
halcanary96fcdcc2015-08-27 07:41:13 -0700460 SkASSERT(nullptr == shortName || 1 == strlen(shortName));
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000461 }
scroggo@google.com58104a92013-04-24 19:25:26 +0000462
463 /**
464 * Set a StringArray to hold the values stored in defaultStrings.
465 * @param array The StringArray to modify.
466 * @param defaultStrings Space separated list of strings that should be inserted into array
467 * individually.
468 */
469 static void SetDefaultStrings(SkCommandLineFlags::StringArray* array,
470 const char* defaultStrings);
471
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000472 // Name of the flag, without initial dashes
473 SkString fName;
scroggo@google.com09fd4d22013-03-20 14:20:18 +0000474 SkString fShortName;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000475 FlagTypes fFlagType;
476 SkString fHelpString;
kkinnunen9ebc3f02015-12-21 23:48:13 -0800477 SkString fExtendedHelpString;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000478 bool* fBoolValue;
479 bool fDefaultBool;
480 int32_t* fIntValue;
481 int32_t fDefaultInt;
482 double* fDoubleValue;
483 double fDefaultDouble;
scroggo@google.comb7dbf632013-04-23 15:38:09 +0000484 SkCommandLineFlags::StringArray* fStrings;
scroggo@google.com161e1ba2013-03-04 16:41:06 +0000485 // Both for the help string and in case fStrings is empty.
486 SkString fDefaultString;
487
488 // In order to keep a linked list.
489 SkFlagInfo* fNext;
490};
scroggo@google.comd9ba9a02013-03-21 19:43:15 +0000491#endif // SK_COMMAND_LINE_FLAGS_H