diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-04-13 05:39:25 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-04-13 05:41:53 +0200 |
commit | 84984bdfd0273b789e0c9bfe397440dd6912912d (patch) | |
tree | b509e5d48e27d727429a39a8b48fda10145875e7 /include | |
parent | bc26e012f3041529939d38ac522c18499ddff982 (diff) |
Include cppcodec instead of using it a system library. Its not available in ubuntu repos for example
Diffstat (limited to 'include')
-rw-r--r-- | include/base64_url.hpp | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/include/base64_url.hpp b/include/base64_url.hpp deleted file mode 100644 index 271940e..0000000 --- a/include/base64_url.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include <cppcodec/base64_rfc4648.hpp> - -static constexpr const char base64_url_alphabet[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' -}; - -class base64_url_impl -{ -public: - template <typename Codec> using codec_impl = cppcodec::detail::stream_codec<Codec, base64_url_impl>; - - static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { - static_assert(sizeof(base64_url_alphabet) == 64, "base64 alphabet must have 64 values"); - return sizeof(base64_url_alphabet); - } - static CPPCODEC_ALWAYS_INLINE constexpr char symbol(cppcodec::detail::alphabet_index_t idx) - { - return base64_url_alphabet[idx]; - } - static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) { return c; } - - static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return true; } - static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return true; } - static CPPCODEC_ALWAYS_INLINE constexpr char padding_symbol() { return '='; } - static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char c) { return c == '='; } - static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } - - // RFC4648 does not specify any whitespace being allowed in base64 encodings. - static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char) { return false; } -}; - -using base64_url = cppcodec::detail::codec<cppcodec::detail::base64<base64_url_impl>>;
\ No newline at end of file |