mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-20 22:31:33 +02:00
Compare commits
164 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7bee573a72 | ||
![]() |
5568abb6ab | ||
![]() |
67486480ac | ||
![]() |
0e3bb789b8 | ||
![]() |
e1eabbfebf | ||
![]() |
e416b534b8 | ||
![]() |
212ef8eb2b | ||
![]() |
7bf06a5885 | ||
![]() |
1822523289 | ||
![]() |
156a4403ab | ||
![]() |
ad5da7f131 | ||
![]() |
62be3f1212 | ||
![]() |
8dbe25a51d | ||
![]() |
7cfd4bb1d8 | ||
![]() |
037a108c49 | ||
![]() |
79a127a8b6 | ||
![]() |
ace27f6238 | ||
![]() |
cc2ded6338 | ||
![]() |
13a746f6fa | ||
![]() |
b0ff2802d2 | ||
![]() |
4b0c90fc90 | ||
![]() |
4b11fb32cd | ||
![]() |
f707c6b47c | ||
![]() |
081ee0e99a | ||
![]() |
8eaa2e9e74 | ||
![]() |
ac1eb6e1d3 | ||
![]() |
343ceabe9a | ||
![]() |
eb765d21f2 | ||
![]() |
2d5c68055c | ||
![]() |
de68fbd6d0 | ||
![]() |
118cf7270c | ||
![]() |
cf1487f8ba | ||
![]() |
e4cd479bf3 | ||
![]() |
8dae63e4c1 | ||
![]() |
a3f350842c | ||
![]() |
c1e9f92d7f | ||
![]() |
582fe38e78 | ||
![]() |
6443738f66 | ||
![]() |
45eb2ad0c7 | ||
![]() |
37593400c3 | ||
![]() |
60648fc3a8 | ||
![]() |
0482e4fcd1 | ||
![]() |
82a10cba5c | ||
![]() |
0d9a21ea08 | ||
![]() |
f399ec8c30 | ||
![]() |
8ad9ce059b | ||
![]() |
a4aa14d1e2 | ||
![]() |
f7f2d4b990 | ||
![]() |
c675881f3b | ||
![]() |
f6d0cd9a4b | ||
![]() |
4ef5894856 | ||
![]() |
07ddfa1430 | ||
![]() |
252d66a4b2 | ||
![]() |
b4eba4ba09 | ||
![]() |
2266505eed | ||
![]() |
46e2398e02 | ||
![]() |
3662a17e81 | ||
![]() |
66f221d088 | ||
![]() |
9ed4e443fb | ||
![]() |
15aec0493d | ||
![]() |
d6a7bd1995 | ||
![]() |
ff86d61799 | ||
![]() |
97886c50e7 | ||
![]() |
327b0db626 | ||
![]() |
994144dac2 | ||
![]() |
023f81ae9c | ||
![]() |
83fac26762 | ||
![]() |
213ba44b65 | ||
![]() |
fa231139d7 | ||
![]() |
5cd1c6bfa1 | ||
![]() |
c4fb47c00d | ||
![]() |
70e50d9679 | ||
![]() |
978e6b9057 | ||
![]() |
571f1a27a2 | ||
![]() |
c3518c0666 | ||
![]() |
64ac09c492 | ||
![]() |
414da4e8c6 | ||
![]() |
3eadb124fc | ||
![]() |
fd9eb26688 | ||
![]() |
6c59e5195a | ||
![]() |
3bdf646cc6 | ||
![]() |
2bbf10a324 | ||
![]() |
737e6703df | ||
![]() |
7f48ddc85e | ||
![]() |
a84f444ce2 | ||
![]() |
7e597779e4 | ||
![]() |
bf8c830eef | ||
![]() |
5f52ec5030 | ||
![]() |
c71ce9eb49 | ||
![]() |
f105b4bbb0 | ||
![]() |
f64be3b2d0 | ||
![]() |
abac9fe90a | ||
![]() |
5798fa0e47 | ||
![]() |
fe4af1125d | ||
![]() |
ce96ca8bfc | ||
![]() |
57732f0c1b | ||
![]() |
7ccef5b787 | ||
![]() |
1a116fb644 | ||
![]() |
f79fd82953 | ||
![]() |
b9a80697bc | ||
![]() |
467822c97a | ||
![]() |
7ab7eaf61b | ||
![]() |
3ed6b673d4 | ||
![]() |
469040be6b | ||
![]() |
309e96087a | ||
![]() |
2d61fdf865 | ||
![]() |
6e560e345a | ||
![]() |
8b796dc788 | ||
![]() |
240b02174d | ||
![]() |
38a380684e | ||
![]() |
1a615af437 | ||
![]() |
9162610682 | ||
![]() |
c52a58b322 | ||
![]() |
ac3433f5dd | ||
![]() |
dab725624e | ||
![]() |
037b1c22dc | ||
![]() |
0de0b434b3 | ||
![]() |
7eb3d2aa59 | ||
![]() |
0827d08cd7 | ||
![]() |
3d20ec6f21 | ||
![]() |
bcdbf78542 | ||
![]() |
a4af97b32c | ||
![]() |
e00b299fe0 | ||
![]() |
d6cc5494a9 | ||
![]() |
96c688708c | ||
![]() |
79e7a9810c | ||
![]() |
a0ae0289dc | ||
![]() |
31a3d34b49 | ||
![]() |
1c54d804f5 | ||
![]() |
111efdf50f | ||
![]() |
dac8f6290d | ||
![]() |
3bfd142660 | ||
![]() |
d031162d96 | ||
![]() |
8e24d9206a | ||
![]() |
b78b49a7bd | ||
![]() |
561e9ba105 | ||
![]() |
6e84266043 | ||
![]() |
151c92d08d | ||
![]() |
1285470c21 | ||
![]() |
837c5ecfc3 | ||
![]() |
04aa309f24 | ||
![]() |
69b2ea4002 | ||
![]() |
8ddc219365 | ||
![]() |
a9cf916b82 | ||
![]() |
8455a2eb70 | ||
![]() |
5c0f1db25c | ||
![]() |
bf4a57da34 | ||
![]() |
2fcbe6116d | ||
![]() |
0176dd760a | ||
![]() |
d30548af3f | ||
![]() |
ab12b2b2b9 | ||
![]() |
7ce69a362f | ||
![]() |
cc08146b1c | ||
![]() |
6896cc602f | ||
![]() |
d8f366daf2 | ||
![]() |
ef649009e4 | ||
![]() |
847a7852e5 | ||
![]() |
e265beef91 | ||
![]() |
dc679a2572 | ||
![]() |
b6bc7f7ecb | ||
![]() |
501260eb54 | ||
![]() |
8615358515 | ||
![]() |
dd083ca933 | ||
![]() |
c203928fae |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,7 @@
|
||||
# Files generated by the bootstrap script.
|
||||
/INSTALL
|
||||
/AUTHORS
|
||||
/ChangeLog
|
||||
/NEWS
|
||||
/README
|
||||
/ac/
|
||||
|
@@ -1,3 +1,35 @@
|
||||
2015-3-22 version 1.0.1:
|
||||
* Fix compilation error on Mac 10.9 (#244)
|
||||
* Fix typos in documents (#240)
|
||||
* Update CHANGELOG.md for version 1.0.0 (#242)
|
||||
* Fix erb templates for the next code generation (#239)
|
||||
|
||||
2015-03-10 version 1.0.0:
|
||||
* Support msgpack v5 format (str, bin, and ext) https://github.com/msgpack/msgpack/blob/master/spec.md (#142)
|
||||
* Support std::tuple, std::forward_list, std::array, std::unordered_set, std::unordered_map on C++11. tr1 unordered containers are still supported (#53, #130, #137, #154, #169)
|
||||
* Update msgpack-c as a header-only library on C++ (#142)
|
||||
* Move include directory (#142)
|
||||
* Update the name of float format family on msgpack::object from 'dec' to 'f64' (#194)
|
||||
* Remove existing elements on associative containers when unpacking (#127)
|
||||
* Add an API versioning functionality https://github.com/msgpack/msgpack-c/wiki/cpp_versioning (#139)
|
||||
* Add C++11 enum class support (#205)
|
||||
* Map std::vector<char> and std::array<char> to BIN (#100)
|
||||
* Map '\0' teminated char* and char const* to STR (#206)
|
||||
* Add the new parameter on unpacking functions and classes to limit msgpack's bytestream size (https://github.com/msgpack/msgpack-c/wiki/cpp_unpacker#limit-size-of-elements) (#175)
|
||||
* Add the copy or reference choosing function on unpack() and unpacker (https://github.com/msgpack/msgpack-c/wiki/cpp_unpacker#memory-management)
|
||||
* Add the new unpack() overloads for C++11 https://github.com/msgpack/msgpack-c/wiki/cpp_unpacker (#128)
|
||||
* Add a msgpack::object::with_zone (deep) copying function (#133, #163)
|
||||
* Remove the compile-time defined limit of msgpack nest level on C++ (#218)
|
||||
* Add the new unpack() overloads that use an existing zone (#201)
|
||||
* Add the range-based for loop support on msgpack object array and map (#203)
|
||||
* Add msgpack revision getter function for 'revision' (#237)
|
||||
* Support EXT for C (#118, #129)
|
||||
* Fix unpacking buffer allocation problem when malformed data is given (#160, #185)
|
||||
* Add dll exporting function on MSVC (#162)
|
||||
* Fix msgpack::zone::allocate_no_align(). Now it allocates the memory that is not aligned as expected (#171)
|
||||
* Improve documents (https://github.com/msgpack/msgpack-c/wiki)
|
||||
* Other bug fixes and refactoring: #62, #91, #95, #97, #107, #109, #113, #117, #119, #121, #122, #123, #126, #131, #136, #138, #140, #143, #145, #146, #150, #151, #152, #156, #157, #158, #161, #165, #170, #172, #179, #180, #181, #182, #183, #192, #195, #199, #200, #207, #211, #212, #219, #222, #224, #230, #231, #232, #233, #234, #235
|
||||
|
||||
2014-07-02 version 0.5.9:
|
||||
|
||||
* Support std::tr1 unordered containers by default (#51, #63, #68, #69)
|
@@ -1,7 +1,7 @@
|
||||
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.6)
|
||||
PROJECT (msgpack)
|
||||
|
||||
FILE (READ ${CMAKE_SOURCE_DIR}/include/msgpack/version_master.h contents)
|
||||
FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/version_master.h contents)
|
||||
STRING (REGEX MATCH "#define MSGPACK_VERSION_MAJOR *([0-9a-zA-Z_]*)" NULL_OUT ${contents})
|
||||
SET (VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
STRING (REGEX MATCH "#define MSGPACK_VERSION_MINOR *([0-9a-zA-Z_]*)" NULL_OUT ${contents})
|
||||
@@ -83,6 +83,7 @@ LIST (APPEND msgpack_HEADERS
|
||||
include/msgpack/unpack_template.h
|
||||
include/msgpack/util.h
|
||||
include/msgpack/sysdep.h
|
||||
include/msgpack/gcc_atomic.h
|
||||
include/msgpack/sbuffer.h
|
||||
include/msgpack/version.h
|
||||
include/msgpack/vrefbuffer.h
|
||||
@@ -102,6 +103,7 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/adaptor/bool_fwd.hpp
|
||||
include/msgpack/adaptor/char_ptr.hpp
|
||||
include/msgpack/adaptor/char_ptr_fwd.hpp
|
||||
include/msgpack/adaptor/check_container_size.hpp
|
||||
include/msgpack/adaptor/cpp11/array.hpp
|
||||
include/msgpack/adaptor/cpp11/array_fwd.hpp
|
||||
include/msgpack/adaptor/cpp11/array_char.hpp
|
||||
@@ -110,6 +112,10 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/adaptor/cpp11/forward_list_fwd.hpp
|
||||
include/msgpack/adaptor/cpp11/tuple.hpp
|
||||
include/msgpack/adaptor/cpp11/tuple_fwd.hpp
|
||||
include/msgpack/adaptor/cpp11/unordered_map.hpp
|
||||
include/msgpack/adaptor/cpp11/unordered_map_fwd.hpp
|
||||
include/msgpack/adaptor/cpp11/unordered_set.hpp
|
||||
include/msgpack/adaptor/cpp11/unordered_set_fwd.hpp
|
||||
include/msgpack/adaptor/define.hpp
|
||||
include/msgpack/adaptor/deque.hpp
|
||||
include/msgpack/adaptor/deque_fwd.hpp
|
||||
@@ -147,6 +153,8 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/adaptor/tr1/unordered_set_fwd.hpp
|
||||
include/msgpack/adaptor/vector.hpp
|
||||
include/msgpack/adaptor/vector_fwd.hpp
|
||||
include/msgpack/adaptor/vector_bool.hpp
|
||||
include/msgpack/adaptor/vector_bool_fwd.hpp
|
||||
include/msgpack/adaptor/vector_char.hpp
|
||||
include/msgpack/adaptor/vector_char_fwd.hpp
|
||||
include/msgpack/cpp_config.hpp
|
||||
@@ -211,12 +219,16 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" ST
|
||||
ENDIF ()
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
ELSE ()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC90" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC10")
|
||||
SET_SOURCE_FILES_PROPERTIES(${msgpack_SOURCES} PROPERTIES LANGUAGE CXX)
|
||||
ENDIF()
|
||||
|
||||
IF (NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
SET(CMAKE_INSTALL_LIBDIR lib)
|
||||
ENDIF ()
|
||||
|
4
NOTICE
4
NOTICE
@@ -1,4 +0,0 @@
|
||||
MessagePack is developed by FURUHASHI Sadayuki, licensed under Apache License,
|
||||
Version 2.0. The original software and related information is available at
|
||||
http://msgpack.sourceforge.jp/.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
The serialization library is production-ready.
|
||||
|
||||
Currently, no RPC implementation is not available.
|
||||
Currently, RPC implementation is not available.
|
||||
|
||||
# Install
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
The serialization library is production-ready.
|
||||
|
||||
Currently, RPC implementation is testing phase. Requires newer kernel, not running on RHEL5/CentOS5.
|
||||
Currently, RPC implementation is in testing phase. Requires newer kernel, not running on RHEL5/CentOS5.
|
||||
|
||||
# Install
|
||||
|
||||
|
231
README.md
231
README.md
@@ -1,71 +1,163 @@
|
||||
# Msgpack for C/C++
|
||||
`msgpack` for C/C++
|
||||
===================
|
||||
|
||||
Version 1.0.1 [](https://travis-ci.org/msgpack/msgpack-c)
|
||||
|
||||
It's like JSON but small and fast.
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
## Overview
|
||||
[MessagePack](http://msgpack.org/) is an efficient binary serialization
|
||||
format, which lets you exchange data among multiple languages like JSON,
|
||||
except that it's faster and smaller. Small integers are encoded into a
|
||||
single byte while typical short strings require only one extra byte in
|
||||
addition to the strings themselves.
|
||||
|
||||
MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one extra byte in addition to the strings themselves.
|
||||
Example
|
||||
-------
|
||||
|
||||
In C:
|
||||
|
||||
## License
|
||||
```c
|
||||
#include <msgpack.h>
|
||||
#include <stdio.h>
|
||||
|
||||
Msgpack is Copyright (C) 2008-2014 FURUHASHI Sadayuki and licensed under the Apache License, Version 2.0 (the "License"). For details see the `COPYING` file in this directory.
|
||||
int main(void)
|
||||
{
|
||||
/* msgpack::sbuffer is a simple buffer implementation. */
|
||||
msgpack_sbuffer sbuf;
|
||||
msgpack_sbuffer_init(&sbuf);
|
||||
|
||||
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
|
||||
msgpack_packer pk;
|
||||
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
|
||||
|
||||
## Contributing
|
||||
msgpack_pack_array(&pk, 3);
|
||||
msgpack_pack_int(&pk, 1);
|
||||
msgpack_pack_true(&pk);
|
||||
msgpack_pack_str(&pk, 7);
|
||||
msgpack_pack_str_body(&pk, "example", 7);
|
||||
|
||||
The source for msgpack-c is held at [msgpack-c](https://github.com/msgpack/msgpack-c) github.com site.
|
||||
/* deserialize the buffer into msgpack_object instance. */
|
||||
/* deserialized object is valid during the msgpack_zone instance alive. */
|
||||
msgpack_zone mempool;
|
||||
msgpack_zone_init(&mempool, 2048);
|
||||
|
||||
To report an issue, use the [msgpack-c issue tracker](https://github.com/msgpack/msgpack-c/issues) at github.com.
|
||||
msgpack_object deserialized;
|
||||
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
|
||||
|
||||
## Version
|
||||
0.6.0 [](https://travis-ci.org/msgpack/msgpack-c)
|
||||
/* print the deserialized object. */
|
||||
msgpack_object_print(stdout, deserialized);
|
||||
puts("");
|
||||
|
||||
## Using Msgpack
|
||||
msgpack_zone_destroy(&mempool);
|
||||
msgpack_sbuffer_destroy(&sbuf);
|
||||
|
||||
### Header only library for C++
|
||||
When you use msgpack on C++03 and C++11, you just add msgpack-c/include to your include path. You don't need to link any msgpack libraries.
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
e.g.)
|
||||
See [`QUICKSTART-C.md`](./QUICKSTART-C.md) for more details.
|
||||
|
||||
In C++:
|
||||
|
||||
```c++
|
||||
#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::unpacked result;
|
||||
|
||||
msgpack::unpack(result, str.data(), str.size());
|
||||
|
||||
// deserialized object is valid during the msgpack::unpacked instance alive.
|
||||
msgpack::object deserialized = result.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;
|
||||
}
|
||||
```
|
||||
|
||||
See [`QUICKSTART-CPP.md`](./QUICKSTART-CPP.md) for more details.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### C++ Header Only Library
|
||||
|
||||
When you use msgpack on C++03 and C++11, you can just add
|
||||
msgpack-c/include to your include path:
|
||||
|
||||
g++ -I msgpack-c/include your_source_file.cpp
|
||||
|
||||
If you want to use C version of msgpack, you need to build it. You can also install C and C++ version of msgpack.
|
||||
If you want to use C version of msgpack, you need to build it. You can
|
||||
also install the C and C++ versions of msgpack.
|
||||
|
||||
### Building and Installing
|
||||
|
||||
#### Install from git repository
|
||||
|
||||
##### Using autotools
|
||||
You will need gcc (4.1.0 or higher), autotools.
|
||||
|
||||
For C:
|
||||
C++03 and C:
|
||||
You will need:
|
||||
|
||||
$ git clone https://github.com/redboltz/msgpack-c/tree/cxx_separate
|
||||
$ cd msgpack-c
|
||||
$ ./bootstrap
|
||||
$ ./configure
|
||||
$ make
|
||||
$ sudo make install
|
||||
- `gcc >= 4.1.0` or `clang >= 3.3.0`
|
||||
- `autoconf >= 2.60`
|
||||
- `automake >= 1.10`
|
||||
- `libtool >= 2.2.4`
|
||||
|
||||
For C++11:
|
||||
The build steps below are for C and C++03. If compiling for C++11,
|
||||
add `-std=c++11` to the environmental variable `CXXFLAGS` with
|
||||
`export CXXFLAGS="$CXXFLAGS -std=c++11"` prior to following the
|
||||
directions below.
|
||||
|
||||
$ git clone https://github.com/msgpack/msgpack-c.git
|
||||
$ cd msgpack-c
|
||||
$ ./bootstrap
|
||||
$ ./configure CXXFLAGS="-std=c++11"
|
||||
$ make
|
||||
$ sudo make install
|
||||
```bash
|
||||
$ git clone https://github.com/msgpack/msgpack-c
|
||||
$ cd msgpack-c
|
||||
$ ./bootstrap
|
||||
$ ./configure
|
||||
$ make
|
||||
```
|
||||
|
||||
You need the compiler that fully supports C++11.
|
||||
You can install the resulting library like this:
|
||||
|
||||
```bash
|
||||
$ sudo make install
|
||||
```
|
||||
##### Using cmake
|
||||
|
||||
###### CUI
|
||||
###### Using the Terminal (CLI)
|
||||
|
||||
You will need gcc (4.1.0 or higher), cmake.
|
||||
You will need:
|
||||
|
||||
- `gcc >= 4.1.0`
|
||||
- `cmake >= 2.8.0`
|
||||
|
||||
C and C++03:
|
||||
|
||||
$ git clone https://github.com/msgpack/msgpack-c.git
|
||||
$ cd msgpack-c
|
||||
@@ -73,15 +165,14 @@ You will need gcc (4.1.0 or higher), cmake.
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
If you want to setup C++11 version of msgpack, execute the following command:
|
||||
If you want to setup C++11 version of msgpack instead,
|
||||
execute the following commands:
|
||||
|
||||
$ git clone https://github.com/msgpack/msgpack-c.git
|
||||
$ cd msgpack-c
|
||||
$ cmake -DMSGPACK_CXX11=ON .
|
||||
$ sudo make install
|
||||
|
||||
You need the compiler that fully supports C++11.
|
||||
|
||||
##### GUI on Windows
|
||||
|
||||
Clone msgpack-c git repository.
|
||||
@@ -92,61 +183,37 @@ or using GUI git client.
|
||||
|
||||
e.g.) tortoise git https://code.google.com/p/tortoisegit/
|
||||
|
||||
1. Launch cmake GUI client. http://www.cmake.org/cmake/resources/software.html
|
||||
1. Launch [cmake GUI client](http://www.cmake.org/cmake/resources/software.html).
|
||||
|
||||
1. Set 'Where is the source code:' text box and 'Where to build the binaries:' text box.
|
||||
2. Set 'Where is the source code:' text box and 'Where to build
|
||||
the binaries:' text box.
|
||||
|
||||
1. Click 'Configure' button.
|
||||
3. Click 'Configure' button.
|
||||
|
||||
1. Choose your Visual Studio version.
|
||||
4. Choose your Visual Studio version.
|
||||
|
||||
1. Click 'Generate' button.
|
||||
5. Click 'Generate' button.
|
||||
|
||||
1. Open the created msgpack.sln on Visual Studio.
|
||||
6. Open the created msgpack.sln on Visual Studio.
|
||||
|
||||
1. Build all.
|
||||
7. Build all.
|
||||
|
||||
### Documentation
|
||||
|
||||
#### Install from package
|
||||
You can get addtional information on the
|
||||
[wiki](https://github.com/msgpack/msgpack-c/wiki/cpp_overview).
|
||||
|
||||
Install from package for this branch (poc/0.6) is not supported yet.
|
||||
Contributing
|
||||
------------
|
||||
|
||||
### Code Example
|
||||
`msgpack-c` is developed on GitHub at [msgpack/msgpack-c](https://github.com/msgpack/msgpack-c).
|
||||
To report an issue or send a pull request, use the
|
||||
[issue tracker](https://github.com/msgpack/msgpack-c/issues).
|
||||
|
||||
#include <msgpack.hpp>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
Here's the list of [great contributors](https://github.com/msgpack/msgpack-c/graphs/contributors).
|
||||
|
||||
int main() {
|
||||
// This is target object.
|
||||
std::vector<std::string> target;
|
||||
target.push_back("Hello,");
|
||||
target.push_back("World!");
|
||||
|
||||
// Serialize it.
|
||||
msgpack::sbuffer sbuf; // simple buffer
|
||||
msgpack::pack(&sbuf, target);
|
||||
|
||||
// Deserialize the serialized data.
|
||||
msgpack::unpacked msg; // includes memory pool and deserialized object
|
||||
msgpack::unpack(msg, sbuf.data(), sbuf.size());
|
||||
msgpack::object obj = msg.get();
|
||||
|
||||
// Print the deserialized object to stdout.
|
||||
std::cout << obj << std::endl; // ["Hello," "World!"]
|
||||
|
||||
// Convert the deserialized object to staticaly typed object.
|
||||
std::vector<std::string> result;
|
||||
obj.convert(&result);
|
||||
|
||||
// If the type is mismatched, it throws msgpack::type_error.
|
||||
obj.as<int>(); // type is mismatched, msgpack::type_error is thrown
|
||||
}
|
||||
|
||||
### Documents
|
||||
|
||||
You can get addtional information on the wiki:
|
||||
|
||||
https://github.com/msgpack/msgpack-c/wiki/cpp_overview
|
||||
License
|
||||
-------
|
||||
|
||||
`msgpack-c` is licensed under the Apache License Version 2.0. See
|
||||
the [`LICENSE`](./LICENSE) file for details.
|
||||
|
@@ -36,6 +36,7 @@ test -f AUTHORS || touch AUTHORS
|
||||
test -f COPYING || touch COPYING
|
||||
test -f ChangeLog || touch ChangeLog
|
||||
test -f NEWS || touch NEWS
|
||||
test -f NOTICE || touch NOTICE
|
||||
test -f README || cp -f README.md README
|
||||
|
||||
ACLOCAL="aclocal"
|
||||
|
@@ -80,5 +80,4 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
|
@@ -1,4 +1,4 @@
|
||||
AC_INIT(msgpack, m4_esyscmd([cat include/msgpack/version_master.h | tr -d "\n" | sed -e 's/#define MSGPACK_VERSION_MAJOR\s*\(\w*\)/\1./g' -e 's/#define MSGPACK_VERSION_MINOR\s*\(\w*\)/\1./g' -e 's/#define MSGPACK_VERSION_REVISION\s*\(\w*\)/\1/g']))
|
||||
AC_INIT(msgpack, m4_esyscmd([cat include/msgpack/version_master.h | tr -d "\n" | sed -e 's/#define MSGPACK_VERSION_MAJOR[[:space:]]*\([[:alnum:]]*\)/\1./g' -e 's/#define MSGPACK_VERSION_MINOR[[:space:]]*\([[:alnum:]]*\)/\1./g' -e 's/#define MSGPACK_VERSION_REVISION[[:space:]]*\([[:alnum:]]*\)/\1/g' | tr -d "\n"]))
|
||||
AC_CONFIG_AUX_DIR(ac)
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/adaptor/msgpack_tuple_fwd.hpp"
|
||||
#include "msgpack/adaptor/int_fwd.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
|
||||
#define MSGPACK_DEFINE(...) \
|
||||
@@ -42,23 +43,25 @@
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
namespace msgpack { \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
template <> \
|
||||
inline object const& operator>> (object const& o, enum& v) \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
int tmp; \
|
||||
o >> tmp; \
|
||||
v = static_cast<enum>(tmp); \
|
||||
return o; \
|
||||
} \
|
||||
template <> \
|
||||
inline void operator<< (object::with_zone& o, const enum& v) \
|
||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
||||
{ \
|
||||
o << static_cast<int>(v); \
|
||||
} \
|
||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
||||
{ \
|
||||
o << static_cast<int>(v); \
|
||||
} \
|
||||
namespace detail { \
|
||||
template <typename Stream> \
|
||||
struct packer_serializer<Stream, enum> { \
|
||||
static packer<Stream>& pack(packer<Stream>& o, const enum& v) { \
|
||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
||||
return o << static_cast<int>(v); \
|
||||
} \
|
||||
}; \
|
||||
@@ -87,11 +90,11 @@ struct define<> {
|
||||
}
|
||||
void msgpack_unpack(msgpack::object const& o)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
}
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone&) const
|
||||
{
|
||||
o->type = type::ARRAY;
|
||||
o->type = msgpack::type::ARRAY;
|
||||
o->via.array.ptr = nullptr;
|
||||
o->via.array.size = 0;
|
||||
}
|
||||
@@ -112,7 +115,7 @@ struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
||||
}
|
||||
void msgpack_unpack(msgpack::object const& o)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
const size_t size = o.via.array.size;
|
||||
if(size > 0) {
|
||||
msgpack::object *ptr = o.via.array.ptr;
|
||||
@@ -124,11 +127,11 @@ struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
||||
}
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = type::ARRAY;
|
||||
o->via.array.ptr = static_cast<object*>(z.allocate_align(sizeof(object)*<%=i+1%>));
|
||||
o->type = msgpack::type::ARRAY;
|
||||
o->via.array.ptr = static_cast<msgpack::object*>(z.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
|
||||
o->via.array.size = <%=i+1%>;
|
||||
<%0.upto(i) {|j|%>
|
||||
o->via.array.ptr[<%=j%>] = object(a<%=j%>, z);<%}%>
|
||||
o->via.array.ptr[<%=j%>] = msgpack::object(a<%=j%>, z);<%}%>
|
||||
}
|
||||
<%0.upto(i) {|j|%>
|
||||
A<%=j%>& a<%=j%>;<%}%>
|
||||
|
@@ -95,7 +95,7 @@ private:
|
||||
template <>
|
||||
struct tuple<> {
|
||||
tuple() {}
|
||||
tuple(object const& o) { o.convert(*this); }
|
||||
tuple(msgpack::object const& o) { o.convert(*this); }
|
||||
typedef tuple<> value_type;
|
||||
};
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
@@ -105,7 +105,7 @@ struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
||||
tuple() {}
|
||||
tuple(typename tuple_type<A0>::transparent_reference _a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference _a<%=j%><%}%>) :
|
||||
a0(_a0)<%1.upto(i) {|j|%>, a<%=j%>(_a<%=j%>)<%}%> {}
|
||||
tuple(object const& o) { o.convert(*this); }
|
||||
tuple(msgpack::object const& o) { o.convert(*this); }
|
||||
template <int N> typename tuple_element<value_type, N>::reference get()
|
||||
{ return tuple_element<value_type, N>(*this).get(); }
|
||||
template <int N> typename const_tuple_element<value_type, N>::const_reference get() const
|
||||
@@ -136,19 +136,19 @@ inline tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<
|
||||
|
||||
} // namespace type
|
||||
|
||||
inline object const& operator>> (
|
||||
object const& o,
|
||||
inline msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<>&) {
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
return o;
|
||||
}
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
inline object const& operator>> (
|
||||
object const& o,
|
||||
inline msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.via.array.size < <%=i+1%>) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size < <%=i+1%>) { throw msgpack::type_error(); }
|
||||
<%0.upto(i) {|j|%>
|
||||
o.via.array.ptr[<%=j%>].convert<typename type::tuple_type<A<%=j%>>::type>(v.template get<<%=j%>>());<%}%>
|
||||
return o;
|
||||
@@ -156,16 +156,16 @@ inline object const& operator>> (
|
||||
<%}%>
|
||||
|
||||
template <typename Stream>
|
||||
inline const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<>&) {
|
||||
o.pack_array(0);
|
||||
return o;
|
||||
}
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
inline const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
||||
o.pack_array(<%=i+1%>);
|
||||
<%0.upto(i) {|j|%>
|
||||
@@ -175,22 +175,22 @@ inline const packer<Stream>& operator<< (
|
||||
<%}%>
|
||||
|
||||
inline void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<>&) {
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
}
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
inline void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
||||
o.type = type::ARRAY;
|
||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object)*<%=i+1%>));
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
|
||||
o.via.array.size = <%=i+1%>;
|
||||
<%0.upto(i) {|j|%>
|
||||
o.via.array.ptr[<%=j%>] = object(v.template get<<%=j%>>(), o.zone);<%}%>
|
||||
o.via.array.ptr[<%=j%>] = msgpack::object(v.template get<<%=j%>>(), o.zone);<%}%>
|
||||
}
|
||||
<%}%>
|
||||
|
||||
|
@@ -77,36 +77,36 @@ tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::tr
|
||||
|
||||
} // namespace type
|
||||
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<>&);
|
||||
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
|
||||
<%}%>
|
||||
|
||||
template <typename Stream>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<>&);
|
||||
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
|
||||
<%}%>
|
||||
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<>&);
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
|
||||
<%}%>
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MSGPACK_ZONE_ALIGN
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(int)
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||
#endif
|
||||
|
||||
<% GENERATION_LIMIT = 15 %>
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
zone(size_t chunk_size = MSGPACK_ZONE_CHUNK_SIZE) /* throw() */;
|
||||
|
||||
public:
|
||||
void* allocate_align(size_t size);
|
||||
void* allocate_align(size_t size, size_t align = MSGPACK_ZONE_ALIGN);
|
||||
void* allocate_no_align(size_t size);
|
||||
|
||||
void push_finalizer(void (*func)(void*), void* data);
|
||||
@@ -161,21 +161,21 @@ public:
|
||||
void clear();
|
||||
|
||||
void swap(zone& o);
|
||||
static void* operator new(std::size_t size) throw(std::bad_alloc)
|
||||
static void* operator new(std::size_t size)
|
||||
{
|
||||
void* p = ::malloc(size);
|
||||
if (!p) throw std::bad_alloc();
|
||||
return p;
|
||||
}
|
||||
static void operator delete(void *p) throw()
|
||||
static void operator delete(void *p) /* throw() */
|
||||
{
|
||||
::free(p);
|
||||
}
|
||||
static void* operator new(std::size_t size, void* place) throw()
|
||||
static void* operator new(std::size_t size, void* place) /* throw() */
|
||||
{
|
||||
return ::operator new(size, place);
|
||||
}
|
||||
static void operator delete(void* p, void* place) throw()
|
||||
static void operator delete(void* p, void* place) /* throw() */
|
||||
{
|
||||
::operator delete(p, place);
|
||||
}
|
||||
@@ -194,16 +194,30 @@ private:
|
||||
static void object_delete(void* obj);
|
||||
|
||||
void* allocate_expand(size_t size);
|
||||
private:
|
||||
zone(const zone&);
|
||||
zone& operator=(const zone&);
|
||||
};
|
||||
|
||||
inline zone::zone(size_t chunk_size) /* throw() */ :m_chunk_size(chunk_size), m_chunk_list(m_chunk_size)
|
||||
{
|
||||
}
|
||||
|
||||
inline void* zone::allocate_align(size_t size)
|
||||
inline void* zone::allocate_align(size_t size, size_t align)
|
||||
{
|
||||
return allocate_no_align(
|
||||
((size)+((MSGPACK_ZONE_ALIGN)-1)) & ~((MSGPACK_ZONE_ALIGN)-1));
|
||||
char* aligned =
|
||||
reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
(m_chunk_list.m_ptr + (align - 1))) / align * align);
|
||||
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||
if(m_chunk_list.m_free >= adjusted_size) {
|
||||
m_chunk_list.m_free -= adjusted_size;
|
||||
m_chunk_list.m_ptr += adjusted_size;
|
||||
return aligned;
|
||||
}
|
||||
return reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
allocate_expand(size + (align - 1))) / align * align);
|
||||
}
|
||||
|
||||
inline void* zone::allocate_no_align(size_t size)
|
||||
@@ -226,7 +240,12 @@ inline void* zone::allocate_expand(size_t size)
|
||||
size_t sz = m_chunk_size;
|
||||
|
||||
while(sz < size) {
|
||||
sz *= 2;
|
||||
size_t tmp_sz = sz * 2;
|
||||
if (tmp_sz <= sz) {
|
||||
sz = size;
|
||||
break;
|
||||
}
|
||||
sz = tmp_sz;
|
||||
}
|
||||
|
||||
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
|
||||
@@ -261,7 +280,10 @@ inline void zone::clear()
|
||||
|
||||
inline void zone::swap(zone& o)
|
||||
{
|
||||
std::swap(*this, o);
|
||||
using std::swap;
|
||||
swap(m_chunk_size, o.m_chunk_size);
|
||||
swap(m_chunk_list, o.m_chunk_list);
|
||||
swap(m_finalizer_array, o.m_finalizer_array);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@@ -10,7 +10,7 @@ typedef struct receiver {
|
||||
|
||||
receiver r;
|
||||
|
||||
size_t receiver_init(receiver *r) {
|
||||
void receiver_init(receiver *r) {
|
||||
msgpack_packer pk;
|
||||
|
||||
msgpack_sbuffer_init(&r->sbuf);
|
||||
@@ -67,7 +67,7 @@ void unpack(receiver* r) {
|
||||
int recv_count = 0;
|
||||
while (recv_len > 0) {
|
||||
int i = 0;
|
||||
printf("receive count: %d %d bytes received.:\n", recv_count++, recv_len);
|
||||
printf("receive count: %d %zd bytes received.:\n", recv_count++, recv_len);
|
||||
ret = msgpack_unpacker_next(unp, &result);
|
||||
while (ret == MSGPACK_UNPACK_SUCCESS) {
|
||||
msgpack_object obj = result.data;
|
83
example/cpp03/class_intrusive.cpp
Normal file
83
example/cpp03/class_intrusive.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
// msgpack.hpp is also ok
|
||||
#include <msgpack_fwd.hpp>
|
||||
|
||||
|
||||
class my_class {
|
||||
public:
|
||||
my_class() {} // When you want to convert from msgpack::object to my_class,
|
||||
// my_class should be default constractible.
|
||||
my_class(std::string const& name, int age):name_(name), age_(age) {}
|
||||
|
||||
friend bool operator==(my_class const& lhs, my_class const& rhs) {
|
||||
return lhs.name_ == rhs.name_ && lhs.age_ == rhs.age_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
int age_;
|
||||
|
||||
public:
|
||||
MSGPACK_DEFINE(name_, age_);
|
||||
};
|
||||
|
||||
void print(std::string const& buf) {
|
||||
for (std::string::const_iterator it = buf.begin(), end = buf.end();
|
||||
it != end;
|
||||
++it) {
|
||||
std::cout
|
||||
<< std::setw(2)
|
||||
<< std::hex
|
||||
<< std::setfill('0')
|
||||
<< (static_cast<int>(*it) & 0xff)
|
||||
<< ' ';
|
||||
}
|
||||
std::cout << std::dec << std::endl;
|
||||
}
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
int main() {
|
||||
{ // pack, unpack
|
||||
my_class my("John Smith", 42);
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, my);
|
||||
|
||||
print(ss.str());
|
||||
|
||||
msgpack::unpacked unp;
|
||||
msgpack::unpack(unp, ss.str().data(), ss.str().size());
|
||||
msgpack::object obj = unp.get();
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<my_class>() == my);
|
||||
}
|
||||
{ // create object with zone
|
||||
my_class my("John Smith", 42);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj(my, z);
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<my_class>() == my);
|
||||
}
|
||||
}
|
139
example/cpp03/class_non_intrusive.cpp
Normal file
139
example/cpp03/class_non_intrusive.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
// msgpack.hpp should be included at after user declarations
|
||||
#include <msgpack_fwd.hpp>
|
||||
|
||||
|
||||
// declarations
|
||||
class my_class;
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
|
||||
object const& operator>> (msgpack::object const& o, my_class& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (msgpack::packer<Stream>& o, my_class const& v);
|
||||
|
||||
void operator<< (msgpack::object::with_zone& o, my_class const& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
} // namespace msgpack
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
class my_class {
|
||||
public:
|
||||
my_class() {} // When you want to convert from msgpack::object to my_class,
|
||||
// my_class should be default constractible.
|
||||
my_class(std::string const& name, int age):name_(name), age_(age) {}
|
||||
|
||||
// my_class should provide getters for the data members you want to pack.
|
||||
std::string const& get_name() const { return name_; }
|
||||
int get_age() const { return age_; }
|
||||
|
||||
friend bool operator==(my_class const& lhs, my_class const& rhs) {
|
||||
return lhs.name_ == rhs.name_ && lhs.age_ == rhs.age_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
int age_;
|
||||
};
|
||||
|
||||
|
||||
// definitions
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
|
||||
inline object const& operator>> (msgpack::object const& o, my_class& v) {
|
||||
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
|
||||
if (o.via.array.size != 2) throw msgpack::type_error();
|
||||
v = my_class(
|
||||
o.via.array.ptr[0].as<std::string>(),
|
||||
o.via.array.ptr[1].as<int>());
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (msgpack::packer<Stream>& o, my_class const& v) {
|
||||
// packing member variables as an array.
|
||||
o.pack_array(2);
|
||||
o.pack(v.get_name());
|
||||
o.pack(v.get_age());
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, my_class const& v) {
|
||||
o.type = type::ARRAY;
|
||||
o.via.array.size = 2;
|
||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object) * o.via.array.size));
|
||||
o.via.array.ptr[0] = msgpack::object(v.get_name(), o.zone);
|
||||
o.via.array.ptr[1] = msgpack::object(v.get_age(), o.zone);
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
} // namespace msgpack
|
||||
|
||||
|
||||
void print(std::string const& buf) {
|
||||
for (std::string::const_iterator it = buf.begin(), end = buf.end();
|
||||
it != end;
|
||||
++it) {
|
||||
std::cout
|
||||
<< std::setw(2)
|
||||
<< std::hex
|
||||
<< std::setfill('0')
|
||||
<< (static_cast<int>(*it) & 0xff)
|
||||
<< ' ';
|
||||
}
|
||||
std::cout << std::dec << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
{ // pack, unpack
|
||||
my_class my("John Smith", 42);
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, my);
|
||||
|
||||
print(ss.str());
|
||||
|
||||
msgpack::unpacked unp;
|
||||
msgpack::unpack(unp, ss.str().data(), ss.str().size());
|
||||
msgpack::object obj = unp.get();
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<my_class>() == my);
|
||||
}
|
||||
{ // create object with zone
|
||||
my_class my("John Smith", 42);
|
||||
msgpack::zone z;
|
||||
msgpack::object obj(my, z);
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<my_class>() == my);
|
||||
}
|
||||
}
|
75
example/cpp03/custom.cpp
Normal file
75
example/cpp03/custom.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <msgpack.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
class old_class {
|
||||
public:
|
||||
old_class() : value("default") { }
|
||||
|
||||
std::string value;
|
||||
|
||||
MSGPACK_DEFINE(value);
|
||||
};
|
||||
|
||||
class new_class {
|
||||
public:
|
||||
new_class() : value("default"), flag(-1) { }
|
||||
|
||||
std::string value;
|
||||
int flag;
|
||||
|
||||
MSGPACK_DEFINE(value, flag);
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
{
|
||||
old_class oc;
|
||||
new_class nc;
|
||||
|
||||
std::stringstream sbuf;
|
||||
msgpack::pack(sbuf, oc);
|
||||
|
||||
msgpack::unpacked result;
|
||||
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size());
|
||||
msgpack::object obj = result.get();
|
||||
|
||||
obj.convert(&nc);
|
||||
|
||||
std::cout << obj << " value=" << nc.value << " flag=" << nc.flag << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
new_class nc;
|
||||
old_class oc;
|
||||
|
||||
std::stringstream sbuf;
|
||||
msgpack::pack(sbuf, nc);
|
||||
|
||||
msgpack::unpacked result;
|
||||
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size());
|
||||
msgpack::object obj = result.get();
|
||||
|
||||
obj.convert(&oc);
|
||||
|
||||
std::cout << obj << " value=" << oc.value << std::endl;
|
||||
}
|
||||
}
|
68
example/cpp03/enum.cpp
Normal file
68
example/cpp03/enum.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
enum my_enum {
|
||||
elem1,
|
||||
elem2,
|
||||
elem3
|
||||
};
|
||||
|
||||
MSGPACK_ADD_ENUM(my_enum);
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
{ // pack, unpack
|
||||
std::stringstream sbuf;
|
||||
msgpack::pack(sbuf, elem1);
|
||||
msgpack::pack(sbuf, elem2);
|
||||
my_enum e3 = elem3;
|
||||
msgpack::pack(sbuf, e3);
|
||||
|
||||
msgpack::unpacked result;
|
||||
std::size_t off = 0;
|
||||
|
||||
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size(), off);
|
||||
std::cout << result.get().as<my_enum>() << std::endl;
|
||||
assert(result.get().as<my_enum>() == elem1);
|
||||
|
||||
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size(), off);
|
||||
std::cout << result.get().as<my_enum>() << std::endl;
|
||||
assert(result.get().as<my_enum>() == elem2);
|
||||
|
||||
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size(), off);
|
||||
std::cout << result.get().as<my_enum>() << std::endl;
|
||||
assert(result.get().as<my_enum>() == elem3);
|
||||
}
|
||||
{ // create object without zone
|
||||
msgpack::object obj(elem2);
|
||||
std::cout << obj.as<my_enum>() << std::endl;
|
||||
assert(obj.as<my_enum>() == elem2);
|
||||
}
|
||||
{ // create object with zone
|
||||
msgpack::zone z;
|
||||
msgpack::object objz(elem3, z);
|
||||
std::cout << objz.as<my_enum>() << std::endl;
|
||||
assert(objz.as<my_enum>() == elem3);
|
||||
}
|
||||
}
|
@@ -1,3 +1,20 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <msgpack.hpp>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@@ -84,4 +101,3 @@ int main(void)
|
||||
std::cout << "received: " << o << std::endl;
|
||||
}
|
||||
}
|
||||
|
47
example/cpp03/reuse_zone.cpp
Normal file
47
example/cpp03/reuse_zone.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
|
||||
int main() {
|
||||
std::vector<int> v;
|
||||
v.push_back(1);
|
||||
v.push_back(42);
|
||||
std::string s("ABC");
|
||||
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, v);
|
||||
msgpack::pack(ss, s);
|
||||
|
||||
msgpack::zone z;
|
||||
std::size_t offset = 0;
|
||||
|
||||
// msgpack array is constructed on z.
|
||||
msgpack::object obj = msgpack::unpack(z, ss.str().data(), ss.str().size(), offset);
|
||||
assert(obj.as<std::vector<int> >() == v);
|
||||
|
||||
// msgpack str is constructed on z.
|
||||
assert(msgpack::unpack(z, ss.str().data(), ss.str().size(), offset).as<std::string>() == s);
|
||||
}
|
@@ -1,3 +1,20 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <msgpack.hpp>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@@ -35,4 +52,3 @@ int main(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,3 +1,20 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2013-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// g++ -std=c++11 -O3 -g -Ipath_to_msgpack_src -Ipath_to_boost speed_test.cc -Lpath_to_boost_lib -lboost_timer -lboost_system
|
||||
// export LD_LIBRARY_PATH=path_to_boost_lib
|
||||
|
||||
@@ -52,4 +69,3 @@ int main(void)
|
||||
{
|
||||
test_map_pack_unpack();
|
||||
}
|
||||
|
@@ -1,3 +1,20 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2013-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// g++ -std=c++11 -O3 -g -Ipath_to_msgpack_src -Ipath_to_boost speed_test.cc -Lpath_to_boost_lib -lboost_timer -lboost_system
|
||||
// export LD_LIBRARY_PATH=path_to_boost_lib
|
||||
|
||||
@@ -75,4 +92,3 @@ int main(void)
|
||||
{
|
||||
test_array_of_array();
|
||||
}
|
||||
|
@@ -1,3 +1,20 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <msgpack.hpp>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
@@ -13,7 +30,7 @@ public:
|
||||
|
||||
~Server() { }
|
||||
|
||||
typedef msgpack::unique_ptr<msgpack::zone> auto_zone;
|
||||
typedef msgpack::unique_ptr<msgpack::zone> unique_zone;
|
||||
|
||||
void socket_readable()
|
||||
{
|
||||
@@ -37,7 +54,7 @@ public:
|
||||
msgpack::unpacked result;
|
||||
while (m_pac.next(&result)) {
|
||||
msgpack::object msg = result.get();
|
||||
auto_zone& life = result.zone();
|
||||
unique_zone& life = result.zone();
|
||||
process_message(msg, life);
|
||||
}
|
||||
|
||||
@@ -47,7 +64,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void process_message(msgpack::object msg, auto_zone& life)
|
||||
void process_message(msgpack::object msg, unique_zone&)
|
||||
{
|
||||
std::cout << "message reached: " << msg << std::endl;
|
||||
}
|
||||
@@ -59,26 +76,27 @@ private:
|
||||
|
||||
|
||||
static void* run_server(void* arg)
|
||||
try {
|
||||
Server* srv = reinterpret_cast<Server*>(arg);
|
||||
{
|
||||
try {
|
||||
Server* srv = reinterpret_cast<Server*>(arg);
|
||||
|
||||
while(true) {
|
||||
srv->socket_readable();
|
||||
while(true) {
|
||||
srv->socket_readable();
|
||||
}
|
||||
return NULL;
|
||||
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "error while processing client packet: "
|
||||
<< e.what() << std::endl;
|
||||
return NULL;
|
||||
|
||||
} catch (...) {
|
||||
std::cerr << "error while processing client packet: "
|
||||
<< "unknown error" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "error while processing client packet: "
|
||||
<< e.what() << std::endl;
|
||||
return NULL;
|
||||
|
||||
} catch (...) {
|
||||
std::cerr << "error while processing client packet: "
|
||||
<< "unknown error" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
struct fwriter {
|
||||
fwriter(int fd) : m_fp( fdopen(fd, "w") ) { }
|
||||
|
||||
@@ -130,4 +148,3 @@ int main(void)
|
||||
|
||||
pthread_join(thread, NULL);
|
||||
}
|
||||
|
108
example/cpp11/container.cpp
Normal file
108
example/cpp11/container.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
// MessagePack for C++ example
|
||||
//
|
||||
// Copyright (C) 2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <forward_list>
|
||||
#include <string>
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
void array() {
|
||||
std::array<int, 5> a { 1, 2, 3, 4, 5 };
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, a);
|
||||
|
||||
msgpack::unpacked und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::object obj = und.get();
|
||||
std::array<int, 5> const& new_a = obj.as<std::array<int, 5>>();
|
||||
|
||||
assert(new_a == a);
|
||||
}
|
||||
|
||||
void tuple() {
|
||||
std::tuple<bool, std::string, int> t(true, "ABC", 42);
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, t);
|
||||
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
auto obj = und.get();
|
||||
assert(obj.as<decltype(t)>() == t);
|
||||
}
|
||||
|
||||
void unordered_map() {
|
||||
std::unordered_map<std::string, int> m { {"ABC", 1}, {"DEF", 3} };
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, m);
|
||||
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
assert(und.get().as<decltype(m)>() == m);
|
||||
}
|
||||
|
||||
void unordered_set() {
|
||||
std::unordered_set<std::string> s { "ABC", "DEF" };
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, s);
|
||||
|
||||
assert(msgpack::unpack(ss.str().data(), ss.str().size()).get().as<decltype(s)>() == s);
|
||||
}
|
||||
|
||||
void forward_list() {
|
||||
using type = std::forward_list<std::string>;
|
||||
type f { "ABC", "DEF" };
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, f);
|
||||
|
||||
assert(msgpack::unpack(ss.str().data(), ss.str().size()).get().as<type>() == f);
|
||||
}
|
||||
|
||||
void combi() {
|
||||
std::array<int, 5> a { 1, 2, 3, 4, 5 };
|
||||
std::tuple<bool, std::string, int> t {true, "ABC", 42};
|
||||
std::unordered_map<std::string, int> m { {"ABC", 1}, {"DEF", 3} };
|
||||
std::unordered_set<std::string> s { "ABC", "DEF" };
|
||||
std::forward_list<std::string> f { "ABC", "DEF" };
|
||||
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, a);
|
||||
msgpack::pack(ss, t);
|
||||
msgpack::pack(ss, m);
|
||||
msgpack::pack(ss, s);
|
||||
msgpack::pack(ss, f);
|
||||
|
||||
std::size_t offset = 0;
|
||||
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(a)>() == a);
|
||||
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(t)>() == t);
|
||||
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(m)>() == m);
|
||||
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(s)>() == s);
|
||||
assert(msgpack::unpack(ss.str().data(), ss.str().size(), offset).get().as<decltype(f)>() == f);
|
||||
}
|
||||
|
||||
int main() {
|
||||
array();
|
||||
tuple();
|
||||
unordered_map();
|
||||
unordered_set();
|
||||
forward_list();
|
||||
combi();
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
#include <msgpack.hpp>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
class old_class {
|
||||
public:
|
||||
old_class() : value("default") { }
|
||||
|
||||
std::string value;
|
||||
|
||||
MSGPACK_DEFINE(value);
|
||||
};
|
||||
|
||||
class new_class {
|
||||
public:
|
||||
new_class() : value("default"), flag(-1) { }
|
||||
|
||||
std::string value;
|
||||
int flag;
|
||||
|
||||
MSGPACK_DEFINE(value, flag);
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
{
|
||||
old_class oc;
|
||||
new_class nc;
|
||||
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, oc);
|
||||
|
||||
msgpack::unpacked result;
|
||||
msgpack::unpack(result, sbuf.data(), sbuf.size());
|
||||
msgpack::object obj = result.get();
|
||||
|
||||
obj.convert(&nc);
|
||||
|
||||
std::cout << obj << " value=" << nc.value << " flag=" << nc.flag << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
new_class nc;
|
||||
old_class oc;
|
||||
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, nc);
|
||||
|
||||
msgpack::unpacked result;
|
||||
msgpack::unpack(result, sbuf.data(), sbuf.size());
|
||||
msgpack::object obj = result.get();
|
||||
|
||||
obj.convert(&oc);
|
||||
|
||||
std::cout << obj << " value=" << oc.value << std::endl;
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "msgpack/object.hpp"
|
||||
#include "msgpack/iterator.hpp"
|
||||
#include "msgpack/zone.hpp"
|
||||
#include "msgpack/pack.hpp"
|
||||
#include "msgpack/unpack.hpp"
|
||||
|
@@ -26,29 +26,29 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
inline object const& operator>> (object const& o, bool& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, bool& v)
|
||||
{
|
||||
if(o.type != type::BOOLEAN) { throw type_error(); }
|
||||
if(o.type != msgpack::type::BOOLEAN) { throw msgpack::type_error(); }
|
||||
v = o.via.boolean;
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const bool& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& v)
|
||||
{
|
||||
if(v) { o.pack_true(); }
|
||||
else { o.pack_false(); }
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, bool v)
|
||||
inline void operator<< (msgpack::object& o, bool v)
|
||||
{
|
||||
o.type = type::BOOLEAN;
|
||||
o.type = msgpack::type::BOOLEAN;
|
||||
o.via.boolean = v;
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, bool v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, bool v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -25,11 +25,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
object const& operator>> (object const& o, bool& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, bool& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const bool& v);
|
||||
void operator<< (object& o, bool v);
|
||||
void operator<< (object::with_zone& o, bool v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& v);
|
||||
void operator<< (msgpack::object& o, bool v);
|
||||
void operator<< (msgpack::object::with_zone& o, bool v);
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014 KONDO Takatoshi
|
||||
// Copyright (C) 2014-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace msgpack {
|
||||
@@ -27,30 +29,46 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const char* v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v)
|
||||
{
|
||||
std::size_t size = std::strlen(v);
|
||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||
o.pack_str(size);
|
||||
o.pack_str_body(v, size);
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, const char* v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const char* v)
|
||||
{
|
||||
std::size_t size = std::strlen(v);
|
||||
o.type = type::STR;
|
||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||
o.type = msgpack::type::STR;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||
o.via.str.ptr = ptr;
|
||||
o.via.str.size = static_cast<uint32_t>(size);
|
||||
memcpy(ptr, v, size);
|
||||
o.via.str.size = size;
|
||||
std::memcpy(ptr, v, size);
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, const char* v)
|
||||
inline void operator<< (msgpack::object& o, const char* v)
|
||||
{
|
||||
std::size_t size = std::strlen(v);
|
||||
o.type = type::STR;
|
||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||
o.type = msgpack::type::STR;
|
||||
o.via.str.ptr = v;
|
||||
o.via.str.size = static_cast<uint32_t>(size);
|
||||
o.via.str.size = size;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, char* v)
|
||||
{
|
||||
return msgpack::operator<<(o, static_cast<const char*>(v));
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, char* v)
|
||||
{
|
||||
msgpack::operator<<(o, static_cast<const char*>(v));
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, char* v)
|
||||
{
|
||||
msgpack::operator<<(o, static_cast<const char*>(v));
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -27,9 +27,14 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const char* v);
|
||||
void operator<< (object::with_zone& o, const char* v);
|
||||
void operator<< (object& o, const char* v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v);
|
||||
void operator<< (msgpack::object::with_zone& o, const char* v);
|
||||
void operator<< (msgpack::object& o, const char* v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, char* v);
|
||||
void operator<< (object::with_zone& o, char* v);
|
||||
void operator<< (object& o, char* v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
61
include/msgpack/adaptor/check_container_size.hpp
Normal file
61
include/msgpack/adaptor/check_container_size.hpp
Normal file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef MSGPACK_CHECK_CONTAINER_SIZE_HPP
|
||||
#define MSGPACK_CHECK_CONTAINER_SIZE_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
struct container_size_overflow : public std::runtime_error {
|
||||
explicit container_size_overflow(const std::string& msg)
|
||||
:std::runtime_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit container_size_overflow(const char* msg):
|
||||
std::runtime_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <std::size_t N>
|
||||
inline void check_container_size(std::size_t size) {
|
||||
if (size > 0xffffffff) throw container_size_overflow("container size overflow");
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void check_container_size<4>(std::size_t size) {
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T>
|
||||
inline uint32_t checked_get_container_size(T size) {
|
||||
detail::check_container_size<sizeof(T)>(size);
|
||||
return static_cast<uint32_t>(size);
|
||||
}
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_CHECK_CONTAINER_SIZE_HPP
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014 KONDO Takatoshi
|
||||
// Copyright (C) 2014-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -29,12 +30,12 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
inline object const& operator>> (object const& o, std::array<T, N>& v) {
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.via.array.size != N) { throw type_error(); }
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::array<T, N>& v) {
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size != N) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size > 0) {
|
||||
object* p = o.via.array.ptr;
|
||||
object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
T* it = &v[0];
|
||||
do {
|
||||
p->convert(*it);
|
||||
@@ -46,23 +47,25 @@ inline object const& operator>> (object const& o, std::array<T, N>& v) {
|
||||
}
|
||||
|
||||
template <typename Stream, typename T, std::size_t N>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::array<T, N>& v) {
|
||||
o.pack_array(v.size());
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<T, N>& v) {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(auto const& e : v) o.pack(e);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
inline void operator<< (object::with_zone& o, const std::array<T, N>& v) {
|
||||
o.type = type::ARRAY;
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v) {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
o.via.array.size = v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
o.via.array.size = size;
|
||||
o.via.array.ptr = p;
|
||||
for (auto const& e : v) *p++ = object(e, o.zone);
|
||||
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014 KONDO Takatoshi
|
||||
// Copyright (C) 2014-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace msgpack {
|
||||
@@ -27,49 +29,52 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <std::size_t N>
|
||||
inline object const& operator>> (object const& o, std::array<char, N>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::array<char, N>& v)
|
||||
{
|
||||
switch (o.type) {
|
||||
case type::BIN:
|
||||
if(o.via.bin.size != N) { throw type_error(); }
|
||||
case msgpack::type::BIN:
|
||||
if(o.via.bin.size != N) { throw msgpack::type_error(); }
|
||||
std::memcpy(v.data(), o.via.bin.ptr, o.via.bin.size);
|
||||
break;
|
||||
case type::STR:
|
||||
if(o.via.str.size != N) { throw type_error(); }
|
||||
case msgpack::type::STR:
|
||||
if(o.via.str.size != N) { throw msgpack::type_error(); }
|
||||
std::memcpy(v.data(), o.via.str.ptr, N);
|
||||
break;
|
||||
default:
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream, std::size_t N>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::array<char, N>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<char, N>& v)
|
||||
{
|
||||
o.pack_bin(v.size());
|
||||
o.pack_bin_body(v.data(), v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_bin(size);
|
||||
o.pack_bin_body(v.data(), size);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
inline void operator<< (object& o, const std::array<char, N>& v)
|
||||
inline void operator<< (msgpack::object& o, const std::array<char, N>& v)
|
||||
{
|
||||
o.type = type::BIN;
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::BIN;
|
||||
o.via.bin.ptr = v.data();
|
||||
o.via.bin.size = static_cast<uint32_t>(v.size());
|
||||
o.via.bin.size = size;
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
inline void operator<< (object::with_zone& o, const std::array<char, N>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::array<char, N>& v)
|
||||
{
|
||||
o.type = type::BIN;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.size()));
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::BIN;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||
o.via.bin.ptr = ptr;
|
||||
o.via.bin.size = static_cast<uint32_t>(v.size());
|
||||
std::memcpy(ptr, v.data(), v.size());
|
||||
o.via.bin.size = size;
|
||||
std::memcpy(ptr, v.data(), size);
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -27,16 +27,16 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <std::size_t N>
|
||||
object const& operator>> (object const& o, std::array<char, N>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::array<char, N>& v);
|
||||
|
||||
template <typename Stream, std::size_t N>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::array<char, N>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<char, N>& v);
|
||||
|
||||
template <std::size_t N>
|
||||
void operator<< (object& o, const std::array<char, N>& v);
|
||||
void operator<< (msgpack::object& o, const std::array<char, N>& v);
|
||||
|
||||
template <std::size_t N>
|
||||
void operator<< (object::with_zone& o, const std::array<char, N>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::array<char, N>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -29,13 +29,13 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
object const& operator>> (object const& o, std::array<T, N>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::array<T, N>& v);
|
||||
|
||||
template <typename Stream, typename T, std::size_t N>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::array<T, N>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<T, N>& v);
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
void operator<< (object::with_zone& o, const std::array<T, N>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014 KONDO Takatoshi
|
||||
// Copyright (C) 2014 KONDO-2015 Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
@@ -29,11 +30,11 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, std::forward_list<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::forward_list<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
object* p = o.via.array.ptr;
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
for (auto &e : v) {
|
||||
p->convert(e);
|
||||
++p;
|
||||
@@ -42,27 +43,28 @@ inline object const& operator>> (object const& o, std::forward_list<T>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::forward_list<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::forward_list<T>& v)
|
||||
{
|
||||
o.pack_array(std::distance(v.begin(), v.end()));
|
||||
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
||||
o.pack_array(size);
|
||||
for(auto const& e : v) o.pack(e);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const std::forward_list<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::forward_list<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
std::size_t size = std::distance(v.begin(), v.end());
|
||||
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
||||
o.via.array.size = size;
|
||||
object* p = static_cast<object*>(
|
||||
o.zone.allocate_align(sizeof(object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(
|
||||
o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
o.via.array.ptr = p;
|
||||
for(auto const& e : v) *p++ = object(e, o.zone);
|
||||
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,13 +29,13 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, std::forward_list<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::forward_list<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::forward_list<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::forward_list<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const std::forward_list<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::forward_list<T>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
@@ -27,11 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
// --- Pack ( from tuple to packer stream ---
|
||||
// --- Pack from tuple to packer stream ---
|
||||
template <typename Stream, typename Tuple, std::size_t N>
|
||||
struct StdTuplePacker {
|
||||
static void pack(
|
||||
packer<Stream>& o,
|
||||
msgpack::packer<Stream>& o,
|
||||
const Tuple& v) {
|
||||
StdTuplePacker<Stream, Tuple, N-1>::pack(o, v);
|
||||
o.pack(std::get<N-1>(v));
|
||||
@@ -41,7 +42,7 @@ struct StdTuplePacker {
|
||||
template <typename Stream, typename Tuple>
|
||||
struct StdTuplePacker<Stream, Tuple, 1> {
|
||||
static void pack (
|
||||
packer<Stream>& o,
|
||||
msgpack::packer<Stream>& o,
|
||||
const Tuple& v) {
|
||||
o.pack(std::get<0>(v));
|
||||
}
|
||||
@@ -50,17 +51,18 @@ struct StdTuplePacker<Stream, Tuple, 1> {
|
||||
template <typename Stream, typename Tuple>
|
||||
struct StdTuplePacker<Stream, Tuple, 0> {
|
||||
static void pack (
|
||||
packer<Stream>&,
|
||||
msgpack::packer<Stream>&,
|
||||
const Tuple&) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
inline const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const std::tuple<Args...>& v) {
|
||||
o.pack_array(sizeof...(Args));
|
||||
uint32_t size = checked_get_container_size(sizeof...(Args));
|
||||
o.pack_array(size);
|
||||
StdTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
|
||||
return o;
|
||||
}
|
||||
@@ -70,7 +72,7 @@ inline const packer<Stream>& operator<< (
|
||||
template <typename Tuple, std::size_t N>
|
||||
struct StdTupleConverter {
|
||||
static void convert(
|
||||
object const& o,
|
||||
msgpack::object const& o,
|
||||
Tuple& v) {
|
||||
StdTupleConverter<Tuple, N-1>::convert(o, v);
|
||||
o.via.array.ptr[N-1].convert<typename std::remove_reference<decltype(std::get<N-1>(v))>::type>(std::get<N-1>(v));
|
||||
@@ -80,7 +82,7 @@ struct StdTupleConverter {
|
||||
template <typename Tuple>
|
||||
struct StdTupleConverter<Tuple, 1> {
|
||||
static void convert (
|
||||
object const& o,
|
||||
msgpack::object const& o,
|
||||
Tuple& v) {
|
||||
o.via.array.ptr[0].convert<typename std::remove_reference<decltype(std::get<0>(v))>::type>(std::get<0>(v));
|
||||
}
|
||||
@@ -89,17 +91,17 @@ struct StdTupleConverter<Tuple, 1> {
|
||||
template <typename Tuple>
|
||||
struct StdTupleConverter<Tuple, 0> {
|
||||
static void convert (
|
||||
object const&,
|
||||
msgpack::object const&,
|
||||
Tuple&) {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
inline object const& operator>> (
|
||||
object const& o,
|
||||
inline msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
std::tuple<Args...>& v) {
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.via.array.size < sizeof...(Args)) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
||||
StdTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
return o;
|
||||
}
|
||||
@@ -108,37 +110,38 @@ inline object const& operator>> (
|
||||
template <typename Tuple, std::size_t N>
|
||||
struct StdTupleToObjectWithZone {
|
||||
static void convert(
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const Tuple& v) {
|
||||
StdTupleToObjectWithZone<Tuple, N-1>::convert(o, v);
|
||||
o.via.array.ptr[N-1] = object(std::get<N-1>(v), o.zone);
|
||||
o.via.array.ptr[N-1] = msgpack::object(std::get<N-1>(v), o.zone);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tuple>
|
||||
struct StdTupleToObjectWithZone<Tuple, 1> {
|
||||
static void convert (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const Tuple& v) {
|
||||
o.via.array.ptr[0] = object(std::get<0>(v), o.zone);
|
||||
o.via.array.ptr[0] = msgpack::object(std::get<0>(v), o.zone);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tuple>
|
||||
struct StdTupleToObjectWithZone<Tuple, 0> {
|
||||
static void convert (
|
||||
object::with_zone&,
|
||||
msgpack::object::with_zone&,
|
||||
const Tuple&) {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
inline void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
std::tuple<Args...> const& v) {
|
||||
o.type = type::ARRAY;
|
||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object)*sizeof...(Args)));
|
||||
o.via.array.size = sizeof...(Args);
|
||||
uint32_t size = checked_get_container_size(sizeof...(Args));
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
o.via.array.size = size;
|
||||
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
}
|
||||
|
||||
|
@@ -27,13 +27,13 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
// --- Pack ( from tuple to packer stream ---
|
||||
// --- Pack from tuple to packer stream ---
|
||||
template <typename Stream, typename Tuple, std::size_t N>
|
||||
struct StdTuplePacker;
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const std::tuple<Args...>& v);
|
||||
|
||||
// --- Convert from tuple to object ---
|
||||
@@ -42,8 +42,8 @@ template <typename Tuple, std::size_t N>
|
||||
struct StdTupleConverter;
|
||||
|
||||
template <typename... Args>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
std::tuple<Args...>& v);
|
||||
|
||||
// --- Convert from tuple to object with zone ---
|
||||
@@ -52,7 +52,7 @@ struct StdTupleToObjectWithZone;
|
||||
|
||||
template <typename... Args>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
std::tuple<Args...> const& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
142
include/msgpack/adaptor/cpp11/unordered_map.hpp
Normal file
142
include/msgpack/adaptor/cpp11/unordered_map.hpp
Normal file
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef MSGPACK_TYPE_UNORDERED_MAP_HPP
|
||||
#define MSGPACK_TYPE_UNORDERED_MAP_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename K, typename V>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_map<K, V>& v)
|
||||
{
|
||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
std::unordered_map<K, V> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
K key;
|
||||
p->key.convert(key);
|
||||
p->val.convert(tmp[key]);
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v)
|
||||
{
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename std::unordered_map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_map<K,V>& v)
|
||||
{
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
typename std::unordered_map<K,V>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multimap<K, V>& v)
|
||||
{
|
||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
std::unordered_multimap<K, V> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
std::pair<K, V> value;
|
||||
p->key.convert(value.first);
|
||||
p->val.convert(value.second);
|
||||
tmp.insert(value);
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v)
|
||||
{
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename std::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& v)
|
||||
{
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
typename std::unordered_multimap<K,V>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
||||
#endif // MSGPACK_TYPE_UNORDERED_MAP_HPP
|
53
include/msgpack/adaptor/cpp11/unordered_map_fwd.hpp
Normal file
53
include/msgpack/adaptor/cpp11/unordered_map_fwd.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
|
||||
#define MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename K, typename V>
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_map<K, V>& v);
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_map<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multimap<K, V>& v);
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
||||
#endif // MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
|
134
include/msgpack/adaptor/cpp11/unordered_set.hpp
Normal file
134
include/msgpack/adaptor/cpp11/unordered_set.hpp
Normal file
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef MSGPACK_TYPE_UNORDERED_SET_HPP
|
||||
#define MSGPACK_TYPE_UNORDERED_SET_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_set<T>& v)
|
||||
{
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
std::unordered_set<T> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
tmp.insert(p->as<T>());
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_set<T>& v)
|
||||
{
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename std::unordered_set<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_set<T>& v)
|
||||
{
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
typename std::unordered_set<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multiset<T>& v)
|
||||
{
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
std::unordered_multiset<T> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
tmp.insert(p->as<T>());
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v)
|
||||
{
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename std::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multiset<T>& v)
|
||||
{
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
typename std::unordered_multiset<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_TYPE_UNORDERED_SET_HPP
|
52
include/msgpack/adaptor/cpp11/unordered_set_fwd.hpp
Normal file
52
include/msgpack/adaptor/cpp11/unordered_set_fwd.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
|
||||
#define MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_set<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_set<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_set<T>& v);
|
||||
|
||||
template <typename T>
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multiset<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_multiset<T>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <deque>
|
||||
|
||||
namespace msgpack {
|
||||
@@ -27,12 +29,12 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, std::deque<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::deque<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
object* p = o.via.array.ptr;
|
||||
object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
typename std::deque<T>::iterator it = v.begin();
|
||||
for(; p < pend; ++p, ++it) {
|
||||
p->convert(*it);
|
||||
@@ -41,9 +43,10 @@ inline object const& operator>> (object const& o, std::deque<T>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::deque<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::deque<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename std::deque<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
@@ -52,20 +55,21 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const std::deque<T>& v)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const std::deque<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
object* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
typename std::deque<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(*it, o.zone);
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
|
@@ -27,11 +27,11 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, std::deque<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::deque<T>& v);
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::deque<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::deque<T>& v);
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const std::deque<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3704,501 +3704,501 @@ tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16,
|
||||
|
||||
} // namespace type
|
||||
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<>&);
|
||||
|
||||
|
||||
template <typename A0>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0>& v);
|
||||
|
||||
template <typename A0, typename A1>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29, typename A30>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29, typename A30, typename A31>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31>& v);
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<>&);
|
||||
|
||||
|
||||
template <typename Stream, typename A0>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29, typename A30>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30>& v);
|
||||
|
||||
template <typename Stream, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29, typename A30, typename A31>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31>& v);
|
||||
|
||||
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<>&);
|
||||
|
||||
template <typename A0>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0>& v);
|
||||
|
||||
template <typename A0, typename A1>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29, typename A30>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30>& v);
|
||||
|
||||
template <typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15, typename A16, typename A17, typename A18, typename A19, typename A20, typename A21, typename A22, typename A23, typename A24, typename A25, typename A26, typename A27, typename A28, typename A29, typename A30, typename A31>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31>& v);
|
||||
|
||||
|
||||
|
@@ -47,24 +47,27 @@
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
namespace msgpack { \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
template <> \
|
||||
inline object const& operator>> (object const& o, enum& v) \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
int tmp; \
|
||||
std::underlying_type<enum>::type tmp; \
|
||||
o >> tmp; \
|
||||
v = static_cast<enum>(tmp); \
|
||||
return o; \
|
||||
} \
|
||||
template <> \
|
||||
inline void operator<< (object::with_zone& o, const enum& v) \
|
||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
||||
{ \
|
||||
int tmp = static_cast<std::underlying_type<enum>::type>(v); \
|
||||
auto tmp = static_cast<std::underlying_type<enum>::type>(v); \
|
||||
o << tmp; \
|
||||
} \
|
||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
||||
{ \
|
||||
auto tmp = static_cast<std::underlying_type<enum>::type>(v); \
|
||||
o << tmp; \
|
||||
} \
|
||||
namespace detail { \
|
||||
template <typename Stream> \
|
||||
struct packer_serializer<Stream, enum> { \
|
||||
static packer<Stream>& pack(packer<Stream>& o, const enum& v) { \
|
||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
||||
return o << static_cast<std::underlying_type<enum>::type>(v); \
|
||||
} \
|
||||
}; \
|
||||
@@ -126,14 +129,14 @@ struct define {
|
||||
}
|
||||
void msgpack_unpack(msgpack::object const& o)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
|
||||
define_imp<std::tuple<Args&...>, sizeof...(Args)>::unpack(o, a);
|
||||
}
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = type::ARRAY;
|
||||
o->via.array.ptr = static_cast<object*>(z.allocate_align(sizeof(object)*sizeof...(Args)));
|
||||
o->type = msgpack::type::ARRAY;
|
||||
o->via.array.ptr = static_cast<msgpack::object*>(z.allocate_align(sizeof(msgpack::object)*sizeof...(Args)));
|
||||
o->via.array.size = sizeof...(Args);
|
||||
|
||||
define_imp<std::tuple<Args&...>, sizeof...(Args)>::object(o, z, a);
|
||||
@@ -153,11 +156,11 @@ struct define<> {
|
||||
}
|
||||
void msgpack_unpack(msgpack::object const& o)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
}
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone&) const
|
||||
{
|
||||
o->type = type::ARRAY;
|
||||
o->type = msgpack::type::ARRAY;
|
||||
o->via.array.ptr = NULL;
|
||||
o->via.array.size = 0;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ namespace type {
|
||||
public:
|
||||
using base = std::tuple<Types...>;
|
||||
|
||||
using base::tuple;
|
||||
using base::base;
|
||||
|
||||
tuple() = default;
|
||||
tuple(tuple const&) = default;
|
||||
@@ -91,11 +91,11 @@ namespace type {
|
||||
}
|
||||
} // namespace type
|
||||
|
||||
// --- Pack ( from tuple to packer stream ---
|
||||
// --- Pack from tuple to packer stream ---
|
||||
template <typename Stream, typename Tuple, std::size_t N>
|
||||
struct MsgpackTuplePacker {
|
||||
static void pack(
|
||||
packer<Stream>& o,
|
||||
msgpack::packer<Stream>& o,
|
||||
const Tuple& v) {
|
||||
MsgpackTuplePacker<Stream, Tuple, N-1>::pack(o, v);
|
||||
o.pack(type::get<N-1>(v));
|
||||
@@ -105,7 +105,7 @@ struct MsgpackTuplePacker {
|
||||
template <typename Stream, typename Tuple>
|
||||
struct MsgpackTuplePacker<Stream, Tuple, 1> {
|
||||
static void pack (
|
||||
packer<Stream>& o,
|
||||
msgpack::packer<Stream>& o,
|
||||
const Tuple& v) {
|
||||
o.pack(type::get<0>(v));
|
||||
}
|
||||
@@ -114,14 +114,14 @@ struct MsgpackTuplePacker<Stream, Tuple, 1> {
|
||||
template <typename Stream, typename Tuple>
|
||||
struct MsgpackTuplePacker<Stream, Tuple, 0> {
|
||||
static void pack (
|
||||
packer<Stream>&,
|
||||
msgpack::packer<Stream>&,
|
||||
const Tuple&) {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<Args...>& v) {
|
||||
o.pack_array(sizeof...(Args));
|
||||
MsgpackTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
|
||||
@@ -133,7 +133,7 @@ const packer<Stream>& operator<< (
|
||||
template <typename Tuple, std::size_t N>
|
||||
struct MsgpackTupleConverter {
|
||||
static void convert(
|
||||
object const& o,
|
||||
msgpack::object const& o,
|
||||
Tuple& v) {
|
||||
MsgpackTupleConverter<Tuple, N-1>::convert(o, v);
|
||||
o.via.array.ptr[N-1].convert<typename std::remove_reference<decltype(type::get<N-1>(v))>::type>(type::get<N-1>(v));
|
||||
@@ -143,7 +143,7 @@ struct MsgpackTupleConverter {
|
||||
template <typename Tuple>
|
||||
struct MsgpackTupleConverter<Tuple, 1> {
|
||||
static void convert (
|
||||
object const& o,
|
||||
msgpack::object const& o,
|
||||
Tuple& v) {
|
||||
o.via.array.ptr[0].convert<typename std::remove_reference<decltype(type::get<0>(v))>::type>(type::get<0>(v));
|
||||
}
|
||||
@@ -152,17 +152,17 @@ struct MsgpackTupleConverter<Tuple, 1> {
|
||||
template <typename Tuple>
|
||||
struct MsgpackTupleConverter<Tuple, 0> {
|
||||
static void convert (
|
||||
object const&,
|
||||
msgpack::object const&,
|
||||
Tuple&) {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<Args...>& v) {
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.via.array.size < sizeof...(Args)) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
||||
MsgpackTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
return o;
|
||||
}
|
||||
@@ -171,36 +171,36 @@ object const& operator>> (
|
||||
template <typename Tuple, std::size_t N>
|
||||
struct MsgpackTupleToObjectWithZone {
|
||||
static void convert(
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const Tuple& v) {
|
||||
MsgpackTupleToObjectWithZone<Tuple, N-1>::convert(o, v);
|
||||
o.via.array.ptr[N-1] = object(type::get<N-1>(v), o.zone);
|
||||
o.via.array.ptr[N-1] = msgpack::object(type::get<N-1>(v), o.zone);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tuple>
|
||||
struct MsgpackTupleToObjectWithZone<Tuple, 1> {
|
||||
static void convert (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
const Tuple& v) {
|
||||
o.via.array.ptr[0] = object(type::get<0>(v), o.zone);
|
||||
o.via.array.ptr[0] = msgpack::object(type::get<0>(v), o.zone);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tuple>
|
||||
struct MsgpackTupleToObjectWithZone<Tuple, 0> {
|
||||
static void convert (
|
||||
object::with_zone&,
|
||||
msgpack::object::with_zone&,
|
||||
const Tuple&) {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
inline void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
type::tuple<Args...> const& v) {
|
||||
o.type = type::ARRAY;
|
||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object)*sizeof...(Args)));
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*sizeof...(Args)));
|
||||
o.via.array.size = sizeof...(Args);
|
||||
MsgpackTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
}
|
||||
|
@@ -54,8 +54,8 @@ template <typename Stream, typename Tuple, std::size_t N>
|
||||
struct MsgpackTuplePacker;
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
const packer<Stream>& operator<< (
|
||||
packer<Stream>& o,
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<Args...>& v);
|
||||
|
||||
// --- Convert from tuple to object ---
|
||||
@@ -64,8 +64,8 @@ template <typename Tuple, std::size_t N>
|
||||
struct MsgpackTupleConverter;
|
||||
|
||||
template <typename... Args>
|
||||
object const& operator>> (
|
||||
object const& o,
|
||||
msgpack::object const& operator>> (
|
||||
msgpack::object const& o,
|
||||
type::tuple<Args...>& v);
|
||||
|
||||
// --- Convert from tuple to object with zone ---
|
||||
@@ -74,7 +74,7 @@ struct MsgpackTupleToObjectWithZone;
|
||||
|
||||
template <typename... Args>
|
||||
void operator<< (
|
||||
object::with_zone& o,
|
||||
msgpack::object::with_zone& o,
|
||||
type::tuple<Args...> const& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -57,152 +57,152 @@ typedef fix_int<int64_t> fix_int64;
|
||||
} // namespace type
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_int8& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int8& v)
|
||||
{ v = type::detail::convert_integer<int8_t>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_int16& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int16& v)
|
||||
{ v = type::detail::convert_integer<int16_t>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_int32& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int32& v)
|
||||
{ v = type::detail::convert_integer<int32_t>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_int64& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int64& v)
|
||||
{ v = type::detail::convert_integer<int64_t>(o); return o; }
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_uint8& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint8& v)
|
||||
{ v = type::detail::convert_integer<uint8_t>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_uint16& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint16& v)
|
||||
{ v = type::detail::convert_integer<uint16_t>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_uint32& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint32& v)
|
||||
{ v = type::detail::convert_integer<uint32_t>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, type::fix_uint64& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint64& v)
|
||||
{ v = type::detail::convert_integer<uint64_t>(o); return o; }
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int8& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int8& v)
|
||||
{ o.pack_fix_int8(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int16& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int16& v)
|
||||
{ o.pack_fix_int16(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int32& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int32& v)
|
||||
{ o.pack_fix_int32(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int64& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int64& v)
|
||||
{ o.pack_fix_int64(v); return o; }
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint8& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint8& v)
|
||||
{ o.pack_fix_uint8(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint16& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint16& v)
|
||||
{ o.pack_fix_uint16(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint32& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint32& v)
|
||||
{ o.pack_fix_uint32(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint64& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint64& v)
|
||||
{ o.pack_fix_uint64(v); return o; }
|
||||
|
||||
|
||||
inline void operator<< (object& o, type::fix_int8 v)
|
||||
inline void operator<< (msgpack::object& o, type::fix_int8 v)
|
||||
{
|
||||
if (v.get() < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v.get();
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, type::fix_int16 v)
|
||||
inline void operator<< (msgpack::object& o, type::fix_int16 v)
|
||||
{
|
||||
if(v.get() < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v.get();
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, type::fix_int32 v)
|
||||
inline void operator<< (msgpack::object& o, type::fix_int32 v)
|
||||
{
|
||||
if (v.get() < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v.get();
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, type::fix_int64 v)
|
||||
inline void operator<< (msgpack::object& o, type::fix_int64 v)
|
||||
{
|
||||
if (v.get() < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v.get();
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void operator<< (object& o, type::fix_uint8 v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
inline void operator<< (msgpack::object& o, type::fix_uint8 v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
|
||||
inline void operator<< (object& o, type::fix_uint16 v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
inline void operator<< (msgpack::object& o, type::fix_uint16 v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
|
||||
inline void operator<< (object& o, type::fix_uint32 v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
inline void operator<< (msgpack::object& o, type::fix_uint32 v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
|
||||
inline void operator<< (object& o, type::fix_uint64 v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
inline void operator<< (msgpack::object& o, type::fix_uint64 v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_int8 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int8 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_int16 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int16 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_int32 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int32 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_int64 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int64 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_uint8 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint8 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_uint16 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint16 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_uint32 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint32 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::fix_uint64 v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint64 v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -45,53 +45,53 @@ typedef fix_int<int64_t> fix_int64;
|
||||
} // namespace type
|
||||
|
||||
|
||||
object const& operator>> (object const& o, type::fix_int8& v);
|
||||
object const& operator>> (object const& o, type::fix_int16& v);
|
||||
object const& operator>> (object const& o, type::fix_int32& v);
|
||||
object const& operator>> (object const& o, type::fix_int64& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int8& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int16& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int32& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int64& v);
|
||||
|
||||
object const& operator>> (object const& o, type::fix_uint8& v);
|
||||
object const& operator>> (object const& o, type::fix_uint16& v);
|
||||
object const& operator>> (object const& o, type::fix_uint32& v);
|
||||
object const& operator>> (object const& o, type::fix_uint64& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint8& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint16& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint32& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint64& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int8& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int8& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int16& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int16& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int32& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int32& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_int64& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int64& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint8& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint8& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint16& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint16& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint32& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint32& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::fix_uint64& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint64& v);
|
||||
|
||||
void operator<< (object& o, type::fix_int8 v);
|
||||
void operator<< (object& o, type::fix_int16 v);
|
||||
void operator<< (object& o, type::fix_int32 v);
|
||||
void operator<< (object& o, type::fix_int64 v);
|
||||
void operator<< (msgpack::object& o, type::fix_int8 v);
|
||||
void operator<< (msgpack::object& o, type::fix_int16 v);
|
||||
void operator<< (msgpack::object& o, type::fix_int32 v);
|
||||
void operator<< (msgpack::object& o, type::fix_int64 v);
|
||||
|
||||
void operator<< (object& o, type::fix_uint8 v);
|
||||
void operator<< (object& o, type::fix_uint16 v);
|
||||
void operator<< (object& o, type::fix_uint32 v);
|
||||
void operator<< (object& o, type::fix_uint64 v);
|
||||
void operator<< (msgpack::object& o, type::fix_uint8 v);
|
||||
void operator<< (msgpack::object& o, type::fix_uint16 v);
|
||||
void operator<< (msgpack::object& o, type::fix_uint32 v);
|
||||
void operator<< (msgpack::object& o, type::fix_uint64 v);
|
||||
|
||||
void operator<< (object::with_zone& o, type::fix_int8 v);
|
||||
void operator<< (object::with_zone& o, type::fix_int16 v);
|
||||
void operator<< (object::with_zone& o, type::fix_int32 v);
|
||||
void operator<< (object::with_zone& o, type::fix_int64 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_int8 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_int16 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_int32 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_int64 v);
|
||||
|
||||
void operator<< (object::with_zone& o, type::fix_uint8 v);
|
||||
void operator<< (object::with_zone& o, type::fix_uint16 v);
|
||||
void operator<< (object::with_zone& o, type::fix_uint32 v);
|
||||
void operator<< (object::with_zone& o, type::fix_uint64 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint8 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint16 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint32 v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint64 v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -29,73 +29,73 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
// FIXME check overflow, underflow
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, float& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, float& v)
|
||||
{
|
||||
if(o.type == type::DOUBLE) {
|
||||
v = static_cast<float>(o.via.dec);
|
||||
if(o.type == msgpack::type::FLOAT) {
|
||||
v = static_cast<float>(o.via.f64);
|
||||
}
|
||||
else if (o.type == type::POSITIVE_INTEGER) {
|
||||
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||
v = static_cast<float>(o.via.u64);
|
||||
}
|
||||
else if (o.type == type::NEGATIVE_INTEGER) {
|
||||
else if (o.type == msgpack::type::NEGATIVE_INTEGER) {
|
||||
v = static_cast<float>(o.via.i64);
|
||||
}
|
||||
else {
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const float& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const float& v)
|
||||
{
|
||||
o.pack_float(v);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, double& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, double& v)
|
||||
{
|
||||
if(o.type == type::DOUBLE) {
|
||||
v = o.via.dec;
|
||||
if(o.type == msgpack::type::FLOAT) {
|
||||
v = o.via.f64;
|
||||
}
|
||||
else if (o.type == type::POSITIVE_INTEGER) {
|
||||
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||
v = static_cast<double>(o.via.u64);
|
||||
}
|
||||
else if (o.type == type::NEGATIVE_INTEGER) {
|
||||
else if (o.type == msgpack::type::NEGATIVE_INTEGER) {
|
||||
v = static_cast<double>(o.via.i64);
|
||||
}
|
||||
else {
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const double& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const double& v)
|
||||
{
|
||||
o.pack_double(v);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
inline void operator<< (object& o, float v)
|
||||
inline void operator<< (msgpack::object& o, float v)
|
||||
{
|
||||
o.type = type::DOUBLE;
|
||||
o.via.dec = static_cast<double>(v);
|
||||
o.type = msgpack::type::FLOAT;
|
||||
o.via.f64 = static_cast<double>(v);
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, double v)
|
||||
inline void operator<< (msgpack::object& o, double v)
|
||||
{
|
||||
o.type = type::DOUBLE;
|
||||
o.via.dec = v;
|
||||
o.type = msgpack::type::FLOAT;
|
||||
o.via.f64 = v;
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, float v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, float v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, double v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, double v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -26,16 +26,16 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
object const& operator>> (object const& o, float& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, float& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const float& v);
|
||||
object const& operator>> (object const& o, double& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const float& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, double& v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const double& v);
|
||||
void operator<< (object& o, float v);
|
||||
void operator<< (object& o, double v);
|
||||
void operator<< (object::with_zone& o, float v);
|
||||
void operator<< (object::with_zone& o, double v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const double& v);
|
||||
void operator<< (msgpack::object& o, float v);
|
||||
void operator<< (msgpack::object& o, double v);
|
||||
void operator<< (msgpack::object::with_zone& o, float v);
|
||||
void operator<< (msgpack::object::with_zone& o, double v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -33,29 +33,29 @@ namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct convert_integer_sign<T, true> {
|
||||
static inline T convert(object const& o) {
|
||||
if(o.type == type::POSITIVE_INTEGER) {
|
||||
static inline T convert(msgpack::object const& o) {
|
||||
if(o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||
if(o.via.u64 > static_cast<uint64_t>(std::numeric_limits<T>::max()))
|
||||
{ throw type_error(); }
|
||||
{ throw msgpack::type_error(); }
|
||||
return static_cast<T>(o.via.u64);
|
||||
} else if(o.type == type::NEGATIVE_INTEGER) {
|
||||
} else if(o.type == msgpack::type::NEGATIVE_INTEGER) {
|
||||
if(o.via.i64 < static_cast<int64_t>(std::numeric_limits<T>::min()))
|
||||
{ throw type_error(); }
|
||||
{ throw msgpack::type_error(); }
|
||||
return static_cast<T>(o.via.i64);
|
||||
}
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct convert_integer_sign<T, false> {
|
||||
static inline T convert(object const& o) {
|
||||
if(o.type == type::POSITIVE_INTEGER) {
|
||||
static inline T convert(msgpack::object const& o) {
|
||||
if(o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||
if(o.via.u64 > static_cast<uint64_t>(std::numeric_limits<T>::max()))
|
||||
{ throw type_error(); }
|
||||
{ throw msgpack::type_error(); }
|
||||
return static_cast<T>(o.via.u64);
|
||||
}
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,47 +65,23 @@ namespace detail {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static inline T convert_integer(object const& o)
|
||||
static inline T convert_integer(msgpack::object const& o)
|
||||
{
|
||||
return detail::convert_integer_sign<T, is_signed<T>::value>::convert(o);
|
||||
}
|
||||
|
||||
template <bool Signed>
|
||||
struct pack_char_sign;
|
||||
|
||||
template <>
|
||||
struct pack_char_sign<true> {
|
||||
template <typename Stream>
|
||||
static inline packer<Stream>& pack(packer<Stream>& o, char v) {
|
||||
o.pack_int8(v); return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack_char_sign<false> {
|
||||
template <typename Stream>
|
||||
static inline packer<Stream>& pack(packer<Stream>& o, char v) {
|
||||
o.pack_uint8(v); return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
static inline packer<Stream>& pack_char(packer<Stream>& o, char v) {
|
||||
return pack_char_sign<is_signed<char>::value>::pack(o, v);
|
||||
}
|
||||
|
||||
template <bool Signed>
|
||||
struct object_char_sign;
|
||||
|
||||
template <>
|
||||
struct object_char_sign<true> {
|
||||
static inline void make(object& o, char v) {
|
||||
static inline void make(msgpack::object& o, char v) {
|
||||
if (v < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
@@ -113,216 +89,216 @@ namespace detail {
|
||||
|
||||
template <>
|
||||
struct object_char_sign<false> {
|
||||
static inline void make(object& o, char v) {
|
||||
o.type = type::POSITIVE_INTEGER, o.via.u64 = v;
|
||||
static inline void make(msgpack::object& o, char v) {
|
||||
o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v;
|
||||
}
|
||||
};
|
||||
|
||||
static inline void object_char(object& o, char v) {
|
||||
static inline void object_char(msgpack::object& o, char v) {
|
||||
return object_char_sign<is_signed<char>::value>::make(o, v);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace type
|
||||
|
||||
inline object const& operator>> (object const& o, char& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, char& v)
|
||||
{ v = type::detail::convert_integer<char>(o); return o; }
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, signed char& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed char& v)
|
||||
{ v = type::detail::convert_integer<signed char>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, signed short& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed short& v)
|
||||
{ v = type::detail::convert_integer<signed short>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, signed int& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed int& v)
|
||||
{ v = type::detail::convert_integer<signed int>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, signed long& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed long& v)
|
||||
{ v = type::detail::convert_integer<signed long>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, signed long long& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed long long& v)
|
||||
{ v = type::detail::convert_integer<signed long long>(o); return o; }
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, unsigned char& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned char& v)
|
||||
{ v = type::detail::convert_integer<unsigned char>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, unsigned short& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned short& v)
|
||||
{ v = type::detail::convert_integer<unsigned short>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, unsigned int& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned int& v)
|
||||
{ v = type::detail::convert_integer<unsigned int>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, unsigned long& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned long& v)
|
||||
{ v = type::detail::convert_integer<unsigned long>(o); return o; }
|
||||
|
||||
inline object const& operator>> (object const& o, unsigned long long& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned long long& v)
|
||||
{ v = type::detail::convert_integer<unsigned long long>(o); return o; }
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, char v)
|
||||
{ return type::detail::pack_char(o, v); }
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, char v)
|
||||
{ o.pack_char(v); return o; }
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, signed char v)
|
||||
{ o.pack_int8(v); return o; }
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed char v)
|
||||
{ o.pack_signed_char(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, signed short v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed short v)
|
||||
{ o.pack_short(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, signed int v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed int v)
|
||||
{ o.pack_int(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, signed long v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long v)
|
||||
{ o.pack_long(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, signed long long v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long long v)
|
||||
{ o.pack_long_long(v); return o; }
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, unsigned char v)
|
||||
{ o.pack_uint8(v); return o; }
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned char v)
|
||||
{ o.pack_unsigned_char(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, unsigned short v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned short v)
|
||||
{ o.pack_unsigned_short(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, unsigned int v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned int v)
|
||||
{ o.pack_unsigned_int(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, unsigned long v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long v)
|
||||
{ o.pack_unsigned_long(v); return o; }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, unsigned long long v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long long v)
|
||||
{ o.pack_unsigned_long_long(v); return o; }
|
||||
|
||||
|
||||
inline void operator<< (object& o, char v)
|
||||
inline void operator<< (msgpack::object& o, char v)
|
||||
{ type::detail::object_char(o, v); }
|
||||
|
||||
|
||||
inline void operator<< (object& o, signed char v)
|
||||
inline void operator<< (msgpack::object& o, signed char v)
|
||||
{
|
||||
if (v < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, signed short v)
|
||||
inline void operator<< (msgpack::object& o, signed short v)
|
||||
{
|
||||
if (v < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, signed int v)
|
||||
inline void operator<< (msgpack::object& o, signed int v)
|
||||
{
|
||||
if (v < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, signed long v)
|
||||
inline void operator<< (msgpack::object& o, signed long v)
|
||||
{
|
||||
if (v < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
}
|
||||
else {
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, signed long long v)
|
||||
inline void operator<< (msgpack::object& o, signed long long v)
|
||||
{
|
||||
if (v < 0) {
|
||||
o.type = type::NEGATIVE_INTEGER;
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
}
|
||||
else{
|
||||
o.type = type::POSITIVE_INTEGER;
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, unsigned char v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
inline void operator<< (msgpack::object& o, unsigned char v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
|
||||
inline void operator<< (object& o, unsigned short v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
inline void operator<< (msgpack::object& o, unsigned short v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
|
||||
inline void operator<< (object& o, unsigned int v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
inline void operator<< (msgpack::object& o, unsigned int v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
|
||||
inline void operator<< (object& o, unsigned long v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
inline void operator<< (msgpack::object& o, unsigned long v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
|
||||
inline void operator<< (object& o, unsigned long long v)
|
||||
{ o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
inline void operator<< (msgpack::object& o, unsigned long long v)
|
||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||
|
||||
|
||||
|
||||
inline void operator<< (object::with_zone& o, char v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, char v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
inline void operator<< (object::with_zone& o, signed char v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, signed char v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, signed short v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, signed short v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, signed int v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, signed int v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, signed long v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, signed long v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, const signed long long& v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, const signed long long& v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
inline void operator<< (object::with_zone& o, unsigned char v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, unsigned char v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, unsigned short v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, unsigned short v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, unsigned int v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, unsigned int v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, unsigned long v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, unsigned long v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
inline void operator<< (object::with_zone& o, const unsigned long long& v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, const unsigned long long& v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -25,73 +25,73 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1){
|
||||
|
||||
object const& operator>> (object const& o, char& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, char& v);
|
||||
|
||||
object const& operator>> (object const& o, signed char& v);
|
||||
object const& operator>> (object const& o, signed short& v);
|
||||
object const& operator>> (object const& o, signed int& v);
|
||||
object const& operator>> (object const& o, signed long& v);
|
||||
object const& operator>> (object const& o, signed long long& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, signed char& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, signed short& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, signed int& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, signed long& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, signed long long& v);
|
||||
|
||||
object const& operator>> (object const& o, unsigned char& v);
|
||||
object const& operator>> (object const& o, unsigned short& v);
|
||||
object const& operator>> (object const& o, unsigned int& v);
|
||||
object const& operator>> (object const& o, unsigned long& v);
|
||||
object const& operator>> (object const& o, unsigned long long& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned char& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned short& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned int& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned long& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned long long& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, char v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, char v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, signed char v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed char v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, signed short v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed short v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, signed int v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed int v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, signed long v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, signed long long v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long long v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, unsigned char v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned char v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, unsigned short v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned short v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, unsigned int v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned int v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, unsigned long v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long v);
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, unsigned long long v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long long v);
|
||||
|
||||
|
||||
void operator<< (object& o, char v);
|
||||
void operator<< (msgpack::object& o, char v);
|
||||
|
||||
void operator<< (object& o, signed char v);
|
||||
void operator<< (object& o, signed short v);
|
||||
void operator<< (object& o, signed int v);
|
||||
void operator<< (object& o, signed long v);
|
||||
void operator<< (object& o, signed long long v);
|
||||
void operator<< (msgpack::object& o, signed char v);
|
||||
void operator<< (msgpack::object& o, signed short v);
|
||||
void operator<< (msgpack::object& o, signed int v);
|
||||
void operator<< (msgpack::object& o, signed long v);
|
||||
void operator<< (msgpack::object& o, signed long long v);
|
||||
|
||||
void operator<< (object& o, unsigned char v);
|
||||
void operator<< (object& o, unsigned short v);
|
||||
void operator<< (object& o, unsigned int v);
|
||||
void operator<< (object& o, unsigned long v);
|
||||
void operator<< (object& o, unsigned long long v);
|
||||
void operator<< (msgpack::object& o, unsigned char v);
|
||||
void operator<< (msgpack::object& o, unsigned short v);
|
||||
void operator<< (msgpack::object& o, unsigned int v);
|
||||
void operator<< (msgpack::object& o, unsigned long v);
|
||||
void operator<< (msgpack::object& o, unsigned long long v);
|
||||
|
||||
void operator<< (object::with_zone& o, char v);
|
||||
void operator<< (msgpack::object::with_zone& o, char v);
|
||||
|
||||
void operator<< (object::with_zone& o, signed char v);
|
||||
void operator<< (object::with_zone& o, signed short v);
|
||||
void operator<< (object::with_zone& o, signed int v);
|
||||
void operator<< (object::with_zone& o, signed long v);
|
||||
void operator<< (object::with_zone& o, const signed long long& v);
|
||||
void operator<< (msgpack::object::with_zone& o, signed char v);
|
||||
void operator<< (msgpack::object::with_zone& o, signed short v);
|
||||
void operator<< (msgpack::object::with_zone& o, signed int v);
|
||||
void operator<< (msgpack::object::with_zone& o, signed long v);
|
||||
void operator<< (msgpack::object::with_zone& o, const signed long long& v);
|
||||
|
||||
void operator<< (object::with_zone& o, unsigned char v);
|
||||
void operator<< (object::with_zone& o, unsigned short v);
|
||||
void operator<< (object::with_zone& o, unsigned int v);
|
||||
void operator<< (object::with_zone& o, unsigned long v);
|
||||
void operator<< (object::with_zone& o, const unsigned long long& v);
|
||||
void operator<< (msgpack::object::with_zone& o, unsigned char v);
|
||||
void operator<< (msgpack::object::with_zone& o, unsigned short v);
|
||||
void operator<< (msgpack::object::with_zone& o, unsigned int v);
|
||||
void operator<< (msgpack::object::with_zone& o, unsigned long v);
|
||||
void operator<< (msgpack::object::with_zone& o, const unsigned long long& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace msgpack {
|
||||
@@ -27,12 +29,12 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, std::list<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::list<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
object* p = o.via.array.ptr;
|
||||
object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
typename std::list<T>::iterator it = v.begin();
|
||||
for(; p < pend; ++p, ++it) {
|
||||
p->convert(*it);
|
||||
@@ -41,31 +43,33 @@ inline object const& operator>> (object const& o, std::list<T>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::list<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::list<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename std::list<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const std::list<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::list<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
object* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
typename std::list<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(*it, o.zone);
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
|
@@ -27,11 +27,11 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, std::list<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::list<T>& v);
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::list<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::list<T>& v);
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const std::list<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::list<T>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
@@ -45,12 +47,12 @@ namespace detail {
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline object const& operator>> (object const& o, type::assoc_vector<K,V>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::assoc_vector<K,V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
v.resize(o.via.map.size);
|
||||
object_kv* p = o.via.map.ptr;
|
||||
object_kv* const pend = o.via.map.ptr + o.via.map.size;
|
||||
msgpack::object_kv* p = o.via.map.ptr;
|
||||
msgpack::object_kv* const pend = o.via.map.ptr + o.via.map.size;
|
||||
std::pair<K, V>* it(&v.front());
|
||||
for(; p < pend; ++p, ++it) {
|
||||
p->key.convert(it->first);
|
||||
@@ -61,11 +63,12 @@ inline object const& operator>> (object const& o, type::assoc_vector<K,V>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::assoc_vector<K,V>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::assoc_vector<K,V>& v)
|
||||
{
|
||||
o.pack_map(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename type::assoc_vector<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
@@ -73,21 +76,22 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const type::assoc_vector<K
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (object::with_zone& o, const type::assoc_vector<K,V>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<K,V>& v)
|
||||
{
|
||||
o.type = type::MAP;
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
object_kv* p = static_cast<object_kv*>(o.zone.allocate_align(sizeof(object_kv)*v.size()));
|
||||
object_kv* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = v.size();
|
||||
o.via.map.size = size;
|
||||
typename type::assoc_vector<K,V>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = object(it->first, o.zone);
|
||||
p->val = object(it->second, o.zone);
|
||||
p->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -96,11 +100,11 @@ inline void operator<< (object::with_zone& o, const type::assoc_vector<K,V>& v)
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline object const& operator>> (object const& o, std::map<K, V>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::map<K, V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
object_kv* p(o.via.map.ptr);
|
||||
object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
std::map<K, V> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
K key;
|
||||
@@ -119,11 +123,12 @@ inline object const& operator>> (object const& o, std::map<K, V>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::map<K,V>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::map<K,V>& v)
|
||||
{
|
||||
o.pack_map(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename std::map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
@@ -131,21 +136,22 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const std::map<K,V>& v)
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (object::with_zone& o, const std::map<K,V>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::map<K,V>& v)
|
||||
{
|
||||
o.type = type::MAP;
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
object_kv* p = static_cast<object_kv*>(o.zone.allocate_align(sizeof(object_kv)*v.size()));
|
||||
object_kv* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = v.size();
|
||||
o.via.map.size = size;
|
||||
typename std::map<K,V>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = object(it->first, o.zone);
|
||||
p->val = object(it->second, o.zone);
|
||||
p->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -154,11 +160,11 @@ inline void operator<< (object::with_zone& o, const std::map<K,V>& v)
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline object const& operator>> (object const& o, std::multimap<K, V>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::multimap<K, V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
object_kv* p(o.via.map.ptr);
|
||||
object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
std::multimap<K, V> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
std::pair<K, V> value;
|
||||
@@ -171,11 +177,12 @@ inline object const& operator>> (object const& o, std::multimap<K, V>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::multimap<K,V>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multimap<K,V>& v)
|
||||
{
|
||||
o.pack_map(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename std::multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
@@ -183,21 +190,22 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const std::multimap<K,V>&
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (object::with_zone& o, const std::multimap<K,V>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::multimap<K,V>& v)
|
||||
{
|
||||
o.type = type::MAP;
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
object_kv* p = static_cast<object_kv*>(o.zone.allocate_align(sizeof(object_kv)*v.size()));
|
||||
object_kv* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = v.size();
|
||||
o.via.map.size = size;
|
||||
typename std::multimap<K,V>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = object(it->first, o.zone);
|
||||
p->val = object(it->second, o.zone);
|
||||
p->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
|
@@ -42,25 +42,25 @@ namespace detail {
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
object const& operator>> (object const& o, type::assoc_vector<K,V>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::assoc_vector<K,V>& v);
|
||||
template <typename Stream, typename K, typename V>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::assoc_vector<K,V>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::assoc_vector<K,V>& v);
|
||||
template <typename K, typename V>
|
||||
void operator<< (object::with_zone& o, const type::assoc_vector<K,V>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
object const& operator>> (object const& o, std::map<K, V>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::map<K, V>& v);
|
||||
template <typename Stream, typename K, typename V>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::map<K,V>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::map<K,V>& v);
|
||||
template <typename K, typename V>
|
||||
void operator<< (object::with_zone& o, const std::map<K,V>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::map<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
object const& operator>> (object const& o, std::multimap<K, V>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::multimap<K, V>& v);
|
||||
template <typename Stream, typename K, typename V>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::multimap<K,V>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multimap<K,V>& v);
|
||||
template <typename K, typename V>
|
||||
void operator<< (object::with_zone& o, const std::multimap<K,V>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::multimap<K,V>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -32,30 +32,30 @@ struct nil { };
|
||||
} // namespace type
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, type::nil&)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::nil&)
|
||||
{
|
||||
if(o.type != type::NIL) { throw type_error(); }
|
||||
if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::nil&)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::nil&)
|
||||
{
|
||||
o.pack_nil();
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, type::nil)
|
||||
inline void operator<< (msgpack::object& o, type::nil)
|
||||
{
|
||||
o.type = type::NIL;
|
||||
o.type = msgpack::type::NIL;
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, type::nil v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::nil v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
template <>
|
||||
inline void object::as<void>() const
|
||||
inline void msgpack::object::as<void>() const
|
||||
{
|
||||
msgpack::type::nil v;
|
||||
convert(v);
|
||||
|
@@ -32,17 +32,17 @@ struct nil;
|
||||
} // namespace type
|
||||
|
||||
|
||||
object const& operator>> (object const& o, type::nil&);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::nil&);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::nil&);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::nil&);
|
||||
|
||||
void operator<< (object& o, type::nil);
|
||||
void operator<< (msgpack::object& o, type::nil);
|
||||
|
||||
void operator<< (object::with_zone& o, type::nil v);
|
||||
void operator<< (msgpack::object::with_zone& o, type::nil v);
|
||||
|
||||
template <>
|
||||
inline void object::as<void>() const;
|
||||
inline void msgpack::object::as<void>() const;
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -27,17 +27,17 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline object const& operator>> (object const& o, std::pair<T1, T2>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::pair<T1, T2>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.via.array.size != 2) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size != 2) { throw msgpack::type_error(); }
|
||||
o.via.array.ptr[0].convert(v.first);
|
||||
o.via.array.ptr[1].convert(v.second);
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream, typename T1, typename T2>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::pair<T1, T2>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::pair<T1, T2>& v)
|
||||
{
|
||||
o.pack_array(2);
|
||||
o.pack(v.first);
|
||||
@@ -46,14 +46,14 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const std::pair<T1, T2>& v
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline void operator<< (object::with_zone& o, const std::pair<T1, T2>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::pair<T1, T2>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*2));
|
||||
o.type = msgpack::type::ARRAY;
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*2));
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = 2;
|
||||
p[0] = object(v.first, o.zone);
|
||||
p[1] = object(v.second, o.zone);
|
||||
p[0] = msgpack::object(v.first, o.zone);
|
||||
p[1] = msgpack::object(v.second, o.zone);
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -27,13 +27,13 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T1, typename T2>
|
||||
object const& operator>> (object const& o, std::pair<T1, T2>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::pair<T1, T2>& v);
|
||||
|
||||
template <typename Stream, typename T1, typename T2>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::pair<T1, T2>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::pair<T1, T2>& v);
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void operator<< (object::with_zone& o, const std::pair<T1, T2>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::pair<T1, T2>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -40,7 +40,7 @@ struct raw_ref {
|
||||
|
||||
bool operator== (const raw_ref& x) const
|
||||
{
|
||||
return size == x.size && memcmp(ptr, x.ptr, size) == 0;
|
||||
return size == x.size && std::memcmp(ptr, x.ptr, size) == 0;
|
||||
}
|
||||
|
||||
bool operator!= (const raw_ref& x) const
|
||||
@@ -50,13 +50,13 @@ struct raw_ref {
|
||||
|
||||
bool operator< (const raw_ref& x) const
|
||||
{
|
||||
if(size == x.size) { return memcmp(ptr, x.ptr, size) < 0; }
|
||||
if(size == x.size) { return std::memcmp(ptr, x.ptr, size) < 0; }
|
||||
else { return size < x.size; }
|
||||
}
|
||||
|
||||
bool operator> (const raw_ref& x) const
|
||||
{
|
||||
if(size == x.size) { return memcmp(ptr, x.ptr, size) > 0; }
|
||||
if(size == x.size) { return std::memcmp(ptr, x.ptr, size) > 0; }
|
||||
else { return size > x.size; }
|
||||
}
|
||||
};
|
||||
@@ -64,31 +64,31 @@ struct raw_ref {
|
||||
} // namespace type
|
||||
|
||||
|
||||
inline object const& operator>> (object const& o, type::raw_ref& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, msgpack::type::raw_ref& v)
|
||||
{
|
||||
if(o.type != type::BIN) { throw type_error(); }
|
||||
if(o.type != msgpack::type::BIN) { throw msgpack::type_error(); }
|
||||
v.ptr = o.via.bin.ptr;
|
||||
v.size = o.via.bin.size;
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const type::raw_ref& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::type::raw_ref& v)
|
||||
{
|
||||
o.pack_bin(v.size);
|
||||
o.pack_bin_body(v.ptr, v.size);
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, const type::raw_ref& v)
|
||||
inline void operator<< (msgpack::object& o, const msgpack::type::raw_ref& v)
|
||||
{
|
||||
o.type = type::BIN;
|
||||
o.type = msgpack::type::BIN;
|
||||
o.via.bin.ptr = v.ptr;
|
||||
o.via.bin.size = v.size;
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, const type::raw_ref& v)
|
||||
{ static_cast<object&>(o) << v; }
|
||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::type::raw_ref& v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -34,14 +34,14 @@ struct raw_ref;
|
||||
} // namespace type
|
||||
|
||||
|
||||
object const& operator>> (object const& o, type::raw_ref& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, type::raw_ref& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const type::raw_ref& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::raw_ref& v);
|
||||
|
||||
void operator<< (object& o, const type::raw_ref& v);
|
||||
void operator<< (msgpack::object& o, const type::raw_ref& v);
|
||||
|
||||
void operator<< (object::with_zone& o, const type::raw_ref& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const type::raw_ref& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <set>
|
||||
|
||||
@@ -28,11 +29,11 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, std::set<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::set<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
object* p = o.via.array.ptr + o.via.array.size;
|
||||
object* const pbegin = o.via.array.ptr;
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
std::set<T> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
@@ -43,31 +44,33 @@ inline object const& operator>> (object const& o, std::set<T>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::set<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::set<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename std::set<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const std::set<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::set<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
object* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
typename std::set<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(*it, o.zone);
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -76,11 +79,11 @@ inline void operator<< (object::with_zone& o, const std::set<T>& v)
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, std::multiset<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::multiset<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
object* p = o.via.array.ptr + o.via.array.size;
|
||||
object* const pbegin = o.via.array.ptr;
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
std::multiset<T> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
@@ -91,31 +94,33 @@ inline object const& operator>> (object const& o, std::multiset<T>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::multiset<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multiset<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename std::multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const std::multiset<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::multiset<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
object* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
typename std::multiset<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(*it, o.zone);
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
|
@@ -28,22 +28,22 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, std::set<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::set<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::set<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::set<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const std::set<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::set<T>& v);
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, std::multiset<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::multiset<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::multiset<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multiset<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const std::multiset<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::multiset<T>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,50 +20,55 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
inline object const& operator>> (object const& o, std::string& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::string& v)
|
||||
{
|
||||
switch (o.type) {
|
||||
case type::BIN:
|
||||
case msgpack::type::BIN:
|
||||
v.assign(o.via.bin.ptr, o.via.bin.size);
|
||||
break;
|
||||
case type::STR:
|
||||
case msgpack::type::STR:
|
||||
v.assign(o.via.str.ptr, o.via.str.size);
|
||||
break;
|
||||
default:
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::string& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::string& v)
|
||||
{
|
||||
o.pack_str(v.size());
|
||||
o.pack_str_body(v.data(), v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_str(size);
|
||||
o.pack_str_body(v.data(), size);
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, const std::string& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::string& v)
|
||||
{
|
||||
o.type = type::STR;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.size()));
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::STR;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||
o.via.str.ptr = ptr;
|
||||
o.via.str.size = static_cast<uint32_t>(v.size());
|
||||
memcpy(ptr, v.data(), v.size());
|
||||
o.via.str.size = size;
|
||||
std::memcpy(ptr, v.data(), v.size());
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, const std::string& v)
|
||||
inline void operator<< (msgpack::object& o, const std::string& v)
|
||||
{
|
||||
o.type = type::STR;
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::STR;
|
||||
o.via.str.ptr = v.data();
|
||||
o.via.str.size = static_cast<uint32_t>(v.size());
|
||||
o.via.str.size = size;
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -26,14 +26,14 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
object const& operator>> (object const& o, std::string& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::string& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::string& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::string& v);
|
||||
|
||||
void operator<< (object::with_zone& o, const std::string& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::string& v);
|
||||
|
||||
void operator<< (object& o, const std::string& v);
|
||||
void operator<< (msgpack::object& o, const std::string& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,10 +20,11 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#define MSGPACK_HAS_STD_UNOURDERED_MAP
|
||||
#define MSGPACK_HAS_STD_UNORDERED_MAP
|
||||
#include <unordered_map>
|
||||
#define MSGPACK_STD_TR1 std
|
||||
|
||||
@@ -31,7 +32,7 @@
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
|
||||
#define MSGPACK_HAS_STD_TR1_UNOURDERED_MAP
|
||||
#define MSGPACK_HAS_STD_TR1_UNORDERED_MAP
|
||||
|
||||
#include <tr1/unordered_map>
|
||||
#define MSGPACK_STD_TR1 std::tr1
|
||||
@@ -40,17 +41,18 @@
|
||||
|
||||
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#if defined(MSGPACK_STD_TR1)
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename K, typename V>
|
||||
inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
object_kv* p(o.via.map.ptr);
|
||||
object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
MSGPACK_STD_TR1::unordered_map<K, V> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
K key;
|
||||
@@ -62,11 +64,12 @@ inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_map
|
||||
}
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v)
|
||||
{
|
||||
o.pack_map(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
@@ -74,21 +77,22 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::uno
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v)
|
||||
{
|
||||
o.type = type::MAP;
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
object_kv* p = static_cast<object_kv*>(o.zone.allocate_align(sizeof(object_kv)*v.size()));
|
||||
object_kv* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = v.size();
|
||||
o.via.map.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_map<K,V>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = object(it->first, o.zone);
|
||||
p->val = object(it->second, o.zone);
|
||||
p->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -97,11 +101,11 @@ inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_m
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
object_kv* p(o.via.map.ptr);
|
||||
object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
MSGPACK_STD_TR1::unordered_multimap<K, V> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
std::pair<K, V> value;
|
||||
@@ -114,11 +118,12 @@ inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_mul
|
||||
}
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v)
|
||||
{
|
||||
o.pack_map(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
@@ -126,21 +131,22 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::uno
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v)
|
||||
{
|
||||
o.type = type::MAP;
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
object_kv* p = static_cast<object_kv*>(o.zone.allocate_align(sizeof(object_kv)*v.size()));
|
||||
object_kv* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = v.size();
|
||||
o.via.map.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_multimap<K,V>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = object(it->first, o.zone);
|
||||
p->val = object(it->second, o.zone);
|
||||
p->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -153,4 +159,6 @@ inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_m
|
||||
|
||||
#undef MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#define MSGPACK_HAS_STD_UNOURDERED_MAP
|
||||
#define MSGPACK_HAS_STD_UNORDERED_MAP
|
||||
#include <unordered_map>
|
||||
#define MSGPACK_STD_TR1 std
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
|
||||
#define MSGPACK_HAS_STD_TR1_UNOURDERED_MAP
|
||||
#define MSGPACK_HAS_STD_TR1_UNORDERED_MAP
|
||||
|
||||
#include <tr1/unordered_map>
|
||||
#define MSGPACK_STD_TR1 std::tr1
|
||||
@@ -40,28 +40,29 @@
|
||||
|
||||
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#if defined(MSGPACK_STD_TR1)
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename K, typename V>
|
||||
object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v);
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V>& v);
|
||||
|
||||
template <typename Stream, typename K, typename V>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v);
|
||||
|
||||
template <typename K, typename V>
|
||||
void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
@@ -69,4 +70,6 @@ void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap
|
||||
|
||||
#undef MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_MAP_FWD_HPP
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
||||
// Copyright (C) 2008-2015 FURUHASHI Sadayuki
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,10 +20,11 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#define MSGPACK_HAS_STD_UNOURDERED_SET
|
||||
#define MSGPACK_HAS_STD_UNORDERED_SET
|
||||
#include <unordered_set>
|
||||
#define MSGPACK_STD_TR1 std
|
||||
|
||||
@@ -31,7 +32,7 @@
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
|
||||
#define MSGPACK_HAS_STD_TR1_UNOURDERED_SET
|
||||
#define MSGPACK_HAS_STD_TR1_UNORDERED_SET
|
||||
|
||||
#include <tr1/unordered_set>
|
||||
#define MSGPACK_STD_TR1 std::tr1
|
||||
@@ -40,16 +41,18 @@
|
||||
|
||||
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#if defined(MSGPACK_STD_TR1)
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_set<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_set<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
object* p = o.via.array.ptr + o.via.array.size;
|
||||
object* const pbegin = o.via.array.ptr;
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
MSGPACK_STD_TR1::unordered_set<T> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
@@ -60,31 +63,33 @@ inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_set
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_set<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
object* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_set<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(*it, o.zone);
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -93,11 +98,11 @@ inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_s
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
object* p = o.via.array.ptr + o.via.array.size;
|
||||
object* const pbegin = o.via.array.ptr;
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
MSGPACK_STD_TR1::unordered_multiset<T> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
@@ -108,9 +113,10 @@ inline object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_mul
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
@@ -119,20 +125,21 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::uno
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
object* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_multiset<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(*it, o.zone);
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -145,4 +152,6 @@ inline void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_m
|
||||
|
||||
#undef MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_SET_HPP
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#define MSGPACK_HAS_STD_UNOURDERED_SET
|
||||
#define MSGPACK_HAS_STD_UNORDERED_SET
|
||||
#include <unordered_set>
|
||||
#define MSGPACK_STD_TR1 std
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#if __GNUC__ >= 4
|
||||
|
||||
#define MSGPACK_HAS_STD_TR1_UNOURDERED_SET
|
||||
#define MSGPACK_HAS_STD_TR1_UNORDERED_SET
|
||||
|
||||
#include <tr1/unordered_set>
|
||||
#define MSGPACK_STD_TR1 std::tr1
|
||||
@@ -40,27 +40,29 @@
|
||||
|
||||
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
|
||||
#if defined(MSGPACK_STD_TR1)
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_set<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_set<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T>& v);
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
@@ -68,4 +70,6 @@ void operator<< (object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset
|
||||
|
||||
#undef MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_SET_FWD_HPP
|
||||
|
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace msgpack {
|
||||
@@ -27,13 +29,13 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, std::vector<T>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
if(o.via.array.size > 0) {
|
||||
object* p = o.via.array.ptr;
|
||||
object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
T* it = &v[0];
|
||||
do {
|
||||
p->convert(*it);
|
||||
@@ -45,9 +47,10 @@ inline object const& operator>> (object const& o, std::vector<T>& v)
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::vector<T>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename std::vector<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
@@ -56,20 +59,21 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const std::vector<T>& v)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const std::vector<T>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<T>& v)
|
||||
{
|
||||
o.type = type::ARRAY;
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
object* p = static_cast<object*>(o.zone.allocate_align(sizeof(object)*v.size()));
|
||||
object* const pend = p + v.size();
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
typename std::vector<T>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(*it, o.zone);
|
||||
*p = msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
|
80
include/msgpack/adaptor/vector_bool.hpp
Normal file
80
include/msgpack/adaptor/vector_bool.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef MSGPACK_TYPE_VECTOR_BOOL_HPP
|
||||
#define MSGPACK_TYPE_VECTOR_BOOL_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<bool>& v)
|
||||
{
|
||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if (o.via.array.size > 0) {
|
||||
v.resize(o.via.array.size);
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
for (std::vector<bool>::iterator it = v.begin(), end = v.end();
|
||||
it != end;
|
||||
++it) {
|
||||
*it = p->as<bool>();
|
||||
++p;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<bool>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
for(std::vector<bool>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(static_cast<bool>(*it));
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<bool>& v)
|
||||
{
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*v.size()));
|
||||
msgpack::object* const pend = p + v.size();
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
std::vector<bool>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(static_cast<bool>(*it), o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_TYPE_VECTOR_BOOL_HPP
|
40
include/msgpack/adaptor/vector_bool_fwd.hpp
Normal file
40
include/msgpack/adaptor/vector_bool_fwd.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef MSGPACK_TYPE_VECTOR_BOOL_FWD_HPP
|
||||
#define MSGPACK_TYPE_VECTOR_BOOL_FWD_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
object const& operator>> (object const& o, std::vector<bool>& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::vector<bool>& v);
|
||||
|
||||
void operator<< (object::with_zone& o, const std::vector<bool>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_TYPE_VECTOR_BOOL_FWD_HPP
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2014 KONDO Takatoshi
|
||||
// Copyright (C) 2014-2015 KONDO Takatoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -20,53 +20,58 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
inline object const& operator>> (object const& o, std::vector<char>& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<char>& v)
|
||||
{
|
||||
switch (o.type) {
|
||||
case type::BIN:
|
||||
case msgpack::type::BIN:
|
||||
v.resize(o.via.bin.size);
|
||||
std::memcpy(v.data(), o.via.bin.ptr, o.via.bin.size);
|
||||
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
|
||||
break;
|
||||
case type::STR:
|
||||
case msgpack::type::STR:
|
||||
v.resize(o.via.str.size);
|
||||
std::memcpy(v.data(), o.via.str.ptr, o.via.str.size);
|
||||
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
|
||||
break;
|
||||
default:
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::vector<char>& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<char>& v)
|
||||
{
|
||||
o.pack_bin(v.size());
|
||||
o.pack_bin_body(v.data(), v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_bin(size);
|
||||
o.pack_bin_body(&v.front(), size);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, const std::vector<char>& v)
|
||||
inline void operator<< (msgpack::object& o, const std::vector<char>& v)
|
||||
{
|
||||
o.type = type::BIN;
|
||||
o.via.bin.ptr = v.data();
|
||||
o.via.bin.size = static_cast<uint32_t>(v.size());
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::BIN;
|
||||
o.via.bin.ptr = &v.front();
|
||||
o.via.bin.size = size;
|
||||
}
|
||||
|
||||
inline void operator<< (object::with_zone& o, const std::vector<char>& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<char>& v)
|
||||
{
|
||||
o.type = type::BIN;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.size()));
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::BIN;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||
o.via.bin.ptr = ptr;
|
||||
o.via.bin.size = static_cast<uint32_t>(v.size());
|
||||
std::memcpy(ptr, v.data(), v.size());
|
||||
o.via.bin.size = size;
|
||||
std::memcpy(ptr, &v.front(), size);
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
@@ -26,14 +26,14 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
object const& operator>> (object const& o, std::vector<char>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::vector<char>& v);
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::vector<char>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<char>& v);
|
||||
|
||||
void operator<< (object& o, const std::vector<char>& v);
|
||||
void operator<< (msgpack::object& o, const std::vector<char>& v);
|
||||
|
||||
void operator<< (object::with_zone& o, const std::vector<char>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::vector<char>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -27,13 +27,13 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, std::vector<T>& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, std::vector<T>& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const std::vector<T>& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<T>& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const std::vector<T>& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const std::vector<T>& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -35,7 +35,9 @@
|
||||
#if __cplusplus < 201103
|
||||
|
||||
#if !defined(nullptr)
|
||||
#define nullptr (0)
|
||||
# if _MSC_VER < 1600
|
||||
# define nullptr (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MSGPACK_ZONE_ALIGN
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(int)
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
zone(size_t chunk_size = MSGPACK_ZONE_CHUNK_SIZE) /* throw() */;
|
||||
|
||||
public:
|
||||
void* allocate_align(size_t size);
|
||||
void* allocate_align(size_t size, size_t align = MSGPACK_ZONE_ALIGN);
|
||||
void* allocate_no_align(size_t size);
|
||||
|
||||
void push_finalizer(void (*func)(void*), void* data);
|
||||
@@ -161,21 +161,21 @@ public:
|
||||
void clear();
|
||||
|
||||
void swap(zone& o);
|
||||
static void* operator new(std::size_t size) throw(std::bad_alloc)
|
||||
static void* operator new(std::size_t size)
|
||||
{
|
||||
void* p = ::malloc(size);
|
||||
if (!p) throw std::bad_alloc();
|
||||
return p;
|
||||
}
|
||||
static void operator delete(void *p) throw()
|
||||
static void operator delete(void *p) /* throw() */
|
||||
{
|
||||
::free(p);
|
||||
}
|
||||
static void* operator new(std::size_t size, void* place) throw()
|
||||
static void* operator new(std::size_t size, void* place) /* throw() */
|
||||
{
|
||||
return ::operator new(size, place);
|
||||
}
|
||||
static void operator delete(void* p, void* place) throw()
|
||||
static void operator delete(void* p, void* place) /* throw() */
|
||||
{
|
||||
::operator delete(p, place);
|
||||
}
|
||||
@@ -239,16 +239,30 @@ private:
|
||||
static void object_delete(void* obj);
|
||||
|
||||
void* allocate_expand(size_t size);
|
||||
private:
|
||||
zone(const zone&);
|
||||
zone& operator=(const zone&);
|
||||
};
|
||||
|
||||
inline zone::zone(size_t chunk_size) /* throw() */ :m_chunk_size(chunk_size), m_chunk_list(m_chunk_size)
|
||||
{
|
||||
}
|
||||
|
||||
inline void* zone::allocate_align(size_t size)
|
||||
inline void* zone::allocate_align(size_t size, size_t align)
|
||||
{
|
||||
return allocate_no_align(
|
||||
((size)+((MSGPACK_ZONE_ALIGN)-1)) & ~((MSGPACK_ZONE_ALIGN)-1));
|
||||
char* aligned =
|
||||
reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
(m_chunk_list.m_ptr + (align - 1))) / align * align);
|
||||
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||
if(m_chunk_list.m_free >= adjusted_size) {
|
||||
m_chunk_list.m_free -= adjusted_size;
|
||||
m_chunk_list.m_ptr += adjusted_size;
|
||||
return aligned;
|
||||
}
|
||||
return reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
allocate_expand(size + (align - 1))) / align * align);
|
||||
}
|
||||
|
||||
inline void* zone::allocate_no_align(size_t size)
|
||||
@@ -271,7 +285,12 @@ inline void* zone::allocate_expand(size_t size)
|
||||
size_t sz = m_chunk_size;
|
||||
|
||||
while(sz < size) {
|
||||
sz *= 2;
|
||||
size_t tmp_sz = sz * 2;
|
||||
if (tmp_sz <= sz) {
|
||||
sz = size;
|
||||
break;
|
||||
}
|
||||
sz = tmp_sz;
|
||||
}
|
||||
|
||||
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
|
||||
@@ -306,7 +325,10 @@ inline void zone::clear()
|
||||
|
||||
inline void zone::swap(zone& o)
|
||||
{
|
||||
std::swap(*this, o);
|
||||
using std::swap;
|
||||
swap(m_chunk_size, o.m_chunk_size);
|
||||
swap(m_chunk_list, o.m_chunk_list);
|
||||
swap(m_finalizer_array, o.m_finalizer_array);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MSGPACK_ZONE_ALIGN
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(int)
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||
#endif
|
||||
|
||||
namespace msgpack {
|
||||
@@ -96,14 +96,14 @@ private:
|
||||
++m_tail;
|
||||
}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
finalizer_array(finalizer_array&& other)
|
||||
finalizer_array(finalizer_array&& other) noexcept
|
||||
:m_tail(other.m_tail), m_end(other.m_end), m_array(other.m_array)
|
||||
{
|
||||
other.m_tail = nullptr;
|
||||
other.m_end = nullptr;
|
||||
other.m_array = nullptr;
|
||||
}
|
||||
finalizer_array& operator=(finalizer_array&& other)
|
||||
finalizer_array& operator=(finalizer_array&& other) noexcept
|
||||
{
|
||||
this->~finalizer_array();
|
||||
new (this) finalizer_array(std::move(other));
|
||||
@@ -161,12 +161,12 @@ private:
|
||||
m_ptr = reinterpret_cast<char*>(m_head) + sizeof(chunk);
|
||||
}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
chunk_list(chunk_list&& other)
|
||||
chunk_list(chunk_list&& other) noexcept
|
||||
:m_free(other.m_free), m_ptr(other.m_ptr), m_head(other.m_head)
|
||||
{
|
||||
other.m_head = nullptr;
|
||||
}
|
||||
chunk_list& operator=(chunk_list&& other)
|
||||
chunk_list& operator=(chunk_list&& other) noexcept
|
||||
{
|
||||
this->~chunk_list();
|
||||
new (this) chunk_list(std::move(other));
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
zone(size_t chunk_size = MSGPACK_ZONE_CHUNK_SIZE) noexcept;
|
||||
|
||||
public:
|
||||
void* allocate_align(size_t size);
|
||||
void* allocate_align(size_t size, size_t align = MSGPACK_ZONE_ALIGN);
|
||||
void* allocate_no_align(size_t size);
|
||||
|
||||
void push_finalizer(void (*func)(void*), void* data);
|
||||
@@ -224,11 +224,11 @@ public:
|
||||
|
||||
zone(zone&&) = default;
|
||||
zone& operator=(zone&&) = default;
|
||||
zone(const zone&) = delete;
|
||||
zone& operator=(const zone&) = delete;
|
||||
|
||||
private:
|
||||
void undo_allocate(size_t size);
|
||||
zone(const zone&);
|
||||
zone& operator=(const zone&);
|
||||
|
||||
template <typename T>
|
||||
static void object_destruct(void* obj);
|
||||
@@ -243,10 +243,21 @@ inline zone::zone(size_t chunk_size) noexcept:m_chunk_size(chunk_size), m_chunk_
|
||||
{
|
||||
}
|
||||
|
||||
inline void* zone::allocate_align(size_t size)
|
||||
inline void* zone::allocate_align(size_t size, size_t align)
|
||||
{
|
||||
return allocate_no_align(
|
||||
((size)+((MSGPACK_ZONE_ALIGN)-1)) & ~((MSGPACK_ZONE_ALIGN)-1));
|
||||
char* aligned =
|
||||
reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
(m_chunk_list.m_ptr + (align - 1))) / align * align);
|
||||
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||
if(m_chunk_list.m_free >= adjusted_size) {
|
||||
m_chunk_list.m_free -= adjusted_size;
|
||||
m_chunk_list.m_ptr += adjusted_size;
|
||||
return aligned;
|
||||
}
|
||||
return reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
allocate_expand(size + (align - 1))) / align * align);
|
||||
}
|
||||
|
||||
inline void* zone::allocate_no_align(size_t size)
|
||||
@@ -269,7 +280,12 @@ inline void* zone::allocate_expand(size_t size)
|
||||
size_t sz = m_chunk_size;
|
||||
|
||||
while(sz < size) {
|
||||
sz *= 2;
|
||||
size_t tmp_sz = sz * 2;
|
||||
if (tmp_sz <= sz) {
|
||||
sz = size;
|
||||
break;
|
||||
}
|
||||
sz = tmp_sz;
|
||||
}
|
||||
|
||||
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
|
||||
|
@@ -15,8 +15,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MSGPACK_FBUFFER_H__
|
||||
#define MSGPACK_FBUFFER_H__
|
||||
#ifndef MSGPACK_FBUFFER_H
|
||||
#define MSGPACK_FBUFFER_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -44,4 +44,3 @@ static inline int msgpack_fbuffer_write(void* data, const char* buf, unsigned in
|
||||
#endif
|
||||
|
||||
#endif /* msgpack/fbuffer.h */
|
||||
|
||||
|
@@ -44,9 +44,14 @@ public:
|
||||
return m_file;
|
||||
}
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
private:
|
||||
fbuffer(const fbuffer&);
|
||||
fbuffer& operator= (const fbuffer&);
|
||||
fbuffer& operator=(const fbuffer&);
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
fbuffer(const fbuffer&) = delete;
|
||||
fbuffer& operator=(const fbuffer&) = delete;
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
|
42
include/msgpack/iterator.hpp
Normal file
42
include/msgpack/iterator.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2015 MIZUKI Hirata
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#ifndef MSGPACK_ITERATOR_HPP
|
||||
#define MSGPACK_ITERATOR_HPP
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include <msgpack_fwd.hpp>
|
||||
|
||||
namespace msgpack
|
||||
{
|
||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
{
|
||||
inline object_kv* begin(object_map &map) { return map.ptr; }
|
||||
inline const object_kv* begin(const object_map &map) { return map.ptr; }
|
||||
inline object_kv* end(object_map &map) { return map.ptr + map.size; }
|
||||
inline const object_kv* end(const object_map &map) { return map.ptr + map.size; }
|
||||
|
||||
inline object* begin(object_array &array) { return array.ptr; }
|
||||
inline const object* begin(const object_array &array) { return array.ptr; }
|
||||
inline object* end(object_array &array) { return array.ptr + array.size; }
|
||||
inline const object* end(const object_array &array) { return array.ptr + array.size; }
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
#endif // MSGPACK_ITERATOR_HPP
|
@@ -37,7 +37,10 @@ typedef enum {
|
||||
MSGPACK_OBJECT_BOOLEAN = 0x01,
|
||||
MSGPACK_OBJECT_POSITIVE_INTEGER = 0x02,
|
||||
MSGPACK_OBJECT_NEGATIVE_INTEGER = 0x03,
|
||||
MSGPACK_OBJECT_DOUBLE = 0x04,
|
||||
MSGPACK_OBJECT_FLOAT = 0x04,
|
||||
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
|
||||
MSGPACK_OBJECT_DOUBLE = MSGPACK_OBJECT_FLOAT, /* obsolete */
|
||||
#endif /* MSGPACK_USE_LEGACY_NAME_AS_FLOAT */
|
||||
MSGPACK_OBJECT_STR = 0x05,
|
||||
MSGPACK_OBJECT_ARRAY = 0x06,
|
||||
MSGPACK_OBJECT_MAP = 0x07,
|
||||
@@ -79,7 +82,10 @@ typedef union {
|
||||
bool boolean;
|
||||
uint64_t u64;
|
||||
int64_t i64;
|
||||
double dec;
|
||||
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
|
||||
double dec; /* obsolete*/
|
||||
#endif /* MSGPACK_USE_LEGACY_NAME_AS_FLOAT */
|
||||
double f64;
|
||||
msgpack_object_array array;
|
||||
msgpack_object_map map;
|
||||
msgpack_object_str str;
|
||||
@@ -97,9 +103,10 @@ typedef struct msgpack_object_kv {
|
||||
msgpack_object val;
|
||||
} msgpack_object_kv;
|
||||
|
||||
|
||||
MSGPACK_DLLEXPORT
|
||||
void msgpack_object_print(FILE* out, msgpack_object o);
|
||||
|
||||
MSGPACK_DLLEXPORT
|
||||
bool msgpack_object_equal(const msgpack_object x, const msgpack_object y);
|
||||
|
||||
/** @} */
|
||||
@@ -110,4 +117,3 @@ bool msgpack_object_equal(const msgpack_object x, const msgpack_object y);
|
||||
#endif
|
||||
|
||||
#endif /* msgpack/object.h */
|
||||
|
||||
|
@@ -38,16 +38,24 @@
|
||||
#include "msgpack/adaptor/set_fwd.hpp"
|
||||
#include "msgpack/adaptor/string_fwd.hpp"
|
||||
#include "msgpack/adaptor/vector_fwd.hpp"
|
||||
#include "msgpack/adaptor/vector_bool_fwd.hpp"
|
||||
#include "msgpack/adaptor/vector_char_fwd.hpp"
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include "msgpack/adaptor/tr1/unordered_map_fwd.hpp"
|
||||
#include "msgpack/adaptor/tr1/unordered_set_fwd.hpp"
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include "adaptor/cpp11/array_fwd.hpp"
|
||||
#include "adaptor/cpp11/array_char_fwd.hpp"
|
||||
#include "adaptor/cpp11/forward_list_fwd.hpp"
|
||||
#include "adaptor/cpp11/tuple_fwd.hpp"
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
#include "adaptor/cpp11/unordered_map_fwd.hpp"
|
||||
#include "adaptor/cpp11/unordered_set_fwd.hpp"
|
||||
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include <string.h>
|
||||
#include <stdexcept>
|
||||
@@ -74,17 +82,17 @@ struct object::implicit_type {
|
||||
operator T() { return obj.as<T>(); }
|
||||
|
||||
private:
|
||||
object const& obj;
|
||||
msgpack::object const& obj;
|
||||
};
|
||||
|
||||
inline object const& operator>> (object const& o, object& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, msgpack::object& v)
|
||||
{
|
||||
v = o;
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline object const& operator>> (object const& o, T& v)
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, T& v)
|
||||
{
|
||||
// If you get a error 'class your_class has no member named 'msgpack_unpack',
|
||||
// check the following:
|
||||
@@ -145,7 +153,7 @@ public:
|
||||
namespace detail {
|
||||
template <typename Stream, typename T>
|
||||
struct packer_serializer {
|
||||
static packer<Stream>& pack(packer<Stream>& o, const T& v) {
|
||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const T& v) {
|
||||
// If you get a error 'const class your_class has no member named 'msgpack_pack',
|
||||
// check the following:
|
||||
// 1. The class your_class should have MSGPACK_DEFINE macro or
|
||||
@@ -156,7 +164,7 @@ struct packer_serializer {
|
||||
// namespace msgpack {
|
||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
// template <typename Stream>
|
||||
// inline packer<Stream>& operator<< (packer<Stream>& o, const your_class& v)
|
||||
// inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const your_class& v)
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
@@ -169,14 +177,14 @@ struct packer_serializer {
|
||||
// namespace msgpack {
|
||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
// template <typename Stream>
|
||||
// packer<Stream>& operator<< (packer<Stream>& o, const your_class& v);
|
||||
// msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const your_class& v);
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
// then, #include "msgpack.hpp", finally place the operator definitions as follows:
|
||||
//
|
||||
// template <typename Stream>
|
||||
// inline packer<Stream>& operator<< (packer<Stream>& o, const your_class& v) {
|
||||
// inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const your_class& v) {
|
||||
// // packing operation
|
||||
// }
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
@@ -188,69 +196,170 @@ struct packer_serializer {
|
||||
};
|
||||
}
|
||||
|
||||
// serialize operator
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const T& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
||||
{
|
||||
return detail::packer_serializer<Stream, T>::pack(o, v);
|
||||
o.type = v.type;
|
||||
|
||||
switch(v.type) {
|
||||
case msgpack::type::NIL:
|
||||
case msgpack::type::BOOLEAN:
|
||||
case msgpack::type::POSITIVE_INTEGER:
|
||||
case msgpack::type::NEGATIVE_INTEGER:
|
||||
case msgpack::type::FLOAT:
|
||||
std::memcpy(&o.via, &v.via, sizeof(v.via));
|
||||
return;
|
||||
|
||||
case msgpack::type::STR: {
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.str.size));
|
||||
o.via.str.ptr = ptr;
|
||||
o.via.str.size = v.via.str.size;
|
||||
std::memcpy(ptr, v.via.str.ptr, v.via.str.size);
|
||||
return;
|
||||
}
|
||||
|
||||
case msgpack::type::BIN: {
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.bin.size));
|
||||
o.via.bin.ptr = ptr;
|
||||
o.via.bin.size = v.via.bin.size;
|
||||
std::memcpy(ptr, v.via.bin.ptr, v.via.bin.size);
|
||||
return;
|
||||
}
|
||||
|
||||
case msgpack::type::EXT: {
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.ext.size + 1));
|
||||
o.via.ext.ptr = ptr;
|
||||
o.via.ext.size = v.via.ext.size;
|
||||
std::memcpy(ptr, v.via.ext.ptr, v.via.ext.size + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
case msgpack::type::ARRAY:
|
||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object) * v.via.array.size));
|
||||
o.via.array.size = v.via.array.size;
|
||||
for (msgpack::object
|
||||
* po(o.via.array.ptr),
|
||||
* pv(v.via.array.ptr),
|
||||
* const pvend(v.via.array.ptr + v.via.array.size);
|
||||
pv < pvend;
|
||||
++po, ++pv) {
|
||||
new (po) msgpack::object(*pv, o.zone);
|
||||
}
|
||||
return;
|
||||
|
||||
case msgpack::type::MAP:
|
||||
o.via.map.ptr = (object_kv*)o.zone.allocate_align(sizeof(object_kv) * v.via.map.size);
|
||||
o.via.map.size = v.via.map.size;
|
||||
for(msgpack::object_kv
|
||||
* po(o.via.map.ptr),
|
||||
* pv(v.via.map.ptr),
|
||||
* const pvend(v.via.map.ptr + v.via.map.size);
|
||||
pv < pvend;
|
||||
++po, ++pv) {
|
||||
object_kv* kv = new (po) object_kv;
|
||||
new (&kv->key) msgpack::object(pv->key, o.zone);
|
||||
new (&kv->val) msgpack::object(pv->val, o.zone);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::object::with_zone& v)
|
||||
{
|
||||
return o << static_cast<msgpack::object const&>(v);
|
||||
}
|
||||
|
||||
// deconvert operator
|
||||
template <typename T>
|
||||
inline void operator<< (object::with_zone& o, const T& v)
|
||||
inline void operator<< (msgpack::object::with_zone& o, const T& v)
|
||||
{
|
||||
// If you get a error 'const class your_class has no member named 'msgpack_object',
|
||||
// check the following:
|
||||
// 1. The class your_class should have MSGPACK_DEFINE macro or
|
||||
//
|
||||
// 2. The class your_class should have the following operator declaration and
|
||||
// definition:
|
||||
//
|
||||
// namespace msgpack {
|
||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
// void operator<< (object::with_zone& o, const your_class& v);
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
// See 3.
|
||||
//
|
||||
// 3. #include "msgpack.hpp" too early.
|
||||
// Replace msgpack.hpp with msgpack_fwd.hpp, then,
|
||||
// place operator declarations as follows:
|
||||
//
|
||||
// namespace msgpack {
|
||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
// void operator<< (object::with_zone& o, const your_class& v);
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
// then, #include "msgpack.hpp", finally place the operator definitions as follows:
|
||||
//
|
||||
// void operator<< (object::with_zone& o, const your_class& v) {
|
||||
// // set object attributes using v.
|
||||
// }
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
v.msgpack_object(static_cast<object*>(&o), o.zone);
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
template <typename T>
|
||||
inline packer<Stream>& packer<Stream>::pack(const T& v)
|
||||
inline msgpack::packer<Stream>& packer<Stream>::pack(const T& v)
|
||||
{
|
||||
msgpack::operator<<(*this, v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool operator==(const object& x, const object& y)
|
||||
inline bool operator==(const msgpack::object& x, const msgpack::object& y)
|
||||
{
|
||||
if(x.type != y.type) { return false; }
|
||||
|
||||
switch(x.type) {
|
||||
case type::NIL:
|
||||
case msgpack::type::NIL:
|
||||
return true;
|
||||
|
||||
case type::BOOLEAN:
|
||||
case msgpack::type::BOOLEAN:
|
||||
return x.via.boolean == y.via.boolean;
|
||||
|
||||
case type::POSITIVE_INTEGER:
|
||||
case msgpack::type::POSITIVE_INTEGER:
|
||||
return x.via.u64 == y.via.u64;
|
||||
|
||||
case type::NEGATIVE_INTEGER:
|
||||
case msgpack::type::NEGATIVE_INTEGER:
|
||||
return x.via.i64 == y.via.i64;
|
||||
|
||||
case type::DOUBLE:
|
||||
return x.via.dec == y.via.dec;
|
||||
case msgpack::type::FLOAT:
|
||||
return x.via.f64 == y.via.f64;
|
||||
|
||||
case type::STR:
|
||||
case msgpack::type::STR:
|
||||
return x.via.str.size == y.via.str.size &&
|
||||
memcmp(x.via.str.ptr, y.via.str.ptr, x.via.str.size) == 0;
|
||||
std::memcmp(x.via.str.ptr, y.via.str.ptr, x.via.str.size) == 0;
|
||||
|
||||
case type::BIN:
|
||||
case msgpack::type::BIN:
|
||||
return x.via.bin.size == y.via.bin.size &&
|
||||
memcmp(x.via.bin.ptr, y.via.bin.ptr, x.via.bin.size) == 0;
|
||||
std::memcmp(x.via.bin.ptr, y.via.bin.ptr, x.via.bin.size) == 0;
|
||||
|
||||
case type::EXT:
|
||||
case msgpack::type::EXT:
|
||||
return x.via.ext.size == y.via.ext.size &&
|
||||
memcmp(x.via.ext.ptr, y.via.ext.ptr, x.via.ext.size) == 0;
|
||||
std::memcmp(x.via.ext.ptr, y.via.ext.ptr, x.via.ext.size) == 0;
|
||||
|
||||
case type::ARRAY:
|
||||
case msgpack::type::ARRAY:
|
||||
if(x.via.array.size != y.via.array.size) {
|
||||
return false;
|
||||
} else if(x.via.array.size == 0) {
|
||||
return true;
|
||||
} else {
|
||||
object* px = x.via.array.ptr;
|
||||
object* const pxend = x.via.array.ptr + x.via.array.size;
|
||||
object* py = y.via.array.ptr;
|
||||
msgpack::object* px = x.via.array.ptr;
|
||||
msgpack::object* const pxend = x.via.array.ptr + x.via.array.size;
|
||||
msgpack::object* py = y.via.array.ptr;
|
||||
do {
|
||||
if(!(*px == *py)) {
|
||||
return false;
|
||||
@@ -261,15 +370,15 @@ inline bool operator==(const object& x, const object& y)
|
||||
return true;
|
||||
}
|
||||
|
||||
case type::MAP:
|
||||
case msgpack::type::MAP:
|
||||
if(x.via.map.size != y.via.map.size) {
|
||||
return false;
|
||||
} else if(x.via.map.size == 0) {
|
||||
return true;
|
||||
} else {
|
||||
object_kv* px = x.via.map.ptr;
|
||||
object_kv* const pxend = x.via.map.ptr + x.via.map.size;
|
||||
object_kv* py = y.via.map.ptr;
|
||||
msgpack::object_kv* px = x.via.map.ptr;
|
||||
msgpack::object_kv* const pxend = x.via.map.ptr + x.via.map.size;
|
||||
msgpack::object_kv* py = y.via.map.ptr;
|
||||
do {
|
||||
if(!(px->key == py->key) || !(px->val == py->val)) {
|
||||
return false;
|
||||
@@ -286,32 +395,32 @@ inline bool operator==(const object& x, const object& y)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool operator==(const object& x, const T& y)
|
||||
inline bool operator==(const msgpack::object& x, const T& y)
|
||||
try {
|
||||
return x == object(y);
|
||||
return x == msgpack::object(y);
|
||||
} catch (msgpack::type_error&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool operator!=(const object& x, const object& y)
|
||||
inline bool operator!=(const msgpack::object& x, const msgpack::object& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <typename T>
|
||||
inline bool operator==(const T& y, const object x)
|
||||
inline bool operator==(const T& y, const msgpack::object x)
|
||||
{ return x == y; }
|
||||
|
||||
template <typename T>
|
||||
inline bool operator!=(const object& x, const T& y)
|
||||
inline bool operator!=(const msgpack::object& x, const T& y)
|
||||
{ return !(x == y); }
|
||||
|
||||
template <typename T>
|
||||
inline bool operator!=(const T& y, const object& x)
|
||||
inline bool operator!=(const T& y, const msgpack::object& x)
|
||||
{ return x != y; }
|
||||
|
||||
|
||||
inline object::implicit_type object::convert() const
|
||||
inline msgpack::object::implicit_type object::convert() const
|
||||
{
|
||||
return implicit_type(*this);
|
||||
return msgpack::object::implicit_type(*this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -337,12 +446,48 @@ inline T object::as() const
|
||||
|
||||
inline object::object()
|
||||
{
|
||||
type = type::NIL;
|
||||
type = msgpack::type::NIL;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline object::object(const T& v)
|
||||
{
|
||||
// If you get a error 'no matching function call to
|
||||
// operator<<(msgpack::v?::object::object(const T&)
|
||||
// [with T = your_class]'
|
||||
//
|
||||
// check the following:
|
||||
// 1. The class your_class should have MSGPACK_DEFINE macro or
|
||||
//
|
||||
// 2. The class your_class should have the following operator declaration and
|
||||
// definition:
|
||||
//
|
||||
// namespace msgpack {
|
||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
// void operator<< (object& o, const your_class& v);
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
// See 3.
|
||||
//
|
||||
// 3. #include "msgpack.hpp" too early.
|
||||
// Replace msgpack.hpp with msgpack_fwd.hpp, then,
|
||||
// place operator declarations as follows:
|
||||
//
|
||||
// namespace msgpack {
|
||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
// void operator<< (object& o, const your_class& v);
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
// then, #include "msgpack.hpp", finally place the operator definitions as follows:
|
||||
//
|
||||
// void operator<< (object& o, const your_class& v) {
|
||||
// // set object attributes using v.
|
||||
// }
|
||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
// } // namespace msgpack
|
||||
//
|
||||
msgpack::operator<<(*this, v);
|
||||
}
|
||||
|
||||
@@ -354,7 +499,7 @@ inline object& object::operator=(const T& v)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
object::object(const T& v, zone& z)
|
||||
object::object(const T& v, msgpack::zone& z)
|
||||
{
|
||||
with_zone oz(z);
|
||||
msgpack::operator<<(oz, v);
|
||||
@@ -363,7 +508,7 @@ object::object(const T& v, zone& z)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
object::object(const T& v, zone* z)
|
||||
object::object(const T& v, msgpack::zone* z)
|
||||
{
|
||||
with_zone oz(*z);
|
||||
msgpack::operator<<(oz, v);
|
||||
@@ -372,58 +517,58 @@ object::object(const T& v, zone* z)
|
||||
}
|
||||
|
||||
|
||||
inline object::object(msgpack_object o)
|
||||
inline object::object(const msgpack_object& o)
|
||||
{
|
||||
// FIXME beter way?
|
||||
::memcpy(this, &o, sizeof(o));
|
||||
std::memcpy(this, &o, sizeof(o));
|
||||
}
|
||||
|
||||
inline void operator<< (object& o, msgpack_object v)
|
||||
inline void operator<< (msgpack::object& o, const msgpack_object& v)
|
||||
{
|
||||
// FIXME beter way?
|
||||
::memcpy(&o, &v, sizeof(v));
|
||||
std::memcpy(&o, &v, sizeof(v));
|
||||
}
|
||||
|
||||
inline object::operator msgpack_object() const
|
||||
{
|
||||
// FIXME beter way?
|
||||
msgpack_object obj;
|
||||
::memcpy(&obj, this, sizeof(obj));
|
||||
std::memcpy(&obj, this, sizeof(obj));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
// obsolete
|
||||
template <typename T>
|
||||
inline void convert(T& v, object const& o)
|
||||
inline void convert(T& v, msgpack::object const& o)
|
||||
{
|
||||
o.convert(v);
|
||||
}
|
||||
|
||||
// obsolete
|
||||
template <typename Stream, typename T>
|
||||
inline void pack(packer<Stream>& o, const T& v)
|
||||
inline void pack(msgpack::packer<Stream>& o, const T& v)
|
||||
{
|
||||
o.pack(v);
|
||||
}
|
||||
|
||||
// obsolete
|
||||
template <typename Stream, typename T>
|
||||
inline void pack_copy(packer<Stream>& o, T v)
|
||||
inline void pack_copy(msgpack::packer<Stream>& o, T v)
|
||||
{
|
||||
pack(o, v);
|
||||
}
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const object& v)
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::object& v)
|
||||
{
|
||||
switch(v.type) {
|
||||
case type::NIL:
|
||||
case msgpack::type::NIL:
|
||||
o.pack_nil();
|
||||
return o;
|
||||
|
||||
case type::BOOLEAN:
|
||||
case msgpack::type::BOOLEAN:
|
||||
if(v.via.boolean) {
|
||||
o.pack_true();
|
||||
} else {
|
||||
@@ -431,45 +576,45 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const object& v)
|
||||
}
|
||||
return o;
|
||||
|
||||
case type::POSITIVE_INTEGER:
|
||||
case msgpack::type::POSITIVE_INTEGER:
|
||||
o.pack_uint64(v.via.u64);
|
||||
return o;
|
||||
|
||||
case type::NEGATIVE_INTEGER:
|
||||
case msgpack::type::NEGATIVE_INTEGER:
|
||||
o.pack_int64(v.via.i64);
|
||||
return o;
|
||||
|
||||
case type::DOUBLE:
|
||||
o.pack_double(v.via.dec);
|
||||
case msgpack::type::FLOAT:
|
||||
o.pack_double(v.via.f64);
|
||||
return o;
|
||||
|
||||
case type::STR:
|
||||
case msgpack::type::STR:
|
||||
o.pack_str(v.via.str.size);
|
||||
o.pack_str_body(v.via.str.ptr, v.via.str.size);
|
||||
return o;
|
||||
|
||||
case type::BIN:
|
||||
case msgpack::type::BIN:
|
||||
o.pack_bin(v.via.bin.size);
|
||||
o.pack_bin_body(v.via.bin.ptr, v.via.bin.size);
|
||||
return o;
|
||||
|
||||
case type::EXT:
|
||||
case msgpack::type::EXT:
|
||||
o.pack_ext(v.via.ext.size, v.via.ext.type());
|
||||
o.pack_ext_body(v.via.ext.data(), v.via.ext.size);
|
||||
return o;
|
||||
|
||||
case type::ARRAY:
|
||||
case msgpack::type::ARRAY:
|
||||
o.pack_array(v.via.array.size);
|
||||
for(object* p(v.via.array.ptr),
|
||||
for(msgpack::object* p(v.via.array.ptr),
|
||||
* const pend(v.via.array.ptr + v.via.array.size);
|
||||
p < pend; ++p) {
|
||||
msgpack::operator<<(o, *p);
|
||||
}
|
||||
return o;
|
||||
|
||||
case type::MAP:
|
||||
case msgpack::type::MAP:
|
||||
o.pack_map(v.via.map.size);
|
||||
for(object_kv* p(v.via.map.ptr),
|
||||
for(msgpack::object_kv* p(v.via.map.ptr),
|
||||
* const pend(v.via.map.ptr + v.via.map.size);
|
||||
p < pend; ++p) {
|
||||
msgpack::operator<<(o, p->key);
|
||||
@@ -478,51 +623,58 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const object& v)
|
||||
return o;
|
||||
|
||||
default:
|
||||
throw type_error();
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& s, const object& o)
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::object::with_zone& v)
|
||||
{
|
||||
return o << static_cast<msgpack::object>(v);
|
||||
}
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& s, const msgpack::object& o)
|
||||
{
|
||||
switch(o.type) {
|
||||
case type::NIL:
|
||||
case msgpack::type::NIL:
|
||||
s << "nil";
|
||||
break;
|
||||
|
||||
case type::BOOLEAN:
|
||||
case msgpack::type::BOOLEAN:
|
||||
s << (o.via.boolean ? "true" : "false");
|
||||
break;
|
||||
|
||||
case type::POSITIVE_INTEGER:
|
||||
case msgpack::type::POSITIVE_INTEGER:
|
||||
s << o.via.u64;
|
||||
break;
|
||||
|
||||
case type::NEGATIVE_INTEGER:
|
||||
case msgpack::type::NEGATIVE_INTEGER:
|
||||
s << o.via.i64;
|
||||
break;
|
||||
|
||||
case type::DOUBLE:
|
||||
s << o.via.dec;
|
||||
case msgpack::type::FLOAT:
|
||||
s << o.via.f64;
|
||||
break;
|
||||
|
||||
case type::STR:
|
||||
case msgpack::type::STR:
|
||||
(s << '"').write(o.via.str.ptr, o.via.str.size) << '"';
|
||||
break;
|
||||
|
||||
case type::BIN:
|
||||
case msgpack::type::BIN:
|
||||
(s << '"').write(o.via.bin.ptr, o.via.bin.size) << '"';
|
||||
break;
|
||||
|
||||
case type::EXT:
|
||||
case msgpack::type::EXT:
|
||||
s << "EXT";
|
||||
break;
|
||||
|
||||
case type::ARRAY:
|
||||
case msgpack::type::ARRAY:
|
||||
s << "[";
|
||||
if(o.via.array.size != 0) {
|
||||
object* p(o.via.array.ptr);
|
||||
msgpack::object* p(o.via.array.ptr);
|
||||
s << *p;
|
||||
++p;
|
||||
for(object* const pend(o.via.array.ptr + o.via.array.size);
|
||||
for(msgpack::object* const pend(o.via.array.ptr + o.via.array.size);
|
||||
p < pend; ++p) {
|
||||
s << ", " << *p;
|
||||
}
|
||||
@@ -530,13 +682,13 @@ inline std::ostream& operator<< (std::ostream& s, const object& o)
|
||||
s << "]";
|
||||
break;
|
||||
|
||||
case type::MAP:
|
||||
case msgpack::type::MAP:
|
||||
s << "{";
|
||||
if(o.via.map.size != 0) {
|
||||
object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
s << p->key << "=>" << p->val;
|
||||
++p;
|
||||
for(object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
for(msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
p < pend; ++p) {
|
||||
s << ", " << p->key << "=>" << p->val;
|
||||
}
|
||||
|
@@ -36,7 +36,10 @@ namespace type {
|
||||
BOOLEAN = MSGPACK_OBJECT_BOOLEAN,
|
||||
POSITIVE_INTEGER = MSGPACK_OBJECT_POSITIVE_INTEGER,
|
||||
NEGATIVE_INTEGER = MSGPACK_OBJECT_NEGATIVE_INTEGER,
|
||||
DOUBLE = MSGPACK_OBJECT_DOUBLE,
|
||||
FLOAT = MSGPACK_OBJECT_FLOAT,
|
||||
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
|
||||
DOUBLE = MSGPACK_OBJECT_DOUBLE, // obsolete
|
||||
#endif // MSGPACK_USE_LEGACY_NAME_AS_FLOAT
|
||||
STR = MSGPACK_OBJECT_STR,
|
||||
BIN = MSGPACK_OBJECT_BIN,
|
||||
ARRAY = MSGPACK_OBJECT_ARRAY,
|
||||
@@ -51,12 +54,12 @@ struct object_kv;
|
||||
|
||||
struct object_array {
|
||||
uint32_t size;
|
||||
object* ptr;
|
||||
msgpack::object* ptr;
|
||||
};
|
||||
|
||||
struct object_map {
|
||||
uint32_t size;
|
||||
object_kv* ptr;
|
||||
msgpack::object_kv* ptr;
|
||||
};
|
||||
|
||||
struct object_str {
|
||||
@@ -81,18 +84,21 @@ struct object {
|
||||
bool boolean;
|
||||
uint64_t u64;
|
||||
int64_t i64;
|
||||
double dec;
|
||||
object_array array;
|
||||
object_map map;
|
||||
object_str str;
|
||||
object_bin bin;
|
||||
object_ext ext;
|
||||
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
|
||||
double dec; // obsolete
|
||||
#endif // MSGPACK_USE_LEGACY_NAME_AS_FLOAT
|
||||
double f64;
|
||||
msgpack::object_array array;
|
||||
msgpack::object_map map;
|
||||
msgpack::object_str str;
|
||||
msgpack::object_bin bin;
|
||||
msgpack::object_ext ext;
|
||||
};
|
||||
|
||||
type::object_type type;
|
||||
msgpack::type::object_type type;
|
||||
union_type via;
|
||||
|
||||
bool is_nil() const { return type == type::NIL; }
|
||||
bool is_nil() const { return type == msgpack::type::NIL; }
|
||||
|
||||
template <typename T>
|
||||
T as() const;
|
||||
@@ -104,17 +110,17 @@ struct object {
|
||||
|
||||
object();
|
||||
|
||||
object(msgpack_object o);
|
||||
object(const msgpack_object& o);
|
||||
|
||||
template <typename T>
|
||||
explicit object(const T& v);
|
||||
|
||||
template <typename T>
|
||||
object(const T& v, zone& z);
|
||||
object(const T& v, msgpack::zone& z);
|
||||
|
||||
// obsolete
|
||||
template <typename T>
|
||||
object(const T& v, zone* z);
|
||||
object(const T& v, msgpack::zone* z);
|
||||
|
||||
template <typename T>
|
||||
object& operator=(const T& v);
|
||||
@@ -133,8 +139,8 @@ public:
|
||||
class type_error : public std::bad_cast { };
|
||||
|
||||
struct object_kv {
|
||||
object key;
|
||||
object val;
|
||||
msgpack::object key;
|
||||
msgpack::object val;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
@@ -142,26 +148,32 @@ template <typename Stream, typename T>
|
||||
struct packer_serializer;
|
||||
} // namespace detail
|
||||
|
||||
object const& operator>> (object const& o, object& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, msgpack::object& v);
|
||||
|
||||
template <typename T>
|
||||
object const& operator>> (object const& o, T& v);
|
||||
msgpack::object const& operator>> (msgpack::object const& o, T& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const T& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const T& v);
|
||||
|
||||
void operator<< (msgpack::object::with_zone& o, const msgpack::object& v);
|
||||
|
||||
void operator<< (msgpack::object::with_zone& o, const msgpack::object::with_zone& v);
|
||||
|
||||
template <typename Stream>
|
||||
class packer;
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const object& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::object& v);
|
||||
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::object::with_zone& v);
|
||||
|
||||
template <typename Stream, typename T>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const T& v);
|
||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const T& v);
|
||||
|
||||
template <typename T>
|
||||
void operator<< (object::with_zone& o, const T& v);
|
||||
void operator<< (msgpack::object::with_zone& o, const T& v);
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <stdexcept>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
#include <climits>
|
||||
|
||||
#include "sysdep.h"
|
||||
|
||||
@@ -77,18 +78,18 @@ public:
|
||||
packer<Stream>& pack_true();
|
||||
packer<Stream>& pack_false();
|
||||
|
||||
packer<Stream>& pack_array(size_t n);
|
||||
packer<Stream>& pack_array(uint32_t n);
|
||||
|
||||
packer<Stream>& pack_map(size_t n);
|
||||
packer<Stream>& pack_map(uint32_t n);
|
||||
|
||||
packer<Stream>& pack_str(size_t l);
|
||||
packer<Stream>& pack_str_body(const char* b, size_t l);
|
||||
packer<Stream>& pack_str(uint32_t l);
|
||||
packer<Stream>& pack_str_body(const char* b, uint32_t l);
|
||||
|
||||
packer<Stream>& pack_bin(size_t l);
|
||||
packer<Stream>& pack_bin_body(const char* b, size_t l);
|
||||
packer<Stream>& pack_bin(uint32_t l);
|
||||
packer<Stream>& pack_bin_body(const char* b, uint32_t l);
|
||||
|
||||
packer<Stream>& pack_ext(size_t l, int8_t type);
|
||||
packer<Stream>& pack_ext_body(const char* b, size_t l);
|
||||
packer<Stream>& pack_ext_body(const char* b, uint32_t l);
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
@@ -114,7 +115,14 @@ private:
|
||||
private:
|
||||
Stream& m_stream;
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
private:
|
||||
packer(const packer&);
|
||||
packer& operator=(const packer&);
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
packer(const packer&) = delete;
|
||||
packer& operator=(const packer&) = delete;
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
packer();
|
||||
};
|
||||
|
||||
@@ -131,6 +139,15 @@ inline void pack(Stream& s, const T& v)
|
||||
packer<Stream>(s).pack(v);
|
||||
}
|
||||
|
||||
// serialize operator
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const T& v)
|
||||
{
|
||||
return detail::packer_serializer<Stream, T>::pack(o, v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(__LITTLE_ENDIAN__)
|
||||
template <typename T>
|
||||
inline char take8_8(T d) {
|
||||
@@ -213,7 +230,7 @@ inline packer<Stream>& packer<Stream>::pack_int64(int64_t d)
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_uint8(uint8_t d)
|
||||
{
|
||||
char buf[2] = {static_cast<char>(0xcc), take8_8(d)};
|
||||
char buf[2] = {static_cast<char>(0xccu), take8_8(d)};
|
||||
append_buffer(buf, 2);
|
||||
return *this;
|
||||
}
|
||||
@@ -222,7 +239,7 @@ template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_uint16(uint16_t d)
|
||||
{
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], d);
|
||||
append_buffer(buf, 3);
|
||||
return *this;
|
||||
}
|
||||
@@ -231,7 +248,7 @@ template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_uint32(uint32_t d)
|
||||
{
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], d);
|
||||
append_buffer(buf, 5);
|
||||
return *this;
|
||||
}
|
||||
@@ -240,7 +257,7 @@ template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_uint64(uint64_t d)
|
||||
{
|
||||
char buf[9];
|
||||
buf[0] = static_cast<char>(0xcf); _msgpack_store64(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xcfu); _msgpack_store64(&buf[1], d);
|
||||
append_buffer(buf, 9);
|
||||
return *this;
|
||||
}
|
||||
@@ -248,7 +265,7 @@ inline packer<Stream>& packer<Stream>::pack_fix_uint64(uint64_t d)
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_int8(int8_t d)
|
||||
{
|
||||
char buf[2] = {static_cast<char>(0xd0), take8_8(d)};
|
||||
char buf[2] = {static_cast<char>(0xd0u), take8_8(d)};
|
||||
append_buffer(buf, 2);
|
||||
return *this;
|
||||
}
|
||||
@@ -257,7 +274,7 @@ template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_int16(int16_t d)
|
||||
{
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], d);
|
||||
append_buffer(buf, 3);
|
||||
return *this;
|
||||
}
|
||||
@@ -266,7 +283,7 @@ template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_int32(int32_t d)
|
||||
{
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xd2); _msgpack_store32(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], d);
|
||||
append_buffer(buf, 5);
|
||||
return *this;
|
||||
}
|
||||
@@ -275,7 +292,7 @@ template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_fix_int64(int64_t d)
|
||||
{
|
||||
char buf[9];
|
||||
buf[0] = static_cast<char>(0xd3); _msgpack_store64(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xd3u); _msgpack_store64(&buf[1], d);
|
||||
append_buffer(buf, 9);
|
||||
return *this;
|
||||
}
|
||||
@@ -283,11 +300,25 @@ inline packer<Stream>& packer<Stream>::pack_fix_int64(int64_t d)
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_char(char d)
|
||||
{ _pack_char(m_stream, d); return *this; }
|
||||
{
|
||||
#if defined(CHAR_MIN)
|
||||
#if CHAR_MIN < 0
|
||||
pack_imp_int8(d);
|
||||
#else
|
||||
pack_imp_uint8(d);
|
||||
#endif
|
||||
#else
|
||||
#error CHAR_MIN is not defined
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_signed_char(signed char d)
|
||||
{ _pack_signed_char(m_stream, d); return *this; }
|
||||
{
|
||||
pack_imp_int8(d);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_short(short d)
|
||||
@@ -424,7 +455,10 @@ inline packer<Stream>& packer<Stream>::pack_long_long(long long d)
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_unsigned_char(unsigned char d)
|
||||
{ _pack_unsigned_char(m_stream, d); return *this; }
|
||||
{
|
||||
pack_imp_uint8(d);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_unsigned_short(unsigned short d)
|
||||
@@ -565,7 +599,7 @@ inline packer<Stream>& packer<Stream>::pack_float(float d)
|
||||
union { float f; uint32_t i; } mem;
|
||||
mem.f = d;
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xca); _msgpack_store32(&buf[1], mem.i);
|
||||
buf[0] = static_cast<char>(0xcau); _msgpack_store32(&buf[1], mem.i);
|
||||
append_buffer(buf, 5);
|
||||
return *this;
|
||||
}
|
||||
@@ -576,7 +610,7 @@ inline packer<Stream>& packer<Stream>::pack_double(double d)
|
||||
union { double f; uint64_t i; } mem;
|
||||
mem.f = d;
|
||||
char buf[9];
|
||||
buf[0] = static_cast<char>(0xcb);
|
||||
buf[0] = static_cast<char>(0xcbu);
|
||||
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
|
||||
// https://github.com/msgpack/msgpack-perl/pull/1
|
||||
mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
|
||||
@@ -590,7 +624,7 @@ inline packer<Stream>& packer<Stream>::pack_double(double d)
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_nil()
|
||||
{
|
||||
const char d = static_cast<char>(0xc0);
|
||||
const char d = static_cast<char>(0xc0u);
|
||||
append_buffer(&d, 1);
|
||||
return *this;
|
||||
}
|
||||
@@ -598,7 +632,7 @@ inline packer<Stream>& packer<Stream>::pack_nil()
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_true()
|
||||
{
|
||||
const char d = static_cast<char>(0xc3);
|
||||
const char d = static_cast<char>(0xc3u);
|
||||
append_buffer(&d, 1);
|
||||
return *this;
|
||||
}
|
||||
@@ -606,100 +640,100 @@ inline packer<Stream>& packer<Stream>::pack_true()
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_false()
|
||||
{
|
||||
const char d = static_cast<char>(0xc2);
|
||||
const char d = static_cast<char>(0xc2u);
|
||||
append_buffer(&d, 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_array(size_t n)
|
||||
inline packer<Stream>& packer<Stream>::pack_array(uint32_t n)
|
||||
{
|
||||
if(n < 16) {
|
||||
char d = static_cast<char>(0x90 | n);
|
||||
char d = static_cast<char>(0x90u | n);
|
||||
append_buffer(&d, 1);
|
||||
} else if(n < 65536) {
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xdc); _msgpack_store16(&buf[1], static_cast<uint16_t>(n));
|
||||
buf[0] = static_cast<char>(0xdcu); _msgpack_store16(&buf[1], static_cast<uint16_t>(n));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xdd); _msgpack_store32(&buf[1], static_cast<uint32_t>(n));
|
||||
buf[0] = static_cast<char>(0xddu); _msgpack_store32(&buf[1], static_cast<uint32_t>(n));
|
||||
append_buffer(buf, 5);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_map(size_t n)
|
||||
inline packer<Stream>& packer<Stream>::pack_map(uint32_t n)
|
||||
{
|
||||
if(n < 16) {
|
||||
unsigned char d = 0x80 | n;
|
||||
unsigned char d = static_cast<unsigned char>(0x80u | n);
|
||||
char buf = take8_8(d);
|
||||
append_buffer(&buf, 1);
|
||||
} else if(n < 65536) {
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xde); _msgpack_store16(&buf[1], static_cast<uint16_t>(n));
|
||||
buf[0] = static_cast<char>(0xdeu); _msgpack_store16(&buf[1], static_cast<uint16_t>(n));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xdf); _msgpack_store32(&buf[1], static_cast<uint32_t>(n));
|
||||
buf[0] = static_cast<char>(0xdfu); _msgpack_store32(&buf[1], static_cast<uint32_t>(n));
|
||||
append_buffer(buf, 5);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_str(size_t l)
|
||||
inline packer<Stream>& packer<Stream>::pack_str(uint32_t l)
|
||||
{
|
||||
if(l < 32) {
|
||||
unsigned char d = 0xa0 | static_cast<uint8_t>(l);
|
||||
unsigned char d = 0xa0u | static_cast<uint8_t>(l);
|
||||
char buf = take8_8(d);
|
||||
append_buffer(&buf, 1);
|
||||
} else if(l < 256) {
|
||||
char buf[2];
|
||||
buf[0] = static_cast<char>(0xd9); buf[1] = static_cast<uint8_t>(l);
|
||||
buf[0] = static_cast<char>(0xd9u); buf[1] = static_cast<uint8_t>(l);
|
||||
append_buffer(buf, 2);
|
||||
} else if(l < 65536) {
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xda); _msgpack_store16(&buf[1], static_cast<uint16_t>(l));
|
||||
buf[0] = static_cast<char>(0xdau); _msgpack_store16(&buf[1], static_cast<uint16_t>(l));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xdb); _msgpack_store32(&buf[1], static_cast<uint32_t>(l));
|
||||
buf[0] = static_cast<char>(0xdbu); _msgpack_store32(&buf[1], static_cast<uint32_t>(l));
|
||||
append_buffer(buf, 5);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_str_body(const char* b, size_t l)
|
||||
inline packer<Stream>& packer<Stream>::pack_str_body(const char* b, uint32_t l)
|
||||
{
|
||||
append_buffer(b, l);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_bin(size_t l)
|
||||
inline packer<Stream>& packer<Stream>::pack_bin(uint32_t l)
|
||||
{
|
||||
if(l < 256) {
|
||||
char buf[2];
|
||||
buf[0] = static_cast<char>(0xc4); buf[1] = static_cast<uint8_t>(l);
|
||||
buf[0] = static_cast<char>(0xc4u); buf[1] = static_cast<uint8_t>(l);
|
||||
append_buffer(buf, 2);
|
||||
} else if(l < 65536) {
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xc5); _msgpack_store16(&buf[1], static_cast<uint16_t>(l));
|
||||
buf[0] = static_cast<char>(0xc5u); _msgpack_store16(&buf[1], static_cast<uint16_t>(l));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xc6); _msgpack_store32(&buf[1], static_cast<uint32_t>(l));
|
||||
buf[0] = static_cast<char>(0xc6u); _msgpack_store32(&buf[1], static_cast<uint32_t>(l));
|
||||
append_buffer(buf, 5);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_bin_body(const char* b, size_t l)
|
||||
inline packer<Stream>& packer<Stream>::pack_bin_body(const char* b, uint32_t l)
|
||||
{
|
||||
append_buffer(b, l);
|
||||
return *this;
|
||||
@@ -711,50 +745,50 @@ inline packer<Stream>& packer<Stream>::pack_ext(size_t l, int8_t type)
|
||||
switch(l) {
|
||||
case 1: {
|
||||
char buf[2];
|
||||
buf[0] = static_cast<char>(0xd4);
|
||||
buf[0] = static_cast<char>(0xd4u);
|
||||
buf[1] = static_cast<char>(type);
|
||||
append_buffer(buf, 2);
|
||||
} break;
|
||||
case 2: {
|
||||
char buf[2];
|
||||
buf[0] = static_cast<char>(0xd5);
|
||||
buf[0] = static_cast<char>(0xd5u);
|
||||
buf[1] = static_cast<char>(type);
|
||||
append_buffer(buf, 2);
|
||||
} break;
|
||||
case 4: {
|
||||
char buf[2];
|
||||
buf[0] = static_cast<char>(0xd6);
|
||||
buf[0] = static_cast<char>(0xd6u);
|
||||
buf[1] = static_cast<char>(type);
|
||||
append_buffer(buf, 2);
|
||||
} break;
|
||||
case 8: {
|
||||
char buf[2];
|
||||
buf[0] = static_cast<char>(0xd7);
|
||||
buf[0] = static_cast<char>(0xd7u);
|
||||
buf[1] = static_cast<char>(type);
|
||||
append_buffer(buf, 2);
|
||||
} break;
|
||||
case 16: {
|
||||
char buf[2];
|
||||
buf[0] = static_cast<char>(0xd8);
|
||||
buf[0] = static_cast<char>(0xd8u);
|
||||
buf[1] = static_cast<char>(type);
|
||||
append_buffer(buf, 2);
|
||||
} break;
|
||||
default:
|
||||
if(l < 256) {
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xc7);
|
||||
buf[0] = static_cast<char>(0xc7u);
|
||||
buf[1] = static_cast<char>(l);
|
||||
buf[2] = static_cast<char>(type);
|
||||
append_buffer(buf, 3);
|
||||
} else if(l < 65536) {
|
||||
char buf[4];
|
||||
buf[0] = static_cast<char>(0xc8);
|
||||
buf[0] = static_cast<char>(0xc8u);
|
||||
_msgpack_store16(&buf[1], static_cast<uint16_t>(l));
|
||||
buf[3] = static_cast<char>(type);
|
||||
append_buffer(buf, 4);
|
||||
} else {
|
||||
char buf[6];
|
||||
buf[0] = static_cast<char>(0xc9);
|
||||
buf[0] = static_cast<char>(0xc9u);
|
||||
_msgpack_store32(&buf[1], static_cast<uint32_t>(l));
|
||||
buf[5] = static_cast<char>(type);
|
||||
append_buffer(buf, 6);
|
||||
@@ -765,7 +799,7 @@ inline packer<Stream>& packer<Stream>::pack_ext(size_t l, int8_t type)
|
||||
}
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_ext_body(const char* b, size_t l)
|
||||
inline packer<Stream>& packer<Stream>::pack_ext_body(const char* b, uint32_t l)
|
||||
{
|
||||
append_buffer(b, l);
|
||||
return *this;
|
||||
@@ -781,7 +815,7 @@ inline void packer<Stream>::pack_imp_uint8(T d)
|
||||
append_buffer(&buf, 1);
|
||||
} else {
|
||||
/* unsigned 8 */
|
||||
char buf[2] = {static_cast<char>(0xcc), take8_8(d)};
|
||||
char buf[2] = {static_cast<char>(0xccu), take8_8(d)};
|
||||
append_buffer(buf, 2);
|
||||
}
|
||||
}
|
||||
@@ -796,12 +830,12 @@ inline void packer<Stream>::pack_imp_uint16(T d)
|
||||
append_buffer(&buf, 1);
|
||||
} else if(d < (1<<8)) {
|
||||
/* unsigned 8 */
|
||||
char buf[2] = {static_cast<char>(0xcc), take8_16(d)};
|
||||
char buf[2] = {static_cast<char>(0xccu), take8_16(d)};
|
||||
append_buffer(buf, 2);
|
||||
} else {
|
||||
/* unsigned 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
}
|
||||
}
|
||||
@@ -817,19 +851,19 @@ inline void packer<Stream>::pack_imp_uint32(T d)
|
||||
append_buffer(&buf, 1);
|
||||
} else {
|
||||
/* unsigned 8 */
|
||||
char buf[2] = {static_cast<char>(0xcc), take8_32(d)};
|
||||
char buf[2] = {static_cast<char>(0xccu), take8_32(d)};
|
||||
append_buffer(buf, 2);
|
||||
}
|
||||
} else {
|
||||
if(d < (1<<16)) {
|
||||
/* unsigned 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
/* unsigned 32 */
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
append_buffer(buf, 5);
|
||||
}
|
||||
}
|
||||
@@ -846,24 +880,24 @@ inline void packer<Stream>::pack_imp_uint64(T d)
|
||||
append_buffer(&buf, 1);
|
||||
} else {
|
||||
/* unsigned 8 */
|
||||
char buf[2] = {static_cast<char>(0xcc), take8_64(d)};
|
||||
char buf[2] = {static_cast<char>(0xccu), take8_64(d)};
|
||||
append_buffer(buf, 2);
|
||||
}
|
||||
} else {
|
||||
if(d < (1ULL<<16)) {
|
||||
/* unsigned 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
} else if(d < (1ULL<<32)) {
|
||||
/* unsigned 32 */
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
append_buffer(buf, 5);
|
||||
} else {
|
||||
/* unsigned 64 */
|
||||
char buf[9];
|
||||
buf[0] = static_cast<char>(0xcf); _msgpack_store64(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xcfu); _msgpack_store64(&buf[1], d);
|
||||
append_buffer(buf, 9);
|
||||
}
|
||||
}
|
||||
@@ -875,7 +909,7 @@ inline void packer<Stream>::pack_imp_int8(T d)
|
||||
{
|
||||
if(d < -(1<<5)) {
|
||||
/* signed 8 */
|
||||
char buf[2] = {static_cast<char>(0xd0), take8_8(d)};
|
||||
char buf[2] = {static_cast<char>(0xd0u), take8_8(d)};
|
||||
append_buffer(buf, 2);
|
||||
} else {
|
||||
/* fixnum */
|
||||
@@ -892,11 +926,11 @@ inline void packer<Stream>::pack_imp_int16(T d)
|
||||
if(d < -(1<<7)) {
|
||||
/* signed 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
|
||||
buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
/* signed 8 */
|
||||
char buf[2] = {static_cast<char>(0xd0), take8_16(d)};
|
||||
char buf[2] = {static_cast<char>(0xd0u), take8_16(d)};
|
||||
append_buffer(buf, 2);
|
||||
}
|
||||
} else if(d < (1<<7)) {
|
||||
@@ -906,12 +940,12 @@ inline void packer<Stream>::pack_imp_int16(T d)
|
||||
} else {
|
||||
if(d < (1<<8)) {
|
||||
/* unsigned 8 */
|
||||
char buf[2] = {static_cast<char>(0xcc), take8_16(d)};
|
||||
char buf[2] = {static_cast<char>(0xccu), take8_16(d)};
|
||||
append_buffer(buf, 2);
|
||||
} else {
|
||||
/* unsigned 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
}
|
||||
}
|
||||
@@ -925,16 +959,16 @@ inline void packer<Stream>::pack_imp_int32(T d)
|
||||
if(d < -(1<<15)) {
|
||||
/* signed 32 */
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xd2); _msgpack_store32(&buf[1], static_cast<int32_t>(d));
|
||||
buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], static_cast<int32_t>(d));
|
||||
append_buffer(buf, 5);
|
||||
} else if(d < -(1<<7)) {
|
||||
/* signed 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
|
||||
buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
/* signed 8 */
|
||||
char buf[2] = { static_cast<char>(0xd0), take8_32(d)};
|
||||
char buf[2] = { static_cast<char>(0xd0u), take8_32(d)};
|
||||
append_buffer(buf, 2);
|
||||
}
|
||||
} else if(d < (1<<7)) {
|
||||
@@ -944,17 +978,17 @@ inline void packer<Stream>::pack_imp_int32(T d)
|
||||
} else {
|
||||
if(d < (1<<8)) {
|
||||
/* unsigned 8 */
|
||||
char buf[2] = { static_cast<char>(0xcc), take8_32(d)};
|
||||
char buf[2] = { static_cast<char>(0xccu), take8_32(d)};
|
||||
append_buffer(buf, 2);
|
||||
} else if(d < (1<<16)) {
|
||||
/* unsigned 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
/* unsigned 32 */
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
append_buffer(buf, 5);
|
||||
}
|
||||
}
|
||||
@@ -969,23 +1003,23 @@ inline void packer<Stream>::pack_imp_int64(T d)
|
||||
if(d < -(1LL<<31)) {
|
||||
/* signed 64 */
|
||||
char buf[9];
|
||||
buf[0] = static_cast<char>(0xd3); _msgpack_store64(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xd3u); _msgpack_store64(&buf[1], d);
|
||||
append_buffer(buf, 9);
|
||||
} else {
|
||||
/* signed 32 */
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xd2); _msgpack_store32(&buf[1], static_cast<int32_t>(d));
|
||||
buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], static_cast<int32_t>(d));
|
||||
append_buffer(buf, 5);
|
||||
}
|
||||
} else {
|
||||
if(d < -(1<<7)) {
|
||||
/* signed 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xd1); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
|
||||
buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], static_cast<int16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
} else {
|
||||
/* signed 8 */
|
||||
char buf[2] = {static_cast<char>(0xd0), take8_64(d)};
|
||||
char buf[2] = {static_cast<char>(0xd0u), take8_64(d)};
|
||||
append_buffer(buf, 2);
|
||||
}
|
||||
}
|
||||
@@ -997,24 +1031,24 @@ inline void packer<Stream>::pack_imp_int64(T d)
|
||||
if(d < (1LL<<16)) {
|
||||
if(d < (1<<8)) {
|
||||
/* unsigned 8 */
|
||||
char buf[2] = {static_cast<char>(0xcc), take8_64(d)};
|
||||
char buf[2] = {static_cast<char>(0xccu), take8_64(d)};
|
||||
append_buffer(buf, 2);
|
||||
} else {
|
||||
/* unsigned 16 */
|
||||
char buf[3];
|
||||
buf[0] = static_cast<char>(0xcd); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
buf[0] = static_cast<char>(0xcdu); _msgpack_store16(&buf[1], static_cast<uint16_t>(d));
|
||||
append_buffer(buf, 3);
|
||||
}
|
||||
} else {
|
||||
if(d < (1LL<<32)) {
|
||||
/* unsigned 32 */
|
||||
char buf[5];
|
||||
buf[0] = static_cast<char>(0xce); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
buf[0] = static_cast<char>(0xceu); _msgpack_store32(&buf[1], static_cast<uint32_t>(d));
|
||||
append_buffer(buf, 5);
|
||||
} else {
|
||||
/* unsigned 64 */
|
||||
char buf[9];
|
||||
buf[0] = static_cast<char>(0xcf); _msgpack_store64(&buf[1], d);
|
||||
buf[0] = static_cast<char>(0xcfu); _msgpack_store64(&buf[1], d);
|
||||
append_buffer(buf, 9);
|
||||
}
|
||||
}
|
||||
|
@@ -811,50 +811,50 @@ msgpack_pack_inline_func(_ext)(msgpack_pack_user x, size_t l, int8_t type)
|
||||
{
|
||||
switch(l) {
|
||||
case 1: {
|
||||
char buf[2];
|
||||
unsigned char buf[2];
|
||||
buf[0] = 0xd4;
|
||||
buf[1] = type;
|
||||
msgpack_pack_append_buffer(x, buf, 2);
|
||||
} break;
|
||||
case 2: {
|
||||
char buf[2];
|
||||
unsigned char buf[2];
|
||||
buf[0] = 0xd5;
|
||||
buf[1] = type;
|
||||
msgpack_pack_append_buffer(x, buf, 2);
|
||||
} break;
|
||||
case 4: {
|
||||
char buf[2];
|
||||
unsigned char buf[2];
|
||||
buf[0] = 0xd6;
|
||||
buf[1] = type;
|
||||
msgpack_pack_append_buffer(x, buf, 2);
|
||||
} break;
|
||||
case 8: {
|
||||
char buf[2];
|
||||
unsigned char buf[2];
|
||||
buf[0] = 0xd7;
|
||||
buf[1] = type;
|
||||
msgpack_pack_append_buffer(x, buf, 2);
|
||||
} break;
|
||||
case 16: {
|
||||
char buf[2];
|
||||
unsigned char buf[2];
|
||||
buf[0] = 0xd8;
|
||||
buf[1] = type;
|
||||
msgpack_pack_append_buffer(x, buf, 2);
|
||||
} break;
|
||||
default:
|
||||
if(l < 256) {
|
||||
char buf[3];
|
||||
unsigned char buf[3];
|
||||
buf[0] = 0xc7;
|
||||
buf[1] = l;
|
||||
buf[1] = (unsigned char)l;
|
||||
buf[2] = type;
|
||||
msgpack_pack_append_buffer(x, buf, 3);
|
||||
} else if(l < 65536) {
|
||||
char buf[4];
|
||||
unsigned char buf[4];
|
||||
buf[0] = 0xc8;
|
||||
_msgpack_store16(&buf[1], l);
|
||||
buf[3] = type;
|
||||
msgpack_pack_append_buffer(x, buf, 4);
|
||||
} else {
|
||||
char buf[6];
|
||||
unsigned char buf[6];
|
||||
buf[0] = 0xc9;
|
||||
_msgpack_store32(&buf[1], l);
|
||||
buf[5] = type;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user