#include <CommandLineFlags.h>
|
static bool | CreateBoolFlag (const char *name, const char *shortName, bool *pBool, bool defaultValue, const char *helpString) |
|
static bool | CreateStringFlag (const char *name, const char *shortName, CommandLineFlags::StringArray *pStrings, const char *defaultValue, const char *helpString, const char *extendedHelpString) |
|
static bool | CreateIntFlag (const char *name, int *pInt, int defaultValue, const char *helpString) |
|
static bool | CreateIntFlag (const char *name, const char *shortName, int *pInt, int defaultValue, const char *helpString) |
|
static bool | CreateDoubleFlag (const char *name, double *pDouble, double defaultValue, const char *helpString) |
|
Definition at line 273 of file CommandLineFlags.h.
◆ FlagTypes
Enumerator |
---|
kBool_FlagType | |
kString_FlagType | |
kInt_FlagType | |
kDouble_FlagType | |
Definition at line 275 of file CommandLineFlags.h.
◆ append()
void SkFlagInfo::append |
( |
const char * |
string | ) |
|
|
inline |
Definition at line 382 of file CommandLineFlags.h.
382 {
384 fStrings->append(string);
385 } else {
386 SkDEBUGFAIL(
"Can only append to kString_FlagType");
387 }
388 }
#define SkDEBUGFAIL(message)
◆ CreateBoolFlag()
static bool SkFlagInfo::CreateBoolFlag |
( |
const char * |
name, |
|
|
const char * |
shortName, |
|
|
bool * |
pBool, |
|
|
bool |
defaultValue, |
|
|
const char * |
helpString |
|
) |
| |
|
inlinestatic |
Each Create<Type>Flag function creates an SkFlagInfo of the specified type. The SkFlagInfo object is appended to a list, which is deleted when CommandLineFlags::Parse is called. Therefore, each call should be made before the call to ::Parse. They are not intended to be called directly. Instead, use the macros described above.
- Parameters
-
name | Long version (at least 2 characters) of the name of the flag. This name can be referenced on the command line as "--name" to set the value of this flag. |
shortName | Short version (one character) of the name of the flag. This name can be referenced on the command line as "-shortName" to set the value of this flag. |
p<Type> | Pointer to a global variable which holds the value set by CommandLineFlags. |
defaultValue | The default value of this flag. The variable pointed to by p<Type> will be set to this value initially. This is also displayed as part of the help output. |
helpString | Explanation of what this flag changes in the program. |
Definition at line 296 of file CommandLineFlags.h.
300 {
302 info->fBoolValue = pBool;
304 return true;
305 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
const SkString & name() const
const SkString & shortName() const
SkString defaultValue() const
◆ CreateDoubleFlag()
static bool SkFlagInfo::CreateDoubleFlag |
( |
const char * |
name, |
|
|
double * |
pDouble, |
|
|
double |
defaultValue, |
|
|
const char * |
helpString |
|
) |
| |
|
inlinestatic |
See comments for CreateBoolFlag.
Definition at line 347 of file CommandLineFlags.h.
350 {
352 info->fDoubleValue = pDouble;
354 return true;
355 }
◆ CreateIntFlag() [1/2]
static bool SkFlagInfo::CreateIntFlag |
( |
const char * |
name, |
|
|
const char * |
shortName, |
|
|
int * |
pInt, |
|
|
int |
defaultValue, |
|
|
const char * |
helpString |
|
) |
| |
|
inlinestatic |
◆ CreateIntFlag() [2/2]
static bool SkFlagInfo::CreateIntFlag |
( |
const char * |
name, |
|
|
int * |
pInt, |
|
|
int |
defaultValue, |
|
|
const char * |
helpString |
|
) |
| |
|
inlinestatic |
See comments for CreateBoolFlag.
Definition at line 323 of file CommandLineFlags.h.
326 {
328 info->fIntValue = pInt;
330 return true;
331 }
◆ CreateStringFlag()
bool SkFlagInfo::CreateStringFlag |
( |
const char * |
name, |
|
|
const char * |
shortName, |
|
|
CommandLineFlags::StringArray * |
pStrings, |
|
|
const char * |
defaultValue, |
|
|
const char * |
helpString, |
|
|
const char * |
extendedHelpString |
|
) |
| |
|
static |
See comments for CreateBoolFlag.
- Parameters
-
pStrings | Unlike the others, this is a pointer to an array of values. |
defaultValue | Thise default will be parsed so that strings separated by spaces will be added to pStrings. |
Definition at line 16 of file CommandLineFlags.cpp.
21 {
25
26 info->fStrings = pStrings;
28 return true;
29}
◆ defaultValue()
SkString SkFlagInfo::defaultValue |
( |
| ) |
const |
|
inline |
Definition at line 423 of file CommandLineFlags.h.
423 {
425 switch (fFlagType) {
427 result.printf(
"%s", fDefaultBool ?
"true" :
"false");
428 break;
433 }
435 }
◆ extendedHelp()
const SkString & SkFlagInfo::extendedHelp |
( |
| ) |
const |
|
inline |
◆ getFlagType()
◆ help()
const SkString & SkFlagInfo::help |
( |
| ) |
const |
|
inline |
◆ match()
bool SkFlagInfo::match |
( |
const char * |
string | ) |
|
Returns true if the string matches this flag. For a boolean flag, also sets the value, since a boolean flag can be set in a number of ways without looking at the following string: –name –noname –name=true –name=false –name=1 –name=0 –name=TRUE –name=FALSE
Definition at line 92 of file CommandLineFlags.cpp.
92 {
94 string++;
97 string++;
98
99 compareName = &fName;
100 } else {
101
102 compareName = &fShortName;
103 }
105
106 if (compareName->
equals(
string)) {
107 *fBoolValue = true;
108 return true;
109 }
111 string += 2;
112
113 if (fName.
equals(
string)) {
114 *fBoolValue = false;
115 return true;
116 }
117 return false;
118 }
120 if (equalIndex > 0) {
121
123 if (
flag.equals(*compareName)) {
124
125 string += equalIndex + 1;
127 return true;
128 } else {
129 return false;
130 }
131 }
132 }
133 return compareName->
equals(
string);
134 }
135
136
137 return false;
138}
static bool parse_bool_arg(const char *string, bool *result)
static bool SkStrStartsWith(const char string[], const char prefixStr[])
static int SkStrFind(const char string[], const char substring[])
bool equals(const SkString &) const
FlutterSemanticsFlag flag
◆ name()
const SkString & SkFlagInfo::name |
( |
| ) |
const |
|
inline |
◆ next()
◆ resetStrings()
void SkFlagInfo::resetStrings |
( |
| ) |
|
|
inline |
Definition at line 374 of file CommandLineFlags.h.
374 {
376 fStrings->reset();
377 } else {
378 SkDEBUGFAIL(
"Can only call resetStrings on kString_FlagType");
379 }
380 }
◆ setBool()
void SkFlagInfo::setBool |
( |
bool |
value | ) |
|
|
inline |
◆ setDouble()
void SkFlagInfo::setDouble |
( |
double |
value | ) |
|
|
inline |
◆ setInt()
void SkFlagInfo::setInt |
( |
int |
value | ) |
|
|
inline |
◆ shortName()
const SkString & SkFlagInfo::shortName |
( |
| ) |
const |
|
inline |
◆ typeAsString()
SkString SkFlagInfo::typeAsString |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: