hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sample.cpp
Go to the documentation of this file.
1 
14 #include <sstream>
15 #include <iostream>
16 
17 #include "EncodeDecodeBase64.hpp"
18 
19 void printTitle(const std::string& title)
20 {
21  std::cout << std::string(title.length(), '=') << std::endl << title << std::endl << std::string(title.length(), '=') << std::endl;
22 }
23 
25 {
26  printTitle("Sample use encodeBase64");
27 
28  const std::string data = "Hello world!";
29  std::string encodeString = HCE::encodeBase64(data);
30 
31  std::cout << "Input string: " << data << std::endl;
32  std::cout << "Encode string: " << encodeString << std::endl;
33 
34 #if JSON_USE_BASE64 == 1
35  std::cout << "JSON_USE_BASE64 == 1" << std::endl;
36  std::cout << ((encodeString=="SGVsbG8gd29ybGQh")?"Success":"Fail") << std::endl;
37 #else
38  std::cout << "JSON_USE_BASE64 != 1" << std::endl;
39  std::cout << ((encodeString==data)?"Success":"Fail") << std::endl;
40 #endif
41 }
42 
44 {
45  printTitle("Sample use decodeBase64");
46 
47  const std::string data = "Hello world!";
48  std::string encodeString;
49 
50 #if JSON_USE_BASE64 == 1
51  std::cout << "JSON_USE_BASE64 == 1" << std::endl;
52  encodeString = "SGVsbG8gd29ybGQh";
53 #else
54  std::cout << "JSON_USE_BASE64 != 1" << std::endl;
55  encodeString = data;
56 #endif
57 
58  std::string decodeString = HCE::decodeBase64(encodeString);
59 
60  std::cout << "Input string: " << encodeString << std::endl;
61  std::cout << "Decode string: " << decodeString << std::endl;
62 
63  std::cout << ((decodeString==data)?"Success":"Fail") << std::endl;
64 }
65 
66 int main(void)
67 {
70 
71  return 0;
72 }