Created
April 24, 2010 16:25
-
-
Save frsyuki/377751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msgpack.hpp> | |
#include <iostream> | |
struct myclass { | |
int num; | |
std::string str; | |
MSGPACK_DEFINE(num, str); | |
}; | |
int main(void) | |
{ | |
msgpack::object o1(1.2); | |
std::cout << o1 << std::endl; | |
if(o1 == 1.2) { | |
std::cout << "dynamic double == static double" << std::endl; | |
} | |
std::string str("dynamic type in C++"); | |
msgpack::zone z2; | |
msgpack::object o2(str, &z2); | |
std::cout << o2 << std::endl; | |
if(o2 == str) { | |
std::cout << "dynamic string == static string" << std::endl; | |
} | |
if(o2 != 1) { | |
std::cout << "dynamic string != static int" << std::endl; | |
} | |
if(msgpack::object(true) != false) { | |
std::cout << "dynamic boolean true != dynamic boolean false" << std::endl; | |
} | |
std::list<std::vector<int> > ls; | |
std::vector<int> vec1; | |
vec1.push_back(0); | |
ls.push_back(vec1); | |
std::vector<int> vec2; | |
vec2.push_back(1); | |
ls.push_back(vec2); | |
msgpack::zone z3; | |
msgpack::object o3(ls, &z3); | |
std::cout << o3 << std::endl; | |
myclass my; | |
my.num = 2; | |
my.str = "custom class"; | |
msgpack::zone z4; | |
msgpack::object o4(my, &z4); | |
std::cout << o4 << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment