Ocean
Ocean::IO::Base64 Class Reference

This class implements function to encode binary information to text encoding and vice versa. More...

Public Types

typedef std::vector< uint8_t > Buffer
 Definition of a vector holding characters. More...
 

Static Public Member Functions

static void encode (const uint8_t *buffer, const size_t bufferSize, Buffer &encodedText)
 Encodes binary information by application of Base64 to a text encoding. More...
 
static bool decode (const uint8_t *encodedText, const size_t encodedTextSize, Buffer &buffer)
 Decodes a text encoding by application of an inverse Base64 to binary information. More...
 
static void encode3 (const uint8_t bytes3[3], uint8_t encoded4[4])
 Encodes 3 bytes of binary information to 4 bytes with text encoding. More...
 
static bool decode4 (const uint8_t encoded4[4], uint8_t bytes3[3])
 Decodes 4 bytes with text encoding to 3 bytes of binary information. More...
 
static uint8_t isEncoded (const uint8_t encodedValue)
 Returns whether a given byte is text encoded. More...
 

Static Protected Attributes

static constexpr const char * encodedCharacters_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
 The possible encoded characters. More...
 

Detailed Description

This class implements function to encode binary information to text encoding and vice versa.

Member Typedef Documentation

◆ Buffer

typedef std::vector<uint8_t> Ocean::IO::Base64::Buffer

Definition of a vector holding characters.

Member Function Documentation

◆ decode()

static bool Ocean::IO::Base64::decode ( const uint8_t *  encodedText,
const size_t  encodedTextSize,
Buffer buffer 
)
static

Decodes a text encoding by application of an inverse Base64 to binary information.

Parameters
encodedTextThe encoded text to decode
encodedTextSizeThe size of the text to decode, in characters, with range [4, infinity)
bufferThe resulting binary information
Returns
True, if the given encoded text was valid

◆ decode4()

bool Ocean::IO::Base64::decode4 ( const uint8_t  encoded4[4],
uint8_t  bytes3[3] 
)
inlinestatic

Decodes 4 bytes with text encoding to 3 bytes of binary information.

Parameters
encoded4The four encoded byte to decode
bytes3The resulting three text encoded bytes
Returns
True, if succeeded

◆ encode()

static void Ocean::IO::Base64::encode ( const uint8_t *  buffer,
const size_t  bufferSize,
Buffer encodedText 
)
static

Encodes binary information by application of Base64 to a text encoding.

Parameters
bufferThe buffer to encode
bufferSizeThe size of the buffer to encode, in bytes, with range [1, infinity)
encodedTextThe resulting encoded text

◆ encode3()

void Ocean::IO::Base64::encode3 ( const uint8_t  bytes3[3],
uint8_t  encoded4[4] 
)
inlinestatic

Encodes 3 bytes of binary information to 4 bytes with text encoding.

Parameters
bytes3The three bytes to encode
encoded4The resulting four encoded bytes

◆ isEncoded()

unsigned char Ocean::IO::Base64::isEncoded ( const uint8_t  encodedValue)
inlinestatic

Returns whether a given byte is text encoded.

Parameters
encodedValueThe text encoded value to check
Returns
The corresponding value with range [0, 59] if the value is text encoded, 64 otherwise

Field Documentation

◆ encodedCharacters_

constexpr const char* Ocean::IO::Base64::encodedCharacters_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
staticconstexprprotected

The possible encoded characters.


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