From c1e1768cc9dc3d2da15381274da58fe8a64b735e Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 20 Jun 2016 21:03:00 +0200 Subject: [PATCH] [DEV] remove base64 for library --- ejson/base64.cpp | 110 ----------------------------------------------- ejson/base64.h | 15 ------- lutin_ejson.py | 2 - 3 files changed, 127 deletions(-) delete mode 100644 ejson/base64.cpp delete mode 100644 ejson/base64.h diff --git a/ejson/base64.cpp b/ejson/base64.cpp deleted file mode 100644 index 0a25388..0000000 --- a/ejson/base64.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/** @file - * @author Edouard DUPIN - * @copyright 2011, Edouard DUPIN, all right reserved - * @license APACHE v2.0 (see license file) - */ -#include -#include - -static const std::string base64Elements = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -const std::vector& getReverseTable() { - static std::vector table; - if (table.size() == 0) { - table.resize(256,0); - for (size_t iii=0; iii> 2; - bit4[1] = ((bit3[0] & 0x03) << 4) + ((bit3[1] & 0xf0) >> 4); - bit4[2] = ((bit3[1] & 0x0f) << 2) + ((bit3[2] & 0xc0) >> 6); - bit4[3] = bit3[2] & 0x3f; - for(int32_t jjj=0; jjj<4 ; ++jjj) { - out += base64Elements[bit4[jjj]]; - } - } - } - // Residual packing ... - if (iii != 0) { - for(int32_t jjj=iii; jjj<3; ++jjj) { - bit3[jjj] = 0; - } - bit4[0] = (bit3[0] & 0xfc) >> 2; - bit4[1] = ((bit3[0] & 0x03) << 4) + ((bit3[1] & 0xf0) >> 4); - bit4[2] = ((bit3[1] & 0x0f) << 2) + ((bit3[2] & 0xc0) >> 6); - bit4[3] = bit3[2] & 0x3f; - for (int32_t jjj=0; jjj ejson::base64::decode(const std::string& _data) { - int32_t len = _data.size(); - int32_t iii = 0; - int32_t id = 0; - uint8_t bit4[4]; - uint8_t bit3[3]; - std::vector out; - const std::vector& base64ElementsReverse = getReverseTable(); - while ( len-- - && _data[id] != '=' - && isBase64(_data[id]) == true) { - bit4[iii++] = _data[id]; - id++; - if (iii == 4) { - iii = 0; - for (int32_t jjj=0; jjj<4; ++jjj) { - bit4[jjj] = base64ElementsReverse[bit4[jjj]]; - } - bit3[0] = (bit4[0] << 2) + ((bit4[1] & 0x30) >> 4); - bit3[1] = ((bit4[1] & 0xf) << 4) + ((bit4[2] & 0x3c) >> 2); - bit3[2] = ((bit4[2] & 0x3) << 6) + bit4[3]; - for (int32_t jjj=0; jjj<3; ++jjj) { - out.push_back(bit3[jjj]); - } - } - } - if (iii != 0) { - for (int32_t jjj=iii; jjj<4; ++jjj) { - bit4[jjj] = 0; - } - for (int32_t jjj = 0; jjj <4; ++jjj) { - bit4[jjj] = base64ElementsReverse[bit4[jjj]]; - } - bit3[0] = (bit4[0] << 2) + ((bit4[1] & 0x30) >> 4); - bit3[1] = ((bit4[1] & 0xf) << 4) + ((bit4[2] & 0x3c) >> 2); - bit3[2] = ((bit4[2] & 0x3) << 6) + bit4[3]; - for (int32_t jjj=0; jjj - -namespace ejson { - namespace base64 { - std::string encode(const uint8_t* _data, int32_t _len); - std::vector decode(const std::string& _data); - } -} diff --git a/lutin_ejson.py b/lutin_ejson.py index def3654..447e472 100644 --- a/lutin_ejson.py +++ b/lutin_ejson.py @@ -40,7 +40,6 @@ def create(target, module_name): 'ejson/String.cpp', 'ejson/Object.cpp', 'ejson/Value.cpp', - 'ejson/base64.cpp', 'ejson/internal/Document.cpp', 'ejson/internal/Array.cpp', 'ejson/internal/Boolean.cpp', @@ -63,7 +62,6 @@ def create(target, module_name): 'ejson/Object.h', 'ejson/Value.h', 'ejson/iterator.h', - 'ejson/base64.h', 'ejson/details/iterator.hxx', 'ejson/internal/Document.h', 'ejson/internal/Array.h',