MCPcopy Create free account
hub / github.com/FastLED/FastLED / parseInt

Function parseInt

src/fl/stl/charconv.cpp.hpp:253–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253int parseInt(const char *str, fl::size len) {
254 int result = 0;
255 int sign = 1;
256 fl::size pos = 0;
257
258 // Handle empty input
259 if (len == 0) {
260 return 0;
261 }
262
263 // Skip leading whitespace
264 while (pos < len &&
265 (str[pos] == ' ' || str[pos] == '\t' || str[pos] == '\n' ||
266 str[pos] == '\r' || str[pos] == '\f' || str[pos] == '\v')) {
267 pos++;
268 }
269
270 // Handle optional sign
271 if (pos < len && str[pos] == '-') {
272 sign = -1;
273 pos++;
274 } else if (pos < len && str[pos] == '+') {
275 pos++;
276 }
277
278 // Parse digits
279 while (pos < len && str[pos] >= '0' && str[pos] <= '9') {
280 result = result * 10 + (str[pos] - '0');
281 pos++;
282 }
283
284 return sign * result;
285}
286
287int parseInt(const char *str) {
288 // Calculate length manually to avoid strlen dependency

Callers 7

scan_array_lookaheadMethod · 0.70
parse_int_arrayMethod · 0.70
parse_float_arrayMethod · 0.70
on_tokenMethod · 0.70
app.tsFile · 0.50
processUiChangesMethod · 0.50
loadHexFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected