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.encoder - multiple declarations

Function Base64Impl.encoder

Construct an Encoder that iterates over the Base64 encoding of the given input range.

Prototype

Base64Impl.Encoder!Range encoder(Range)(
  Range range
)
if (isInputRange!Range);

Parameters

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

Returns

If range is a range of bytes, an Encoder that iterates over the bytes of the corresponding Base64 encoding.

If range is a range of ranges of bytes, an Encoder that iterates over the Base64 encoded strings of each element of the range.

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

Example

This example encodes the input one line at a time.

File f = File("text.txt", "r");
scope(exit) f.close();

uint line = 0;
foreach (encoded; Base64.encoder(f.byLine()))
{
    writeln(++line, ". ", encoded);
}

Example

This example encodes the input data one byte at a time.

ubyte[] data = cast(ubyte[]) "0123456789";

// The ElementType of data is not aggregation type
foreach (encoded; Base64.encoder(data))
{
    writeln(encoded);
}

Struct Base64Impl.Encoder

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

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] char[]

Methods

Name Description
popFront Advance the range to the next chunk of encoded data.

Note

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

Struct Base64Impl.Encoder

An input range that iterates over the encoded bytes of the given source data.

It 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 encoded character.

Note

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

Authors

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

License

Boost License 1.0.

Comments