mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-18 11:39:02 +02:00
Added EXT support.
Removed obsolete unpack functions. Updated examples that no longer use obsolete functions. Added reference checking function to unpacked. ( unpacked::referenced() ) Added std:: namespace. Added reference or copy choice function and default behavior: When you use unpacker, default behavior is: STR, BIN, EXT types are always held by reference. When you don't use unpacker, default behavior is: STR, BIN, EXT types are always held by copy. The memory is allocated from zone. You can customize the behavior passing your custom judging function to unpack() or unpacker's constructor.
This commit is contained in:
@@ -51,23 +51,11 @@ void test_array_of_array() {
|
||||
buffer.seekg(0);
|
||||
std::string str(buffer.str());
|
||||
|
||||
// deserialized object is valid during the msgpack::zone instance alive.
|
||||
msgpack::zone mempool;
|
||||
msgpack::object deserialized;
|
||||
std::cout << "Start unpacking..." << std::endl;
|
||||
{
|
||||
boost::timer::cpu_timer timer;
|
||||
msgpack::unpack(str.data(), str.size(), NULL, &mempool, &deserialized);
|
||||
std::string result = timer.format();
|
||||
std::cout << result << std::endl;
|
||||
}
|
||||
std::cout << "Unpack finished..." << std::endl;
|
||||
|
||||
msgpack::unpacked unpacked;
|
||||
std::cout << "Start unpacking...by void unpack(unpacked* result, const char* data, size_t len, size_t* offset = NULL)" << std::endl;
|
||||
std::cout << "Start unpacking...by void unpack(unpacked& result, const char* data, size_t len)" << std::endl;
|
||||
{
|
||||
boost::timer::cpu_timer timer;
|
||||
msgpack::unpack(&unpacked, str.data(), str.size());
|
||||
msgpack::unpack(unpacked, str.data(), str.size());
|
||||
std::string result = timer.format();
|
||||
std::cout << result << std::endl;
|
||||
}
|
||||
@@ -76,7 +64,7 @@ void test_array_of_array() {
|
||||
std::cout << "Start converting..." << std::endl;
|
||||
{
|
||||
boost::timer::cpu_timer timer;
|
||||
deserialized.convert(&v2);
|
||||
unpacked.get().convert(&v2);
|
||||
std::string result = timer.format();
|
||||
std::cout << result << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user