mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
it complies and crow updated
This commit is contained in:
parent
9b3a27baa9
commit
f9925d6c3b
20 changed files with 870 additions and 513 deletions
47
ext/crow/utility.h
Normal file → Executable file
47
ext/crow/utility.h
Normal file → Executable file
|
@ -6,6 +6,7 @@
|
|||
#include <type_traits>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace crow
|
||||
{
|
||||
|
@ -14,7 +15,7 @@ namespace crow
|
|||
#ifndef CROW_MSVC_WORKAROUND
|
||||
struct OutOfRange
|
||||
{
|
||||
OutOfRange(unsigned pos, unsigned length) {}
|
||||
OutOfRange(unsigned /*pos*/, unsigned /*length*/) {}
|
||||
};
|
||||
constexpr unsigned requires_in_range( unsigned i, unsigned len )
|
||||
{
|
||||
|
@ -129,7 +130,7 @@ template <> \
|
|||
struct parameter_tag<t> \
|
||||
{ \
|
||||
static const int value = i; \
|
||||
};
|
||||
}
|
||||
CROW_INTERNAL_PARAMETER_TAG(int, 1);
|
||||
CROW_INTERNAL_PARAMETER_TAG(char, 1);
|
||||
CROW_INTERNAL_PARAMETER_TAG(short, 1);
|
||||
|
@ -499,5 +500,47 @@ template <typename F, typename Set>
|
|||
using arg = typename std::tuple_element<i, std::tuple<Args...>>::type;
|
||||
};
|
||||
|
||||
std::string base64encode(const char* data, size_t size, const char* key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
|
||||
{
|
||||
std::string ret;
|
||||
ret.resize((size+2) / 3 * 4);
|
||||
auto it = ret.begin();
|
||||
while(size >= 3)
|
||||
{
|
||||
*it++ = key[(((unsigned char)*data)&0xFC)>>2];
|
||||
unsigned char h = (((unsigned char)*data++) & 0x03) << 4;
|
||||
*it++ = key[h|((((unsigned char)*data)&0xF0)>>4)];
|
||||
h = (((unsigned char)*data++) & 0x0F) << 2;
|
||||
*it++ = key[h|((((unsigned char)*data)&0xC0)>>6)];
|
||||
*it++ = key[((unsigned char)*data++)&0x3F];
|
||||
|
||||
size -= 3;
|
||||
}
|
||||
if (size == 1)
|
||||
{
|
||||
*it++ = key[(((unsigned char)*data)&0xFC)>>2];
|
||||
unsigned char h = (((unsigned char)*data++) & 0x03) << 4;
|
||||
*it++ = key[h];
|
||||
*it++ = '=';
|
||||
*it++ = '=';
|
||||
}
|
||||
else if (size == 2)
|
||||
{
|
||||
*it++ = key[(((unsigned char)*data)&0xFC)>>2];
|
||||
unsigned char h = (((unsigned char)*data++) & 0x03) << 4;
|
||||
*it++ = key[h|((((unsigned char)*data)&0xF0)>>4)];
|
||||
h = (((unsigned char)*data++) & 0x0F) << 2;
|
||||
*it++ = key[h];
|
||||
*it++ = '=';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string base64encode_urlsafe(const char* data, size_t size)
|
||||
{
|
||||
return base64encode(data, size, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
|
||||
}
|
||||
|
||||
|
||||
} // namespace utility
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue