Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

2233 lines (1611 sloc) 63.54 kb
<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>msgpack</title>
<link rel="stylesheet" type="text/css" href="candydoc/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="candydoc/ie56hack.css"><![endif]-->
<script language="JavaScript" src="candydoc/util.js" type="text/javascript"></script>
<script language="JavaScript" src="candydoc/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="candydoc/explorer.js" type="text/javascript"></script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("msgpack");</script>
<table class="content">
<tr><td id="docbody"><h1>msgpack</h1><!-- Generated by Ddoc from src/msgpack.d -->
MessagePack serializer and deserializer implementation.
<br><br>
MessagePack is a binary-based serialization specification.
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=blue>auto</font> data = tuple(<font color=red>"MessagePack!"</font>, [1, 2], <font color=blue>true</font>);
<font color=blue>auto</font> serialized = pack(data);
<font color=green>// ...
</font>
<font color=blue>typeof</font>(data) deserialized;
unpack(serialized, deserialized);
<font color=blue>assert</font>(data == deserialized);
</pre>
<br><br>
<b>See Also:</b><br>
<a href="http://msgpack.org/">The MessagePack Project</a><br>
<a href="http://wiki.msgpack.org/display/MSGPACK/Design+of+Serialization">MessagePack Design concept</a><br>
<a href="http://wiki.msgpack.org/display/MSGPACK/Format+specification">MessagePack data format</a>
<br><br>
<b>License:</b><br>
<a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
<br><br>
<b>Authors:</b><br>
Masahiro Nakagawa<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">struct
<span class="currsymbol">RefBuffer</span>
<script>explorer.outline.addDecl('RefBuffer');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>
<span class="currsymbol">RefBuffer</span>
<script>explorer.outline.addDecl('RefBuffer');</script>
</b>
is a reference stored buffer for more efficient serialization
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=blue>auto</font> packer = packer(<u>RefBuffer</u>(16)); <font color=green>// threshold is 16
</font>
<font color=green>// packs data
</font>
writev(fd, <font color=blue>cast</font>(<font color=blue>void</font>*)packer.buffer.vector.ptr, packer.buffer.vector.length);
</pre>
<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe this(const(ulong) <span class="funcparam">threshold</span>, const(ulong) <span class="funcparam">chunkSize</span> = cast(const(ulong))8192);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Constructs a buffer.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">const(ulong) <span class="funcparam">threshold</span></td>
<td>the <span class="funcparam">threshold</span> of writing value or stores reference.</td></tr>
<tr>
<td nowrap valign="top" style="padding-right: 8px">const(ulong) <span class="funcparam">chunkSize</span></td>
<td>the default size of chunk for allocation.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">nothrow @property @safe ubyte[]
<span class="currsymbol">data</span>
<script>explorer.outline.addDecl('data');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Returns the buffer contents that excluding references.
<br><br>
<b>Returns:</b><br>
the non-contiguous copied contents.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">nothrow @property ref @safe iovec[]
<span class="currsymbol">vector</span>
<script>explorer.outline.addDecl('vector');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Forwards to all buffer contents.
<br><br>
<b>Returns:</b><br>
the array of iovec struct that stores references.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe void
<span class="currsymbol">put</span>
<script>explorer.outline.addDecl('put');</script>
(in ubyte <span class="funcparam">value</span>);
<br>@safe void
<span class="currsymbol">put</span>
<script>explorer.outline.addDecl('put');</script>
(in ubyte[] <span class="funcparam">value</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Writes the argument to buffer and stores the reference of writed content
if the argument size is smaller than threshold,
otherwise stores the reference of argument directly.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">ubyte <span class="funcparam">value</span></td>
<td>the content to write.</td></tr>
</table><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">class
<span class="currsymbol">MessagePackException</span>
<script>explorer.outline.addDecl('MessagePackException');</script>
: object.Exception;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>
<span class="currsymbol">MessagePackException</span>
<script>explorer.outline.addDecl('MessagePackException');</script>
</b>
is a root Exception for MessagePack related operation.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">struct
<span class="currsymbol">Packer</span>
<script>explorer.outline.addDecl('Packer');</script>
(Stream) if (isOutputRange!(Stream,ubyte) &amp;&amp; isOutputRange!(Stream,ubyte[]));
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>
<span class="currsymbol">Packer</span>
<script>explorer.outline.addDecl('Packer');</script>
</b>
is a <b>MessagePack</b>
serializer
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=blue>auto</font> packer = packer(Appender!(<font color=blue>ubyte</font>[])());
packer.packArray(<font color=blue>false</font>, 100, 1e-10, <font color=blue>null</font>);
stdout.rawWrite(packer.buffer.data);
</pre>
<br><br>
<b>NOTE:</b><br>
Current implementation can't deal with a circular reference.
If you try to serialize a object that has circular reference, runtime raises 'Stack Overflow'.<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">this(Stream <span class="funcparam">stream</span>, bool <span class="funcparam">withFieldName</span> = false);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Constructs a packer with <i><span class="funcparam">stream</span></i>.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">Stream <span class="funcparam">stream</span></td>
<td>the <span class="funcparam">stream</span> to write.</td></tr>
<tr>
<td nowrap valign="top" style="padding-right: 8px">bool <span class="funcparam">withFieldName</span></td>
<td>serialize a field name at class or struct</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Stream
<span class="currsymbol">stream</span>
<script>explorer.outline.addDecl('stream');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Forwards to
<span class="currsymbol">stream</span>
<script>explorer.outline.addDecl('stream');</script>
.
<br><br>
<b>Returns:</b><br>
the
<span class="currsymbol">stream</span>
<script>explorer.outline.addDecl('stream');</script>
.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">value</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">value</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">value</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">value</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">value</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Serializes argument and writes to stream.
<br><br>
If the argument is the pointer type, dereferences the pointer and serializes pointed value.
<pre class="d_code"> <font color=blue>int</font> a = 10;
<font color=blue>int</font>* b = &amp;b;
packer.<u>pack</u>(b); <font color=green>// serializes 10, not address of a
</font></pre>
Serializes nil if the argument of nullable type is <b>null</b>.
<br><br>
<b>NOTE:</b><br>
MessagePack doesn't define <font color=blue>real</font> type format.
Don't serialize <font color=blue>real</font> if you communicate with other languages.
Transfer <font color=blue>double</font> serialization if <font color=blue>real</font> on your environment equals <font color=blue>double</font>.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">value</td>
<td>the content to serialize.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">value</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">value</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">array</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">array</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(Types...)(auto ref const Types <span class="funcparam">objects</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Overload for
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(<b>null</b>) for 2.057 or later<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(in T <span class="funcparam">object</span>);
<br>Packer
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(T)(auto ref T <span class="funcparam">object</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Serializes <i>object</i> and writes to stream.
<br><br>
Calling <b>toMsgpack</b>
if <font color=blue>class</font> and <font color=blue>struct</font> implement <b>toMsgpack</b>
method. <b>toMsgpack</b>
signature is:
<pre class="d_code"> <font color=blue>void</font> toMsgpack(Packer)(<font color=blue>ref</font> Packer packer) <font color=blue>const</font>
</pre>
This method serializes all members of T object if <font color=blue>class</font> and <font color=blue>struct</font> don't implement <b>toMsgpack</b>
.
<br><br>
An object that doesn't implement <b>toMsgpack</b>
is serialized to Array type.
<pre class="d_code"> packer.<u>pack</u>(tuple(<font color=blue>true</font>, 1, <font color=red>"Hi!"</font>)) <font color=green>// -&gt; '[true, 1, "Hi!"]', not 'ture, 1, "Hi!"'
</font>
<font color=blue>struct</font> Foo
{
<font color=blue>int</font> num = 10;
string msg = <font color=red>"D!"</font>;
}
packer.<u>pack</u>(Foo()); <font color=green>// -&gt; '[10, "D!"]'
</font>
<font color=blue>class</font> Base
{
<font color=blue>bool</font> flag = <font color=blue>true</font>;
}
<font color=blue>class</font> Derived : Base
{
<font color=blue>double</font> = 0.5f;
}
packer.<u>pack</u>(<font color=blue>new</font> Derived()); <font color=green>// -&gt; '[true, 0.5f]'
</font></pre>
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">object</td>
<td>the content to serialize.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Packer
<span class="currsymbol">packArray</span>
<script>explorer.outline.addDecl('packArray');</script>
(Types...)(auto ref const Types <span class="funcparam">objects</span>);
<br>Packer
<span class="currsymbol">packMap</span>
<script>explorer.outline.addDecl('packMap');</script>
(Types...)(auto ref const Types <span class="funcparam">objects</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Serializes the arguments as container to stream.
<br><br>
<pre class="d_code"> packer.<u>packArray</u>(<font color=blue>true</font>, 1); <font color=green>// -&gt; [true, 1]
</font> packer.packMap(<font color=red>"Hi"</font>, 100); <font color=green>// -&gt; ["Hi":100]
</font></pre>
In packMap, the number of arguments must be even.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">objects</td>
<td>the contents to serialize.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Packer
<span class="currsymbol">beginArray</span>
<script>explorer.outline.addDecl('beginArray');</script>
(in size_t <span class="funcparam">length</span>);
<br>Packer
<span class="currsymbol">beginMap</span>
<script>explorer.outline.addDecl('beginMap');</script>
(in size_t <span class="funcparam">length</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Serializes the type-information to stream.
<br><br>
These methods don't serialize contents.
You need to call pack method to serialize contents at your own risk.
<pre class="d_code"> packer.<u>beginArray</u>(3).pack(<font color=blue>true</font>, 1); <font color=green>// -&gt; [true, 1,
</font>
<font color=green>// other operation
</font>
packer.pack(<font color=red>"Hi!"</font>); <font color=green>// -&gt; [true, 1, "Hi!"]
</font></pre>
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">size_t <span class="funcparam">length</span></td>
<td>the <span class="funcparam">length</span> of container.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Packer!(Stream)
<span class="currsymbol">packer</span>
<script>explorer.outline.addDecl('packer');</script>
(Stream)(Stream <span class="funcparam">stream</span>, bool <span class="funcparam">withFieldName</span> = false);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Helper for <b>Packer</b>
construction.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">stream</td>
<td>the stream to write.</td></tr>
</table><br>
<b>Returns:</b><br>
a <b>Packer</b>
object instantiated and initialized according to the arguments.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">class
<span class="currsymbol">UnpackException</span>
<script>explorer.outline.addDecl('UnpackException');</script>
: msgpack.MessagePackException;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>
<span class="currsymbol">UnpackException</span>
<script>explorer.outline.addDecl('UnpackException');</script>
</b>
is thrown on deserialization failure<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">template
<span class="currsymbol">InternalBuffer</span>
<script>explorer.outline.addDecl('InternalBuffer');</script>
()</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Internal buffer and related operations for Unpacker
<br><br>
Following Unpackers mixin this template. So, Unpacker can use following methods.
<br><br>
<pre class="d_code"> <font color=green>//buffer image:
</font> +-------------------------------------------+
| [object] | [obj | unparsed... | unused... |
+-------------------------------------------+
^ offset
^ current
^ used
^ buffer.length
</pre>
This mixin template is a private.<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">ubyte[]
<span class="currsymbol">buffer</span>
<script>explorer.outline.addDecl('buffer');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Forwards to internal
<span class="currsymbol">buffer</span>
<script>explorer.outline.addDecl('buffer');</script>
.
<br><br>
<b>Returns:</b><br>
the reference of internal
<span class="currsymbol">buffer</span>
<script>explorer.outline.addDecl('buffer');</script>
.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">void
<span class="currsymbol">feed</span>
<script>explorer.outline.addDecl('feed');</script>
(in ubyte[] <span class="funcparam">target</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Fills internal buffer with <i><span class="funcparam">target</span></i>.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">ubyte[] <span class="funcparam">target</span></td>
<td>new serialized buffer to deserialize.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">void
<span class="currsymbol">bufferConsumed</span>
<script>explorer.outline.addDecl('bufferConsumed');</script>
(in size_t <span class="funcparam">size</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Consumes buffer. This method is helper for buffer property.
You must use this method if you write bytes to buffer directly.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">size_t <span class="funcparam">size</span></td>
<td>the number of consuming.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">void
<span class="currsymbol">removeUnparsed</span>
<script>explorer.outline.addDecl('removeUnparsed');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Removes unparsed buffer.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">const size_t
<span class="currsymbol">size</span>
<script>explorer.outline.addDecl('size');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>Returns:</b><br>
the total
<span class="currsymbol">size</span>
<script>explorer.outline.addDecl('size');</script>
including unparsed buffer
<span class="currsymbol">size</span>
<script>explorer.outline.addDecl('size');</script>
.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">const size_t
<span class="currsymbol">parsedSize</span>
<script>explorer.outline.addDecl('parsedSize');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>Returns:</b><br>
the parsed size of buffer.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">const size_t
<span class="currsymbol">unparsedSize</span>
<script>explorer.outline.addDecl('unparsedSize');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>Returns:</b><br>
the unparsed size of buffer.<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">struct
<span class="currsymbol">Unpacker</span>
<script>explorer.outline.addDecl('Unpacker');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>This <b>
<span class="currsymbol">Unpacker</span>
<script>explorer.outline.addDecl('Unpacker');</script>
</b>
is a <b>MessagePack</b>
direct-conversion deserializer
<br><br>
This implementation is suitable for fixed data.
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=green>// serializedData is [10, 0.1, false]
</font> <font color=blue>auto</font> unpacker = <u>Unpacker</u>(serializedData);
<font color=blue>uint</font> n;
<font color=blue>double</font> d;
<font color=blue>bool</font> b;
unpacker.unpackArray(n, d, b);
<font color=green>// using Tuple
</font> Tuple!(<font color=blue>uint</font>, <font color=blue>double</font>, <font color=blue>bool</font>) record;
unpacker.unpack(record); <font color=green>// record is [10, 0.1, false]
</font></pre>
<br><br>
<b>NOTE:</b><br>
<span class="currsymbol">Unpacker</span>
<script>explorer.outline.addDecl('Unpacker');</script>
becomes template struct if Phobos supports truly IO module.<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe this(const(ubyte[]) <span class="funcparam">target</span>, const(ulong) <span class="funcparam">bufferSize</span> = cast(const(ulong))8192);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Constructs a <b>Unpacker</b>
.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">const(ubyte[]) <span class="funcparam">target</span></td>
<td>byte buffer to deserialize</td></tr>
<tr>
<td nowrap valign="top" style="padding-right: 8px">const(ulong) <span class="funcparam">bufferSize</span></td>
<td>size limit of buffer size</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">nothrow @safe void
<span class="currsymbol">clear</span>
<script>explorer.outline.addDecl('clear');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Clears states for next deserialization.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">value</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">value</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">value</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">value</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">value</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(T <span class="funcparam">value</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(Types...)(ref Types <span class="funcparam">objects</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes <i>T</i> object and assigns to <i>value</i>.
<br><br>
If the argument is pointer, dereferences pointer and assigns deserialized value.
<pre class="d_code"> <font color=blue>int</font>* a;
unpacker.<u>unpack</u>(a) <font color=green>// enforce throws Exception because a is null or
</font> <font color=green>// no throw if deserialized value is nil
</font>
<font color=blue>int</font> b; a = &amp;b;
unpacker.<u>unpack</u>(b) <font color=green>// b is deserialized value or
</font> <font color=green>// assigns null if deserialized value is nil
</font></pre>
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">value</td>
<td>the reference of value to assign.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.
<br><br>
<b>Throws:</b><br>
UnpackException when doesn't read from buffer or precision loss occurs and
MessagePackException when <i>T</i> type doesn't match serialized type.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">array</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">array</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes <i>T</i> object and assigns to <i>array</i>.
<br><br>
This is convenient method for array deserialization.
Rollback will be completely successful if you deserialize raw type((u)byte[] or string types).
But, Rollback will be one element(e.g. int) if you deserialize other types(e.g. int[], int[int])
<br><br>
No assign if the length of deserialized object is 0.
<br><br>
In a static array, this method checks the length. Do rollback and throw exception
if length of <i>array</i> is different from length of deserialized object.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">array</td>
<td>the reference of array to assign.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.
<br><br>
<b>Throws:</b><br>
UnpackException when doesn't read from buffer or precision loss occurs and
MessagePackException when <i>T</i> type doesn't match serialized type.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T, Args...)(ref T <span class="funcparam">object</span>, auto ref Args <span class="funcparam">args</span>);
<br>Unpacker
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(T)(ref T <span class="funcparam">object</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes <i>T</i> object and assigns to <i>object</i>.
<br><br>
Calling <b>fromMsgpack</b>
if <font color=blue>class</font> and <font color=blue>struct</font> implement <b>fromMsgpack</b>
method. <b>fromMsgpack</b>
signature is:
<pre class="d_code"> <font color=blue>void</font> fromMsgpack(<font color=blue>ref</font> Unpacker unpacker)
</pre>
Assumes <b>std.typecons.Tuple</b>
or simple struct if <font color=blue>struct</font> doesn't implement <b>fromMsgpack</b>
.
Checks length if <i>T</i> is a <b>std.typecons.Tuple</b>
or simple struct.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">object</td>
<td>the reference of object to assign.</td></tr>
<tr>
<td nowrap valign="top" style="padding-right: 8px">args</td>
<td>the arguments to class constructor(class only).
This is used at new statement if <i>object</i> is <font color=blue><b>null</b></font>.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Unpacker
<span class="currsymbol">unpackArray</span>
<script>explorer.outline.addDecl('unpackArray');</script>
(Types...)(ref Types <span class="funcparam">objects</span>);
<br>Unpacker
<span class="currsymbol">unpackMap</span>
<script>explorer.outline.addDecl('unpackMap');</script>
(Types...)(ref Types <span class="funcparam">objects</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes the container object and assigns to each argument.
<br><br>
These methods check the length. Do rollback if
the length of arguments is different from length of deserialized object.
<br><br>
In unpackMap, the number of arguments must be even.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">objects</td>
<td>the references of object to assign.</td></tr>
</table><br>
<b>Returns:</b><br>
self, i.e. for method chaining.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe size_t
<span class="currsymbol">beginArray</span>
<script>explorer.outline.addDecl('beginArray');</script>
();
<br>@safe size_t
<span class="currsymbol">beginMap</span>
<script>explorer.outline.addDecl('beginMap');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes the type-information of container.
<br><br>
These methods don't deserialize contents.
You need to call unpack method to deserialize contents at your own risk.
<pre class="d_code"> <font color=green>// serialized data is [1, "Hi!"];
</font> <font color=blue>int</font> num;
unpacker.<u>beginArray</u>(2).unpack(num); <font color=green>// num is 1
</font>
<font color=green>// other operation
</font>
string str;
unpacker.unpack(str); <font color=green>// str is "Hi!"
</font></pre>
<br><br>
<b>Returns:</b><br>
the container size.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">int
<span class="currsymbol">scan</span>
<script>explorer.outline.addDecl('scan');</script>
(Types...)(scope int delegate(ref Types) <span class="funcparam">dg</span>);
<br>int
<span class="currsymbol">opApply</span>
<script>explorer.outline.addDecl('opApply');</script>
(Types...)(scope int delegate(ref Types) <span class="funcparam">dg</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Scans an entire buffer and converts each objects.
<br><br>
This method is used for unpacking record-like objects.
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=green>// serialized data is "[1, 2][3, 4][5, 6][...".
</font> <font color=blue>auto</font> unpacker = Unpacker(serializedData);
<font color=blue>foreach</font> (n, d; &amp;unpacker.<u>scan</u>!(<font color=blue>int</font>, <font color=blue>int</font>)) <font color=green>// == "foreach (int n, int d; unpacker)"
</font> writeln(n, d); <font color=green>// 1st loop "1, 2", 2nd loop "3, 4"...
</font></pre>
<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">struct
<span class="currsymbol">Value</span>
<script>explorer.outline.addDecl('Value');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>
<span class="currsymbol">Value</span>
<script>explorer.outline.addDecl('Value');</script>
</b>
is a <b>MessagePack</b>
value representation
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=blue>auto</font> unpacker = StreamingUnpacker(pack(1, 0.1L) ~ pack(<font color=blue>true</font>) ~ pack(<font color=red>"foobarbaz"</font>));
<font color=blue>foreach</font> (unpacked; unpacker) {
<font color=blue>if</font> (unpacked.type == <u>Value</u>.Type.array) {
<font color=blue>foreach</font> (obj; unpacked) {
<font color=blue>switch</font> (obj.type) {
<font color=blue>case</font> <u>Value</u>.Type.unsigned: writeln(obj.as!(<font color=blue>uint</font>)); <font color=blue>break</font>;
<font color=blue>case</font> <u>Value</u>.Type.floating: writeln(obj.as!(<font color=blue>real</font>)); <font color=blue>break</font>;
defalut:
<font color=blue>throw</font> <font color=blue>new</font> Exception(<font color=red>"Unknown type"</font>);
}
}
} <font color=blue>else</font> {
<font color=blue>if</font> (unpacked.type == <u>Value</u>.Type.boolean)
writeln(unpacked.as!(<font color=blue>bool</font>));
<font color=blue>else</font>
writeln(<font color=red>"Message: "</font>, unpacked.as!(string));
}
}
</pre>
<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">enum
<span class="currsymbol">Type</span>
<script>explorer.outline.addDecl('Type');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>MessagePack</b>
value type<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">nil</span>
<script>explorer.outline.addDecl('nil');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<span class="currsymbol">nil</span>
<script>explorer.outline.addDecl('nil');</script>
(<b>null</b> in D)<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">boolean</span>
<script>explorer.outline.addDecl('boolean');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>true</b>, <b>false</b><br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">unsigned</span>
<script>explorer.outline.addDecl('unsigned');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>positive fixnum, uint 8, uint 16, uint 32, uint 64<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">signed</span>
<script>explorer.outline.addDecl('signed');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>negative fixnum, int 8, int 16, int 32, int 64<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">floating</span>
<script>explorer.outline.addDecl('floating');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>float, double, real<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">array</span>
<script>explorer.outline.addDecl('array');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>fix
<span class="currsymbol">array</span>
<script>explorer.outline.addDecl('array');</script>
,
<span class="currsymbol">array</span>
<script>explorer.outline.addDecl('array');</script>
16,
<span class="currsymbol">array</span>
<script>explorer.outline.addDecl('array');</script>
32<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">map</span>
<script>explorer.outline.addDecl('map');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>fix
<span class="currsymbol">map</span>
<script>explorer.outline.addDecl('map');</script>
,
<span class="currsymbol">map</span>
<script>explorer.outline.addDecl('map');</script>
16,
<span class="currsymbol">map</span>
<script>explorer.outline.addDecl('map');</script>
32<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">
<span class="currsymbol">raw</span>
<script>explorer.outline.addDecl('raw');</script>
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>fix
<span class="currsymbol">raw</span>
<script>explorer.outline.addDecl('raw');</script>
,
<span class="currsymbol">raw</span>
<script>explorer.outline.addDecl('raw');</script>
16,
<span class="currsymbol">raw</span>
<script>explorer.outline.addDecl('raw');</script>
32<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">union
<span class="currsymbol">Via</span>
<script>explorer.outline.addDecl('Via');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>msgpack value representation<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">bool
<span class="currsymbol">boolean</span>
<script>explorer.outline.addDecl('boolean');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>corresponding to Type.
<span class="currsymbol">boolean</span>
<script>explorer.outline.addDecl('boolean');</script>
<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">ulong
<span class="currsymbol">uinteger</span>
<script>explorer.outline.addDecl('uinteger');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>corresponding to Type.unsigned<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">long
<span class="currsymbol">integer</span>
<script>explorer.outline.addDecl('integer');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>corresponding to Type.signed<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">real
<span class="currsymbol">floating</span>
<script>explorer.outline.addDecl('floating');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>corresponding to Type.
<span class="currsymbol">floating</span>
<script>explorer.outline.addDecl('floating');</script>
<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Value[]
<span class="currsymbol">array</span>
<script>explorer.outline.addDecl('array');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>corresponding to Type.
<span class="currsymbol">array</span>
<script>explorer.outline.addDecl('array');</script>
<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Value[Value]
<span class="currsymbol">map</span>
<script>explorer.outline.addDecl('map');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>corresponding to Type.
<span class="currsymbol">map</span>
<script>explorer.outline.addDecl('map');</script>
<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">ubyte[]
<span class="currsymbol">raw</span>
<script>explorer.outline.addDecl('raw');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>corresponding to Type.
<span class="currsymbol">raw</span>
<script>explorer.outline.addDecl('raw');</script>
<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Type
<span class="currsymbol">type</span>
<script>explorer.outline.addDecl('type');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>represents value
<span class="currsymbol">type</span>
<script>explorer.outline.addDecl('type');</script>
<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Via
<span class="currsymbol">via</span>
<script>explorer.outline.addDecl('via');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>represents real value<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe this(Type <span class="funcparam">type</span> = cast(Type)0);
<br>@trusted this(bool <span class="funcparam">value</span>, Type <span class="funcparam">type</span> = cast(Type)1);
<br>@trusted this(ulong <span class="funcparam">value</span>, Type <span class="funcparam">type</span> = cast(Type)2);
<br>@trusted this(long <span class="funcparam">value</span>, Type <span class="funcparam">type</span> = cast(Type)3);
<br>@trusted this(real <span class="funcparam">value</span>, Type <span class="funcparam">type</span> = cast(Type)4);
<br>@trusted this(Value[] <span class="funcparam">value</span>, Type <span class="funcparam">type</span> = cast(Type)5);
<br>@trusted this(Value[Value] <span class="funcparam">value</span>, Type <span class="funcparam">type</span> = cast(Type)6);
<br>@trusted this(ubyte[] <span class="funcparam">value</span>, Type <span class="funcparam">type</span> = cast(Type)7);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Constructs a <b>Value</b>
with arguments.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">value</td>
<td>the real content.</td></tr>
<tr>
<td nowrap valign="top" style="padding-right: 8px">Type <span class="funcparam">type</span></td>
<td>the <span class="funcparam">type</span> of value.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T)();
<br>T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T)();
<br>T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T)();
<br>T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T)();
<br>T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T)();
<br>T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T)();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Converts value to <i>T</i> type.
<br><br>
<b>Returns:</b><br>
converted value.
<br><br>
<b>Throws:</b><br>
MessagePackException if type is mismatched.
<br><br>
<b>NOTE:</b><br>
Current implementation uses cast.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T, Args...)(Args <span class="funcparam">args</span>);
<br>T
<span class="currsymbol">as</span>
<script>explorer.outline.addDecl('as');</script>
(T)();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Converts to <i>T</i> type.
<br><br>
Calling <b>fromMsgpack</b>
if <font color=blue>class</font> and <font color=blue>struct</font> implement <b>fromMsgpack</b>
method. <b>fromMsgpack</b>
signature is:
<pre class="d_code"> <font color=blue>void</font> fromMsgpack(Value value)
</pre>
This method assigns converted values to all members of T object if <font color=blue>class</font> and <font color=blue>struct</font> don't implement <b>fromMsgpack</b>
.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">args</td>
<td>arguments to class constructor(class only).</td></tr>
</table><br>
<b>Returns:</b><br>
converted value.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">const void
<span class="currsymbol">toMsgpack</span>
<script>explorer.outline.addDecl('toMsgpack');</script>
(Packer)(ref Packer <span class="funcparam">packer</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Special method called by <b>Packer</b>
.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">packer</td>
<td>a MessagePack serializer.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">const bool
<span class="currsymbol">opEquals</span>
<script>explorer.outline.addDecl('opEquals');</script>
(Tdummy = void)(ref const const(Value) <span class="funcparam">other</span>);
<br>const bool
<span class="currsymbol">opEquals</span>
<script>explorer.outline.addDecl('opEquals');</script>
(T : bool)(in const(T) <span class="funcparam">other</span>);
<br>const bool
<span class="currsymbol">opEquals</span>
<script>explorer.outline.addDecl('opEquals');</script>
(T : ulong)(in const(T) <span class="funcparam">other</span>);
<br>const bool
<span class="currsymbol">opEquals</span>
<script>explorer.outline.addDecl('opEquals');</script>
(T : real)(in const(T) <span class="funcparam">other</span>);
<br>const bool
<span class="currsymbol">opEquals</span>
<script>explorer.outline.addDecl('opEquals');</script>
(T : const(Value[]))(in const(T) <span class="funcparam">other</span>);
<br>const bool
<span class="currsymbol">opEquals</span>
<script>explorer.outline.addDecl('opEquals');</script>
(T : const(Value[Value]))(in const(T) <span class="funcparam">other</span>);
<br>const bool
<span class="currsymbol">opEquals</span>
<script>explorer.outline.addDecl('opEquals');</script>
(T : ubyte[])(in const(T) <span class="funcparam">other</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Comparison for equality. @trusted for union.<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">struct
<span class="currsymbol">Unpacked</span>
<script>explorer.outline.addDecl('Unpacked');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd><b>
<span class="currsymbol">Unpacked</span>
<script>explorer.outline.addDecl('Unpacked');</script>
</b>
is a <b>Range</b>
wrapper for stream deserialization result<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Value
<span class="currsymbol">value</span>
<script>explorer.outline.addDecl('value');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>deserialized
<span class="currsymbol">value</span>
<script>explorer.outline.addDecl('value');</script>
<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe this(ref Value <span class="funcparam">value</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Constructs a <b>Unpacked</b>
with argument.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">Value <span class="funcparam">value</span></td>
<td>a deserialized <span class="funcparam">value</span>.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">const nothrow @property @trusted bool
<span class="currsymbol">empty</span>
<script>explorer.outline.addDecl('empty');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>InputRange primitive operation that checks iteration state.
<br><br>
<b>Returns:</b><br>
<b>true</b> if there are no more elements to be iterated.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@property @trusted size_t
<span class="currsymbol">length</span>
<script>explorer.outline.addDecl('length');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Range primitive operation that returns the
<span class="currsymbol">length</span>
<script>explorer.outline.addDecl('length');</script>
of the range.
<br><br>
<b>Returns:</b><br>
the number of values.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@property ref @trusted Value
<span class="currsymbol">front</span>
<script>explorer.outline.addDecl('front');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>InputRange primitive operation that returns the currently iterated element.
<br><br>
<b>Returns:</b><br>
the deserialized <b>Value</b>
.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@trusted void
<span class="currsymbol">popFront</span>
<script>explorer.outline.addDecl('popFront');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>InputRange primitive operation that advances the range to its next element.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">nothrow ref @trusted Value
<span class="currsymbol">opIndex</span>
<script>explorer.outline.addDecl('opIndex');</script>
(size_t <span class="funcparam">n</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>RandomAccessRange primitive operation.
<br><br>
<b>Returns:</b><br>
the deserialized <b>Value</b>
at <i><span class="funcparam">n</span></i> position.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@trusted Value[]
<span class="currsymbol">opSlice</span>
<script>explorer.outline.addDecl('opSlice');</script>
(size_t <span class="funcparam">from</span>, size_t <span class="funcparam">to</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Returns a slice of the range.
<br><br>
<b>Paramas:</b><br>
<span class="funcparam">from</span> = the start point of slicing.
<span class="funcparam">to</span> = the end point of slicing.
<br><br>
<b>Returns:</b><br>
the slice of Values.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@property @safe Unpacked
<span class="currsymbol">save</span>
<script>explorer.outline.addDecl('save');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Range primitive operation that returns the snapshot.
<br><br>
<b>Returns:</b><br>
the snapshot of this Value.<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">struct
<span class="currsymbol">StreamingUnpacker</span>
<script>explorer.outline.addDecl('StreamingUnpacker');</script>
;
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>This <b>
<span class="currsymbol">StreamingUnpacker</span>
<script>explorer.outline.addDecl('StreamingUnpacker');</script>
</b>
is a <b>MessagePack</b>
streaming deserializer
<br><br>
This implementation enables you to load multiple objects from a stream(like network).
<br><br>
<b>Example:</b><br>
<pre class="d_code"> ...
<font color=blue>auto</font> unpacker = <u>StreamingUnpacker</u>(serializedData);
...
<font color=green>// appends new data to buffer if pre execute() call didn't finish deserialization.
</font> unpacker.feed(newSerializedData);
<font color=blue>while</font> (unpacker.execute()) {
<font color=blue>foreach</font> (obj; unpacker.purge()) {
<font color=green>// do stuff (obj is a Value)
</font> }
}
<font color=blue>if</font> (unpacker.size)
<font color=blue>throw</font> <font color=blue>new</font> Exception(<font color=red>"Message is too large"</font>);
</pre>
<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe this(const(ubyte[]) <span class="funcparam">target</span>, const(ulong) <span class="funcparam">bufferSize</span> = cast(const(ulong))8192);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Constructs a <b>StreamingUnpacker</b>
.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">const(ubyte[]) <span class="funcparam">target</span></td>
<td>byte buffer to deserialize</td></tr>
<tr>
<td nowrap valign="top" style="padding-right: 8px">const(ulong) <span class="funcparam">bufferSize</span></td>
<td>size limit of buffer size</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@property @safe Unpacked
<span class="currsymbol">unpacked</span>
<script>explorer.outline.addDecl('unpacked');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Forwards to deserialized object.
<br><br>
<b>Returns:</b><br>
the <b>Unpacked</b>
object contains deserialized value.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">nothrow @safe void
<span class="currsymbol">clear</span>
<script>explorer.outline.addDecl('clear');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Clears some states for next deserialization.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@safe Unpacked
<span class="currsymbol">purge</span>
<script>explorer.outline.addDecl('purge');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Convenient method for unpacking and clearing states.
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=blue>foreach</font> (obj; unpacker.<u>purge</u>()) {
<font color=green>// do stuff
</font> }
</pre>
is equivalent to
<pre class="d_code"> <font color=blue>foreach</font> (obj; unpacker.unpacked) {
<font color=green>// do stuff
</font> }
unpacker.clear();
</pre>
<br><br>
<b>Returns:</b><br>
the <b>Unpacked</b>
object contains deserialized value.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@trusted bool
<span class="currsymbol">execute</span>
<script>explorer.outline.addDecl('execute');</script>
();
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Executes deserialization.
<br><br>
<b>Returns:</b><br>
<b>true</b> if deserialization has been completed, otherwise <b>false</b>.
<br><br>
<b>Throws:</b><br>
<b>UnpackException</b>
when parse error occurs.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">@trusted int
<span class="currsymbol">opApply</span>
<script>explorer.outline.addDecl('opApply');</script>
(scope int delegate(ref Unpacked) <span class="funcparam">dg</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>supports foreach. One loop provides <b>Unpacked</b>
object contains execute() result.
This is convenient in case that <b>MessagePack</b>
values are continuous.<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">ubyte[]
<span class="currsymbol">pack</span>
<script>explorer.outline.addDecl('pack');</script>
(bool withFieldName = false, Args...)(in Args <span class="funcparam">args</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Serializes <i>args</i>.
<br><br>
Assumes single object if the length of <i>args</i> == 1,
otherwise array object.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">args</td>
<td>the contents to serialize.</td></tr>
</table><br>
<b>Returns:</b><br>
a serialized data.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">Unpacked
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(Tdummy = void)(in ubyte[] <span class="funcparam">buffer</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes <i>buffer</i> using stream deserializer.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">buffer</td>
<td>the buffer to deserialize.</td></tr>
</table><br>
<b>Returns:</b><br>
a <b>Unpacked</b>
contains deserialized object.
<br><br>
<b>Throws:</b><br>
UnpackException if deserialization doesn't succeed.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">void
<span class="currsymbol">unpack</span>
<script>explorer.outline.addDecl('unpack');</script>
(Args...)(in ubyte[] <span class="funcparam">buffer</span>, ref Args <span class="funcparam">args</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes <i>buffer</i> using direct-conversion deserializer.
<br><br>
Assumes single object if the length of <i>args</i> == 1,
otherwise array object.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">buffer</td>
<td>the buffer to deserialize.</td></tr>
<tr>
<td nowrap valign="top" style="padding-right: 8px">args</td>
<td>the references of values to assign.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">template
<span class="currsymbol">MessagePackable</span>
<script>explorer.outline.addDecl('MessagePackable');</script>
(Members...)</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Handy helper for creating
<span class="currsymbol">MessagePackable</span>
<script>explorer.outline.addDecl('MessagePackable');</script>
object.
<br><br>
toMsgpack / fromMsgpack are special methods for serialization / deserialization.
This template provides those methods to struct/class.
<br><br>
<b>Example:</b><br>
<pre class="d_code"> <font color=blue>struct</font> S
{
<font color=blue>int</font> num; string str;
<font color=green>// http://d.puremagic.com/issues/show_bug.cgi?id = 1099
</font> <font color=blue>mixin</font> <u>MessagePackable</u>; <font color=green>// all members
</font> <font color=green>// mixin MessagePackable!("num"); // num only
</font> }
</pre>
Defines those methods manually if you treat complex data-structure.<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">const void
<span class="currsymbol">toMsgpack</span>
<script>explorer.outline.addDecl('toMsgpack');</script>
(Packer)(ref Packer <span class="funcparam">packer</span>, bool <span class="funcparam">withFieldName</span> = false);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Serializes members using <i>packer</i>.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">packer</td>
<td>the serializer to pack.</td></tr>
</table><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">void
<span class="currsymbol">fromMsgpack</span>
<script>explorer.outline.addDecl('fromMsgpack');</script>
(Value <span class="funcparam">value</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes <b>MessagePack</b>
object to members using Value.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">Value <span class="funcparam">value</span></td>
<td>the MessagePack <span class="funcparam">value</span> to unpack.</td></tr>
</table><br>
<b>Throws:</b><br>
MessagePackException if <i><span class="funcparam">value</span></i> is not an Array type.<br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl">void
<span class="currsymbol">fromMsgpack</span>
<script>explorer.outline.addDecl('fromMsgpack');</script>
(ref Unpacker <span class="funcparam">unpacker</span>);
</span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>Deserializes <b>MessagePack</b>
object to members using direct-conversion deserializer.
<br><br>
<b>Params:</b><br>
<table><tr>
<td nowrap valign="top" style="padding-right: 8px">value</td>
<td>the reference to direct-conversion deserializer.</td></tr>
</table><br>
<b>Throws:</b><br>
MessagePackException if the size of deserialized value is mismatched.<br><br>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</dd>
</dl>
<script>explorer.outline.decSymbolLevel();</script>
</td></tr>
<tr><td id="docfooter">
Page was generated with
<img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px">
on Mon Jul 2 04:22:38 2012
</td></tr>
</table>
</div>
<script></script>
</body></html>
Jump to Line
Something went wrong with that request. Please try again.