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 #ifndef SK_COMMAND_LINE_FLAGS_H | 8 #ifndef SK_COMMAND_LINE_FLAGS_H |
9 #define SK_COMMAND_LINE_FLAGS_H | 9 #define SK_COMMAND_LINE_FLAGS_H |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 * Parse. | 101 * Parse. |
102 */ | 102 */ |
103 static void SetUsage(const char* usage); | 103 static void SetUsage(const char* usage); |
104 | 104 |
105 /** | 105 /** |
106 * Call at the beginning of main to parse flags created by DEFINE_x, above. | 106 * Call at the beginning of main to parse flags created by DEFINE_x, above. |
107 * Must only be called once. | 107 * Must only be called once. |
108 */ | 108 */ |
109 static void Parse(int argc, char** argv); | 109 static void Parse(int argc, char** argv); |
110 | 110 |
111 /* Takes a list of the form [~][^]match[$] | |
112 ~ causes a matching test to always be skipped | |
113 ^ requires the start of the test to match | |
114 $ requires the end of the test to match | |
115 ^ and $ requires an exact match | |
116 If a test does not match any list entry, it is skipped unless some list ent
ry starts with ~ | |
117 */ | |
118 static bool ShouldSkip(const SkTDArray<const char*>& strings, const char* na
me); | |
119 | |
120 /** | 111 /** |
121 * Custom class for holding the arguments for a string flag. | 112 * Custom class for holding the arguments for a string flag. |
122 * Publicly only has accessors so the strings cannot be modified. | 113 * Publicly only has accessors so the strings cannot be modified. |
123 */ | 114 */ |
124 class StringArray { | 115 class StringArray { |
125 public: | 116 public: |
126 const char* operator[](int i) const { | 117 const char* operator[](int i) const { |
127 SkASSERT(i >= 0 && i < fStrings.count()); | 118 SkASSERT(i >= 0 && i < fStrings.count()); |
128 return fStrings[i].c_str(); | 119 return fStrings[i].c_str(); |
129 } | 120 } |
(...skipping 13 matching lines...) Expand all Loading... |
143 | 134 |
144 void append(const char* string, size_t length) { | 135 void append(const char* string, size_t length) { |
145 fStrings.push_back().set(string, length); | 136 fStrings.push_back().set(string, length); |
146 } | 137 } |
147 | 138 |
148 SkTArray<SkString> fStrings; | 139 SkTArray<SkString> fStrings; |
149 | 140 |
150 friend class SkFlagInfo; | 141 friend class SkFlagInfo; |
151 }; | 142 }; |
152 | 143 |
| 144 /* Takes a list of the form [~][^]match[$] |
| 145 ~ causes a matching test to always be skipped |
| 146 ^ requires the start of the test to match |
| 147 $ requires the end of the test to match |
| 148 ^ and $ requires an exact match |
| 149 If a test does not match any list entry, it is skipped unless some list ent
ry starts with ~ |
| 150 */ |
| 151 static bool ShouldSkip(const SkTDArray<const char*>& strings, const char* na
me); |
| 152 static bool ShouldSkip(const StringArray& strings, const char* name); |
| 153 |
153 private: | 154 private: |
154 static SkFlagInfo* gHead; | 155 static SkFlagInfo* gHead; |
155 static SkString gUsage; | 156 static SkString gUsage; |
156 | 157 |
157 // For access to gHead. | 158 // For access to gHead. |
158 friend class SkFlagInfo; | 159 friend class SkFlagInfo; |
159 }; | 160 }; |
160 | 161 |
161 #define TO_STRING2(s) #s | 162 #define TO_STRING2(s) #s |
162 #define TO_STRING(s) TO_STRING2(s) | 163 #define TO_STRING(s) TO_STRING2(s) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 double* fDoubleValue; | 425 double* fDoubleValue; |
425 double fDefaultDouble; | 426 double fDefaultDouble; |
426 SkCommandLineFlags::StringArray* fStrings; | 427 SkCommandLineFlags::StringArray* fStrings; |
427 // Both for the help string and in case fStrings is empty. | 428 // Both for the help string and in case fStrings is empty. |
428 SkString fDefaultString; | 429 SkString fDefaultString; |
429 | 430 |
430 // In order to keep a linked list. | 431 // In order to keep a linked list. |
431 SkFlagInfo* fNext; | 432 SkFlagInfo* fNext; |
432 }; | 433 }; |
433 #endif // SK_COMMAND_LINE_FLAGS_H | 434 #endif // SK_COMMAND_LINE_FLAGS_H |
OLD | NEW |