Jamoma API  0.6.0.a19
JSON_Base64.h
1 #ifndef LIBJSON_GUARD_BASE64_H
2 #define LIBJSON_GUARD_BASE64_H
3 
4 #include "JSONDebug.h"
5 #if defined(JSON_BINARY) || defined(JSON_EXPOSE_BASE64) //if this is not needed, don't waste space compiling it
6 
7 #include "../Dependencies/libbase64++/libbase64++.h"
8 
9 class JSONBase64 {
10 public:
11  inline static json_string json_encode64(const unsigned char * binary, size_t bytes) json_nothrow json_cold;
12  inline static std::string json_decode64(const json_string & encoded) json_nothrow json_cold;
13 private:
14  JSONBase64(void);
15 };
16 
17 json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes) json_nothrow {
18  #if defined JSON_DEBUG || defined JSON_SAFE
19  return libbase64::encode<json_string, json_char, json_uchar, true>(binary, bytes);
20  #else
21  return libbase64::encode<json_string, json_char, json_uchar, false>(binary, bytes);
22  #endif
23 }
24 
25 std::string JSONBase64::json_decode64(const json_string & encoded) json_nothrow {
26  #if defined JSON_DEBUG || defined JSON_SAFE
27  return libbase64::decode<json_string, json_char, json_uchar, true>(encoded);
28  #else
29  return libbase64::decode<json_string, json_char, json_uchar, false>(encoded);
30  #endif
31 }
32 
33 
34 #endif
35 #endif