Skip to content
KvConfigGetI64

KvConfigGetI64

Description

Parse and fetch a signed 64-bit integer config value.

Parameters

Name Direction Description
cfg in,out Parsed config.
key in Lookup key. Prefer Str *; Zstr accepted.
value out Parsed integer.

Success

true if key exists and value is a valid integer.

Failure

false

Usage example (Cross-references)

Usage examples (Cross-references)
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 2);
        result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);
        result = result && KvConfigGetI64(&cfg, "b", &b) && (b == 2);
        result = result && (MapPairCount(&cfg) == 2);
        result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);
        result = result && KvConfigGetI64(&cfg, "b", &b) && (b == 2);
    
        StrDeinit(&src);
        result = result && (StrIterIndex(&si) == StrIterLength(&si));
        result = result && (MapPairCount(&cfg) == 2);
        result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);
        result = result && KvConfigGetI64(&cfg, "b", &b) && (b == 2);
        result = result && (MapPairCount(&cfg) == 2);
        result = result && KvConfigGetI64(&cfg, "a", &a) && (a == 1);
        result = result && KvConfigGetI64(&cfg, "b", &b) && (b == 2);
    
        StrDeinit(&src);
        result = result && KvConfigContains(&cfg, "host");
        result = result && host && StrCmp(host, "localhost") == 0;
        result = result && KvConfigGetI64(&cfg, "port", &port) && (port == 8080);
        result = result && KvConfigGetBool(&cfg, "debug", &debug) && debug;
        (void)KvConfigParse(input, &cfg);
    
        result = result && KvConfigGetI64(&cfg, "workers", &workers) && (workers == 16);
        result = result && KvConfigGetF64(&cfg, "pi", &pi) && (pi > 3.1415 && pi < 3.1416);
        result = result && KvConfigGetBool(&cfg, "enabled", &enabled) && enabled;
        result = result && KvConfigGetBool(&cfg, "disabled", &disabled) && !disabled;
        result = result && !KvConfigGetBool(&cfg, "invalid_bool", &enabled);
        result = result && !KvConfigGetI64(&cfg, "pi", &workers);
        result = result && !KvConfigGetF64(&cfg, "missing", &pi);
        f64  ratio   = 0.0;
        bool en      = false;
        result       = result && KvConfigGetI64(&cfg, &k_workers, &workers) && (workers == 16);
        result       = result && KvConfigGetF64(&cfg, &k_ratio, &ratio) && (ratio > 0.24 && ratio < 0.26);
        result       = result && KvConfigGetBool(&cfg, &k_enabled, &en) && en;
        result = result && host && (StrCmp(host, "localhost") == 0);
        result = result && name && (StrCmp(name, "misra") == 0);
        result = result && KvConfigGetI64(&cfg, "port", &port) && (port == 8080);
    
        StrDeinit(&src);
Last updated on