#include <SkParse.h>
|
static int | Count (const char str[]) |
|
static int | Count (const char str[], char separator) |
|
static const char * | FindColor (const char str[], SkColor *value) |
|
static const char * | FindHex (const char str[], uint32_t *value) |
|
static const char * | FindMSec (const char str[], SkMSec *value) |
|
static const char * | FindNamedColor (const char str[], size_t len, SkColor *color) |
|
static const char * | FindS32 (const char str[], int32_t *value) |
|
static const char * | FindScalar (const char str[], SkScalar *value) |
|
static const char * | FindScalars (const char str[], SkScalar value[], int count) |
|
static bool | FindBool (const char str[], bool *value) |
|
static int | FindList (const char str[], const char list[]) |
|
Definition at line 20 of file SkParse.h.
◆ Count() [1/2]
int SkParse::Count |
( |
const char |
str[] | ) |
|
|
static |
Definition at line 72 of file SkParse.cpp.
73{
74 char c;
76 goto skipLeading;
77 do {
79 do {
80 if ((c = *str++) == '\0')
81 goto goHome;
82 }
while (
is_sep(c) ==
false);
83skipLeading:
84 do {
85 if ((c = *str++) == '\0')
86 goto goHome;
88 } while (true);
89goHome:
91}
static bool is_sep(int c)
◆ Count() [2/2]
int SkParse::Count |
( |
const char |
str[], |
|
|
char |
separator |
|
) |
| |
|
static |
Definition at line 93 of file SkParse.cpp.
94{
95 char c;
97 goto skipLeading;
98 do {
100 do {
101 if ((c = *str++) == '\0')
102 goto goHome;
103 } while (c != separator);
104skipLeading:
105 do {
106 if ((c = *str++) == '\0')
107 goto goHome;
108 } while (c == separator);
109 } while (true);
110goHome:
112}
◆ FindBool()
bool SkParse::FindBool |
( |
const char |
str[], |
|
|
bool * |
value |
|
) |
| |
|
static |
Definition at line 260 of file SkParse.cpp.
261{
262 static const char* gYes[] = { "yes", "1", "true" };
263 static const char* gNo[] = { "no", "0", "false" };
264
266 {
267 if (value) *
value =
true;
268 return true;
269 }
270 else if (
lookup_str(str, gNo, std::size(gNo)))
271 {
272 if (value) *
value =
false;
273 return true;
274 }
275 return false;
276}
static bool lookup_str(const char str[], const char **table, int count)
◆ FindColor()
const char * SkParse::FindColor |
( |
const char |
str[], |
|
|
SkColor * |
value |
|
) |
| |
|
static |
Definition at line 349 of file SkParseColor.cpp.
349 {
351 if (value[0] == '#') {
352 uint32_t hex;
354
358 if (len == 3 || len == 4) {
360 unsigned r =
nib2byte((hex >> 8) & 0xF);
361 unsigned g =
nib2byte((hex >> 4) & 0xF);
365 } else if (len == 6 || len == 8) {
366 if (len == 6)
367 hex |= oldAlpha << 24;
368 *colorPtr = hex;
370 } else {
371
372 return nullptr;
373 }
374
375
376
377
378
379
380
381
382
383
384
385
386 } else
388}
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkColorGetA(color)
static unsigned nib2byte(unsigned n)
static const char * FindHex(const char str[], uint32_t *value)
static const char * FindNamedColor(const char str[], size_t len, SkColor *color)
◆ FindHex()
const char * SkParse::FindHex |
( |
const char |
str[], |
|
|
uint32_t * |
value |
|
) |
| |
|
static |
Definition at line 114 of file SkParse.cpp.
115{
118
120 return nullptr;
121
122 uint32_t n = 0;
123 int max_digits = 8;
124 int digit;
125
126 while ((digit =
to_hex(*str)) >= 0)
127 {
128 if (--max_digits < 0)
129 return nullptr;
130 n = (n << 4) | digit;
131 str += 1;
132 }
133
134 if (*str == 0 ||
is_ws(*str))
135 {
136 if (value)
138 return str;
139 }
140 return nullptr;
141}
static bool is_hex(int c)
static const char * skip_ws(const char str[])
◆ FindList()
int SkParse::FindList |
( |
const char |
str[], |
|
|
const char |
list[] |
|
) |
| |
|
static |
Definition at line 278 of file SkParse.cpp.
279{
281 int index = 0;
282
283 for (;;)
284 {
285 const char*
end = strchr(list,
',');
286 size_t entryLen;
287
289 entryLen = strlen(list);
290 else
291 entryLen =
end - list;
292
293 if (entryLen == len && memcmp(
target, list, len) == 0)
294 return index;
296 break;
297
299 index += 1;
300 }
301 return -1;
302}
◆ FindMSec()
const char * SkParse::FindMSec |
( |
const char |
str[], |
|
|
SkMSec * |
value |
|
) |
| |
|
static |
Definition at line 177 of file SkParse.cpp.
178{
181
183 if (*str == '-')
184 {
186 str += 1;
187 }
188
190 return nullptr;
191
192 int n = 0;
194 {
195 n = 10*n + *str - '0';
196 str += 1;
197 }
198 int remaining10s = 3;
199 if (*str == '.') {
200 str++;
202 {
203 n = 10*n + *str - '0';
204 str += 1;
205 if (--remaining10s == 0)
206 break;
207 }
208 }
209 while (--remaining10s >= 0)
210 n *= 10;
211 if (value)
213 return str;
214}
static bool is_digit(int c)
static int sign(SkScalar x)
◆ FindNamedColor()
const char * SkParse::FindNamedColor |
( |
const char |
str[], |
|
|
size_t |
len, |
|
|
SkColor * |
color |
|
) |
| |
|
static |
Definition at line 306 of file SkParseColor.cpp.
306 {
307 const auto rec = std::lower_bound(std::begin(
gColorNames),
310 [](
const char*
name,
const char*
key) {
312 });
313
315 return nullptr;
316 }
317
321 }
322
323 return name + strlen(*rec);
324}
static const SkColor gColors[]
#define SkColorSetRGB(r, g, b)
static constexpr const char * gColorNames[]
◆ FindS32()
const char * SkParse::FindS32 |
( |
const char |
str[], |
|
|
int32_t * |
value |
|
) |
| |
|
static |
Definition at line 143 of file SkParse.cpp.
144{
147
149 int64_t maxAbsValue = std::numeric_limits<int>::max();
150 if (*str == '-')
151 {
153 maxAbsValue = -static_cast<int64_t>(std::numeric_limits<int>::min());
154 str += 1;
155 }
156
158 return nullptr;
159 }
160
161 int64_t n = 0;
163 {
164 n = 10*n + *str - '0';
165 if (n > maxAbsValue) {
166 return nullptr;
167 }
168
169 str += 1;
170 }
171 if (value) {
173 }
174 return str;
175}
constexpr int32_t SkToS32(S x)
◆ FindScalar()
const char * SkParse::FindScalar |
( |
const char |
str[], |
|
|
SkScalar * |
value |
|
) |
| |
|
static |
Definition at line 216 of file SkParse.cpp.
216 {
219
220 char* stop;
221 float v = (
float)strtod(str, &stop);
222 if (str == stop) {
223 return nullptr;
224 }
225 if (value) {
227 }
228 return stop;
229}
◆ FindScalars()
const char * SkParse::FindScalars |
( |
const char |
str[], |
|
|
SkScalar |
value[], |
|
|
int |
count |
|
) |
| |
|
static |
Definition at line 231 of file SkParse.cpp.
232{
234
236 {
237 for (;;)
238 {
240 if (--
count == 0 || str ==
nullptr)
241 break;
242
243
245 if (value)
247 }
248 }
249 return str;
250}
static const char * skip_sep(const char str[])
static const char * FindScalar(const char str[], SkScalar *value)
The documentation for this class was generated from the following files: