Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: tools/flags/SkCommandLineFlags.cpp

Issue 14366034: Treat default command line argument properly. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: pType -> p<Type> Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/flags/SkCommandLineFlags.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/flags/SkCommandLineFlags.cpp
diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp
index d634edb31100dafa02404bd24502b9ee8f5d1cb7..7420d2643e9391ca904220319d448b88bf6306dc 100644
--- a/tools/flags/SkCommandLineFlags.cpp
+++ b/tools/flags/SkCommandLineFlags.cpp
@@ -8,6 +8,44 @@
#include "SkCommandLineFlags.h"
#include "SkTDArray.h"
+bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName,
+ SkCommandLineFlags::StringArray* pStrings,
+ const char* defaultValue, const char* helpString) {
+ SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType, helpString));
+ info->fDefaultString.set(defaultValue);
+
+ info->fStrings = pStrings;
+ SetDefaultStrings(pStrings, defaultValue);
+ return true;
+}
+
+void SkFlagInfo::SetDefaultStrings(SkCommandLineFlags::StringArray* pStrings,
+ const char* defaultValue) {
+ pStrings->reset();
+ // If default is "", leave the array empty.
+ size_t defaultLength = strlen(defaultValue);
+ if (defaultLength > 0) {
+ const char* const defaultEnd = defaultValue + defaultLength;
+ const char* begin = defaultValue;
+ while (true) {
+ while (begin < defaultEnd && ' ' == *begin) {
+ begin++;
+ }
+ if (begin < defaultEnd) {
+ const char* end = begin + 1;
+ while (end < defaultEnd && ' ' != *end) {
+ end++;
+ }
+ size_t length = end - begin;
+ pStrings->append(begin, length);
+ begin = end + 1;
+ } else {
+ break;
+ }
+ }
+ }
+}
+
static bool string_is_in(const char* target, const char* set[], size_t len) {
for (size_t i = 0; i < len; i++) {
if (0 == strcmp(target, set[i])) {
« no previous file with comments | « tools/flags/SkCommandLineFlags.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698