digitalmars.D.learn - std.container.Array support in msgpack
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (25/25) Sep 27 2014 I'm trying to figure out how to add raw bytes the packed stream
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (3/4) Sep 28 2014 Update: This is achieved by calling stream_.put() which is only
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?
Sep 27 2014
On Saturday, 27 September 2014 at 21:24:14 UTC, Nordlöw wrote:How do I add the leading byte 146?Update: This is achieved by calling stream_.put() which is only allowed in members of PackerImpl.
Sep 28 2014