Value

Value is a MessagePack value representation

Constructors

this
this(Type type)

Constructs a Value with arguments.

this
this(typeof(null) )
Undocumented in source.
this
this(bool value, Type type)
this(ulong value, Type type)
this(long value, Type type)
this(real value, Type type)
this(Value[] value, Type type)
this(Value[Value] value, Type type)
this(ubyte[] value, Type type)

Constructs a Value with arguments.

this
this(string value, Type type)

This is unsafe overload because using cast internally.

Members

Enums

Type
enum Type

MessagePack value type

Functions

opEquals
bool opEquals(Value other)
bool opEquals(T other)

Comparison for equality. @trusted for union.

toHash
hash_t toHash()
Undocumented in source. Be warned that the author may not have intended to support it.
toMsgpack
void toMsgpack(Packer packer)

Special method called by Packer.

Properties

as
T as [@property getter]

Converts value to T type.

as
Args as [@property setter]

Converts to T type.

Unions

Via
union Via

msgpack value representation

Variables

type
Type type;

represents value type

via
Via via;

represents real value

Examples

auto unpacker = StreamingUnpacker(pack(1, 0.1L) ~ pack(true) ~ pack("foobarbaz"));

foreach (unpacked; unpacker) {
    if (unpacked.type == Value.Type.array) {
        foreach (obj; unpacked) {
            switch (obj.type) {
            case Value.Type.unsigned: writeln(obj.as!(uint)); break;
            case Value.Type.floating:            writeln(obj.as!(real)); break;
            defalut:
                throw new Exception("Unknown type");
            }
        }
    } else {
        if (unpacked.type == Value.Type.boolean)
            writeln(unpacked.as!(bool));
        else
            writeln("Message: ", unpacked.as!(string));
    }
}

Meta