OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
9 #include "SkTDArray.h" | 9 #include "SkTDArray.h" |
10 #include "SkTSort.h" | 10 #include "SkTSort.h" |
11 | 11 |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 | 13 |
14 DEFINE_bool(undefok, false, "Silently ignore unknown flags instead of crashing."
); | 14 DEFINE_bool(undefok, false, "Silently ignore unknown flags instead of crashing."
); |
15 | 15 |
16 template <typename T> static void ignore_result(const T&) {} | 16 template <typename T> static void ignore_result(const T&) {} |
17 | 17 |
18 bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, | 18 bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, |
19 SkCommandLineFlags::StringArray* pStrings, | 19 SkCommandLineFlags::StringArray* pStrings, |
20 const char* defaultValue, const char* helpStri
ng) { | 20 const char* defaultValue, const char* helpStri
ng) { |
21 SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType
, helpString)); | 21 SkFlagInfo* info = new SkFlagInfo(name, shortName, kString_FlagType, helpStr
ing); |
22 info->fDefaultString.set(defaultValue); | 22 info->fDefaultString.set(defaultValue); |
23 | 23 |
24 info->fStrings = pStrings; | 24 info->fStrings = pStrings; |
25 SetDefaultStrings(pStrings, defaultValue); | 25 SetDefaultStrings(pStrings, defaultValue); |
26 return true; | 26 return true; |
27 } | 27 } |
28 | 28 |
29 void SkFlagInfo::SetDefaultStrings(SkCommandLineFlags::StringArray* pStrings, | 29 void SkFlagInfo::SetDefaultStrings(SkCommandLineFlags::StringArray* pStrings, |
30 const char* defaultValue) { | 30 const char* defaultValue) { |
31 pStrings->reset(); | 31 pStrings->reset(); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 327 } |
328 } | 328 } |
329 } | 329 } |
330 } | 330 } |
331 // Since all of the flags have been set, release the memory used by each | 331 // Since all of the flags have been set, release the memory used by each |
332 // flag. FLAGS_x can still be used after this. | 332 // flag. FLAGS_x can still be used after this. |
333 SkFlagInfo* flag = gHead; | 333 SkFlagInfo* flag = gHead; |
334 gHead = NULL; | 334 gHead = NULL; |
335 while (flag != NULL) { | 335 while (flag != NULL) { |
336 SkFlagInfo* next = flag->next(); | 336 SkFlagInfo* next = flag->next(); |
337 SkDELETE(flag); | 337 delete flag; |
338 flag = next; | 338 flag = next; |
339 } | 339 } |
340 if (helpPrinted) { | 340 if (helpPrinted) { |
341 exit(0); | 341 exit(0); |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 namespace { | 345 namespace { |
346 | 346 |
347 template <typename Strings> | 347 template <typename Strings> |
(...skipping 29 matching lines...) Expand all Loading... |
377 } | 377 } |
378 | 378 |
379 } // namespace | 379 } // namespace |
380 | 380 |
381 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const
char* name) { | 381 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const
char* name) { |
382 return ShouldSkipImpl(strings, name); | 382 return ShouldSkipImpl(strings, name); |
383 } | 383 } |
384 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name
) { | 384 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name
) { |
385 return ShouldSkipImpl(strings, name); | 385 return ShouldSkipImpl(strings, name); |
386 } | 386 } |
OLD | NEW |