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

Function Base64Impl.encoder

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

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 encoded bytes of the given source data.

struct Encoder(Range)
  
if (isInputRange!Range && is(ElementType!Range : ubyte));

It 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)Save the current iteration state of the range.

Methods

NameDescription
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.

Struct Base64Impl.Encoder

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

struct Encoder(Range)
  
if (isInputRange!Range && (is(ElementType!Range : const(ubyte)[]) || is(ElementType!Range : const(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] char[]
save[get] typeof(this)Save the current iteration state of the range.

Methods

NameDescription
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.

Authors

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

License

Boost License 1.0.