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

Side by Side Diff: tools/flags/SkCommandLineFlags.h

Issue 22875037: My clang now doesn't complain about !"foo". (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/PathTest.cpp ('k') | tools/flags/SkCommandLineFlags.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 * --name=FALSE 297 * --name=FALSE
298 */ 298 */
299 bool match(const char* string); 299 bool match(const char* string);
300 300
301 FlagTypes getFlagType() const { return fFlagType; } 301 FlagTypes getFlagType() const { return fFlagType; }
302 302
303 void resetStrings() { 303 void resetStrings() {
304 if (kString_FlagType == fFlagType) { 304 if (kString_FlagType == fFlagType) {
305 fStrings->reset(); 305 fStrings->reset();
306 } else { 306 } else {
307 SkASSERT(!"Can only call resetStrings on kString_FlagType"); 307 SkDEBUGFAIL("Can only call resetStrings on kString_FlagType");
308 } 308 }
309 } 309 }
310 310
311 void append(const char* string) { 311 void append(const char* string) {
312 if (kString_FlagType == fFlagType) { 312 if (kString_FlagType == fFlagType) {
313 fStrings->append(string); 313 fStrings->append(string);
314 } else { 314 } else {
315 SkASSERT(!"Can only append to kString_FlagType"); 315 SkDEBUGFAIL("Can only append to kString_FlagType");
316 } 316 }
317 } 317 }
318 318
319 void setInt(int32_t value) { 319 void setInt(int32_t value) {
320 if (kInt_FlagType == fFlagType) { 320 if (kInt_FlagType == fFlagType) {
321 *fIntValue = value; 321 *fIntValue = value;
322 } else { 322 } else {
323 SkASSERT(!"Can only call setInt on kInt_FlagType"); 323 SkDEBUGFAIL("Can only call setInt on kInt_FlagType");
324 } 324 }
325 } 325 }
326 326
327 void setDouble(double value) { 327 void setDouble(double value) {
328 if (kDouble_FlagType == fFlagType) { 328 if (kDouble_FlagType == fFlagType) {
329 *fDoubleValue = value; 329 *fDoubleValue = value;
330 } else { 330 } else {
331 SkASSERT(!"Can only call setDouble on kDouble_FlagType"); 331 SkDEBUGFAIL("Can only call setDouble on kDouble_FlagType");
332 } 332 }
333 } 333 }
334 334
335 void setBool(bool value) { 335 void setBool(bool value) {
336 if (kBool_FlagType == fFlagType) { 336 if (kBool_FlagType == fFlagType) {
337 *fBoolValue = value; 337 *fBoolValue = value;
338 } else { 338 } else {
339 SkASSERT(!"Can only call setBool on kBool_FlagType"); 339 SkDEBUGFAIL("Can only call setBool on kBool_FlagType");
340 } 340 }
341 } 341 }
342 342
343 SkFlagInfo* next() { return fNext; } 343 SkFlagInfo* next() { return fNext; }
344 344
345 const SkString& name() const { return fName; } 345 const SkString& name() const { return fName; }
346 346
347 const SkString& shortName() const { return fShortName; } 347 const SkString& shortName() const { return fShortName; }
348 348
349 const SkString& help() const { return fHelpString; } 349 const SkString& help() const { return fHelpString; }
350 350
351 SkString defaultValue() const { 351 SkString defaultValue() const {
352 SkString result; 352 SkString result;
353 switch (fFlagType) { 353 switch (fFlagType) {
354 case SkFlagInfo::kBool_FlagType: 354 case SkFlagInfo::kBool_FlagType:
355 result.printf("%s", fDefaultBool ? "true" : "false"); 355 result.printf("%s", fDefaultBool ? "true" : "false");
356 break; 356 break;
357 case SkFlagInfo::kString_FlagType: 357 case SkFlagInfo::kString_FlagType:
358 return fDefaultString; 358 return fDefaultString;
359 case SkFlagInfo::kInt_FlagType: 359 case SkFlagInfo::kInt_FlagType:
360 result.printf("%i", fDefaultInt); 360 result.printf("%i", fDefaultInt);
361 break; 361 break;
362 case SkFlagInfo::kDouble_FlagType: 362 case SkFlagInfo::kDouble_FlagType:
363 result.printf("%2.2f", fDefaultDouble); 363 result.printf("%2.2f", fDefaultDouble);
364 break; 364 break;
365 default: 365 default:
366 SkASSERT(!"Invalid flag type"); 366 SkDEBUGFAIL("Invalid flag type");
367 } 367 }
368 return result; 368 return result;
369 } 369 }
370 370
371 SkString typeAsString() const { 371 SkString typeAsString() const {
372 switch (fFlagType) { 372 switch (fFlagType) {
373 case SkFlagInfo::kBool_FlagType: 373 case SkFlagInfo::kBool_FlagType:
374 return SkString("bool"); 374 return SkString("bool");
375 case SkFlagInfo::kString_FlagType: 375 case SkFlagInfo::kString_FlagType:
376 return SkString("string"); 376 return SkString("string");
377 case SkFlagInfo::kInt_FlagType: 377 case SkFlagInfo::kInt_FlagType:
378 return SkString("int"); 378 return SkString("int");
379 case SkFlagInfo::kDouble_FlagType: 379 case SkFlagInfo::kDouble_FlagType:
380 return SkString("double"); 380 return SkString("double");
381 default: 381 default:
382 SkASSERT(!"Invalid flag type"); 382 SkDEBUGFAIL("Invalid flag type");
383 return SkString(); 383 return SkString();
384 } 384 }
385 } 385 }
386 386
387 private: 387 private:
388 SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const ch ar* helpString) 388 SkFlagInfo(const char* name, const char* shortName, FlagTypes type, const ch ar* helpString)
389 : fName(name) 389 : fName(name)
390 , fShortName(shortName) 390 , fShortName(shortName)
391 , fFlagType(type) 391 , fFlagType(type)
392 , fHelpString(helpString) 392 , fHelpString(helpString)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 double* fDoubleValue; 424 double* fDoubleValue;
425 double fDefaultDouble; 425 double fDefaultDouble;
426 SkCommandLineFlags::StringArray* fStrings; 426 SkCommandLineFlags::StringArray* fStrings;
427 // Both for the help string and in case fStrings is empty. 427 // Both for the help string and in case fStrings is empty.
428 SkString fDefaultString; 428 SkString fDefaultString;
429 429
430 // In order to keep a linked list. 430 // In order to keep a linked list.
431 SkFlagInfo* fNext; 431 SkFlagInfo* fNext;
432 }; 432 };
433 #endif // SK_COMMAND_LINE_FLAGS_H 433 #endif // SK_COMMAND_LINE_FLAGS_H
OLDNEW
« no previous file with comments | « tests/PathTest.cpp ('k') | tools/flags/SkCommandLineFlags.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698