TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

#include <tsBase64.h>

Public Member Functions

 Base64 (size_t line_size=DEFAULT_LINE_SIZE)
bool decodeAdd (ByteBlock &bin, const UString &b64)
bool decodeTerminate (ByteBlock &bin)
void encodeAdd (UString &b64, const void *data, size_t size)
void encodeTerminate (UString &b64)
void reset ()

Static Public Member Functions

static bool Decode (ByteBlock &bin, const UString &b64)
static ByteBlock Decoded (const UString &b64)
static void Encode (UString &b64, const void *data, size_t size, size_t line_size=DEFAULT_LINE_SIZE)
static UString Encoded (const void *data, size_t size, size_t line_size=DEFAULT_LINE_SIZE)

Static Public Attributes

static constexpr size_t BIN_BLOCK_SIZE = 3
static constexpr size_t DEFAULT_LINE_SIZE = 76
static constexpr UChar PAD_CHAR = u'='
static constexpr size_t STR_BLOCK_SIZE = 4

Detailed Description

Base64 encoder and decoder.

Constructor & Destructor Documentation

◆ Base64()

ts::Base64::Base64 ( size_t line_size = DEFAULT_LINE_SIZE)
explicit

Constructor.

Parameters
[in]line_sizeOutput text line size, when producing encoded Base64. When zero, do not generate new-line characters.

Member Function Documentation

◆ reset()

void ts::Base64::reset ( )

Reset the encoder and decoder.

◆ encodeAdd()

void ts::Base64::encodeAdd ( UString & b64,
const void * data,
size_t size )

Encode binary data and return partial Base64 string. Some input data may be internally kept, waiting for more data to encode. Call encodeTerminate() to properly terminate the encoding of data.

Parameters
[in,out]b64Output string. Produced characters are appended at the end of output.
[in]dataAddress of data to encode.
[in]sizeSize in bytes of data to encode.

◆ encodeTerminate()

void ts::Base64::encodeTerminate ( UString & b64)

Terminate binary data encoding, generate potential end of Base64 stream.

Parameters
[in,out]b64Output string. Produced characters are appended at the end of output.

◆ decodeAdd()

bool ts::Base64::decodeAdd ( ByteBlock & bin,
const UString & b64 )

Decode Base64 string and return partial binary data. Some input Base64 characters may be internally kept, waiting for more characters to decode. Call decodeTerminate() to properly terminate and validate the decoding.

Parameters
[in,out]binOutput binary data. Produced bytes are appended at the end of bin.
[in]b64Partial base64 string.
Returns
True on success, false on invalid input Base64 format.

◆ decodeTerminate()

bool ts::Base64::decodeTerminate ( ByteBlock & bin)

Terminate Base64 decoding.

Parameters
[in,out]binOutput binary data. Produced bytes are appended at the end of bin.
Returns
True on success, false on invalid input Base64 format.

◆ Encode()

void ts::Base64::Encode ( UString & b64,
const void * data,
size_t size,
size_t line_size = DEFAULT_LINE_SIZE )
static

Bulk Base64 encoding.

Parameters
[out]b64Output Base64 string.
[in]dataAddress of data to encode.
[in]sizeSize in bytes of data to encode.
[in]line_sizeOutput text line size, when producing encoded Base64. When zero, do not generate new-line characters.

◆ Encoded()

UString ts::Base64::Encoded ( const void * data,
size_t size,
size_t line_size = DEFAULT_LINE_SIZE )
static

Bulk Base64 encoding.

Parameters
[in]dataAddress of data to encode.
[in]sizeSize in bytes of data to encode.
[in]line_sizeOutput text line size, when producing encoded Base64. When zero, do not generate new-line characters.
Returns
Output Base64 string.

◆ Decode()

bool ts::Base64::Decode ( ByteBlock & bin,
const UString & b64 )
static

Bulk Base64 decoding.

Parameters
[out]binOutput binary data.
[in]b64Full Base64 string.
Returns
True on success, false on invalid input Base64 format.

◆ Decoded()

ByteBlock ts::Base64::Decoded ( const UString & b64)
static

Bulk Base64 decoding.

Parameters
[in]b64Full Base64 string.
Returns
Output binary data. In case of error, return the successfully decoded part. It is not possible to determine if the input Base64 string was full correct or only partially decoded.

Member Data Documentation

◆ PAD_CHAR

UChar ts::Base64::PAD_CHAR = u'='
staticconstexpr

Base64 padding character at end of stream.

◆ BIN_BLOCK_SIZE

size_t ts::Base64::BIN_BLOCK_SIZE = 3
staticconstexpr

Base64 input bytes block size.

◆ STR_BLOCK_SIZE

size_t ts::Base64::STR_BLOCK_SIZE = 4
staticconstexpr

Base64 output characters block size.

◆ DEFAULT_LINE_SIZE

size_t ts::Base64::DEFAULT_LINE_SIZE = 76
staticconstexpr

Default output line size.


The documentation for this class was generated from the following file: