FastLED
3.9.15
Loading...
Searching...
No Matches
◆
operator()()
[7/13]
void
fl::IntConversionVisitor
< int64_t >::operator()
(
const
fl::string
&
str
)
inline
Definition at line
387
of file
json.h
.
389
{
390
// NEW INSTRUCTIONS: AUTO CONVERT STRING TO INT
391
// Try to parse the string as an integer using FastLED's StringFormatter
392
// Validate by checking if string contains only digits (and optional +/- sign)
393
bool
isValidInt
=
true
;
394
fl::size
startPos
= 0;
395
396
// Check for sign
397
if
(
str
.length() > 0 && (
str
[0] ==
'+'
||
str
[0] ==
'-'
)) {
398
startPos
= 1;
399
}
400
401
// Check that all remaining characters are digits
402
for
(
fl::size
i
=
startPos
;
i
<
str
.length();
i
++) {
403
if
(!
StringFormatter::isDigit
(
str
[
i
])) {
404
isValidInt
=
false
;
405
break
;
406
}
407
}
408
409
// If it looks like a valid integer, try to parse it
410
if
(
isValidInt
&&
str
.length() > 0) {
411
int
parsed
=
StringFormatter::parseInt
(
str
.c_str(),
str
.length());
412
result
=
static_cast<
int64_t
>
(
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 Sat Sep 20 2025 20:42:22 for FastLED by
1.13.2