Embedded Template Library 1.0
Loading...
Searching...
No Matches
base64_decoder.h
1//*************************************************************************
3//*************************************************************************///\file
4
5/******************************************************************************
6The MIT License(MIT)
7Embedded Template Library.
8https://github.com/ETLCPP/etl
9https://www.etlcpp.com
10Copyright(c) 2024 John Wellbelove
11Permission is hereby granted, free of charge, to any person obtaining a copy
12of this software and associated documentation files(the "Software"), to deal
13in the Software without restriction, including without limitation the rights
14to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
15copies of the Software, and to permit persons to whom the Software is
16furnished to do so, subject to the following conditions :
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25SOFTWARE.
26******************************************************************************/
27
28#ifndef ETL_BASE64_DECODER_INCLUDED
29#define ETL_BASE64_DECODER_INCLUDED
30
31#include "platform.h"
32#include "static_assert.h"
33#include "error_handler.h"
34#include "type_traits.h"
35#include "binary.h"
36#include "algorithm.h"
37#include "integral_limits.h"
38#include "iterator.h"
39#include "enum_type.h"
40#include "delegate.h"
41#include "span.h"
42
43#include "base64.h"
44
45#include <stdint.h>
46
47#if ETL_USING_STL
48 #include <iterator>
49#endif
50
51#define ETL_IS_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::remove_cv<Type>::type>::value && \
52 (etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
53
54#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 && \
55 (etl::integral_limits<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
56
57namespace etl
58{
59 //*************************************************************************
61 //*************************************************************************
62 class ibase64_decoder : public base64
63 {
64 public:
65
68
69 //*************************************************************************
71 //*************************************************************************
72 template <typename T>
73 ETL_CONSTEXPR14
74 bool decode(T value)
75 {
76 ETL_STATIC_ASSERT(ETL_IS_8_BIT_INTEGRAL(T), "Input type must be an 8 bit integral");
77
78 push_to_input_buffer(value);
79
80 if (input_buffer_is_full())
81 {
82 if (decode_block())
83 {
84 if (callback.is_valid())
85 {
86 if (output_buffer_is_full())
87 {
88 callback(span());
89 reset_output_buffer();
90 }
91 }
92 }
93
94 reset_input_buffer();
95 }
96
97 return !error();
98 }
99
100 //*************************************************************************
102 //*************************************************************************
103 template <typename TInputIterator>
104 ETL_CONSTEXPR14
106 {
107 ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
108
109 while (input_begin != input_end)
110 {
111 if (!decode(*input_begin++))
112 {
113 return false;
114 }
115 }
116
117 return true;
118 }
119
120 //*************************************************************************
122 //*************************************************************************
123 template <typename TInputIterator>
124 ETL_CONSTEXPR14
126 {
127 ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
128
129 while (input_length-- != 0)
130 {
131 if (!decode(*input_begin++))
132 {
133 return false;
134 }
135 }
136
137 return true;
138 }
139
140 //*************************************************************************
142 //*************************************************************************
143 template <typename TInputIterator>
144 ETL_CONSTEXPR14
149
150 //*************************************************************************
152 //*************************************************************************
153 template <typename TInputIterator>
154 ETL_CONSTEXPR14
159
160 //*************************************************************************
162 //*************************************************************************
163 ETL_CONSTEXPR14
164 bool flush()
165 {
166 // Encode any remaining input data.
167 bool success = decode_block();
168
169 reset_input_buffer();
170
171 if (success)
172 {
173 if (callback.is_valid())
174 {
175 // Send any remaining data.
176 if (size() != 0)
177 {
178 callback(span());
179 }
180
181 // Indicate this was the final block.
183
184 reset_output_buffer();
185 }
186 }
187
188 padding_received = false;
189
190 return success;
191 }
192
193 //*************************************************************************
195 //*************************************************************************
196 ETL_CONSTEXPR14
197 void restart()
198 {
199 reset_input_buffer();
200 reset_output_buffer();
201 overflow_detected = false;
202 invalid_data_detected = false;
203 padding_received = false;
204 }
205
206 //*************************************************************************
208 //*************************************************************************
209 ETL_NODISCARD
210 ETL_CONSTEXPR14
211 const unsigned char* begin() const
212 {
213 return p_output_buffer;
214 }
215
216 //*************************************************************************
218 //*************************************************************************
219 ETL_NODISCARD
220 ETL_CONSTEXPR14
221 const unsigned char* end() const
222 {
223 return p_output_buffer + output_buffer_length;
224 }
225
226 //*************************************************************************
228 //*************************************************************************
229 ETL_NODISCARD
230 ETL_CONSTEXPR14
231 const unsigned char* cbegin() const
232 {
233 return p_output_buffer;
234 }
235
236 //*************************************************************************
238 //*************************************************************************
239 ETL_NODISCARD
240 ETL_CONSTEXPR14
241 const unsigned char* cend() const
242 {
243 return p_output_buffer + output_buffer_length;
244 }
245
246 //*************************************************************************
249 //*************************************************************************
250 ETL_NODISCARD
251 ETL_CONSTEXPR14
252 size_t size() const
253 {
254 return output_buffer_length;
255 }
256
257 //*************************************************************************
259 //*************************************************************************
260 ETL_NODISCARD
261 ETL_CONSTEXPR14
262 size_t buffer_size() const
263 {
264 return output_buffer_max_size;
265 }
266
267 //*************************************************************************
270 //*************************************************************************
271 ETL_NODISCARD
272 ETL_CONSTEXPR14
274 {
275 return span_type(begin(), end());
276 }
277
278 //*************************************************************************
280 //*************************************************************************
281 ETL_NODISCARD
282 ETL_CONSTEXPR14
283 bool overflow() const
284 {
285 return overflow_detected;
286 }
287
288 //*************************************************************************
290 //*************************************************************************
291 ETL_NODISCARD
292 ETL_CONSTEXPR14
293 bool invalid_data() const
294 {
295 return invalid_data_detected;
296 }
297
298 //*************************************************************************
300 //*************************************************************************
301 ETL_NODISCARD
302 ETL_CONSTEXPR14
303 bool error() const
304 {
305 return overflow() || invalid_data();
306 }
307
308 protected:
309
310 //*************************************************************************
312 //*************************************************************************
313 ETL_CONSTEXPR14
315 bool use_padding_,
316 unsigned char* p_output_buffer_,
320 , input_buffer()
321 , input_buffer_length(0)
322 , p_output_buffer(p_output_buffer_)
323 , output_buffer_length(0)
324 , output_buffer_max_size(ouput_buffer_max_size_)
326 , overflow_detected(false)
327 , invalid_data_detected(false)
328 , padding_received(false)
329 {
330 }
331
332 //*************************************************************************
334 //*************************************************************************
335 ETL_NODISCARD
336 static
337 ETL_CONSTEXPR14
339 {
340 return input_length - (input_length / 4U);
341 }
342
343 private:
344
345 //*************************************************************************
346 // Translates a sextet into an index
347 //*************************************************************************
348 template <typename T>
349 ETL_CONSTEXPR14
350 uint32_t get_index_from_sextet(T sextet)
351 {
352 const char* encoder_table_end = encoder_table + 64;
353 const char* p_sextet = etl::find(encoder_table, encoder_table_end, static_cast<char>(sextet));
354
356 {
357 return static_cast<uint32_t>(etl::distance(encoder_table, p_sextet));
358 }
359 else
360 {
361 invalid_data_detected = true;
362 return 0;
363 }
364 }
365
366 //*************************************************************************
368 //*************************************************************************
369 template <typename T>
370 ETL_NODISCARD
371 static
372 ETL_CONSTEXPR14
373 T padding()
374 {
375 return static_cast<T>('=');
376 }
377
378 //*************************************************************************
380 //*************************************************************************
381 ETL_CONSTEXPR14
382 bool decode_block()
383 {
384 switch (input_buffer_length)
385 {
386 // Only triggered on call to flush().
387 case 2:
388 {
389 uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 6);
390 sextets = sextets | (get_index_from_sextet(input_buffer[1]));
391 push_to_output_buffer((sextets >> 4) & 0xFF);
392 break;
393 }
394
395 // Only triggered on call to flush().
396 case 3:
397 {
398 uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 12);
399 sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 6);
400 sextets = sextets | (get_index_from_sextet(input_buffer[2]));
401 push_to_output_buffer((sextets >> 10) & 0xFF);
402 push_to_output_buffer((sextets >> 2) & 0xFF);
403 break;
404 }
405
406 // Only triggered on call to decode().
407 case 4:
408 {
409 // Read in four sextets
410 uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 18);
411 sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 12);
412 sextets = sextets | (get_index_from_sextet(input_buffer[2]) << 6);
413 sextets = sextets | (get_index_from_sextet(input_buffer[3]));
414
415 // Write out three octets
416 push_to_output_buffer((sextets >> 16) & 0xFF);
417 push_to_output_buffer((sextets >> 8) & 0xFF);
418 push_to_output_buffer((sextets >> 0) & 0xFF);
419 break;
420 }
421
422 default:
423 {
424 break;
425 }
426 }
427
428 ETL_ASSERT(!invalid_data_detected, ETL_ERROR(etl::base64_invalid_data));
429 ETL_ASSERT(!overflow_detected, ETL_ERROR(etl::base64_overflow));
430
431 return (!invalid_data_detected && !overflow_detected);
432 }
433
434 //*************************************************************************
435 // Push to the output buffer.
436 //*************************************************************************
437 ETL_CONSTEXPR14
438 void push_to_output_buffer(unsigned char c)
439 {
440 if (output_buffer_length < output_buffer_max_size)
441 {
442 p_output_buffer[output_buffer_length++] = c;
443 }
444 else
445 {
446 overflow_detected = true;
447 }
448 }
449
450 //*************************************************************************
451 //
452 //*************************************************************************
453 ETL_CONSTEXPR14
454 bool output_buffer_is_full() const
455 {
456 return output_buffer_length == output_buffer_max_size;
457 }
458
459 //*************************************************************************
460 //
461 //*************************************************************************
462 ETL_CONSTEXPR14
463 bool output_buffer_is_empty() const
464 {
465 return output_buffer_length == 0;
466 }
467
468 //*************************************************************************
469 //
470 //*************************************************************************
471 ETL_CONSTEXPR14
472 void reset_output_buffer()
473 {
474 output_buffer_length = 0;
475 }
476
477 //*************************************************************************
478 // Push to the input buffer.
479 //*************************************************************************
480 template <typename T>
481 ETL_CONSTEXPR14
482 void push_to_input_buffer(T value)
483 {
484 if (value == padding<T>())
485 {
486 padding_received = true;
487 }
488 else
489 {
490 if (padding_received)
491 {
492 ETL_ASSERT_FAIL(ETL_ERROR(etl::base64_invalid_data));
493 invalid_data_detected = true;
494 }
495 else
496 {
497 input_buffer[input_buffer_length++] = static_cast<uint8_t>(value);
498 }
499 }
500 }
501
502 //*************************************************************************
503 //
504 //*************************************************************************
505 ETL_CONSTEXPR14
506 bool input_buffer_is_full() const
507 {
508 return input_buffer_length == 4U;
509 }
510
511 //*************************************************************************
512 //
513 //*************************************************************************
514 ETL_CONSTEXPR14
515 void reset_input_buffer()
516 {
517 input_buffer_length = 0;
518 }
519
520 char input_buffer[4];
521 size_t input_buffer_length;
522
523 unsigned char* p_output_buffer;
524 size_t output_buffer_length;
525 const size_t output_buffer_max_size;
526
527 callback_type callback;
528
529 bool overflow_detected;
530 bool invalid_data_detected;
531 bool padding_received;
532 };
533
534 //*************************************************************************
536 //*************************************************************************
537 template <size_t Buffer_Size = etl::base64::Min_Decode_Buffer_Size>
539 {
540 public:
541
542 ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Decode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Decode_Buffer_Size");
543
544 //*************************************************************************
546 //*************************************************************************
547 ETL_CONSTEXPR14
549 : ibase64_decoder(etl::base64::character_set_1(),
550 etl::base64::Padding::No_Padding,
551 output_buffer,
554 , output_buffer()
555 {
556 }
557
558 //*************************************************************************
560 //*************************************************************************
561 ETL_CONSTEXPR14
563 : ibase64_decoder(etl::base64::character_set_1(),
564 etl::base64::Padding::No_Padding,
565 output_buffer,
567 callback_)
568 , output_buffer()
569 {
570 }
571
572 //*************************************************************************
574 //*************************************************************************
575 ETL_NODISCARD
576 static
577 ETL_CONSTEXPR14
582
583 private:
584
586 unsigned char output_buffer[Buffer_Size];
587 };
588
589 //*************************************************************************
591 //*************************************************************************
592 template <size_t Buffer_Size = etl::base64::Min_Decode_Buffer_Size>
594 {
595 public:
596
597 ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Decode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Decode_Buffer_Size");
598
599 //*************************************************************************
601 //*************************************************************************
602 ETL_CONSTEXPR14
604 : ibase64_decoder(etl::base64::character_set_3(),
605 etl::base64::Padding::No_Padding,
606 output_buffer,
609 , output_buffer()
610 {
611 }
612
613 //*************************************************************************
615 //*************************************************************************
616 ETL_CONSTEXPR14
618 : ibase64_decoder(etl::base64::character_set_3(),
619 etl::base64::Padding::No_Padding,
620 output_buffer,
622 callback_)
623 , output_buffer()
624 {
625 }
626
627 //*************************************************************************
629 //*************************************************************************
630 ETL_NODISCARD
631 static
632 ETL_CONSTEXPR14
637
638 private:
639
641 unsigned char output_buffer[Buffer_Size];
642 };
643
644 //*************************************************************************
646 //*************************************************************************
647 template <size_t Buffer_Size = etl::base64::Min_Decode_Buffer_Size>
649 {
650 public:
651
652 ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Decode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Decode_Buffer_Size");
653
654 //*************************************************************************
656 //*************************************************************************
657 ETL_CONSTEXPR14
659 : ibase64_decoder(etl::base64::character_set_1(),
660 etl::base64::Padding::No_Padding,
661 output_buffer,
664 , output_buffer()
665 {
666 }
667
668 //*************************************************************************
670 //*************************************************************************
671 ETL_CONSTEXPR14
673 : ibase64_decoder(etl::base64::character_set_1(),
674 etl::base64::Padding::No_Padding,
675 output_buffer,
677 callback_)
678 , output_buffer()
679 {
680 }
681
682 //*************************************************************************
684 //*************************************************************************
685 ETL_NODISCARD
686 static
687 ETL_CONSTEXPR14
692
693 private:
694
696 unsigned char output_buffer[Buffer_Size];
697 };
698
699 //*************************************************************************
701 //*************************************************************************
702 template <size_t Buffer_Size = etl::base64::Min_Decode_Buffer_Size>
704 {
705 public:
706
707 ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Decode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Decode_Buffer_Size");
708
709 //*************************************************************************
711 //*************************************************************************
712 ETL_CONSTEXPR14
714 : ibase64_decoder(etl::base64::character_set_1(),
715 etl::base64::Padding::Use_Padding,
716 output_buffer,
719 , output_buffer()
720 {
721 }
722
723 //*************************************************************************
725 //*************************************************************************
726 ETL_CONSTEXPR14
728 : ibase64_decoder(etl::base64::character_set_1(),
729 etl::base64::Padding::Use_Padding,
730 output_buffer,
732 callback_)
733 , output_buffer()
734 {
735 }
736
737 //*************************************************************************
739 //*************************************************************************
740 ETL_NODISCARD
741 static
742 ETL_CONSTEXPR14
747
748 private:
749
751 unsigned char output_buffer[Buffer_Size];
752 };
753
754 //*************************************************************************
756 //*************************************************************************
757 template <size_t Buffer_Size = etl::base64::Min_Decode_Buffer_Size>
759 {
760 public:
761
762 ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Decode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Decode_Buffer_Size");
763
764 //*************************************************************************
766 //*************************************************************************
767 ETL_CONSTEXPR14
769 : ibase64_decoder(etl::base64::character_set_2(),
770 etl::base64::Padding::No_Padding,
771 output_buffer,
774 , output_buffer()
775 {
776 }
777
778 //*************************************************************************
780 //*************************************************************************
781 ETL_CONSTEXPR14
783 : ibase64_decoder(etl::base64::character_set_2(),
784 etl::base64::Padding::No_Padding,
785 output_buffer,
787 callback_)
788 , output_buffer()
789 {
790 }
791
792 //*************************************************************************
794 //*************************************************************************
795 ETL_NODISCARD
796 static
797 ETL_CONSTEXPR14
802
803 private:
804
806 unsigned char output_buffer[Buffer_Size];
807 };
808
809 //*************************************************************************
811 //*************************************************************************
812 template <size_t Buffer_Size = etl::base64::Min_Decode_Buffer_Size>
814 {
815 public:
816
817 ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Decode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Decode_Buffer_Size");
818
819 //*************************************************************************
821 //*************************************************************************
822 ETL_CONSTEXPR14
824 : ibase64_decoder(etl::base64::character_set_2(),
825 etl::base64::Padding::Use_Padding,
826 output_buffer,
829 , output_buffer()
830 {
831 }
832
833 //*************************************************************************
835 //*************************************************************************
836 ETL_CONSTEXPR14
838 : ibase64_decoder(etl::base64::character_set_2(),
839 etl::base64::Padding::Use_Padding,
840 output_buffer,
842 callback_)
843 , output_buffer()
844 {
845 }
846
847 //*************************************************************************
849 //*************************************************************************
850 ETL_NODISCARD
851 static
852 ETL_CONSTEXPR14
857
858 private:
859
861 unsigned char output_buffer[Buffer_Size];
862 };
863}
864
865#undef ETL_IS_TYPE_8_BIT_INTEGRAL
866#undef ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL
867
868#endif
Illegal character exception.
Definition base64.h:84
buffer overflow exception.
Definition base64.h:71
Base64 RFC-2152 Decoder.
Definition base64_decoder.h:539
ETL_CONSTEXPR14 base64_rfc2152_decoder()
Base64 RFC-2152 constructor.
Definition base64_decoder.h:548
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_decoder.h:578
ETL_CONSTEXPR14 base64_rfc2152_decoder(callback_type callback_)
Base64 RFC-2152 constructor.
Definition base64_decoder.h:562
Base64 RFC-3501 Decoder.
Definition base64_decoder.h:594
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_decoder.h:633
ETL_CONSTEXPR14 base64_rfc3501_decoder()
Base64 RFC-3501 constructor.
Definition base64_decoder.h:603
ETL_CONSTEXPR14 base64_rfc3501_decoder(callback_type callback_)
Base64 RFC-3501 constructor.
Definition base64_decoder.h:617
Base64 RFC-4648 Decoder.
Definition base64_decoder.h:649
ETL_CONSTEXPR14 base64_rfc4648_decoder(callback_type callback_)
Base64 RFC-4648 constructor.
Definition base64_decoder.h:672
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_decoder.h:688
ETL_CONSTEXPR14 base64_rfc4648_decoder()
Base64 RFC-4648 constructor.
Definition base64_decoder.h:658
Base64 RFC-4648-Padding Decoder.
Definition base64_decoder.h:704
ETL_CONSTEXPR14 base64_rfc4648_padding_decoder(callback_type callback_)
Base64 RFC-4648-Padding constructor.
Definition base64_decoder.h:727
ETL_CONSTEXPR14 base64_rfc4648_padding_decoder()
Base64 RFC-4648-Padding constructor.
Definition base64_decoder.h:713
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_decoder.h:743
Base64 RFC-4648-URL Decoder.
Definition base64_decoder.h:759
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_decoder.h:798
ETL_CONSTEXPR14 base64_rfc4648_url_decoder()
Base64 RFC-4648-Padding constructor.
Definition base64_decoder.h:768
ETL_CONSTEXPR14 base64_rfc4648_url_decoder(callback_type callback_)
Base64 RFC-4648-Padding constructor.
Definition base64_decoder.h:782
Base64 RFC-4648-URL-Padding Decoder.
Definition base64_decoder.h:814
ETL_CONSTEXPR14 base64_rfc4648_url_padding_decoder()
Base64 RFC-4648-Padding constructor.
Definition base64_decoder.h:823
static ETL_NODISCARD ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
Calculate the required output encode buffer size.
Definition base64_decoder.h:853
ETL_CONSTEXPR14 base64_rfc4648_url_padding_decoder(callback_type callback_)
Base64 RFC-4648-Padding constructor.
Definition base64_decoder.h:837
Common Base64 definitions.
Definition base64.h:110
Definition callback.h:45
Declaration.
Definition delegate_cpp03.h:175
Base64 Decoder.
Definition base64_decoder.h:63
ETL_NODISCARD ETL_CONSTEXPR14 size_t buffer_size() const
Returns the maximum size of the output buffer.
Definition base64_decoder.h:262
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char * end() const
This only returns a useful value if a callback has not been set or called.
Definition base64_decoder.h:221
ETL_CONSTEXPR14 bool decode(TInputIterator input_begin, size_t input_length)
Decode from Base64.
Definition base64_decoder.h:125
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char * cbegin() const
Returns the beginning of the output buffer.
Definition base64_decoder.h:231
ETL_NODISCARD ETL_CONSTEXPR14 span_type span() const
Definition base64_decoder.h:273
ETL_CONSTEXPR14 ibase64_decoder(const char *encoder_table_, bool use_padding_, unsigned char *p_output_buffer_, size_t ouput_buffer_max_size_, callback_type callback_)
Constructor.
Definition base64_decoder.h:314
ETL_NODISCARD ETL_CONSTEXPR14 size_t size() const
Definition base64_decoder.h:252
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char * cend() const
This only returns a useful value if a callback has not been set or called.
Definition base64_decoder.h:241
ETL_CONSTEXPR14 bool decode_final(TInputIterator input_begin, size_t input_length)
Decode from Base64.
Definition base64_decoder.h:155
ETL_CONSTEXPR14 bool flush()
Flush any remaining data to the output.
Definition base64_decoder.h:164
static ETL_NODISCARD ETL_CONSTEXPR14 size_t decoded_size_from_valid_input_length(size_t input_length)
Calculates the minimum buffer size required to decode from Base64.
Definition base64_decoder.h:338
ETL_CONSTEXPR14 bool decode(T value)
Decode to Base64.
Definition base64_decoder.h:74
ETL_NODISCARD ETL_CONSTEXPR14 bool error() const
Returns true if an error was detected.
Definition base64_decoder.h:303
ETL_NODISCARD ETL_CONSTEXPR14 bool overflow() const
Returns true if the output buffer has overflowed.
Definition base64_decoder.h:283
ETL_CONSTEXPR14 void restart()
Reset the encoder.
Definition base64_decoder.h:197
ETL_CONSTEXPR14 bool decode_final(TInputIterator input_begin, TInputIterator input_end)
Decode from Base64.
Definition base64_decoder.h:145
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char * begin() const
Returns the beginning of the output buffer.
Definition base64_decoder.h:211
ETL_NODISCARD ETL_CONSTEXPR14 bool invalid_data() const
Returns true if an invalid character was detected.
Definition base64_decoder.h:293
ETL_CONSTEXPR14 bool decode(TInputIterator input_begin, TInputIterator input_end)
Decode from Base64.
Definition base64_decoder.h:105
#define ETL_ASSERT(b, e)
Definition error_handler.h:316
bitset_ext
Definition absolute.h:38
Definition base64.h:140
pair holds two objects of arbitrary type
Definition utility.h:164