[phobos] std.base64 replacement

Daniel Murphy yebblies at gmail.com
Thu Oct 14 01:30:06 PDT 2010


On Thu, Oct 14, 2010 at 6:52 AM, Shin Fujishiro <rsinfu at gmail.com> wrote:

> So... how?
>
> To tell a truth, I've tried creating decorator ranges for character code
> conversion and zlib decompression, and both required internal caching.
> I think it's a limitation of the decorator design.
>
> Perhaps I'm missing something?  Please tell us if you know a way to
> implement M:N decorators without caching!
>
>
By remembering where it's up to, and only popping items off the input when
it's done with them.  Maybe this is just another form of caching?

eg.
struct byByte
{
  ushort[] data;
  bool hi;
  ubyte v;
  this(ushort[] data) { this.data = data; }
  void popFront()
  {
    v = hi ? (data.front >> 8) : (data.front & 0xFF);
    hi = !hi;
    if (!hi) data.popFront();
  }
  ubyte front() { return v; }
  bool empty() { return data.empty; }
}

I do understand this is not a perfect solution, and does not apply in some
cases.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20101014/c558a9d1/attachment.html>


More information about the phobos mailing list