Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Functions
CommandLineFlags.cpp File Reference
#include "include/private/base/SkTDArray.h"
#include "src/base/SkTSort.h"
#include "tools/flags/CommandLineFlags.h"
#include <stdlib.h>

Go to the source code of this file.

Macros

#define LINE_LENGTH   72
 

Functions

template<typename T >
static void ignore_result (const T &)
 
static bool string_is_in (const char *target, const char *set[], size_t len)
 
static bool parse_bool_arg (const char *string, bool *result)
 
static void print_indented (const SkString &text)
 
static void print_help_for_flag (const SkFlagInfo *flag)
 
static void print_extended_help_for_flag (const SkFlagInfo *flag)
 

Macro Definition Documentation

◆ LINE_LENGTH

#define LINE_LENGTH   72

Definition at line 148 of file CommandLineFlags.cpp.

Function Documentation

◆ ignore_result()

template<typename T >
static void ignore_result ( const T )
static

Definition at line 14 of file CommandLineFlags.cpp.

14{}

◆ parse_bool_arg()

static bool parse_bool_arg ( const char *  string,
bool *  result 
)
static

Check to see whether string represents a boolean value.

Parameters
stringC style string to parse.
resultPointer to a boolean which will be set to the value in the string, if the string represents a boolean.
booleanTrue if the string represents a boolean, false otherwise.

Definition at line 77 of file CommandLineFlags.cpp.

77 {
78 static const char* trueValues[] = {"1", "TRUE", "true"};
79 if (string_is_in(string, trueValues, std::size(trueValues))) {
80 *result = true;
81 return true;
82 }
83 static const char* falseValues[] = {"0", "FALSE", "false"};
84 if (string_is_in(string, falseValues, std::size(falseValues))) {
85 *result = false;
86 return true;
87 }
88 SkDebugf("Parameter \"%s\" not supported.\n", string);
89 return false;
90}
static bool string_is_in(const char *target, const char *set[], size_t len)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
GAsyncResult * result

◆ print_extended_help_for_flag()

static void print_extended_help_for_flag ( const SkFlagInfo flag)
static

Definition at line 201 of file CommandLineFlags.cpp.

201 {
203 print_indented(flag->extendedHelp());
204 SkDebugf("\n");
205}
static void print_indented(const SkString &text)
static void print_help_for_flag(const SkFlagInfo *flag)
FlutterSemanticsFlag flag

◆ print_help_for_flag()

static void print_help_for_flag ( const SkFlagInfo flag)
static

Definition at line 186 of file CommandLineFlags.cpp.

186 {
187 SkDebugf(" --%s", flag->name().c_str());
188 const SkString& shortName = flag->shortName();
189 if (shortName.size() > 0) {
190 SkDebugf(" or -%s", shortName.c_str());
191 }
192 SkDebugf(":\ttype: %s", flag->typeAsString().c_str());
193 if (flag->defaultValue().size() > 0) {
194 SkDebugf("\tdefault: %s", flag->defaultValue().c_str());
195 }
196 SkDebugf("\n");
197 const SkString& help = flag->help();
198 print_indented(help);
199 SkDebugf("\n");
200}
size_t size() const
Definition SkString.h:131
const char * c_str() const
Definition SkString.h:133
help
Definition zip.py:79

◆ print_indented()

static void print_indented ( const SkString text)
static

Definition at line 150 of file CommandLineFlags.cpp.

150 {
151 size_t length = text.size();
152 const char* currLine = text.c_str();
153 const char* stop = currLine + length;
154 while (currLine < stop) {
155 int lineBreak = SkStrFind(currLine, "\n");
156 if (lineBreak < 0) {
157 lineBreak = static_cast<int>(strlen(currLine));
158 }
159 if (lineBreak > LINE_LENGTH) {
160 // No line break within line length. Will need to insert one.
161 // Find a space before the line break.
162 int spaceIndex = LINE_LENGTH - 1;
163 while (spaceIndex > 0 && currLine[spaceIndex] != ' ') {
164 spaceIndex--;
165 }
166 int gap;
167 if (0 == spaceIndex) {
168 // No spaces on the entire line. Go ahead and break mid word.
169 spaceIndex = LINE_LENGTH;
170 gap = 0;
171 } else {
172 // Skip the space on the next line
173 gap = 1;
174 }
175 SkDebugf(" %.*s\n", spaceIndex, currLine);
176 currLine += spaceIndex + gap;
177 } else {
178 // the line break is within the limit. Break there.
179 lineBreak++;
180 SkDebugf(" %.*s", lineBreak, currLine);
181 currLine += lineBreak;
182 }
183 }
184}
#define LINE_LENGTH
static int SkStrFind(const char string[], const char substring[])
Definition SkString.h:41
size_t length
std::u16string text

◆ string_is_in()

static bool string_is_in ( const char *  target,
const char *  set[],
size_t  len 
)
static

Definition at line 61 of file CommandLineFlags.cpp.

61 {
62 for (size_t i = 0; i < len; i++) {
63 if (0 == strcmp(target, set[i])) {
64 return true;
65 }
66 }
67 return false;
68}
uint32_t * target