GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — msgpack-c/example/cpp03/simple.cpp at cpp_master · msgpack/msgpack-c Expand file tree/ Copy pathsimple.cppMore file actions 44 lines (34 loc) · 1.28 KB / Copy pathsimple.cppFile metadata and controls44 lines (34 loc) · 1.28 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 // MessagePack for C++ example // // Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #include <msgpack.hpp> #include <string> #include <iostream> #include <sstream> int main(void) { msgpack::type::tuple<int, bool, std::string> src(1, true, "example"); // serialize the object into the buffer. // any classes that implements write(const char*,size_t) can be a buffer. std::stringstream buffer; msgpack::pack(buffer, src); // send the buffer ... buffer.seekg(0); // deserialize the buffer into msgpack::object instance. std::string str(buffer.str()); msgpack::object_handle oh = msgpack::unpack(str.data(), str.size()); // deserialized object is valid during the msgpack::object_handle instance alive. msgpack::object deserialized = oh.get(); // msgpack::object supports ostream. std::cout << deserialized << std::endl; // convert msgpack::object instance into the original type. // if the type is mismatched, it throws msgpack::type_error exception. msgpack::type::tuple<int, bool, std::string> dst; deserialized.convert(dst); return 0; } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |