View source code
Display the source code in std/base64.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

std.base64.Base64Impl.Decoder/decoder - multiple declarations

Function Base64Impl.decoder

Construct a Decoder that iterates over the decoding of the given Base64 encoded data.

Base64Impl.Decoder!Range decoder(Range) (
  Range range
)
if (isInputRange!Range);

Base64Impl.Decoder!(const(ubyte)[]) decoder (
  const(char)[] range
);

Parameters

NameDescription
range An input range over the data to be decoded, or a char array. Will not accept wchar[] nor dchar[].

Returns

If range is a range or array of char, a Decoder that iterates over the bytes of the corresponding Base64 decoding.

If range is a range of ranges of characters, a Decoder that iterates over the decoded strings corresponding to each element of the range.

In both cases, the returned Decoder will be a forward range if the given range is at least a forward range, otherwise it will be only an input range.

If the input data contains characters not found in the base alphabet of the current Base64 encoding scheme, the returned range may throw a Base64Exception.

Example

This example shows decoding over a range of input data lines.

foreach (decoded; Base64.decoder(stdin.byLine()))
{
    writeln(decoded);
}

This example shows decoding one byte at a time.

auto encoded = Base64.encoder(cast(ubyte[])"0123456789");
foreach (n; map!q{a - '0'}(Base64.decoder(encoded)))
{
    writeln(n);
}

Example

import std.algorithm.comparison : equal;
string encoded =
    "VGhvdSBzaGFsdCBuZXZlciBjb250aW51ZSBhZnRlciBhc3NlcnRpbmcgbnVsbA==";

assert(Base64.decoder(encoded)
    .equal("Thou shalt never continue after asserting null"));

Struct Base64Impl.Decoder

An input range that iterates over the bytes of data decoded from a Base64 encoded string.

struct Decoder(Range)
  
if (isInputRange!Range && is(ElementType!Range : char));

This range will be a forward range if the underlying data source is at least a forward range.

Properties

NameTypeDescription
empty[get] bool
front[get] ubyte
save[get] typeof(this)Saves the current iteration state.

Methods

NameDescription
popFront () Advance to the next decoded byte.

Note

This struct is not intended to be created in user code directly; use the decoder function instead.

Struct Base64Impl.Decoder

An input range that iterates over the decoded data of a range of Base64 encodings.

struct Decoder(Range)
  
if (isInputRange!Range && (is(ElementType!Range : const(char)[]) || is(ElementType!Range : const(ubyte)[])));

This range will be a forward range if the underlying data source is at least a forward range.

Properties

NameTypeDescription
empty[get] bool
front[get] ubyte[]
save[get] typeof(this)Saves the current iteration state.

Methods

NameDescription
popFront () Advance to the next element in the input to be decoded.

Note

This struct is not intended to be created in user code directly; use the decoder function instead.

Authors

Masahiro Nakagawa, Daniel Murphy (Single value Encoder and Decoder)

License

Boost License 1.0.