Call at the beginning of main to parse flags created by DEFINE_x, above. Must only be called once.
215 {
216
217 static bool gOnce;
218 if (gOnce) {
219 SkDebugf(
"Parse should only be called once at the beginning of main!\n");
221 return;
222 }
223 gOnce = true;
224
225 bool helpPrinted = false;
226 bool flagsPrinted = false;
227
228 for (int i = 1; i < argc; i++) {
229 if (0 == strcmp("-h", argv[i]) || 0 == strcmp("--help", argv[i])) {
230
232 for (int j = i + 1; j < argc; j++) {
234 break;
235 }
236 helpFlags.
append(1, &argv[j]);
237 }
238 if (0 == helpFlags.
size()) {
239
241 }
242 if (!flagsPrinted) {
244 flagsPrinted = true;
245 }
246 if (0 == helpFlags.
size()) {
247
251 }
255 if (
flag->extendedHelp().size() > 0) {
256 SkDebugf(
" Use '--help %s' for more information.\n",
257 flag->name().c_str());
258 }
259 }
260 } else {
262 for (
int k = 0; k < helpFlags.
size(); k++) {
263 if (
flag->name().equals(helpFlags[k]) ||
264 flag->shortName().equals(helpFlags[k])) {
267 break;
268 }
269 }
270 }
271 }
272 if (helpFlags.
size() > 0) {
273 SkDebugf(
"Requested help for unrecognized flags:\n");
274 for (
int k = 0; k < helpFlags.
size(); k++) {
276 }
277 }
278 helpPrinted = true;
279 }
280 if (!helpPrinted) {
283 int startI = i;
284 while (
flag !=
nullptr) {
285 if (
flag->match(argv[startI])) {
286 i = startI;
287 if (matchedFlag) {
288
290 } else {
292 }
293 switch (
flag->getFlagType()) {
295
296
298 i++;
301 flag->setBool(value);
302 }
303 }
304 break;
306 flag->resetStrings();
307
308 while (i + 1 < argc) {
310
313 break;
314 }
315 i++;
316 flag->append(argv[i]);
317 }
318 break;
320 i++;
321 flag->setInt(atoi(argv[i]));
322 break;
324 i++;
325 flag->setDouble(atof(argv[i]));
326 break;
328 }
329 }
331 }
332 if (!matchedFlag) {
333#if defined(SK_BUILD_FOR_MAC)
336 i++;
337 } else
338#endif
339 SkDebugf(
"Got unknown flag '%s'. Exiting.\n", argv[i]);
341 }
342 }
343 }
344
345
347 gHead = nullptr;
348 while (
flag !=
nullptr) {
352 }
353 if (helpPrinted) {
355 }
356}
static bool parse_bool_arg(const char *string, bool *result)
static void print_extended_help_for_flag(const SkFlagInfo *flag)
static void ignore_result(const T &)
static void print_help_for_flag(const SkFlagInfo *flag)
static float next(float f)
#define SkDEBUGFAIL(message)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool SkStrStartsWith(const char string[], const char prefixStr[])
void SkTQSort(T *begin, T *end, const C &lessThan)
FlagTypes getFlagType() const
const char * c_str() const
void push_back(const T &v)
void remove(int index, int count=1)
FlutterSemanticsFlag flag