Loading...
Searching...
No Matches
base64_encoder.h
//*************************************************************************
//*************************************************************************///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2024 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_BASE64_ENCODER_INCLUDED
#define ETL_BASE64_ENCODER_INCLUDED
#include "platform.h"
#include "algorithm.h"
#include "binary.h"
#include "delegate.h"
#include "enum_type.h"
#include "error_handler.h"
#include "integral_limits.h"
#include "iterator.h"
#include "span.h"
#include "static_assert.h"
#include "type_traits.h"
#include "base64.h"
#include <stdint.h>
#if ETL_USING_STL
#include <iterator>
#endif
#define ETL_IS_8_BIT_INTEGRAL(Type) \
(etl::is_integral<typename etl::remove_cv<Type>::type>::value && (etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) \
(etl::is_integral< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::value \
&& (etl::integral_limits< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
namespace etl
{
//*************************************************************************
//*************************************************************************
class ibase64_encoder : public base64
{
public:
typedef etl::span<const char> span_type;
typedef etl::delegate<void(const span_type&)> callback_type;
//*************************************************************************
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14 bool encode(T value)
{
ETL_STATIC_ASSERT(ETL_IS_8_BIT_INTEGRAL(T), "Input type must be an 8 bit integral");
push_to_input_buffer(value);
if (input_buffer_is_full())
{
encode_block();
reset_input_buffer();
if (callback.is_valid())
{
if (output_buffer_is_full())
{
callback(span());
reset_output_buffer();
}
}
}
return !error();
}
//*************************************************************************
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, size_t input_length)
{
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
while (input_length-- != 0)
{
if (!encode(*input_begin++))
{
return false;
}
}
return true;
}
//*************************************************************************
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, TInputIterator input_end)
{
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
while (input_begin != input_end)
{
if (!encode(*input_begin++))
{
return false;
}
}
return true;
}
//*************************************************************************
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, size_t input_length)
{
return encode(input_begin, input_length) && flush();
}
//*************************************************************************
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, TInputIterator input_end)
{
return encode(input_begin, input_end) && flush();
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool flush()
{
// Encode any remaining input data.
bool success = encode_block();
reset_input_buffer();
if (success)
{
if (callback.is_valid())
{
// Send any remaining data.
if (size() != 0)
{
callback(span());
}
// Indicate this was the final block.
callback(span_type());
reset_output_buffer();
}
}
return success;
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 void restart()
{
reset_input_buffer();
reset_output_buffer();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 const char* begin() const
{
return p_output_buffer;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 const char* end() const
{
return p_output_buffer + output_buffer_length;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 const char* cbegin() const
{
return p_output_buffer;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 const char* cend() const
{
return p_output_buffer + output_buffer_length;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 size_t size() const
{
return output_buffer_length;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 size_t max_size() const
{
return output_buffer_max_size;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 span_type span() const
{
return span_type(begin(), end());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 bool overflow() const
{
return overflowed;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 bool error() const
{
return overflow();
}
protected:
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 ibase64_encoder(const char* encoder_table_, bool use_padding_, char* p_output_buffer_, size_t ouput_buffer_max_size_,
callback_type callback_)
: base64(encoder_table_, use_padding_)
, input_buffer()
, input_buffer_length(0)
, p_output_buffer(p_output_buffer_)
, output_buffer_length(0)
, output_buffer_max_size(ouput_buffer_max_size_)
, callback(callback_)
, overflowed(false)
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 bool encode_block()
{
switch (input_buffer_length)
{
// Only triggered on call to flush().
case 1:
{
uint32_t octets = input_buffer[0];
octets = octets << 4; // Adjust one octet (8 bits) for two sextets
// worth of data (12 bits)
// Write out two sextets + optional padding.
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
if (use_padding)
{
push_to_output_buffer('=');
push_to_output_buffer('=');
}
break;
}
// Only triggered on call to flush().
case 2:
{
uint32_t octets = (static_cast<uint32_t>(input_buffer[0]) << 8) | input_buffer[1];
octets <<= 2; // Adjust two octets (16 bits) for three sextets worth
// of data (18 bits)
// Write out three sextets + optional padding.
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
if (use_padding)
{
push_to_output_buffer('=');
}
break;
}
// Only triggered on call to encode().
case 3:
{
uint32_t octets = (static_cast<uint32_t>(input_buffer[0]) << 16) | (static_cast<uint32_t>(input_buffer[1]) << 8) | input_buffer[2];
// Write out four sextets
push_to_output_buffer(encoder_table[(octets >> 18) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
break;
}
default:
{
break;
}
}
ETL_ASSERT(!overflowed, ETL_ERROR(etl::base64_overflow));
return !overflowed;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14 size_t encoded_size(size_t input_length, bool use_padding)
{
size_t required_output_length = 0;
if (input_length == 0U)
{
return 0U;
}
if (use_padding)
{
required_output_length = (input_length * 4U) / 3U;
while ((required_output_length % 4U) != 0)
{
++required_output_length;
}
}
else
{
required_output_length = input_length + (((input_length - 1U) / 3U) + 1U);
}
while (required_output_length % 4)
{
++required_output_length;
}
return required_output_length;
}
private:
//*************************************************************************
// Push to the output buffer.
//*************************************************************************
ETL_CONSTEXPR14 void push_to_output_buffer(char c)
{
if (output_buffer_length < output_buffer_max_size)
{
p_output_buffer[output_buffer_length++] = c;
}
else
{
overflowed = true;
}
}
//*************************************************************************
//
//*************************************************************************
ETL_CONSTEXPR14 bool output_buffer_is_full() const
{
return output_buffer_length == output_buffer_max_size;
}
//*************************************************************************
//
//*************************************************************************
ETL_CONSTEXPR14 bool output_buffer_is_empty() const
{
return output_buffer_length == 0;
}
//*************************************************************************
//
//*************************************************************************
ETL_CONSTEXPR14 void reset_output_buffer()
{
output_buffer_length = 0;
}
//*************************************************************************
// Push to the input buffer.
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14 void push_to_input_buffer(T value)
{
input_buffer[input_buffer_length++] = static_cast<uint8_t>(value);
}
//*************************************************************************
//
//*************************************************************************
ETL_CONSTEXPR14 bool input_buffer_is_full() const
{
return input_buffer_length == 3U;
}
//*************************************************************************
//
//*************************************************************************
ETL_CONSTEXPR14 void reset_input_buffer()
{
input_buffer_length = 0;
}
uint8_t input_buffer[3];
size_t input_buffer_length;
char* p_output_buffer;
size_t output_buffer_length;
const size_t output_buffer_max_size;
callback_type callback;
bool overflowed;
};
//*************************************************************************
//*************************************************************************
template <size_t Buffer_Size = etl::base64::Min_Encode_Buffer_Size>
class base64_rfc2152_encoder : public ibase64_encoder
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc2152_encoder()
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc2152_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
private:
char output_buffer[Buffer_Size];
};
//*************************************************************************
//*************************************************************************
template <size_t Buffer_Size = etl::base64::Min_Encode_Buffer_Size>
class base64_rfc3501_encoder : public ibase64_encoder
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc3501_encoder()
: ibase64_encoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc3501_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
private:
char output_buffer[Buffer_Size];
};
//*************************************************************************
//*************************************************************************
template <size_t Buffer_Size = etl::base64::Min_Encode_Buffer_Size>
class base64_rfc4648_encoder : public ibase64_encoder
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_encoder()
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
private:
char output_buffer[Buffer_Size];
};
//*************************************************************************
//*************************************************************************
template <size_t Buffer_Size = etl::base64::Min_Encode_Buffer_Size>
class base64_rfc4648_padding_encoder : public ibase64_encoder
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder()
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::Use_Padding);
}
private:
char output_buffer[Buffer_Size];
};
//*************************************************************************
//*************************************************************************
template <size_t Buffer_Size = etl::base64::Min_Encode_Buffer_Size>
class base64_rfc4648_url_encoder : public ibase64_encoder
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_url_encoder()
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_url_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
private:
char output_buffer[Buffer_Size];
};
//*************************************************************************
//*************************************************************************
template <size_t Buffer_Size = etl::base64::Min_Encode_Buffer_Size>
class base64_rfc4648_url_padding_encoder : public ibase64_encoder
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder()
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::Use_Padding);
}
private:
char output_buffer[Buffer_Size];
};
} // namespace etl
#undef ETL_IS_TYPE_8_BIT_INTEGRAL
#undef ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL
#endif
algorithm.h
base64.h
binary.h
etl::base64_overflow
buffer overflow exception.
Definition base64.h:70
etl::base64_rfc2152_encoder::safe_output_buffer_size
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_encoder.h:507
etl::base64_rfc2152_encoder::base64_rfc2152_encoder
ETL_CONSTEXPR14 base64_rfc2152_encoder()
Base64 RFC-2152 constructor.
Definition base64_encoder.h:487
etl::base64_rfc2152_encoder::base64_rfc2152_encoder
ETL_CONSTEXPR14 base64_rfc2152_encoder(callback_type callback_)
Base64 RFC-2152 constructor.
Definition base64_encoder.h:496
etl::base64_rfc3501_encoder::base64_rfc3501_encoder
ETL_CONSTEXPR14 base64_rfc3501_encoder()
Base64 RFC-3501 constructor.
Definition base64_encoder.h:533
etl::base64_rfc3501_encoder::safe_output_buffer_size
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_encoder.h:553
etl::base64_rfc3501_encoder::base64_rfc3501_encoder
ETL_CONSTEXPR14 base64_rfc3501_encoder(callback_type callback_)
Base64 RFC-3501 constructor.
Definition base64_encoder.h:542
etl::base64_rfc4648_encoder::safe_output_buffer_size
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_encoder.h:599
etl::base64_rfc4648_encoder::base64_rfc4648_encoder
ETL_CONSTEXPR14 base64_rfc4648_encoder(callback_type callback_)
Base64 RFC-4648 constructor.
Definition base64_encoder.h:588
etl::base64_rfc4648_encoder::base64_rfc4648_encoder
ETL_CONSTEXPR14 base64_rfc4648_encoder()
Base64 RFC-4648 constructor.
Definition base64_encoder.h:579
etl::base64_rfc4648_padding_encoder::base64_rfc4648_padding_encoder
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder()
Base64 RFC-4648-Padding constructor.
Definition base64_encoder.h:625
etl::base64_rfc4648_padding_encoder::safe_output_buffer_size
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_encoder.h:645
etl::base64_rfc4648_padding_encoder::base64_rfc4648_padding_encoder
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder(callback_type callback_)
Base64 RFC-4648-Padding constructor.
Definition base64_encoder.h:634
etl::base64_rfc4648_url_encoder::safe_output_buffer_size
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_encoder.h:691
etl::base64_rfc4648_url_encoder::base64_rfc4648_url_encoder
ETL_CONSTEXPR14 base64_rfc4648_url_encoder()
Base64 RFC-4648-URL constructor.
Definition base64_encoder.h:671
etl::base64_rfc4648_url_encoder::base64_rfc4648_url_encoder
ETL_CONSTEXPR14 base64_rfc4648_url_encoder(callback_type callback_)
Base64 RFC-4648-URL constructor.
Definition base64_encoder.h:680
etl::base64_rfc4648_url_padding_encoder::base64_rfc4648_url_padding_encoder
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder()
Base64 RFC-4648-URL constructor.
Definition base64_encoder.h:717
etl::base64_rfc4648_url_padding_encoder::base64_rfc4648_url_padding_encoder
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder(callback_type callback_)
Base64 RFC-4648-URL constructor.
Definition base64_encoder.h:726
etl::base64_rfc4648_url_padding_encoder::safe_output_buffer_size
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_encoder.h:737
etl::base64
Common Base64 definitions.
Definition base64.h:109
etl::delegate
Declaration.
Definition delegate_cpp03.h:191
etl::ibase64_encoder::span
ETL_NODISCARD ETL_CONSTEXPR14 span_type span() const
Definition base64_encoder.h:250
etl::ibase64_encoder::cend
ETL_NODISCARD ETL_CONSTEXPR14 const char * cend() const
Definition base64_encoder.h:222
etl::ibase64_encoder::encode
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, size_t input_length)
Encode to Base64.
Definition base64_encoder.h:102
etl::ibase64_encoder::size
ETL_NODISCARD ETL_CONSTEXPR14 size_t size() const
Definition base64_encoder.h:232
etl::ibase64_encoder::encode_block
ETL_CONSTEXPR14 bool encode_block()
Encode one block of data.
Definition base64_encoder.h:292
etl::ibase64_encoder::restart
ETL_CONSTEXPR14 void restart()
Reset the encoder.
Definition base64_encoder.h:187
etl::ibase64_encoder::overflow
ETL_NODISCARD ETL_CONSTEXPR14 bool overflow() const
Returns true if the output buffer has overflowed.
Definition base64_encoder.h:258
etl::ibase64_encoder::encode
ETL_CONSTEXPR14 bool encode(T value)
Encode to Base64.
Definition base64_encoder.h:74
etl::ibase64_encoder::max_size
ETL_NODISCARD ETL_CONSTEXPR14 size_t max_size() const
Returns the maximum size of the output buffer.
Definition base64_encoder.h:240
etl::ibase64_encoder::end
ETL_NODISCARD ETL_CONSTEXPR14 const char * end() const
Definition base64_encoder.h:205
etl::ibase64_encoder::error
ETL_NODISCARD ETL_CONSTEXPR14 bool error() const
Returns true if an error was detected.
Definition base64_encoder.h:266
etl::ibase64_encoder::encode
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, TInputIterator input_end)
Encode to Base64.
Definition base64_encoder.h:121
etl::ibase64_encoder::ibase64_encoder
ETL_CONSTEXPR14 ibase64_encoder(const char *encoder_table_, bool use_padding_, char *p_output_buffer_, size_t ouput_buffer_max_size_, callback_type callback_)
Constructor.
Definition base64_encoder.h:276
etl::ibase64_encoder::flush
ETL_CONSTEXPR14 bool flush()
Flush any remaining data to the output.
Definition base64_encoder.h:157
etl::ibase64_encoder::begin
ETL_NODISCARD ETL_CONSTEXPR14 const char * begin() const
Returns the beginning of the output buffer.
Definition base64_encoder.h:196
etl::ibase64_encoder::encode_final
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, TInputIterator input_end)
Encode to Base64.
Definition base64_encoder.h:149
etl::ibase64_encoder::encode_final
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, size_t input_length)
Encode to Base64.
Definition base64_encoder.h:140
etl::ibase64_encoder::cbegin
ETL_NODISCARD ETL_CONSTEXPR14 const char * cbegin() const
Returns the beginning of the output buffer.
Definition base64_encoder.h:213
etl::ibase64_encoder::encoded_size
static ETL_NODISCARD ETL_CONSTEXPR14 size_t encoded_size(size_t input_length, bool use_padding)
Calculates the minimum buffer size required to encode to Base64.
Definition base64_encoder.h:363
etl::span
Span - Fixed Extent.
Definition span.h:208
delegate.h
enum_type.h
error_handler.h
ETL_ASSERT
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
integral_limits.h
iterator.h
etl
Definition absolute.h:40
platform.h
span.h
etl::base64::Padding
Definition base64.h:139
type_traits.h