StrParseConfig
Description
Configuration for parsing
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Convert.h:39:
bool trim_space; ///< Trim leading/trailing whitespace
u8 base; ///< Base for integers (0 = auto-detect)
} StrParseConfig;
/// Default configurations
- In
Convert.h:44:
extern const StrIntFormat STR_INT_DEFAULT;
extern const StrFloatFormat STR_FLOAT_DEFAULT;
extern const StrParseConfig STR_PARSE_DEFAULT;
///
- In
Convert.h:109:
/// TAGS: Str, Convert, U64
///
bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config);
///
- In
Convert.h:123:
/// TAGS: Str, Convert, I64
///
bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config);
///
- In
Convert.h:137:
/// TAGS: Str, Convert, F64
///
bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config);
- In
Io.c:3226:
);
u64 value;
StrParseConfig config = {.base = 16};
if (!StrToU64(&hex_str, &value, &config)) {
LOG_ERROR("Failed to parse hex value");- In
Io.c:3267:
);
u64 value;
StrParseConfig config = {.base = 8};
if (!StrToU64(&oct_str, &value, &config)) {
LOG_ERROR("Failed to parse octal value");- In
Str.c:862:
}
bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:949:
}
bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:1009:
}
bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:1165:
{.precision = 6, .force_sci = false, .uppercase = false, .trim_zeros = false, .always_sign = false};
const StrParseConfig STR_PARSE_DEFAULT = {.strict = false, .trim_space = true, .base = 0};- In
Convert.c:253:
StrDeinit(&s);
s = StrInitFromZstr("ABCD", &alloc); // No 0x prefix when base is explicitly 16
StrParseConfig config = {.base = 16};
success = StrToU64(&s, &value, &config);
result = result && (success && value == 0xABCD);- In
Convert.c:510:
// For bases with prefixes, use auto-detect. For others, use explicit base parsing
StrParseConfig parse_config = {.base = base};
bool success = StrToU64(&s, &recovered, config.use_prefix ? NULL : &parse_config);
result = result && success && (recovered == base);- In
Convert.c:570:
Str test_str = StrInitFromZstr(prefix_tests[i].input, &alloc);
u64 value = 0;
StrParseConfig config = {.base = prefix_tests[i].base};
bool success = StrToU64(&test_str, &value, prefix_tests[i].base == 0 ? NULL : &config);
result = result && success && (value == prefix_tests[i].expected);- In
Convert.c:639:
StrFromU64(&s, large_value, &config);
u64 recovered = 0;
StrParseConfig pconfig = {.base = base};
bool success = StrToU64(&s, &recovered, &pconfig); // Can now use explicit base with prefixes
result = result && success && (recovered == large_value);- In
Convert.c:671:
// Test StrToU64 round-trip
u64 recovered = 0;
StrParseConfig parse_config = {.base = base};
bool success = StrToU64(&s, &recovered, &parse_config);- In
Convert.c:687:
u64 recovered = 0;
StrParseConfig parse_config = {.base = base};
bool success = StrToU64(&s, &recovered, &parse_config);- In
Convert.c:706:
u64 recovered = 0;
StrParseConfig parse_config = {.base = base};
bool success = StrToU64(&s, &recovered, &parse_config);- In
Convert.c:1035:
Str s = StrInitFromZstr("5 ", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};
bool ok = StrToF64(&s, &value, &config);
bool pass = ok && F64Abs(value - 5.0) < 1e-9;- In
Convert.c:1050:
Str s = StrInitFromZstr("5 ", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};
bool ok = StrToF64(&s, &value, &config);
bool pass = ok && F64Abs(value - 5.0) < 1e-9;- In
Convert.c:1065:
Str s = StrInitFromZstr("5", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};
bool ok = StrToF64(&s, &value, &config);
bool pass = ok && F64Abs(value - 5.0) < 1e-9;- In
Convert.c:1079:
Str s = StrInitFromZstr("42", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};
bool ok = StrToF64(&s, &value, &config);
bool pass = ok && F64Abs(value - 42.0) < 1e-9;- In
Convert.c:1100:
Str s = StrInitFromZstr("5", &alloc);
u64 value = 0;
StrParseConfig config = {.base = 99};
bool ok = StrToU64(&s, &value, &config);
bool result = (!ok);- In
Convert.c:1118:
Str s = StrInitFromZstr("ff", &alloc);
u64 value = 0;
StrParseConfig config = {.base = 16};
bool ok = StrToU64(&s, &value, &config);
bool result = (ok && value == 255);- In
Convert.c:1239:
Str s = StrInitFromZstr("42 ", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};
bool ok = StrToU64(&s, &value, &config);
bool result = (ok && value == 42);- In
Convert.c:1257:
Str s = StrInitFromZstr("42 ", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};
bool ok = StrToU64(&s, &value, &config);
bool result = (ok && value == 42);- In
Convert.c:1275:
Str s = StrInitFromZstr("42x", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};
bool ok = StrToU64(&s, &value, &config);
bool result = (!ok);- In
Convert.c:1293:
Str s = StrInitFromZstr("42", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};
bool ok = StrToU64(&s, &value, &config);
bool result = (ok && value == 42);- In
Convert.c:1310:
Str bad = {0}; // zeroed magic: ValidateStr must LOG_FATAL
u64 value = 0;
StrParseConfig config = {.base = 10};
StrToU64(&bad, &value, &config);- In
Convert.c:1562:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1577:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x5", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1592:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x5", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1605:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0b1", &alloc);
StrParseConfig cfg = {.base = 2};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1619:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0b1", &alloc);
StrParseConfig cfg = {.base = 2};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1632:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0o7", &alloc);
StrParseConfig cfg = {.base = 8};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1645:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0O7", &alloc);
StrParseConfig cfg = {.base = 8};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1658:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0o7", &alloc);
StrParseConfig cfg = {.base = 8};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1671:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1684:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0X1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1697:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;
bool ok = StrToU64(&s, &out, &cfg);- In
Convert.c:1824:
Str s = StrInitFromZstr("2", &alloc);
u64 value = 999; // sentinel
StrParseConfig config = {.base = 2};
bool success = StrToU64(&s, &value, &config);
// Real code: '2' is invalid in base 2 -> parse fails. The mutant accepts
- In
Convert.c:2080:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0B101", &alloc);
StrParseConfig config = {.base = 2};
u64 value = 0;
bool ok = StrToU64(&s, &value, &config);
Last updated on