FastLED
3.9.15
Loading...
Searching...
No Matches
◆
operator()()
[6/13]
void
fl::IntConversionVisitor
< int64_t >::operator()
(
const
fl::string
&
str
)
inline
Definition at line
330
of file
json.h
.
332
{
333
// NEW INSTRUCTIONS: AUTO CONVERT STRING TO INT
334
// Try to parse the string as an integer using FastLED's StringFormatter
335
// Validate by checking if string contains only digits (and optional +/- sign)
336
bool
isValidInt
=
true
;
337
fl::size
startPos
= 0;
338
339
// Check for sign
340
if
(
str
.length() > 0 && (
str
[0] ==
'+'
||
str
[0] ==
'-'
)) {
341
startPos
= 1;
342
}
343
344
// Check that all remaining characters are digits
345
for
(
fl::size
i
=
startPos
;
i
<
str
.length();
i
++) {
346
if
(!
StringFormatter::isDigit
(
str
[
i
])) {
347
isValidInt
=
false
;
348
break
;
349
}
350
}
351
352
// If it looks like a valid integer, try to parse it
353
if
(
isValidInt
&&
str
.length() > 0) {
354
int
parsed
=
StringFormatter::parseInt
(
str
.c_str(),
str
.length());
355
result
=
static_cast<
IntType
>
(
parsed
);
fl::StringFormatter::parseInt
static int parseInt(const char *str, fl::size len)
Definition
str.cpp:300
fl::IntConversionVisitor< int64_t >::result
fl::optional< int64_t > result
Definition
json.h:366
fl::IntConversionVisitor
Definition
json.h:281
fl
IntConversionVisitor< int64_t >
Generated on Fri Aug 22 2025 20:59:36 for FastLED by
1.13.2