diff options
-rw-r--r-- | modules/codec/c++/base64.hpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/modules/codec/c++/base64.hpp b/modules/codec/c++/base64.hpp index b65060e..4c9ae18 100644 --- a/modules/codec/c++/base64.hpp +++ b/modules/codec/c++/base64.hpp @@ -98,10 +98,40 @@ public: template<typename ToDecode> static error_or<void> decode(data<Schema,encode::Base64>& from, data<Schema, ToDecode>& to){ - (void) to; - (void) from; - return make_error<err::not_implemented>(); + /* + uint64_t b64_len = from.size(); + if((b64_len % 4) != 0){ + return make_error<err::invalid_state>("B64 is not padded"); + } + uint64_t section_len = b64_len / 4u; + + std::string to_str; + + for(uint64_t i = 0u; i < section_len; ++i){ + uint64_t j = 4u*i; + + std::array<char,3> to_bits{0,0,0}; + std::array<char,4> from_bits{ + from.at(j).get(), + from.at(j+1u).get(), + from.at(j+2u).get(), + from.at(j+3u).get() + }; + + for(char iter : from_bits){ + if(!is_base64(iter)){ + return make_error<err::invalid_state>("Not a base64 char"); + } + } + + to_bits[0] = char_array + } + + to = {std::move(to_str)}; + + return saw::make_void(); + */ } }; |