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

Iterates through an InputRange at a time by using Encoder.

Default Encoder encodes chunk data.

Prototype

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

Example

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

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

In addition, You can use Encoder that returns encoded single character. This Encoder performs Range-based and lazy encoding.

Example

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

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

Parameters

NameDescription
range an InputRange to iterate.

Returns

a Encoder object instantiated and initialized according to the arguments.

Struct Base64Impl.Encoder

Range that encodes chunk data at a time.

Properties

Name Type Description
empty [get] bool Range primitive operation that checks iteration state.
front [get] char[] Range primitive operation that returns the currently iterated element.

Methods

Name Description
popFront Range primitive operation that advances the range to its next element.

Struct Base64Impl.Encoder

Range that encodes single character at a time.

Properties

Name Type Description
empty [get] bool Range primitive operation that checks iteration state.
front [get] ubyte Range primitive operation that returns the currently iterated element.

Methods

Name Description
popFront Range primitive operation that advances the range to its next element.

Authors

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

License

Boost License 1.0.

Comments