NAME

Text::KDL::XS::Value - A typed KDL scalar value

SYNOPSIS

if    ($v->is_null)   { ... }
elsif ($v->is_bool)   { ... if $v->as_perl }
elsif ($v->is_number) {
    if ($v->kind eq 'string') {
        # arbitrary-precision; preserved verbatim
        use Math::BigInt;
        my $big = Math::BigInt->new($v->as_string);
    } else {
        my $n = $v->as_number;
    }
}
elsif ($v->is_string) { my $s = $v->as_string }

DESCRIPTION

Represents a single KDL value (argument or property value) with full fidelity to ckdl's value model. KDL numbers may be integers, floats, or arbitrary-precision values represented as strings; this class preserves the distinction via "kind".

METHODS

type - 'null', 'bool', 'number', or 'string'
kind - only for numbers: 'integer', 'float', 'string'
value - the raw underlying scalar (as ckdl produced it). For booleans this is 1/0; for arbitrary-precision numbers it is the verbatim string form. For most consumers, as_perl is more convenient.
type_annotation - KDL type tag (e.g. u32) or undef
is_null, is_bool, is_number, is_string
as_number - numeric coercion (returns the original string for arbitrary-precision integers; pass to Math::BigInt if needed).
as_string - string coercion ("true"/"false" for booleans, undef for null).
as_perl - best-effort native Perl scalar: undef for null, 1/0 for bool, IV/NV/string for numbers, PV for strings.