Base module

base64::Encoder

Base64 encoder.

Encoder

#include <icy/base64.h>

Inherits: Encoder

Base64 encoder.

Public Attributes

ReturnNameDescription
internal::encodestate_state
int_buffersize

_state

internal::encodestate _state

_buffersize

int _buffersize

Public Methods

ReturnNameDescription
Encoder inline#### Parameters
voidencode inlineEncodes the entire input stream and writes Base64 output to ostrm. Resets the encoder state after completion.
voidencode inlineEncodes a string to Base64 and appends the result to out. Resets the encoder state after completion.
ssize_tencode virtual inlineEncodes a raw buffer, writing Base64 characters to outbuf. May be called multiple times before calling [finalize()](#finalize-4).
ssize_tfinalize virtual inlineWrites any pending padding and resets the encoder state. Must be called once after all [encode()](#encode-17) calls to flush the final block.
voidsetLineLength inlineSets the line wrap length for encoded output (0 disables line wrapping).

Encoder

inline

inline Encoder(int buffersize)

Parameters

  • buffersize Internal read buffer size in bytes.

encode

inline

inline void encode(std::istream & istrm, std::ostream & ostrm)

Encodes the entire input stream and writes Base64 output to ostrm. Resets the encoder state after completion.

Parameters

  • istrm Source stream to encode.

  • ostrm Destination stream for Base64 output.


encode

inline

inline void encode(const std::string & in, std::string & out)

Encodes a string to Base64 and appends the result to out. Resets the encoder state after completion.

Parameters

  • in Input string.

  • out Output string to which Base64 characters are appended.


encode

virtual inline

virtual inline ssize_t encode(const char * inbuf, size_t nread, char * outbuf)

Encodes a raw buffer, writing Base64 characters to outbuf. May be called multiple times before calling [finalize()](#finalize-4).

Parameters

  • inbuf Input binary data.

  • nread Number of bytes to encode.

  • outbuf Output buffer; must be at least nread * 4 / 3 + 4 bytes.

Returns

Number of Base64 characters written.


finalize

virtual inline

virtual inline ssize_t finalize(char * outbuf)

Writes any pending padding and resets the encoder state. Must be called once after all [encode()](#encode-17) calls to flush the final block.

Parameters

  • outbuf Output buffer; must be at least 5 bytes.

Returns

Number of characters written.


setLineLength

inline

inline void setLineLength(int lineLength)

Sets the line wrap length for encoded output (0 disables line wrapping).

Parameters

  • lineLength Characters per line; use 0 to disable.