std.container.Array support in msgpack

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 27 14:24:11 PDT 2014


I'm trying to figure out how to add raw bytes the packed stream 
in msgpack-d. My current try is

import std.stdio;
import std.conv: to;
import std.container: Array;
import msgpack;

static void stringArrayPackHandler(E)(ref Packer p,
                                       ref Array!E x)
{
     // p.put(192);
     /* p.packArray(x); */
     foreach (e; x)
         p.pack(e);
}

unittest
{
     registerPackHandler!(Array!string, stringArrayPackHandler);
     Array!string x = ["x", "y"];
     writeln(x.pack);
     writeln(["x", "y"].pack);
}

which outputs

[161, 120, 161, 121]
[146, 161, 120, 161, 121]

How do I add the leading byte 146?


More information about the Digitalmars-d-learn mailing list