8#ifndef SK_COMMAND_LINE_FLAGS_H
9#define SK_COMMAND_LINE_FLAGS_H
121 static void Parse(
int argc,
const char*
const*
argv);
133 return fStrings[
i].c_str();
144 for (
int i = 0;
i < fStrings.
size();
i++) {
145 if (fStrings[
i].
equals(
string)) {
152 void set(
int i,
const char* str) {
153 if (
i >= fStrings.
size()) {
157 fStrings[
i].set(str);
178 if (found !=
nullptr) {
186 void reset() { fStrings.
clear(); }
188 void append(
const char*
string) { fStrings.
push_back().
set(
string); }
215#define TO_STRING2(s) #s
216#define TO_STRING(s) TO_STRING2(s)
218#define DEFINE_bool(name, defaultValue, helpString) \
220 [[maybe_unused]] static bool unused_##name = SkFlagInfo::CreateBoolFlag( \
221 TO_STRING(name), nullptr, &FLAGS_##name, defaultValue, helpString)
225#define DEFINE_bool2(name, shortName, defaultValue, helpString) \
227 [[maybe_unused]] static bool unused_##name = SkFlagInfo::CreateBoolFlag( \
228 TO_STRING(name), TO_STRING(shortName), &FLAGS_##name, defaultValue, helpString)
230#define DECLARE_bool(name) extern bool FLAGS_##name;
232#define DEFINE_string(name, defaultValue, helpString) \
233 CommandLineFlags::StringArray FLAGS_##name; \
234 [[maybe_unused]] static bool unused_##name = SkFlagInfo::CreateStringFlag( \
235 TO_STRING(name), nullptr, &FLAGS_##name, defaultValue, helpString, nullptr)
236#define DEFINE_extended_string(name, defaultValue, helpString, extendedHelpString) \
237 CommandLineFlags::StringArray FLAGS_##name; \
238 [[maybe_unused]] static bool unused_##name = SkFlagInfo::CreateStringFlag( \
239 TO_STRING(name), nullptr, &FLAGS_##name, defaultValue, helpString, extendedHelpString)
243#define DEFINE_string2(name, shortName, defaultValue, helpString) \
244 CommandLineFlags::StringArray FLAGS_##name; \
245 [[maybe_unused]] static bool unused_##name = SkFlagInfo::CreateStringFlag(TO_STRING(name), \
246 TO_STRING(shortName),\
252#define DECLARE_string(name) extern CommandLineFlags::StringArray FLAGS_##name;
254#define DEFINE_int(name, defaultValue, helpString) \
256 [[maybe_unused]] static bool unused_##name = \
257 SkFlagInfo::CreateIntFlag(TO_STRING(name), &FLAGS_##name, defaultValue, helpString)
259#define DEFINE_int_2(name, shortName, defaultValue, helpString) \
261 [[maybe_unused]] static bool unused_##name = SkFlagInfo::CreateIntFlag( \
262 TO_STRING(name), TO_STRING(shortName), &FLAGS_##name, defaultValue, helpString)
264#define DECLARE_int(name) extern int FLAGS_##name;
266#define DEFINE_double(name, defaultValue, helpString) \
267 double FLAGS_##name; \
268 [[maybe_unused]] static bool unused_##name = \
269 SkFlagInfo::CreateDoubleFlag(TO_STRING(name), &FLAGS_##name, defaultValue, helpString)
271#define DECLARE_double(name) extern double FLAGS_##name;
300 const char* helpString) {
302 info->fBoolValue = pBool;
317 const char* helpString,
318 const char* extendedHelpString);
326 const char* helpString) {
328 info->fIntValue = pInt;
337 const char* helpString) {
339 info->fIntValue = pInt;
350 const char* helpString) {
352 info->fDoubleValue = pDouble;
370 bool match(
const char*
string);
378 SkDEBUGFAIL(
"Can only call resetStrings on kString_FlagType");
384 fStrings->append(
string);
386 SkDEBUGFAIL(
"Can only append to kString_FlagType");
394 SkDEBUGFAIL(
"Can only call setInt on kInt_FlagType");
400 *fDoubleValue =
value;
402 SkDEBUGFAIL(
"Can only call setDouble on kDouble_FlagType");
410 SkDEBUGFAIL(
"Can only call setBool on kBool_FlagType");
427 result.printf(
"%s", fDefaultBool ?
"true" :
"false");
451 const char* helpString,
452 const char* extendedHelpString)
456 , fHelpString(helpString)
457 , fExtendedHelpString(extendedHelpString)
458 , fBoolValue(nullptr)
459 , fDefaultBool(
false)
462 , fDoubleValue(nullptr)
464 , fStrings(nullptr) {
465 fNext = CommandLineFlags::gHead;
466 CommandLineFlags::gHead =
this;
489 double* fDoubleValue;
490 double fDefaultDouble;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SkDEBUGFAIL(message)
bool equals(SkDrawable *a, SkDrawable *b)
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
const SkString * begin() const
const char * operator[](int i) const
void set(int i, const char *str)
SkString parseAndValidate(const char *name, const skia_private::THashMap< SkString, E > &possibleValues, E *out) const
bool contains(const char *string) const
StringArray(const skia_private::TArray< SkString > &strings)
const SkString * end() const
static bool ShouldSkip(const SkTDArray< const char * > &strings, const char *name)
static void Parse(int argc, const char *const *argv)
static void SetUsage(const char *usage)
FlagTypes getFlagType() const
static bool CreateIntFlag(const char *name, const char *shortName, int *pInt, int defaultValue, const char *helpString)
void append(const char *string)
const SkString & name() const
static bool CreateIntFlag(const char *name, int *pInt, int defaultValue, const char *helpString)
const SkString & shortName() const
static bool CreateStringFlag(const char *name, const char *shortName, CommandLineFlags::StringArray *pStrings, const char *defaultValue, const char *helpString, const char *extendedHelpString)
static bool CreateBoolFlag(const char *name, const char *shortName, bool *pBool, bool defaultValue, const char *helpString)
const SkString & help() const
static bool CreateDoubleFlag(const char *name, double *pDouble, double defaultValue, const char *helpString)
bool match(const char *string)
SkString typeAsString() const
void setDouble(double value)
SkString defaultValue() const
const SkString & extendedHelp() const
void set(const SkString &src)
V * find(const K &key) const
DEF_SWITCHES_START aot vmservice shared library name
static void usage(char *argv0)