View source code Display the source code in std/base64.d from which this page was generated on github. 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. Page wiki View or edit the community-maintained wiki page associated with this page.

std.base64.base64_impl.decoder - multiple declarations

Function Base64Impl.decoder

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

Prototype

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

Parameters

NameDescription
range An input range over the data to be decoded.

Returns

If range is a range of characters, 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 this case, the length of each subrange must be a multiple of 4; the returned decoder does not keep track of Base64 decoding state across subrange boundaries.

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);
}

Example

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);
}

Struct Base64Impl.Decoder

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

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

Properties

Name Type Description
empty [get] bool
front [get] ubyte[]

Methods

Name Description
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.

Struct Base64Impl.Decoder

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

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

Properties

Name Type Description
empty [get] bool
front [get] ubyte

Methods

Name Description
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.

Authors

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

License

Boost License 1.0.

Comments