PuzzleD

D Interface to libpuzzle
git clone git://xatko.vsos.ethz.ch/PuzzleD.git
Log | Files | Refs

commit 8c5acd2ade7a84ff6f2ec18494bb052f23bc36a3
parent 092ea94561be77dc7526de6a0cc11bef836a7331
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Thu, 27 Aug 2015 12:17:01 +0200

Let CVec and Compressed CVec be generated by hand.

This allows saving the Vectors to some arbitrary memoryâ„¢

Diffstat:
puzzle.d | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/puzzle.d b/puzzle.d @@ -165,6 +165,14 @@ struct CVec{ this(c.ctx); puzzle_uncompress_cvec(ctx, &c.vec, &vec); } + @nogc pure nothrow this(byte[] a){ + this(cast(char*)a.ptr, a.length); + } + @nogc pure nothrow this(char *a, size_t length){ + vec.vec=a; + vec.sizeof_vec=length; + } + this(PuzzleContext *ctx) in{ assert(ctx.valid(), "Context invalid"); @@ -206,6 +214,16 @@ struct CVec_Compressed{ this(c.ctx); puzzle_compress_cvec(ctx, &vec, &c.vec); } + + this(ubyte[] a){ + this(a.ptr,a.length); + } + + this(ubyte* a, size_t length){ + vec.vec=a; + vec.sizeof_compressed_vec=length; + } + this(PuzzleContext *ctx) in{ assert(ctx.valid(), "Context invalid");