Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.ion.deser.low_level

pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == typeof(null)));
Deserialize null value
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x1F]).describe; // null.bool
typeof(null) value;
assert(deserializeValueImpl!(typeof(null))(data, value) == IonErrorCode.none);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == bool));
Deserialize boolean value
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x11]).describe;
bool value;
assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (isIntegral!T && !is(T == enum));
Deserialize integral value.
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x21, 0x07]).describe;
int valueS;
uint valueU;

assert(deserializeValueImpl(data, valueS) == IonErrorCode.none);
assert(valueS == 7);

assert(deserializeValueImpl(data, valueU) == IonErrorCode.none);
assert(valueU == 7);

data = IonValue([0x31, 0x07]).describe;

assert(deserializeValueImpl(data, valueS) == IonErrorCode.none);
assert(valueS == -7);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T : BigInt!maxSize64, size_t maxSize64)(IonDescribedValue data, ref T value);
Deserialize big integer value.
Examples:
import mir.ion.value;
import mir.ion.exception;
import mir.bignum.integer;

auto data = IonValue([0x31, 0x07]).describe;
BigInt!256 value; // 256x64

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value.sign);
assert(value.view.unsigned == 7);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (isFloatingPoint!T);
Deserialize floating point value.

Special deserialisation symbol values

nan"
+inf"
-inf

Examples:
import mir.ion.value;
import mir.ion.exception;
// from ion float
auto data = IonValue([0x44, 0x42, 0xAA, 0x40, 0x00]).describe;
double value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == 85.125);

// from ion double
data = IonValue([0x48, 0x40, 0x55, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00]).describe;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == 85.125);

// from ion decimal
data = IonValue([0x56, 0x00, 0xcb, 0x80, 0xbc, 0x2d, 0x86]).describe;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == -12332422e75);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T : Decimal!maxW64bitSize, size_t maxW64bitSize)(IonDescribedValue data, ref T value);
Deserialize decimal value.
Examples:
import mir.ion.value;
import mir.ion.exception;
import mir.bignum.decimal;

Decimal!256 value; // 256x64 bits

// from ion decimal
auto data = IonValue([0x56, 0x00, 0xcb, 0x80, 0xbc, 0x2d, 0x86]).describe;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(cast(double)value == -12332422e75);
pure nothrow @nogc @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == enum));
Deserialize enum value.
Examples:
import mir.ion.value;
import mir.ion.exception;
enum E {a, b, c}

// from ion string
auto data = IonValue([0x81, 'b']).describe;
E value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == E.b);
pure nothrow @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == string) || is(T == const(char)[]) || is(T == char[]));
Deserialize string value.
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x83, 'b', 'a', 'r']).describe;
string value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == "bar");
pure nothrow @safe IonErrorCode deserializeValueImpl(T : SmallString!maxLength, size_t maxLength)(IonDescribedValue data, ref T value);
Deserialize small string value.
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x83, 'b', 'a', 'r']).describe;
string value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == "bar");
pure nothrow @safe IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == char));
Deserialize ascii value from ion string.
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x81, 'b']).describe;
char value;

assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == 'b');
pure nothrow @nogc @trusted IonErrorCode deserializeScopedValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == string) || is(T == const(char)[]) || is(T == char[]));
Deserializes scoped string value. This function does not allocate a new string and just make a raw cast of Ion data.
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([0x83, 'b', 'a', 'r']).describe;
string value;

assert(deserializeScopedValueImpl(data, value) == IonErrorCode.none);
assert(value == "bar");
IonErrorCode deserializeValueImpl(T)(IonDescribedValue data, ref T value)
if (is(T == E[], E) && !isSomeChar!E);
Examples:
import mir.ion.value;
import mir.ion.exception;

auto data = IonValue([
    0xbe, 0x91, 0x00, 0x00, 0x21, 0x0c,
    0x00, 0x00, 0x48, 0x43, 0x0c, 0x6b,
    0xf5, 0x26, 0x34, 0x00, 0x00, 0x00,
    0x00]).describe;

double[] value;
assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == [12, 100e13]);
IonErrorCode deserializeValueImpl(T : SmallArray!(E, maxLength), E, size_t maxLength)(IonDescribedValue data, out T value);
Examples:
import mir.ion.value;
import mir.ion.exception;
import mir.small_array;

auto data = IonValue([
    0xbe, 0x91, 0x00, 0x00, 0x21, 0x0c,
    0x00, 0x00, 0x48, 0x43, 0x0c, 0x6b,
    0xf5, 0x26, 0x34, 0x00, 0x00, 0x00,
    0x00]).describe;

SmallArray!(double, 3) value;
assert(deserializeValueImpl(data, value) == IonErrorCode.none);
assert(value == [12, 100e13]);