highlighter application  1.1
HCE project utils : highlighter
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
EncodeDecodeBase64.cpp
Go to the documentation of this file.
1 #include <Poco/Base64Encoder.h>
2 #include <Poco/Base64Decoder.h>
3 #include <Poco/StreamCopier.h>
4 #include <sstream>
5 
6 #include "EncodeDecodeBase64.hpp"
7 
8 namespace HCE
9 {
10 //-----------------------------------------------------------------------------
11 std::string encodeBase64(const std::string& data)
12 {
13 #if JSON_USE_BASE64 == 1
14  std::stringstream istr(data);
15  std::stringstream ostr;
16  Poco::Base64Encoder encoder(ostr);
17  Poco::StreamCopier::copyStream(istr, encoder);
18  encoder.close();
19  return ostr.str();
20 #else
21  return data;
22 #endif
23 }
24 //-----------------------------------------------------------------------------
25 std::string decodeBase64(const std::string& data)
26 {
27 #if JSON_USE_BASE64 == 1
28  std::stringstream istr;
29  std::stringstream ostr(data);
30  Poco::Base64Decoder decoder(ostr);
31  Poco::StreamCopier::copyStream(decoder, istr);
32  return istr.str();
33 #else
34  return data;
35 #endif
36 }
37 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
39 } // end namespace HCE
40 
41 
42 
43