The OpenD Programming Language

Base64Impl.decode

Decodes source into a given output range.

  1. ubyte[] decode(R1 source, R2 buffer)
  2. ubyte[] decode(R1 source, R2 buffer)
  3. size_t decode(R1 source, R2 range)
    template Base64Impl(char Map62th, char Map63th, char Padding = '=')
    size_t
    decode
    (
    R1
    R2
    )
    (
    in R1 source
    ,
    auto ref R2 range
    )
    if (
    isArray!R1 &&
    is(ElementType!R1 : dchar)
    &&
    !is(R2 == ubyte[])
    &&
    isOutputRange!(R2, ubyte)
    )
    out (result) { immutable expect = realDecodeLength(source); assert (result == expect, "The result of decode is different from the expected"); }
  4. size_t decode(R1 source, R2 range)
  5. ubyte[] decode(Range source)
  6. ubyte[] decode(Range source)

Parameters

source R1

The input range to decode.

range R2

The output range to store the decoded result.

Return Value

Type: size_t

The number of times the output range's put method was invoked.

Throws

Base64Exception if source contains characters outside the base alphabet of the current Base64 encoding scheme.

Examples

struct OutputRange
{
    ubyte[] result;
    void put(ubyte b) { result ~= b; }
}
OutputRange output;

// This overload of decode() returns the number of calls to put().
assert(Base64.decode("Gis8TV1u", output) == 6);
assert(output.result == [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e]);

Meta