Compare commits

..

54 Commits

Author SHA1 Message Date
Takatoshi Kondo
e59f6e67a5 Merge pull request #468 from redboltz/ver1.4.2
Updated version number.
2016-05-27 18:08:08 +09:00
Takatoshi Kondo
9a8405bcd7 Updated change log and readme. 2016-05-26 20:27:08 +09:00
Takatoshi Kondo
9eca5a9ff6 Updated version number. 2016-05-26 19:50:07 +09:00
Takatoshi Kondo
8388ced33f Merge pull request #467 from redboltz/bp_441
Backported #441 to cpp-1.4.
2016-05-18 21:59:17 +09:00
Takatoshi Kondo
0dcab0b2b1 Backported #441 to cpp-1.4.
Fixed a pointer operation problem at msgpack::zone::chunk_list::clear().
It was only happened on C++03.
2016-05-18 19:21:52 +09:00
Takatoshi Kondo
7df967142d Merge pull request #439 from redboltz/ver1.4.1
Updated the version to 1.4.1.
2016-03-06 20:30:15 +09:00
Takatoshi Kondo
437400c6fe Updated the version to 1.4.1. 2016-03-06 19:54:33 +09:00
Takatoshi Kondo
ae8de13ab6 Merge pull request #438 from redboltz/bp_436
Backported #436 to version 1.4.0.
2016-03-06 18:49:20 +09:00
Takatoshi Kondo
39433e8588 Merge pull request #437 from redboltz/bp_435
Backported #435 to version 1.4.0.
2016-03-06 18:48:52 +09:00
Takatoshi Kondo
94c9bc2ddc Backported #436 to version 1.4.0. 2016-03-06 14:19:10 +09:00
Takatoshi Kondo
1088aa55af Backported #435 to version 1.4.0. 2016-03-06 13:40:40 +09:00
Takatoshi Kondo
66a5fcf8f1 Merge pull request #428 from redboltz/bp_426_1.4
Backported #426 to version 1.4.0.
2016-02-21 00:04:51 +09:00
Takatoshi Kondo
bb0617bd47 Merge pull request #427 from redboltz/bp_423_to_1.4
Backported #423 to version 1.4.0.
2016-02-21 00:03:54 +09:00
Takatoshi Kondo
f642b70e6a Backported #426 to version 1.4.0. 2016-02-20 19:09:18 +09:00
Takatoshi Kondo
3f4ffb9386 Backported #423 to version 1.4.0. 2016-02-20 18:50:13 +09:00
Takatoshi Kondo
cabd8a8a03 Merge pull request #413 from redboltz/version-1.4.0
Release version 1.4.0.
2016-01-22 10:53:12 +09:00
Takatoshi Kondo
8640754417 Release version 1.4.0.
Fixed markdown layouts.
2016-01-22 10:02:59 +09:00
Takatoshi Kondo
7d1be40e10 Merge pull request #410 from redboltz/fix_399
Fixed #399
2016-01-22 00:10:26 +09:00
Takatoshi Kondo
3c271892e3 Fixed #399
If MSGPACK_DISABLE_LEGACY_CONVERT is defined, msgpack::object::convert(T*) is removed.
Added MSGPACK_DISABLE_LEGACY_CONVERT to build system and documents.

Please define MSGPACK_DISABLE_LEGACY_CONVERT and update your code as follows:
Replace
  int i;
  obj.convert(&i); // Removed pointer version
with
  int i;
  obj.convert(i);  // Reference version
2016-01-21 22:28:53 +09:00
Takatoshi Kondo
83ab53ecd4 Merge pull request #412 from redboltz/add_disable_legacy_macros_for_build
Added MSGPACK_DISABLE_LEGACY_NIL to build system and documents.
2016-01-21 22:18:09 +09:00
Takatoshi Kondo
ba73841240 Added MSGPACK_DISABLE_LEGACY_NIL to build system and documents. 2016-01-21 20:47:16 +09:00
Takatoshi Kondo
13afc54ccc Merge pull request #411 from redboltz/change_default_macro
Fixed existing code compile error problem.
2016-01-21 19:34:43 +09:00
Takatoshi Kondo
2865a96ba5 Fixed existing code compile error problem.
Changed macro name from MSGPACK_USE_LEGACY_NIL to
MSGPACK_DISABLE_LEGACY_NIL. msgpack-c shouldn't make compile error on
existing codes by default without major version up.
So if you want to disable msgpack::type::nil, you need to define
MSGPACK_DISABLE_LEGACY_NIL macro.
2016-01-21 17:29:22 +09:00
Takatoshi Kondo
79222b65a3 Merge pull request #409 from redboltz/fix_wshadow
Fixed -Wshadow warning.
2016-01-20 14:58:46 +09:00
Takatoshi Kondo
83f0429db8 Merge pull request #408 from redboltz/replace_nil_with_nil_t
Replaced nil with nil_t.
2016-01-20 14:04:56 +09:00
Takatoshi Kondo
6c035f7d2b Merge pull request #407 from redboltz/add_doc
Added unpack, pack, object, and object_handle documentation.
2016-01-19 09:06:58 +09:00
Takatoshi Kondo
ed5a4123b5 Replaced nil with nil_t.
Added nil typedef for existing codes.
2016-01-18 22:12:38 +09:00
Takatoshi Kondo
b8530e30df Fixed -Wshadow warning. 2016-01-18 21:52:50 +09:00
Takatoshi Kondo
8bf2f33782 Added unpack, pack, object, and object_handle documentation. 2016-01-18 21:49:28 +09:00
Takatoshi Kondo
356fbcf187 Merge pull request #400 from ryochack/fix_fbuffer_warning
Fixed an incompatible type warning
2016-01-15 12:53:15 +09:00
Takatoshi Kondo
1adf90e9df Merge branch 'redboltz-fix_382' 2016-01-15 12:45:07 +09:00
Takatoshi Kondo
c2f523e463 Merge branch 'fix_382' of https://github.com/redboltz/msgpack-c into redboltz-fix_382 2016-01-15 12:44:40 +09:00
Takatoshi Kondo
1e8f5d0d67 Merge pull request #402 from redboltz/fix_395
Fixed #395
2016-01-15 11:11:55 +09:00
Takatoshi Kondo
0a8d25cd35 Merge pull request #404 from jamessan/fix-endian-condition
Check whether MSGPACK_ENDIAN_LITTLE_BYTE is true, not defined.
2016-01-15 11:05:19 +09:00
James McCoy
72e0d1a424 Check whether MSGPACK_ENDIAN_LITTLE_BYTE is true, not defined.
msgpack/predef/other/endian.h always defines both
MSGPACK_ENDIAN_LITTLE_BYTE and MSGPACK_ENDIAN_BIG_BYTE, but they're
defined to a true or false value depending on whether the system is
little/big endian.

Fix this condition to check the truthiness rather than whether it is
defined, like the other locations this macro is checked.

Closes #403

Signed-off-by: James McCoy <jamessan@jamessan.com>
2016-01-14 19:31:27 -05:00
Takatoshi Kondo
c06d4d70ef Fixed #395
libmsgpack.[a|so] is the library file for C++.
libmsgpackc.[a|so] is the library file for C.
Since version 1.0.0, the C++ parts of msgpack-c is a header only
library. So libmsgpack.* shouldn't be generated.

On the autotools building environment, removed libmsgpack.*
generation. On the cmake building environment, replaced libmsgpack.*
with libmsgpackc.* and set so-version to 2.0.0.
2016-01-14 07:59:37 +09:00
Takatoshi Kondo
69f588dd36 Merge pull request #401 from redboltz/fix_392
Fixed #392
2016-01-14 07:57:05 +09:00
Takatoshi Kondo
65b47fa032 Merge pull request #397 from redboltz/fix_396
Fixed #396.
2016-01-13 18:33:41 +09:00
Takatoshi Kondo
22fd249b12 Fixed #392
Avoided the warning when `char` does not have sign using template lazy instantiation.
Removed redundant `inline`.
2016-01-13 17:38:51 +09:00
Takatoshi Kondo
96831350b8 Merge pull request #398 from jamessan/unsigned-char-ci
Add CI testing of signed/unsigned char differences
2016-01-13 15:25:55 +09:00
ryochack
5da3c031fd Fix warning of 'msgpack_fbuffer_write' 2016-01-13 12:18:33 +09:00
James McCoy
71eba2406d Add CI testing of signed/unsigned char differences
This should help catch problems like #392 sooner.

Signed-off-by: James McCoy <jamessan@jamessan.com>
2016-01-12 20:17:43 -05:00
Takatoshi Kondo
892fa8c2bd Fixed #396.
Added Doxyfile to the distribution package.
Generated ChangeLog as a copy of CHANGELOG.md.
2016-01-11 08:57:00 +09:00
Takatoshi Kondo
42e332bb8c Merge pull request #394 from jamessan/cmake-SOVERSION
Set SOVERSION to 4 for CMake builds
2016-01-11 07:45:02 +09:00
James McCoy
40604c3d40 Set SOVERSION to 4 for CMake builds
In aa79fc2f, the SOVERSION was bumped to 4 for autoconf-based builds,
but was left at 3 for CMake builds.  This shouldn't differ based on
which tool is used to build msgpack-c.

Signed-off-by: James McCoy <jamessan@jamessan.com>
2016-01-09 21:31:32 -05:00
Takatoshi Kondo
e183efcce2 Merge pull request #387 from kgrz/update-quick-start-docs-with-new-api
Update install instructions and QUICKSTART-C.md
2015-12-03 23:11:37 +09:00
Kashyap
772e4e01a3 Remove whitespace 2015-12-01 09:27:10 +05:30
Kashyap
3660b495c3 Use post 1.x APIs in Quickstart docs 2015-12-01 09:26:46 +05:30
Kashyap
7a02f03a82 Update install instructions with latest msgpack 2015-12-01 09:26:19 +05:30
Takatoshi Kondo
b8ee27c672 Replaced EXPECT_EQ with EXPECT_TRUE to avoid ostream requirement. 2015-11-19 09:22:40 +09:00
Takatoshi Kondo
ee65a319ba Replaced EXPECT_EQ with EXPECT_TRUE to avoid ostream requirement. 2015-11-18 08:29:35 +09:00
Takatoshi Kondo
46502480e9 Replaced EXPECT_EQ with EXPECT_TRUE to avoid ostream requirement. 2015-11-15 12:40:37 +09:00
Takatoshi Kondo
50e1c23941 Removed gcc_atomic.cpp from CMakelist.txt. 2015-11-15 12:40:17 +09:00
Takatoshi Kondo
39e7856c48 Fixed #382.
Fixed warnings on gcc 4.1.2.
Added gcc version checking for adding -std=c++03 flag.
2015-11-12 00:20:21 +09:00
52 changed files with 1800 additions and 345 deletions

View File

@@ -36,14 +36,14 @@ install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then unzip -q gtest-1.7.0.zip && cd gtest-1.7.0 && sudo cp -r include/gtest /usr/local/include && clang++ src/gtest-all.cc -I. -Iinclude -c && g++ src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mv *.a /usr/local/lib && cd ..; fi
env:
- ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost"
- ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC=""
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost"
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF"
- ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC=""
- ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost"
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC=""
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF"
- ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned"
- ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" CHAR_SIGN="signed"
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="signed"
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF" CHAR_SIGN="unsigned"
- ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="signed"
- ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned"
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="unsigned"
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed"
before_script:
- export PATH=/usr/local/bin:$PATH && rm -rf install
@@ -53,39 +53,39 @@ matrix:
- os: osx
compiler: gcc
- os: osx
env: ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC=""
env: ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" CHAR_SIGN="signed"
- os: osx
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF"
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF" CHAR_SIGN="unsigned"
- os: osx
env: ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost"
env: ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned"
- os: osx
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF"
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed"
- os: linux
compiler: gcc
env: ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost"
env: ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned"
- os: linux
compiler: gcc
env: ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC=""
env: ACTION="ci/build_autotools.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" CHAR_SIGN="signed"
- os: linux
compiler: gcc
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost"
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="signed"
- os: linux
compiler: gcc
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF"
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF" CHAR_SIGN="unsigned"
- os: linux
compiler: clang
env: ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC=""
env: ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="signed"
- os: linux
compiler: clang
env: ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost"
env: ACTION="ci/build_autotools.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned"
- os: linux
compiler: clang
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC=""
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="unsigned"
- os: linux
compiler: clang
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF"
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed"
script:
- git clean -xdf && CMAKE_LIBRARY_PATH=${LIBPATH} ${ACTION} ${VERSION} ${ARCH} ${BOOST} ${BOOST_INC}
- git clean -xdf && CMAKE_LIBRARY_PATH=${LIBPATH} ${ACTION} ${VERSION} ${ARCH} ${BOOST} ${BOOST_INC} ${CHAR_SIGN}

View File

@@ -1,4 +1,55 @@
2015-11-21 version 1.3.0
# 2016-05-26 version 1.4.2
* Fix C++03 msgpack::zone::clear() memory access violation bug (#467)
# 2016-03-06 version 1.4.1
* Fix TARGET_OS_IPHONE checking (#436, #438)
* Fix invalid front() call for empty container (#435. #437)
* Fix compile error on g++6 (C++11 only) (#426, #428)
* Fix zone size expansion logic (#423, #427)
# 2016-01-22 version 1.4.0
## << recommended changes >>
* Define [MSGPACK_DISABLE_LEGACY_NIL](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_nil-since-140), then `msgpack::type::nil` is replaced by with `msgpack::type::nil_t` (#408, #411, #412).
Replace `msgpack::type::nil` with `msgpack::type::nil_t` in client codes.
`msgpack::type::nil` will be removed on the version 2.0.0.
* Define [MSGPACK_DISABLE_LEGACY_CONVERT](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_convert-since-140), then `msgpack::object::convert(T*)` is removed (#410).
Replace calling `msgpack::bojectconvert(T*)` with `msgpack::bojectconvert(T&)` in client codes as follows:
```C++
int i;
obj.convert(&i); // before
```
```C++
int i;
obj.convert(i); // after
```
`msgpack::object::convert(T*)` will be removed on the version 2.0.0.
Define the macros above as follows when you compile C++ codes that use msgpack-c:
```
g++ -Ipath_to_msgpack/include -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT your_code.cpp
```
You can compile existing codes without defining macros above but I recommend defining them and updating your codes to fix the issues #408, #411, #412, #399, and #410. It is also a good preparation for the version 2.0.0.
## << other updates >>
* Improve documents (#387, #407)
* Remove C++ version library (#394, #402)
* Add Doxyfile and ChangeLog to the distribution package (#397)
* Add signed/unsigned char test to travis-ci (#398)
* Remove some warnings (#400, #401, #409)
* Fix endian checking. (#404)
# 2015-11-21 version 1.3.0
* Change the license from the Apache License Version 2.0 to the
Boost Software License, Version 1.0.(#386)
* Remove some warnings (#365)
@@ -6,12 +57,18 @@
* Improve tests (#375, #378, #379, #380)
* Fix msvc specific problem (#376, #383)
* Fix typos (#381)
2015-09-04 version 1.2.0
<< breaking change >>
# 2015-09-04 version 1.2.0
## << breaking changes >>
* Change std::vector<unsigned char> and std::array<unsigned char>
mapped to BIN instead of ARRAY (#243)
* Remove redundant copy (#285)
## << other updates >>
* Add array_ref to map to ARRAY (#243)
* Add variant type and adaptor (#349)
* Add object::convert_if_not_nil() (#357)
@@ -49,8 +106,11 @@
* Add base class serialization. (#265, #277)
* Add and improve examples. (#264, #310, #311, #341, #342, #344)
* Fix wiki URL. (#263)
2015-04-03 version 1.1.0
<< breaking change >>
# 2015-04-03 version 1.1.0
## << breaking changes >>
* Remove msgpack_fwd.hpp
* Improve user types adaptation mechanism (#262)
Since version 1.0.0, users need to obey the correct include order.
@@ -59,18 +119,24 @@
care about include order. Migration guide from 1.0.x to 1.1.0 has
been written. See https://github.com/msgpack/msgpack-c/wiki
## << other updates >>
* Fix vector<bool> size check (#251)
* Fix inttypes.h inclusion on MSVC (#257)
* Support documents generation by Doxygen (#259)
* Remove C99 style variable declaration (#253)
* Improve documents (https://github.com/msgpack/msgpack-c/wiki)
2015-03-22 version 1.0.1:
# 2015-03-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:
# 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)
@@ -96,7 +162,7 @@
* 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:
# 2014-07-02 version 0.5.9:
* Support std::tr1 unordered containers by default (#51, #63, #68, #69)
* Remove some warnings (#56)
@@ -110,7 +176,7 @@
* Add FILE* buffer (#40)
* Other bug fixes and refactoring: #39, #73, #77, #79, #80, #81, #84, #90
2013-12-23 version 0.5.8:
# 2013-12-23 version 0.5.8:
* Move to the new github repository msgpack/msgpack-c
* Support the new deserialization specification
@@ -118,38 +184,38 @@
* Other bug fixes and refactoring: #46, #41, #36, #35, #33, #32, #30, #29, #28, #27, #26, #25, #8, #3
* Update of documents: #23, #18, #17
2011-08-08 version 0.5.7:
# 2011-08-08 version 0.5.7:
* fixes compile error problem with llvm-gcc and Mac OS X Lion
2011-04-24 version 0.5.6:
# 2011-04-24 version 0.5.6:
* #42 fixes double-free problem on msgpack_unpacker_release_zone
2011-02-24 version 0.5.5:
# 2011-02-24 version 0.5.5:
* eliminates dependency of winsock2.h header
* fixes msgpack_vc.postbuild.bat file
* fixes some implicit cast warnings
2010-08-29 version 0.5.4:
# 2010-08-29 version 0.5.4:
* includes msgpack_vc2008.vcproj file in source package
* fixes type::fix_int types
2010-08-27 version 0.5.3:
# 2010-08-27 version 0.5.3:
* adds type::fix_{u,}int{8,16,32,64} types
* adds msgpack_pack_fix_{u,}int{8,16,32,64} functions
* adds packer<Stream>::pack_fix_{u,}int{8,16,32,64} functions
* fixes include paths
2010-07-14 version 0.5.2:
# 2010-07-14 version 0.5.2:
* type::raw::str(), operator==, operator!=, operator< and operator> are now const
* generates version.h using AC_OUTPUT macro in ./configure
2010-07-06 version 0.5.1:
# 2010-07-06 version 0.5.1:
* Add msgpack_vrefbuffer_new and msgpack_vrefbuffer_free
* Add msgpack_sbuffer_new and msgpack_sbuffer_free
@@ -159,7 +225,7 @@
* Add msgpack_version{,_major,_minor} functions to check library version
* ./configure supports --disable-cxx option not to build C++ API
2010-04-29 version 0.5.0:
# 2010-04-29 version 0.5.0:
* msgpack_object_type is changed. MSGPACK_OBJECT_NIL is now 0x00.
* New safe streaming deserializer API.

View File

@@ -14,11 +14,16 @@ SET (prefix ${CMAKE_INSTALL_PREFIX})
SET (exec_prefix "\${prefix}")
SET (libdir "\${exec_prefix}/lib")
SET (includedir "\${prefix}/include")
SET (GNUCXX_STD_SUPPORT_VERSION "4.3")
SET (GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION "4.4")
OPTION (MSGPACK_CXX11 "Using c++11 compiler" OFF)
OPTION (MSGPACK_32BIT "32bit compile" OFF)
OPTION (MSGPACK_BOOST "Using boost libraries" OFF)
SET (CMAKE_CXX_FLAGS "-DMSGPACK_DISABLE_LEGACY_NIL ${CMAKE_CXX_FLAGS}")
SET (CMAKE_CXX_FLAGS "-DMSGPACK_DISABLE_LEGACY_CONVERT ${CMAKE_CXX_FLAGS}")
IF (APPLE)
SET(CMAKE_MACOSX_RPATH ON)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
@@ -43,7 +48,10 @@ IF (MSGPACK_CXX11)
ENDIF ()
ELSE ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET (CMAKE_CXX_FLAGS "-std=c++03 ${CMAKE_CXX_FLAGS}")
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_STD_SUPPORT_VERSION}) OR
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_STD_SUPPORT_VERSION}))
SET (CMAKE_CXX_FLAGS "-std=c++03 ${CMAKE_CXX_FLAGS}")
ENDIF ()
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET (CMAKE_CXX_FLAGS "-std=c++03 ${CMAKE_CXX_FLAGS}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
@@ -76,6 +84,11 @@ IF (MSGPACK_BOOST)
)
ENDIF ()
IF (MSGPACK_CHAR_SIGN)
SET (CMAKE_C_FLAGS "-f${MSGPACK_CHAR_SIGN}-char ${CMAKE_C_FLAGS}")
SET (CMAKE_CXX_FLAGS "-f${MSGPACK_CHAR_SIGN}-char ${CMAKE_CXX_FLAGS}")
ENDIF ()
FILE (GLOB_RECURSE PREDEF_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost/*.h)
FOREACH (F ${PREDEF_FILES})
SET(M "Converting ${F}")
@@ -119,14 +132,8 @@ int main(int argc, char * argv[])
}
" MSGPACK_ENABLE_GCC_CXX_ATOMIC)
IF (MSGPACK_ENABLE_GCC_CXX_ATOMIC)
LIST (APPEND msgpack_SOURCES
src/gcc_atomic.cpp
)
ENDIF ()
LIST (APPEND msgpack_SOURCES
LIST (APPEND msgpackc_SOURCES
src/unpack.c
src/objectc.c
src/version.c
@@ -134,7 +141,7 @@ LIST (APPEND msgpack_SOURCES
src/zone.c
)
LIST (APPEND msgpack_HEADERS
LIST (APPEND msgpackc_HEADERS
include/msgpack/pack_define.h
include/msgpack/pack_template.h
include/msgpack/unpack_define.h
@@ -157,8 +164,8 @@ LIST (APPEND msgpack_HEADERS
FILE (GLOB_RECURSE PREDEF_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/predef/*.h)
LIST (APPEND msgpack_HEADERS ${PREDEF_FILES})
LIST (APPEND msgpack_HEADERS include/msgpack/predef.h)
LIST (APPEND msgpackc_HEADERS ${PREDEF_FILES})
LIST (APPEND msgpackc_HEADERS include/msgpack/predef.h)
IF (MSGPACK_ENABLE_CXX)
LIST (APPEND msgpack_HEADERS
@@ -229,8 +236,8 @@ IF (MSGPACK_ENABLE_CXX)
)
FILE (GLOB_RECURSE PREPROCESSOR_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/preprocessor/*.hpp)
LIST (APPEND msgpack_HEADERS ${PREPROCESSOR_FILES})
LIST (APPEND msgpack_HEADERS include/msgpack/preprocessor.hpp)
LIST (APPEND msgpackc_HEADERS ${PREPROCESSOR_FILES})
LIST (APPEND msgpackc_HEADERS include/msgpack/preprocessor.hpp)
ENDIF ()
EXECUTE_PROCESS (
@@ -250,21 +257,21 @@ INCLUDE_DIRECTORIES (
)
IF (MSGPACK_ENABLE_SHARED)
ADD_LIBRARY (msgpack SHARED
${msgpack_SOURCES}
${msgpack_HEADERS}
ADD_LIBRARY (msgpackc SHARED
${msgpackc_SOURCES}
${msgpackc_HEADERS}
)
ENDIF ()
ADD_LIBRARY (msgpack-static STATIC
${msgpack_SOURCES}
${msgpack_HEADERS}
ADD_LIBRARY (msgpackc-static STATIC
${msgpackc_SOURCES}
${msgpackc_HEADERS}
)
SET_TARGET_PROPERTIES (msgpack-static PROPERTIES OUTPUT_NAME "msgpack")
SET_TARGET_PROPERTIES (msgpackc-static PROPERTIES OUTPUT_NAME "msgpackc")
IF (MSGPACK_ENABLE_SHARED)
SET_TARGET_PROPERTIES (msgpack PROPERTIES IMPORT_SUFFIX "_import.lib")
SET_TARGET_PROPERTIES (msgpack PROPERTIES SOVERSION 3 VERSION 4.0.0)
SET_TARGET_PROPERTIES (msgpackc PROPERTIES IMPORT_SUFFIX "_import.lib")
SET_TARGET_PROPERTIES (msgpackc PROPERTIES SOVERSION 2 VERSION 2.0.0)
ENDIF ()
IF (MSGPACK_BUILD_TESTS)
@@ -278,10 +285,22 @@ ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF (MSGPACK_ENABLE_SHARED)
SET_PROPERTY (TARGET msgpack APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Wno-mismatched-tags -Werror -g -O3 -DPIC")
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 -DPIC")
ENDIF ()
SET_PROPERTY (TARGET msgpack-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Wno-mismatched-tags -Werror -g -O3" )
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3" )
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@@ -291,7 +310,7 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC90" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC10")
SET_SOURCE_FILES_PROPERTIES(${msgpack_SOURCES} PROPERTIES LANGUAGE CXX)
SET_SOURCE_FILES_PROPERTIES(${msgpackc_SOURCES} PROPERTIES LANGUAGE CXX)
ENDIF()
IF (NOT DEFINED CMAKE_INSTALL_LIBDIR)
@@ -303,9 +322,9 @@ IF (MSGPACK_BUILD_EXAMPLES)
ENDIF ()
IF (MSGPACK_ENABLE_SHARED)
SET (MSGPACK_INSTALLTARGETS msgpack msgpack-static)
SET (MSGPACK_INSTALLTARGETS msgpackc msgpackc-static)
ELSE()
SET (MSGPACK_INSTALLTARGETS msgpack-static)
SET (MSGPACK_INSTALLTARGETS msgpackc-static)
ENDIF ()
INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@@ -1,6 +1,7 @@
SUBDIRS = src test
DOC_FILES = \
Doxyfile \
README.md \
LICENSE_1_0.txt \
NOTICE \

View File

@@ -36,9 +36,9 @@ On Gentoo Linux, you can use emerge. Install [dev-libs/msgpack|http://gentoo-por
On the other UNIX-like platforms, download source package from [Releases|http://msgpack.org/releases/cpp/] and run `./configure && make && make install`.
```
$ wget http://msgpack.org/releases/cpp/msgpack-0.5.5.tar.gz
$ tar zxvf msgpack-0.5.5.tar.gz
$ cd msgpack-0.5.5
$ wget http://msgpack.org/releases/cpp/msgpack-1.3.0.tar.gz
$ tar zxvf msgpack-1.3.0.tar.gz
$ cd msgpack-1.3.0
$ ./configure
$ make
$ sudo make install
@@ -88,10 +88,10 @@ int main(void) {
/* serializes ["Hello", "MessagePack"]. */
msgpack_pack_array(pk, 2);
msgpack_pack_raw(pk, 5);
msgpack_pack_raw_body(pk, "Hello", 5);
msgpack_pack_raw(pk, 11);
msgpack_pack_raw_body(pk, "MessagePack", 11);
msgpack_pack_bin(pk, 5);
msgpack_pack_bin_body(pk, "Hello", 5);
msgpack_pack_bin(pk, 11);
msgpack_pack_bin_body(pk, "MessagePack", 11);
/* deserializes it. */
msgpack_unpacked msg;
@@ -119,7 +119,7 @@ int main(void) {
/* creates buffer and serializer instance. */
msgpack_sbuffer* buffer = msgpack_sbuffer_new();
msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);
int j;
for(j = 0; j<23; j++) {
@@ -128,10 +128,10 @@ int main(void) {
/* serializes ["Hello", "MessagePack"]. */
msgpack_pack_array(pk, 3);
msgpack_pack_raw(pk, 5);
msgpack_pack_raw_body(pk, "Hello", 5);
msgpack_pack_raw(pk, 11);
msgpack_pack_raw_body(pk, "MessagePack", 11);
msgpack_pack_bin(pk, 5);
msgpack_pack_bin_body(pk, "Hello", 5);
msgpack_pack_bin(pk, 11);
msgpack_pack_bin_body(pk, "MessagePack", 11);
msgpack_pack_int(pk, j);
/* deserializes it. */
@@ -184,7 +184,7 @@ int main(void) {
}
/* results:
* $ gcc stream.cc -lmsgpack -o stream
* $ gcc stream.cc -lmsgpackc -o stream
* $ ./stream
* 1
* 2

View File

@@ -40,18 +40,20 @@ int main(void) {
// convert it into statically typed object.
std::vector<std::string> rvec;
obj.convert(&rvec);
obj.convert(rvec);
}
```
Compile it as follows:
```
$ g++ hello.cc -lmsgpack -o hello
$ g++ -Ipath_to_msgpack/include -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT hello.cc -o hello
$ ./hello
["Hello", "MessagePack"]
```
See [MSGPACK_DISABLE_LEGACY_NIL](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_nil-since-140) and [MSGPACK_DISABLE_LEGACY_CONVERT](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_convert-since-140).
## Streaming feature
```cpp
@@ -83,7 +85,7 @@ int main(void) {
}
// results:
// $ g++ stream.cc -lmsgpack -o stream
// $ g++ -Ipath_to_msgpack/include -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT stream.cc -o stream
// $ ./stream
// "Log message ... 1"
// "Log message ... 2"
@@ -91,6 +93,8 @@ int main(void) {
}
```
See [MSGPACK_DISABLE_LEGACY_NIL](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_nil-since-140) and [MSGPACK_DISABLE_LEGACY_CONVERT](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_convert-since-140).
### Streaming into an array or map
```cpp
@@ -154,6 +158,6 @@ int main(void) {
// you can convert object to myclass directly
std::vector<myclass> rvec;
obj.convert(&rvec);
obj.convert(rvec);
}
```

View File

@@ -1,7 +1,7 @@
`msgpack` for C/C++
===================
Version 1.3.0 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
Version 1.4.2 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
It's like JSON but small and fast.
@@ -96,7 +96,7 @@ int main(void)
// 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);
deserialized.convert(dst);
return 0;
}
@@ -112,7 +112,9 @@ Usage
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
g++ -I msgpack-c/include -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT your_source_file.cpp
See [MSGPACK_DISABLE_LEGACY_NIL](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_nil-since-140) and [MSGPACK_DISABLE_LEGACY_CONVERT](https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_configure#msgpack_disable_legacy_convert-since-140).
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.

View File

@@ -34,7 +34,7 @@ fi
mkdir -p ac
test -f AUTHORS || touch AUTHORS
test -f COPYING || touch COPYING
test -f ChangeLog || touch ChangeLog
test -f ChangeLog || cp -f CHANGELOG.md ChangeLog
test -f NEWS || touch NEWS
test -f NOTICE || touch NOTICE
test -f README || cp -f README.md README

View File

@@ -28,7 +28,7 @@ else
boost=""
fi
./configure CFLAGS="$bit32" CXXFLAGS="$bit32 $cpp11 $boost -I$4"
./configure CFLAGS="$bit32 -f${CHAR_SIGN}-char" CXXFLAGS="$bit32 -f${CHAR_SIGN}-char $cpp11 $boost -I$4"
ret=$?
if [ $ret -ne 0 ]

View File

@@ -51,7 +51,7 @@ else
shared=""
fi
cmake $cpp11 $bit32 $boost $boost_dir $shared ..
cmake $cpp11 $bit32 $boost $boost_dir $shared -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} ..
ret=$?
if [ $ret -ne 0 ]

View File

@@ -125,6 +125,7 @@ class zone {
::free(c);
c = n;
} else {
m_head = c;
break;
}
}

View File

@@ -12,8 +12,20 @@ FOREACH (source_file ${exec_PROGRAMS})
${source_file}
)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -Wno-mismatched-tags -g -O3")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

View File

@@ -17,11 +17,23 @@ FOREACH (source_file ${exec_PROGRAMS})
${source_file}
)
TARGET_LINK_LIBRARIES (${source_file_we}
msgpack
msgpackc
)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -Wno-mismatched-tags -g -O3")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

View File

@@ -33,7 +33,7 @@ FOREACH (source_file ${exec_PROGRAMS})
${source_file}
)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -Wno-mismatched-tags -g -O3")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
@@ -54,7 +54,7 @@ FOREACH (source_file ${with_pthread_PROGRAMS})
pthread
)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -Wno-mismatched-tags -g -O3 -pthread")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 -pthread")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
@@ -86,9 +86,22 @@ FOREACH (source_file ${with_boost_lib_PROGRAMS})
rt
)
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -Wno-mismatched-tags -g -O3")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -O3")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

View File

@@ -44,7 +44,7 @@ int main(void)
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size());
msgpack::object obj = result.get();
obj.convert(&nc);
obj.convert(nc);
std::cout << obj << " value=" << nc.value << " flag=" << nc.flag << std::endl;
}
@@ -60,7 +60,7 @@ int main(void)
msgpack::unpack(result, sbuf.str().data(), sbuf.str().size());
msgpack::object obj = result.get();
obj.convert(&oc);
obj.convert(oc);
std::cout << obj << " value=" << oc.value << std::endl;
}

View File

@@ -40,7 +40,7 @@ int main(void)
// 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);
deserialized.convert(dst);
return 0;
}

View File

@@ -50,7 +50,7 @@ void test_map_pack_unpack() {
std::cout << "Start converting..." << std::endl;
{
boost::timer::cpu_timer timer;
unpacked.get().convert(&m2);
unpacked.get().convert(m2);
std::string result = timer.format();
std::cout << result << std::endl;
}

View File

@@ -73,7 +73,7 @@ void test_array_of_array() {
std::cout << "Start converting..." << std::endl;
{
boost::timer::cpu_timer timer;
unpacked.get().convert(&v2);
unpacked.get().convert(v2);
std::string result = timer.format();
std::cout << result << std::endl;
}

View File

@@ -15,8 +15,20 @@ IF (MSGPACK_CXX11)
${source_file}
)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -Wno-mismatched-tags -g -O3")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 ")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

View File

@@ -43,7 +43,7 @@ namespace type {
template <typename STR, typename BIN, typename EXT>
struct basic_variant :
boost::variant<
nil, // NIL
nil_t, // NIL
bool, // BOOL
int64_t, // NEGATIVE_INTEGER
uint64_t, // POSITIVE_INTEGER
@@ -62,7 +62,7 @@ struct basic_variant :
>,
private boost::totally_ordered<basic_variant<STR, BIN, EXT> > {
typedef boost::variant<
nil, // NIL
nil_t, // NIL
bool, // BOOL
int64_t, // NEGATIVE_INTEGER
uint64_t, // POSITIVE_INTEGER
@@ -104,7 +104,7 @@ struct basic_variant :
basic_variant(unsigned long long v):base(uint64_t(v)) {}
bool is_nil() const {
return boost::get<nil>(this);
return boost::get<msgpack::type::nil_t>(this);
}
bool is_bool() const {
return boost::get<bool>(this);
@@ -268,7 +268,7 @@ struct as<msgpack::type::basic_variant<STR, BIN, EXT> > {
msgpack::type::basic_variant<STR, BIN, EXT> operator()(msgpack::object const& o) const {
switch(o.type) {
case type::NIL:
return o.as<msgpack::type::nil>();
return o.as<msgpack::type::nil_t>();
case type::BOOLEAN:
return o.as<bool>();
case type::POSITIVE_INTEGER:
@@ -304,7 +304,7 @@ struct convert<msgpack::type::basic_variant<STR, BIN, EXT> > {
msgpack::type::basic_variant<STR, BIN, EXT>& v) const {
switch(o.type) {
case type::NIL:
v = o.as<msgpack::type::nil>();
v = o.as<msgpack::type::nil_t>();
break;
case type::BOOLEAN:
v = o.as<bool>();
@@ -366,8 +366,8 @@ struct pack<msgpack::type::basic_variant<STR, BIN, EXT> > {
namespace detail {
struct object_imp : boost::static_visitor<void> {
void operator()(msgpack::type::nil const& v) const {
object<msgpack::type::nil>()(o_, v);
void operator()(msgpack::type::nil_t const& v) const {
object<msgpack::type::nil_t>()(o_, v);
}
void operator()(bool const& v) const {
object<bool>()(o_, v);

View File

@@ -36,12 +36,13 @@ namespace type {
public:
using base = std::tuple<Types...>;
using base::base;
tuple() = default;
tuple(tuple const&) = default;
tuple(tuple&&) = default;
template<typename... OtherTypes>
tuple(OtherTypes&&... other):base(std::forward<OtherTypes>(other)...) {}
template<typename... OtherTypes>
tuple(tuple<OtherTypes...> const& other):base(static_cast<std::tuple<OtherTypes...> const&>(other)) {}
template<typename... OtherTypes>

View File

@@ -27,7 +27,7 @@ namespace detail {
template <typename T>
struct convert_integer_sign<T, true> {
static inline T convert(msgpack::object const& o) {
static 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 msgpack::type_error(); }
@@ -43,7 +43,7 @@ namespace detail {
template <typename T>
struct convert_integer_sign<T, false> {
static inline T convert(msgpack::object const& o) {
static 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 msgpack::type_error(); }
@@ -69,7 +69,9 @@ namespace detail {
template <>
struct object_char_sign<true> {
static inline void make(msgpack::object& o, char v) {
template <typename T>
static typename msgpack::enable_if<msgpack::is_same<T, char>::value>::type
make(msgpack::object& o, T v) {
if (v < 0) {
o.type = msgpack::type::NEGATIVE_INTEGER;
o.via.i64 = v;
@@ -83,7 +85,7 @@ namespace detail {
template <>
struct object_char_sign<false> {
static inline void make(msgpack::object& o, char v) {
static void make(msgpack::object& o, char v) {
o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v;
}
};

View File

@@ -72,14 +72,16 @@ struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
msgpack::object const& operator()(msgpack::object const& o, type::assoc_vector<K, V, Compare, Alloc>& v) const {
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
v.resize(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);
p->val.convert(it->second);
if (o.via.map.size != 0) {
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);
p->val.convert(it->second);
}
std::sort(v.begin(), v.end(), type::detail::pair_first_less<K, V, Compare, Alloc>());
}
std::sort(v.begin(), v.end(), type::detail::pair_first_less<K, V, Compare, Alloc>());
return o;
}
};
@@ -194,14 +196,22 @@ struct object_with_zone<std::map<K, V, Compare, Alloc> > {
}
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::map<K, V, Compare, Alloc>::const_iterator it(v.begin());
do {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
p->key = msgpack::object(it->first, o.zone);
p->val = msgpack::object(it->second, o.zone);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
++p;
++it;
} while(p < pend);

View File

@@ -21,13 +21,19 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace type {
struct nil { };
struct nil_t { };
inline bool operator<(nil const& lhs, nil const& rhs) {
#if !defined(MSGPACK_DISABLE_LEGACY_NIL)
typedef nil_t nil;
#endif // !defined(MSGPACK_DISABLE_LEGACY_NIL)
inline bool operator<(nil_t const& lhs, nil_t const& rhs) {
return &lhs < &rhs;
}
inline bool operator==(nil const& lhs, nil const& rhs) {
inline bool operator==(nil_t const& lhs, nil_t const& rhs) {
return &lhs == &rhs;
}
@@ -36,32 +42,32 @@ inline bool operator==(nil const& lhs, nil const& rhs) {
namespace adaptor {
template <>
struct convert<type::nil> {
msgpack::object const& operator()(msgpack::object const& o, type::nil&) const {
struct convert<type::nil_t> {
msgpack::object const& operator()(msgpack::object const& o, type::nil_t&) const {
if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
return o;
}
};
template <>
struct pack<type::nil> {
struct pack<type::nil_t> {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::nil&) const {
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::nil_t&) const {
o.pack_nil();
return o;
}
};
template <>
struct object<type::nil> {
void operator()(msgpack::object& o, type::nil) const {
struct object<type::nil_t> {
void operator()(msgpack::object& o, type::nil_t) const {
o.type = msgpack::type::NIL;
}
};
template <>
struct object_with_zone<type::nil> {
void operator()(msgpack::object::with_zone& o, type::nil v) const {
struct object_with_zone<type::nil_t> {
void operator()(msgpack::object::with_zone& o, type::nil_t v) const {
static_cast<msgpack::object&>(o) << v;
}
};
@@ -71,7 +77,7 @@ struct object_with_zone<type::nil> {
template <>
inline void msgpack::object::as<void>() const
{
msgpack::type::nil v;
msgpack::type::nil_t v;
convert(v);
}

View File

@@ -30,11 +30,29 @@ struct convert<std::vector<char, Alloc> > {
switch (o.type) {
case msgpack::type::BIN:
v.resize(o.via.bin.size);
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
if (o.via.bin.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
case msgpack::type::STR:
v.resize(o.via.str.size);
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
if (o.via.str.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
default:
throw msgpack::type_error();
@@ -50,7 +68,9 @@ struct pack<std::vector<char, Alloc> > {
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.pack_bin(size);
o.pack_bin_body(&v.front(), size);
if (size != 0) {
o.pack_bin_body(&v.front(), size);
}
return o;
}
@@ -61,7 +81,9 @@ struct object<std::vector<char, Alloc> > {
void operator()(msgpack::object& o, const std::vector<char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
o.via.bin.ptr = &v.front();
if (size != 0) {
o.via.bin.ptr = &v.front();
}
o.via.bin.size = size;
}
};
@@ -71,10 +93,12 @@ struct object_with_zone<std::vector<char, Alloc> > {
void operator()(msgpack::object::with_zone& o, const std::vector<char, Alloc>& v) const {
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 = size;
std::memcpy(ptr, &v.front(), size);
if (size != 0) {
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
o.via.bin.ptr = ptr;
std::memcpy(ptr, &v.front(), size);
}
}
};

View File

@@ -30,11 +30,29 @@ struct convert<std::vector<unsigned char, Alloc> > {
switch (o.type) {
case msgpack::type::BIN:
v.resize(o.via.bin.size);
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
if (o.via.bin.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
case msgpack::type::STR:
v.resize(o.via.str.size);
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
if (o.via.str.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
default:
throw msgpack::type_error();
@@ -50,7 +68,9 @@ struct pack<std::vector<unsigned char, Alloc> > {
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<unsigned char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.pack_bin(size);
o.pack_bin_body(reinterpret_cast<char const*>(&v.front()), size);
if (size != 0) {
o.pack_bin_body(reinterpret_cast<char const*>(&v.front()), size);
}
return o;
}
@@ -61,7 +81,9 @@ struct object<std::vector<unsigned char, Alloc> > {
void operator()(msgpack::object& o, const std::vector<unsigned char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
o.via.bin.ptr = reinterpret_cast<char const*>(&v.front());
if (size != 0) {
o.via.bin.ptr = reinterpret_cast<char const*>(&v.front());
}
o.via.bin.size = size;
}
};
@@ -71,10 +93,12 @@ struct object_with_zone<std::vector<unsigned char, Alloc> > {
void operator()(msgpack::object::with_zone& o, const std::vector<unsigned char, Alloc>& v) const {
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 = size;
std::memcpy(ptr, &v.front(), size);
if (size != 0) {
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
o.via.bin.ptr = ptr;
std::memcpy(ptr, &v.front(), size);
}
}
};

View File

@@ -125,6 +125,7 @@ class zone {
::free(c);
c = n;
} else {
m_head = c;
break;
}
}

View File

@@ -23,7 +23,7 @@ extern "C" {
* @{
*/
static inline int msgpack_fbuffer_write(void* data, const char* buf, unsigned int len)
static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
{
return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
}

View File

@@ -29,10 +29,17 @@ namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond
/// The class holds object and zone
class object_handle {
public:
/// Constructor that creates nil object and null zone.
object_handle() {}
/// Constructor that creates an object_handle holding object `obj` and zone `z`.
/**
* @param obj object
* @param z zone
*/
object_handle(msgpack::object const& obj, msgpack::unique_ptr<msgpack::zone> z) :
m_obj(obj), m_zone(msgpack::move(z)) { }
@@ -40,12 +47,24 @@ public:
void set(msgpack::object const& obj)
{ m_obj = obj; }
/// Get object reference
/**
* @return object
*/
const msgpack::object& get() const
{ return m_obj; }
/// Get unique_ptr reference of zone.
/**
* @return unique_ptr reference of zone
*/
msgpack::unique_ptr<msgpack::zone>& zone()
{ return m_zone; }
/// Get unique_ptr const reference of zone.
/**
* @return unique_ptr const reference of zone
*/
const msgpack::unique_ptr<msgpack::zone>& zone() const
{ return m_zone; }
@@ -133,6 +152,14 @@ inline std::size_t aligned_zone_size(msgpack::object const& obj) {
return s;
}
/// clone object
/**
* Clone (deep copy) object.
* The copied object is located on newly allocated zone.
* @param obj copy source object
*
* @return object_handle that holds deep copied object and zone.
*/
inline object_handle clone(msgpack::object const& obj) {
std::size_t size = msgpack::aligned_zone_size(obj);
msgpack::unique_ptr<msgpack::zone> z(size == 0 ? nullptr : new msgpack::zone(size));
@@ -496,12 +523,14 @@ inline T& object::convert(T& v) const
return v;
}
#if !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
template <typename T>
inline T* object::convert(T* v) const
{
convert(*v);
return v;
}
#endif // !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
template <typename T>
inline bool object::convert_if_not_nil(T& v) const

View File

@@ -99,7 +99,10 @@ public:
#endif // !defined(MSGPACK_USE_CPP03)
/// Object class that corresponding to MessagePack format object
/**
* See https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_object
*/
struct object {
union union_type {
bool boolean;
@@ -119,42 +122,117 @@ struct object {
msgpack::type::object_type type;
union_type via;
/// Cheking nil
/**
* @return If the object is nil, then return true, else return false.
*/
bool is_nil() const { return type == msgpack::type::NIL; }
#if defined(MSGPACK_USE_CPP03)
/// Get value as T
/**
* If the object can't be converted to T, msgpack::type_error would be thrown.
* @tparam T The type you want to get.
* @return The converted object.
*/
template <typename T>
T as() const;
#else // defined(MSGPACK_USE_CPP03)
/// Get value as T
/**
* If the object can't be converted to T, msgpack::type_error would be thrown.
* @tparam T The type you want to get.
* @return The converted object.
*/
template <typename T>
typename std::enable_if<msgpack::has_as<T>::value, T>::type as() const;
/// Get value as T
/**
* If the object can't be converted to T, msgpack::type_error would be thrown.
* @tparam T The type you want to get.
* @return The converted object.
*/
template <typename T>
typename std::enable_if<!msgpack::has_as<T>::value, T>::type as() const;
#endif // defined(MSGPACK_USE_CPP03)
/// Convert the object
/**
* If the object can't be converted to T, msgpack::type_error would be thrown.
* @tparam T The type of v.
* @param v The value you want to get. `v` is output parameter. `v` is overwritten by converted value from the object.
* @return The reference of `v`.
*/
template <typename T>
T& convert(T& v) const;
#if !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
/// Convert the object (obsolete)
/**
* If the object can't be converted to T, msgpack::type_error would be thrown.
* @tparam T The type of v.
* @param v The pointer of the value you want to get. `v` is output parameter. `*v` is overwritten by converted value from the object.
* @return The pointer of `v`.
*/
template <typename T>
T* convert(T* v) const;
#endif // !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
/// Convert the object if not nil
/**
* If the object is not nil and can't be converted to T, msgpack::type_error would be thrown.
* @tparam T The type of v.
* @param v The value you want to get. `v` is output parameter. `v` is overwritten by converted value from the object if the object is not nil.
* @return If the object is nil, then return false, else return true.
*/
template <typename T>
bool convert_if_not_nil(T& v) const;
/// Default constructor. The object is set to nil.
object();
/// Copy constructor. Object is shallow copied.
object(const msgpack_object& o);
/// Construct object from T
/**
* If `v` is the type that is corresponding to MessegePack format str, bin, ext, array, or map,
* you need to call `object(const T& v, msgpack::zone& z)` instead of this constructor.
*
* @tparam T The type of `v`.
* @param v The value you want to convert.
*/
template <typename T>
explicit object(const T& v);
/// Construct object from T
/**
* The object is constructed on the zone `z`.
* See https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_object
*
* @tparam T The type of `v`.
* @param v The value you want to convert.
* @param z The zone that is used by the object.
*/
template <typename T>
object(const T& v, msgpack::zone& z);
// obsolete
/// Construct object from T (obsolete)
/**
* The object is constructed on the zone `z`.
* Use `object(const T& v, msgpack::zone& z)` instead of this constructor.
* See https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_object
*
* @tparam T The type of `v`.
* @param v The value you want to convert.
* @param z The pointer to the zone that is used by the object.
*/
template <typename T>
object(const T& v, msgpack::zone* z);
@@ -180,7 +258,7 @@ struct object_kv {
};
struct object::with_zone : object {
with_zone(msgpack::zone& zone) : zone(zone) { }
with_zone(msgpack::zone& z) : zone(z) { }
msgpack::zone& zone;
private:
with_zone();

View File

@@ -26,68 +26,566 @@ namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond
/// The class template that supports continuous packing.
/**
* @tparam Stream Any type that have a member function `Stream write(const char*, size_t s)`
*
*/
template <typename Stream>
class packer {
public:
/// Constructor
/**
* This constructor is left for compatibility.
* Use `packer(Stream* s)` instead of the constructor.
*
* @param s A pointer to packing destination stream object.
*/
packer(Stream* s);
/// Constructor
/**
* @param s Packing destination stream object.
*/
packer(Stream& s);
public:
/// Packing function template
/**
* @tparam T The type of packing object.
*
* @param v a packing object.
*
* @return The reference of `*this`.
*/
template <typename T>
packer<Stream>& pack(const T& v);
/// Packing uint8
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum or uint8.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_uint8(uint8_t d);
/// Packing uint16
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, uint8 or uint16.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_uint16(uint16_t d);
/// Packing uint32
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, uint8, uint16 or uint32.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_uint32(uint32_t d);
/// Packing uint16
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, uint8, uint16, uint32 or uint64.
* The minimum byte size expression is used.
* positive fixnum, uint8, uint16, or uint32 is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_uint64(uint64_t d);
/// Packing int8
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, or uint8,
* else the packed type is negative fixnum, or int8
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_int8(int8_t d);
/// Packing int16
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, uint8, or uint16,
* else the packed type is negative fixnum, int8, or int16.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_int16(int16_t d);
/// Packing int32
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, uint8, uint16, or uint32,
* else the packed type is negative fixnum, int8, int16, or int32.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_int32(int32_t d);
/// Packing int32
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, uint8, uint16, uint32, or uint64,
* else the packed type is negative fixnum, int8, int16, int32, or int64.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_int64(int64_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always uint8.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_uint8(uint8_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always uint16.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_uint16(uint16_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always uint32.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_uint32(uint32_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always uint64.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_uint64(uint64_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always int8.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_int8(int8_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always int16.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_int16(int16_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always int32.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_int32(int32_t d);
/// Packing uint8 (fixed packed type).
/**
* The packed type is always int64.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_fix_int64(int64_t d);
/// Packing char
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, or uint*,
* else the packed type is negative fixnum, or int*
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_char(char d);
/// Packing signed char
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, or uint*,
* else the packed type is negative fixnum, or int*
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_signed_char(signed char d);
/// Packing short
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, or uint*,
* else the packed type is negative fixnum, or int*
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_short(short d);
/// Packing int
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, or uint*,
* else the packed type is negative fixnum, or int*
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_int(int d);
/// Packing long
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, or uint*,
* else the packed type is negative fixnum, or int*
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_long(long d);
/// Packing long long
/**
* The byte size of the packed data depends on `d`.
* If `d` is zero or positive, the packed type is positive fixnum, or uint*,
* else the packed type is negative fixnum, or int*
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_long_long(long long d);
/// Packing unsigned char
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, or uint*.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_unsigned_char(unsigned char d);
/// Packing unsigned short
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, or uint*.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_unsigned_short(unsigned short d);
/// Packing unsigned int
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, or uint*.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_unsigned_int(unsigned int d);
/// Packing unsigned long
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, or uint*.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_unsigned_long(unsigned long d);
/// Packing unsigned long long
/**
* The byte size of the packed data depends on `d`.
* The packed type is positive fixnum, or uint*.
* The minimum byte size expression is used.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-int
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_unsigned_long_long(unsigned long long d);
/// Packing float
/**
* The packed type is float32.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-float
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_float(float d);
/// Packing double
/**
* The packed type is float64.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-float
*
* @param d a packing object.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_double(double d);
/// Packing nil
/**
* The packed type is nil.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-nil
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_nil();
/// Packing true
/**
* The packed type is bool, value is true.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#bool-format-family
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_true();
/// Packing false
/**
* The packed type is bool, value is false.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#bool-format-family
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_false();
/// Packing array header and size
/**
* The packed type is array header and array size.
* You need to pack `n` msgpack objects following this header and size.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#array-format-family
*
* @param n The number of array elements (array size).
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_array(uint32_t n);
/// Packing map header and size
/**
* The packed type is map header and map size.
* You need to pack `n` pairs of msgpack objects following this header and size.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#map-format-family
*
* @param n The number of array elements (array size).
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_map(uint32_t n);
/// Packing str header and length
/**
* The packed type is str header and length.
* The minimum byte size length expression is used.
* You need to call `pack_str_body(const char* b, uint32_t l)` after this function calling with the same `l` value.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_str(uint32_t l);
/// Packing str body
/**
* You need to call this function just after `pack_str(uint32_t l)` calling.
* The value `l` should be the same as `pack_str(uint32_t l)` argument `l`.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_str_body(const char* b, uint32_t l);
// v4
/// Packing raw (v4) header and length
/**
* The packed type is raw header and length.
* The minimum byte size length expression is used.
* The format raw (v4) is old MessagePack version4 format.
* You need to call `pack_v4raw_body(const char* b, uint32_t l)` after this function calling with the same `l` value.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_v4raw(uint32_t l);
/// Packing raw (v4) body
/**
* The format raw (v4) is old MessagePack version4 format.
* You need to call this function just after `pack_v4raw(uint32_t l)` calling.
* The value `l` should be the same as `pack_v4raw(uint32_t l)` argument `l`.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-str
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_v4raw_body(const char* b, uint32_t l);
/// Packing bin header and length
/**
* The packed type is bin header and length.
* The minimum byte size length expression is used.
* You need to call `pack_bin_body(const char* b, uint32_t l)` after this function calling with the same `l` value.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_bin(uint32_t l);
/// Packing bin body
/**
* You need to call this function just after `pack_bin(uint32_t l)` calling.
* The value `l` should be the same as `pack_bin(uint32_t l)` argument `l`.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_bin_body(const char* b, uint32_t l);
/// Packing ext header, type, and length
/**
* The packed type is ext.
* The minimum byte size length expression is used.
* The length 1, 2, 4, 8, and 16 can be encoded in the header.
* You need to call `pack_ext_body(const char* b, uint32_t l)` after this function calling with the same `l` value.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#formats-ext
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_ext(size_t l, int8_t type);
/// Packing ext body
/**
* You need to call this function just after `pack_ext(size_t l, int8_t type)` calling.
* The value `l` should be the same as `pack_ext(size_t l, int8_t type)` argument `l`.
* See https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family
*
* @param l The length of string.
*
* @return The reference of `*this`.
*/
packer<Stream>& pack_ext_body(const char* b, uint32_t l);
private:
@@ -128,12 +626,29 @@ public:
};
/// Pack the value as MessagePack format into the stream
/**
* This function template is left for compatibility.
* Use `void pack(Stream& s, const T& v)` instead of the function template.
*
* @tparam Stream Any type that have a member function `Stream write(const char*, size_t s)`
* @tparam T Any type that is adapted to MessagePack
* @param s The pointer to packing destination stream
* @param v Packing value
*/
template <typename Stream, typename T>
inline void pack(Stream* s, const T& v)
{
packer<Stream>(*s).pack(v);
}
/// Pack the value as MessagePack format into the stream
/**
* @tparam Stream Any type that have a member function `Stream write(const char*, size_t s)`
* @tparam T Any type that is adapted to MessagePack
* @param s Packing destination stream
* @param v Packing value
*/
template <typename Stream, typename T>
inline void pack(Stream& s, const T& v)
{

View File

@@ -78,7 +78,7 @@
#endif
#ifdef MSGPACK_ENDIAN_LITTLE_BYTE
#if MSGPACK_ENDIAN_LITTLE_BYTE
# ifdef _WIN32
# if defined(ntohs)
@@ -186,4 +186,8 @@
# define inline __inline
#endif
#ifdef __APPLE__
# include <TargetConditionals.h>
#endif
#endif /* msgpack/sysdep.h */

View File

@@ -60,7 +60,18 @@ namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond
typedef bool (*unpack_reference_func)(msgpack::type::object_type, std::size_t, void*);
/// The type of reference or copy judging function.
/**
* @param type msgpack data type.
* @param size msgpack data size.
* @param user_data The user_data that is set by msgpack::unpack functions.
*
* @return If the data should be referenced, then return true, otherwise (should be copied) false.
*
* This function is called when unpacking STR, BIN, or EXT.
*
*/
typedef bool (*unpack_reference_func)(msgpack::type::object_type type, std::size_t size, void* user_data);
struct unpack_error : public std::runtime_error {
explicit unpack_error(const std::string& msg)
@@ -985,11 +996,21 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
typedef object_handle unpacked;
/// Unpacking class for a stream deserialization.
class unpacker {
public:
/// Constructor
/**
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param initial_buffer_size The memory size to allocate when unpacker is constructed.
* @param limit The size limit information of msgpack::object.
*
*/
unpacker(unpack_reference_func f = &unpacker::default_reference_func,
void* user_data = nullptr,
std::size_t init_buffer_size = MSGPACK_UNPACKER_INIT_BUFFER_SIZE,
std::size_t initial_buffer_size = MSGPACK_UNPACKER_INIT_BUFFER_SIZE,
unpack_limit const& limit = unpack_limit());
#if !defined(MSGPACK_USE_CPP03)
@@ -1000,60 +1021,97 @@ public:
~unpacker();
public:
/*! 1. reserve buffer. at least `size' bytes of capacity will be ready */
/// Reserve a buffer memory.
/**
* @param size The size of allocating memory.
*
* After returning this function, buffer_capacity() returns at least 'size'.
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
void reserve_buffer(std::size_t size = MSGPACK_UNPACKER_RESERVE_SIZE);
/*! 2. read data to the buffer() up to buffer_capacity() bytes */
/// Get buffer pointer.
/**
* You need to care about the memory is enable between buffer() and buffer() + buffer_capacity()
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
char* buffer();
/// Get buffer capacity.
/**
* @return The memory size that you can write.
*
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
std::size_t buffer_capacity() const;
/*! 3. specify the number of bytes actually copied */
/// Notify a buffer consumed information to msgpack::unpacker.
/**
* @param size The size of memory that you consumed.
*
* After copying the data to the memory that is pointed by buffer(), you need to call the
* function to notify how many bytes are consumed. Then you can call next() functions.
*
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
void buffer_consumed(std::size_t size);
/*! 4. repeat next() until it retunrs false */
/// Unpack one msgpack::object. [obsolete]
/**
*
* @param result The object that contains unpacked data.
*
* @return If one msgpack::object is unpacked, then return true, if msgpack::object is incomplete
* and additional data is required, then return false. If data format is invalid, throw
* msgpack::parse_error.
*
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
* This function is obsolete. Use the reference inteface version of next() function instead of
* the pointer interface version.
*/
bool next(unpacked* result);
/// Unpack one msgpack::object.
/**
*
* @param result The object that contains unpacked data.
* @param referenced If the unpacked object contains reference of the buffer,
* then set as true, otherwise false.
*
* @return If one msgpack::object is unpacked, then return true, if msgpack::object is incomplete
* and additional data is required, then return false. If data format is invalid, throw
* msgpack::parse_error.
*
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
bool next(unpacked& result, bool& referenced);
/// Unpack one msgpack::object.
/**
*
* @param result The object that contains unpacked data.
*
* @return If one msgpack::object is unpacked, then return true, if msgpack::object is incomplete
* and additional data is required, then return false. If data format is invalid, throw
* msgpack::parse_error.
*
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
bool next(unpacked& result);
/*! 5. check if the size of message doesn't exceed assumption. */
/// Get message size.
/**
* @return Returns parsed_size() + nonparsed_size()
*/
std::size_t message_size() const;
// Basic usage of the unpacker is as following:
//
// unpacker pac;
// while( /* input is readable */ ) {
//
// // 1.
// pac.reserve_buffer(32*1024);
//
// // 2.
// std::size_t bytes = input.readsome(pac.buffer(), pac.buffer_capacity());
//
// // error handling ...
//
// // 3.
// pac.buffer_consumed(bytes);
//
// // 4.
// unpacked result;
// while(pac.next(&result)) {
// // do some with the object with the zone.
// object obj = result.get();
// std::auto_ptr<msgpack:zone> z = result.zone();
// on_message(obj, z);
//
// //// boost::shared_ptr is also usable:
// // boost::shared_ptr<zone> life(z.release());
// // on_message(result.get(), life);
// }
//
// // 5.
// if(pac.message_size() > 10*1024*1024) {
// throw std::runtime_error("message is too large");
// }
// }
//
/*! for backward compatibility */
bool execute();
@@ -1070,20 +1128,48 @@ public:
void reset();
public:
// These functions are usable when non-MessagePack message follows after
// MessagePack message.
/// Get parsed message size.
/**
* @return Parsed message size.
*
* This function is usable when non-MessagePack message follows after
* MessagePack message.
*/
std::size_t parsed_size() const;
/*! get address of the buffer that is not parsed */
/// Get the address that is not parsed in the buffer.
/**
* @return Address of the buffer that is not parsed
*
* This function is usable when non-MessagePack message follows after
* MessagePack message.
*/
char* nonparsed_buffer();
/// Get the size of the buffer that is not parsed.
/**
* @return Size of the buffer that is not parsed
*
* This function is usable when non-MessagePack message follows after
* MessagePack message.
*/
std::size_t nonparsed_size() const;
/*! skip specified size of non-parsed buffer, leaving the buffer */
// Note that the `size' argument must be smaller than nonparsed_size()
/// Skip the specified size of non-parsed buffer.
/**
* @param size to skip
*
* Note that the `size' argument must be smaller than nonparsed_size().
* This function is usable when non-MessagePack message follows after
* MessagePack message.
*/
void skip_nonparsed_buffer(std::size_t size);
/*! remove unparsed buffer from unpacker */
// Note that reset() leaves non-parsed buffer.
/// Remove nonparsed buffer and reset the current position as a new start point.
/**
* This function is usable when non-MessagePack message follows after
* MessagePack message.
*/
void remove_nonparsed_buffer();
private:
@@ -1112,57 +1198,213 @@ private:
#endif // defined(MSGPACK_USE_CPP03)
};
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return unpacked object that contains unpacked data.
*
*/
unpacked unpack(
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return unpacked object that contains unpacked data.
*
*/
unpacked unpack(
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return unpacked object that contains unpacked data.
*
*/
unpacked unpack(
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return unpacked object that contains unpacked data.
*
*/
unpacked unpack(
const char* data, std::size_t len,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(unpacked& result,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(unpacked& result,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(unpacked& result,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(unpacked& result,
const char* data, std::size_t len,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr,
unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len,
@@ -1170,7 +1412,19 @@ msgpack::object unpack(
unpack_limit const& limit = unpack_limit());
// obsolete
/// Unpack msgpack::object from a buffer. [obsolete]
/**
* @param result The object that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* This function is obsolete. Use the reference inteface version of unpack functions instead of the pointer interface version.
*/
void unpack(unpacked* result,
const char* data, std::size_t len, std::size_t* off = nullptr, bool* referenced = nullptr,
unpack_reference_func f = nullptr, void* user_data = nullptr,

View File

@@ -1,3 +1,3 @@
#define MSGPACK_VERSION_MAJOR 1
#define MSGPACK_VERSION_MINOR 3
#define MSGPACK_VERSION_REVISION 0
#define MSGPACK_VERSION_MINOR 4
#define MSGPACK_VERSION_REVISION 2

View File

@@ -6,5 +6,5 @@ includedir=@includedir@
Name: MessagePack
Description: Binary-based efficient object serialization library
Version: @VERSION@
Libs: -L${libdir} -lmsgpack
Libs: -L${libdir} -lmsgpackc
Cflags: -I${includedir}

View File

@@ -1,25 +1,14 @@
lib_LTLIBRARIES = libmsgpack.la
# For C++
#
# The C++ parts of msgpack-c is a header only library,
# so there is no libraries.
AM_CPPFLAGS = -I../include
# For C
libmsgpack_la_SOURCES = \
unpack.c \
objectc.c \
version.c \
vrefbuffer.c \
zone.c
lib_LTLIBRARIES = libmsgpackc.la
if ENABLE_GCC_CXX_ATOMIC
CXXFLAGS="$CXXFLAGS -DENABLE_GCC_CXX_ATOMIC"
endif
# -version-info CURRENT:REVISION:AGE
libmsgpack_la_LDFLAGS = -version-info 4:0:0 -no-undefined
# backward compatibility
lib_LTLIBRARIES += libmsgpackc.la
#AM_CPPFLAGS = -I../include
AM_CFLAGS = -I../include
libmsgpackc_la_SOURCES = \
unpack.c \
@@ -28,6 +17,7 @@ libmsgpackc_la_SOURCES = \
vrefbuffer.c \
zone.c
# -version-info CURRENT:REVISION:AGE
libmsgpackc_la_LDFLAGS = -version-info 2:0:0 -no-undefined

View File

@@ -74,7 +74,7 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
while(sz < size) {
size_t tmp_sz = sz * 2;
if (tmp_sz <= sz) {
tmp_sz = size;
sz = size;
break;
}
sz = tmp_sz;

View File

@@ -56,9 +56,9 @@ IF (MSGPACK_CXX11)
ENDIF ()
IF (MSGPACK_ENABLE_SHARED)
SET (MSGPACK_TEST_LIB msgpack)
SET (MSGPACK_TEST_LIB msgpackc)
ELSE ()
SET (MSGPACK_TEST_LIB msgpack-static)
SET (MSGPACK_TEST_LIB msgpackc-static)
ENDIF ()
FOREACH (source_file ${check_PROGRAMS})
@@ -75,8 +75,19 @@ FOREACH (source_file ${check_PROGRAMS})
)
ADD_TEST (${source_file_we} ${source_file_we})
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -Wno-mismatched-tags -g -O3")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 ")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4] /WX")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

View File

@@ -1,6 +1,6 @@
AM_CPPFLAGS = -I$(top_srcdir)/include -pthread
AM_CPPFLAGS = -I$(top_srcdir)/include -pthread -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT
AM_C_CPPFLAGS = -I$(top_srcdir)/include -pthread
AM_LDFLAGS = $(top_builddir)/src/libmsgpack.la -lgtest_main -lgtest -lpthread
AM_LDFLAGS = $(top_builddir)/src/libmsgpackc.la -lgtest_main -lgtest -lpthread
check_PROGRAMS = \
array_ref \

View File

@@ -26,7 +26,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_char)
std::vector<char> v2;
msgpack::type::array_ref<std::vector<char> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_char_const)
@@ -48,7 +48,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_char_const)
std::vector<char> v2;
msgpack::type::array_ref<std::vector<char> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_unsigned_char)
@@ -68,7 +68,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_unsigned_char)
std::vector<unsigned char> v2;
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_unsigned_char_const)
@@ -90,7 +90,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_unsigned_char_const)
std::vector<unsigned char> v2;
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_char)
@@ -108,7 +108,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_char)
std::vector<char> v2;
msgpack::type::array_ref<std::vector<char> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_char_const)
@@ -128,7 +128,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_char_const)
std::vector<char> v2;
msgpack::type::array_ref<std::vector<char> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_unsigned_char)
@@ -146,7 +146,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_unsigned_char)
std::vector<unsigned char> v2;
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_unsigned_char_const)
@@ -166,7 +166,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_vector_unsigned_char_const)
std::vector<unsigned char> v2;
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
#if !defined(MSGPACK_USE_CPP03)
@@ -185,7 +185,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_char)
std::array<char, 3> v2;
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_char_const)
@@ -204,7 +204,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_char_const)
std::array<char, 3> v2;
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_unsigned_char)
@@ -221,7 +221,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_unsigned_char)
std::array<unsigned char, 3> v2;
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_unsigned_char_const)
@@ -240,7 +240,7 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_unsigned_char_const)
std::array<unsigned char, 3> v2;
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
upd.get().convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_array_char)
@@ -255,7 +255,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_array_char)
std::array<char, 3> v2;
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_array_char_const)
@@ -272,7 +272,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_array_char_const)
std::array<char, 3> v2;
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_array_unsigned_char)
@@ -287,7 +287,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_array_unsigned_char)
std::array<unsigned char, 3> v2;
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
TEST(MSGPACK_ARRAY_REF, object_with_zone_array_unsigned_char_const)
@@ -304,7 +304,7 @@ TEST(MSGPACK_ARRAY_REF, object_with_zone_array_unsigned_char_const)
std::array<unsigned char, 3> v2;
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
obj.convert(ar2);
EXPECT_EQ(ar1, ar2);
EXPECT_TRUE(ar1 == ar2);
}
#endif // !defined(MSGPACK_USE_CPP03)

View File

@@ -17,7 +17,7 @@ const double kEPS = 1e-10;
TEST(MSGPACK_BOOST, pack_convert_variant_nil)
{
std::stringstream ss;
msgpack::type::variant val1 = msgpack::type::nil();
msgpack::type::variant val1 = msgpack::type::nil_t();
EXPECT_TRUE(val1.is_nil());
msgpack::pack(ss, val1);
@@ -25,28 +25,28 @@ TEST(MSGPACK_BOOST, pack_convert_variant_nil)
msgpack::unpack(ret, ss.str().data(), ss.str().size());
msgpack::type::variant val2 = ret.get().as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_nil());
EXPECT_NO_THROW(boost::get<msgpack::type::nil>(val2));
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
}
TEST(MSGPACK_BOOST, object_variant_nil)
{
msgpack::type::variant val1 = msgpack::type::nil();
msgpack::type::variant val1 = msgpack::type::nil_t();
EXPECT_TRUE(val1.is_nil());
msgpack::object obj(val1);
msgpack::type::variant val2 = obj.as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_nil());
EXPECT_NO_THROW(boost::get<msgpack::type::nil>(val2));
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
}
TEST(MSGPACK_BOOST, object_with_zone_variant_nil)
{
msgpack::zone z;
msgpack::type::variant val1 = msgpack::type::nil();
msgpack::type::variant val1 = msgpack::type::nil_t();
EXPECT_TRUE(val1.is_nil());
msgpack::object obj(val1, z);
msgpack::type::variant val2 = obj.as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_nil());
EXPECT_NO_THROW(boost::get<msgpack::type::nil>(val2));
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
}
// nil (default constructor)
@@ -63,7 +63,7 @@ TEST(MSGPACK_BOOST, pack_convert_variant_nil_default)
msgpack::unpack(ret, ss.str().data(), ss.str().size());
msgpack::type::variant val2 = ret.get().as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_nil());
EXPECT_NO_THROW(boost::get<msgpack::type::nil>(val2));
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
}
TEST(MSGPACK_BOOST, object_variant_nil_default)
@@ -73,7 +73,7 @@ TEST(MSGPACK_BOOST, object_variant_nil_default)
msgpack::object obj(val1);
msgpack::type::variant val2 = obj.as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_nil());
EXPECT_NO_THROW(boost::get<msgpack::type::nil>(val2));
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
}
TEST(MSGPACK_BOOST, object_with_zone_variant_nil_default)
@@ -84,7 +84,7 @@ TEST(MSGPACK_BOOST, object_with_zone_variant_nil_default)
msgpack::object obj(val1, z);
msgpack::type::variant val2 = obj.as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_nil());
EXPECT_NO_THROW(boost::get<msgpack::type::nil>(val2));
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
}
// bool
@@ -147,7 +147,7 @@ TEST(MSGPACK_BOOST, pack_convert_variant_positive_integer)
std::stringstream ss;
msgpack::type::variant val1 = 123;
EXPECT_TRUE(val1.is_uint64_t());
EXPECT_EQ(val1.as_uint64_t(), 123);
EXPECT_EQ(val1.as_uint64_t(), 123U);
msgpack::pack(ss, val1);
@@ -155,7 +155,7 @@ TEST(MSGPACK_BOOST, pack_convert_variant_positive_integer)
msgpack::unpack(ret, ss.str().data(), ss.str().size());
msgpack::type::variant val2 = ret.get().as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_uint64_t());
EXPECT_EQ(val2.as_uint64_t(), 123);
EXPECT_EQ(val2.as_uint64_t(), 123U);
EXPECT_NO_THROW(boost::get<uint64_t>(val2));
EXPECT_TRUE(val1 == val2);
}
@@ -164,11 +164,11 @@ TEST(MSGPACK_BOOST, object_variant_positive_integer)
{
msgpack::type::variant val1 = 123;
EXPECT_TRUE(val1.is_uint64_t());
EXPECT_EQ(val1.as_uint64_t(), 123);
EXPECT_EQ(val1.as_uint64_t(), 123U);
msgpack::object obj(val1);
msgpack::type::variant val2 = obj.as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_uint64_t());
EXPECT_EQ(val2.as_uint64_t(), 123);
EXPECT_EQ(val2.as_uint64_t(), 123U);
EXPECT_NO_THROW(boost::get<uint64_t>(val2));
EXPECT_TRUE(val1 == val2);
}
@@ -178,11 +178,11 @@ TEST(MSGPACK_BOOST, object_with_zone_variant_positive_integer)
msgpack::zone z;
msgpack::type::variant val1 = 123;
EXPECT_TRUE(val1.is_uint64_t());
EXPECT_EQ(val1.as_uint64_t(), 123);
EXPECT_EQ(val1.as_uint64_t(), 123U);
msgpack::object obj(val1, z);
msgpack::type::variant val2 = obj.as<msgpack::type::variant>();
EXPECT_TRUE(val2.is_uint64_t());
EXPECT_EQ(val2.as_uint64_t(), 123);
EXPECT_EQ(val2.as_uint64_t(), 123U);
EXPECT_NO_THROW(boost::get<uint64_t>(val2));
EXPECT_TRUE(val1 == val2);
}

View File

@@ -33,10 +33,10 @@ TEST(convert, compatibility_less)
src[0] = "kumofs";
msgpack::zone z;
msgpack::object obj(src, &z);
msgpack::object obj(src, z);
compatibility c;
EXPECT_NO_THROW( obj.convert(&c) );
EXPECT_NO_THROW( obj.convert(c) );
EXPECT_EQ("kumofs", c.str1);
EXPECT_EQ("default", c.str2);
@@ -50,10 +50,10 @@ TEST(convert, compatibility_more)
src[2] = "cloudy";
msgpack::zone z;
msgpack::object obj(src, &z);
msgpack::object obj(src, z);
compatibility to;
EXPECT_NO_THROW( obj.convert(&to) );
EXPECT_NO_THROW( obj.convert(to) );
EXPECT_EQ("kumofs", to.str1);
EXPECT_EQ("mpio", to.str2);
@@ -65,24 +65,14 @@ TEST(convert, enum_member)
src.flag = enum_member::B;
msgpack::zone z;
msgpack::object obj(src, &z);
msgpack::object obj(src, z);
enum_member to;
EXPECT_NO_THROW( obj.convert(&to) );
EXPECT_NO_THROW( obj.convert(to) );
EXPECT_EQ(enum_member::B, to.flag);
}
TEST(convert, return_value_ptr)
{
msgpack::zone z;
msgpack::object obj(1, z);
int i;
EXPECT_EQ(obj.convert(&i), &i);
EXPECT_EQ(1, i);
}
TEST(convert, return_value_ref)
{
msgpack::zone z;
@@ -94,6 +84,20 @@ TEST(convert, return_value_ref)
EXPECT_EQ(i, j);
}
#if !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
TEST(convert, return_value_ptr)
{
msgpack::zone z;
msgpack::object obj(1, z);
int i;
EXPECT_EQ(obj.convert(&i), &i);
EXPECT_EQ(1, i);
}
#endif // !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
TEST(convert, if_not_nil_nil)
{
msgpack::object obj;

View File

@@ -33,7 +33,7 @@ void check_convert() {
msgpack::unpack(&msg, sbuf.data(), sbuf.size());
T v2;
msg.get().convert(&v2);
msg.get().convert(v2);
EXPECT_EQ(v1.get(), v2.get());
@@ -52,4 +52,3 @@ TEST(fixint, convert)
check_convert<msgpack::type::fix_uint32>();
check_convert<msgpack::type::fix_uint64>();
}

View File

@@ -408,7 +408,7 @@ TEST(MSGPACK, simple_buffer_fixext_1byte_255)
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (int i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
@@ -426,7 +426,7 @@ TEST(MSGPACK, simple_buffer_fixext_2byte_256)
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (int i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));
@@ -444,7 +444,7 @@ TEST(MSGPACK, simple_buffer_fixext_2byte_65535)
msgpack::sbuffer sbuf;
msgpack::packer<msgpack::sbuffer> packer(sbuf);
char buf[size];
for (int i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
for (std::size_t i = 0; i != size; ++i) buf[i] = static_cast<char>(i);
packer.pack_ext(sizeof(buf), 77);
packer.pack_ext_body(buf, sizeof(buf));

View File

@@ -521,7 +521,7 @@ TEST(MSGPACKC, simple_buffer_fixext_1byte_255)
{
const size_t size = 255;
char buf[size];
for (int i = 0; i != size; ++i) buf[i] = i;
for (size_t i = 0; i != size; ++i) buf[i] = i;
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
@@ -548,7 +548,7 @@ TEST(MSGPACKC, simple_buffer_fixext_2byte_256)
{
const size_t size = 256;
char buf[size];
for (int i = 0; i != size; ++i) buf[i] = i;
for (size_t i = 0; i != size; ++i) buf[i] = i;
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
@@ -575,7 +575,7 @@ TEST(MSGPACKC, simple_buffer_fixext_2byte_65535)
{
const size_t size = 65535;
char buf[size];
for (int i = 0; i != size; ++i) buf[i] = i;
for (size_t i = 0; i != size; ++i) buf[i] = i;
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
@@ -602,7 +602,7 @@ TEST(MSGPACKC, simple_buffer_fixext_4byte_65536)
{
const size_t size = 65536;
char buf[size];
for (int i = 0; i != size; ++i) buf[i] = i;
for (size_t i = 0; i != size; ++i) buf[i] = i;
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);

View File

@@ -54,6 +54,20 @@ TEST(MSGPACK_STL, simple_buffer_vector)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_empty)
{
typedef vector<int, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::ARRAY);
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_vector_char)
{
typedef vector<char, test::allocator<char> > type;
@@ -72,6 +86,20 @@ TEST(MSGPACK_STL, simple_buffer_vector_char)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_char_empty)
{
typedef vector<char, test::allocator<char> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::BIN);
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_vector_unsigned_char)
{
typedef vector<unsigned char, test::allocator<unsigned char> > type;
@@ -90,6 +118,20 @@ TEST(MSGPACK_STL, simple_buffer_vector_unsigned_char)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_unsigned_char_empty)
{
typedef vector<unsigned char, test::allocator<unsigned char> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::BIN);
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_vector_uint8_t)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
@@ -109,6 +151,21 @@ TEST(MSGPACK_STL, simple_buffer_vector_uint8_t)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_uint8_t_empty)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
typedef vector<uint8_t, test::allocator<uint8_t> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::BIN);
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_vector_bool)
{
typedef vector<bool, test::allocator<bool> > type;
@@ -125,6 +182,20 @@ TEST(MSGPACK_STL, simple_buffer_vector_bool)
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_vector_bool_empty)
{
typedef vector<bool, test::allocator<bool> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::ARRAY);
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_assoc_vector)
{
@@ -144,9 +215,22 @@ TEST(MSGPACK_STL, simple_buffer_assoc_vector)
}
}
TEST(MSGPACK_STL, simple_buffer_assoc_vector_empty)
{
typedef msgpack::type::assoc_vector<int, int, test::less<int>, test::allocator<std::pair<int, int> > >type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_map)
{
typedef map<int, int, test::less<int>, test::allocator<std::pair<int, int> > > type;
typedef map<int, int, test::less<int>, test::allocator<std::pair<const int, int> > > type;
for (unsigned int k = 0; k < kLoop; k++) {
type val1;
for (unsigned int i = 0; i < kElements; i++)
@@ -161,6 +245,19 @@ TEST(MSGPACK_STL, simple_buffer_map)
}
}
TEST(MSGPACK_STL, simple_buffer_map_empty)
{
typedef map<int, int, test::less<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_deque)
{
typedef deque<int, test::allocator<int> > type;
@@ -178,6 +275,19 @@ TEST(MSGPACK_STL, simple_buffer_deque)
}
}
TEST(MSGPACK_STL, simple_buffer_deque_empty)
{
typedef deque<int, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_list)
{
typedef list<int, test::allocator<int> > type;
@@ -195,6 +305,19 @@ TEST(MSGPACK_STL, simple_buffer_list)
}
}
TEST(MSGPACK_STL, simple_buffer_list_empty)
{
typedef list<int, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type const& val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_set)
{
typedef set<int, test::less<int>, test::allocator<int> > type;
@@ -212,6 +335,19 @@ TEST(MSGPACK_STL, simple_buffer_set)
}
}
TEST(MSGPACK_STL, simple_buffer_set_empty)
{
typedef set<int, test::less<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_pair)
{
for (unsigned int k = 0; k < kLoop; k++) {
@@ -228,7 +364,7 @@ TEST(MSGPACK_STL, simple_buffer_pair)
TEST(MSGPACK_STL, simple_buffer_multimap)
{
typedef multimap<int, int, test::less<int>, test::allocator<std::pair<int, int> > > type;
typedef multimap<int, int, test::less<int>, test::allocator<std::pair<const int, int> > > type;
for (unsigned int k = 0; k < kLoop; k++) {
type val1;
for (unsigned int i = 0; i < kElements; i++) {
@@ -256,6 +392,18 @@ TEST(MSGPACK_STL, simple_buffer_multimap)
}
}
TEST(MSGPACK_STL, simple_buffer_multimap_empty)
{
typedef multimap<int, int, test::less<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_STL, simple_buffer_multiset)
{
typedef multiset<int, test::less<int>, test::allocator<int> > type;
@@ -283,6 +431,18 @@ TEST(MSGPACK_STL, simple_buffer_multiset)
}
}
TEST(MSGPACK_STL, simple_buffer_multiset_empty)
{
typedef multiset<int, test::less<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TUPLE, simple_tuple)
{
msgpack::sbuffer sbuf;
@@ -350,9 +510,21 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_map)
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_map_empty)
{
typedef tr1::unordered_map<int, int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multimap)
{
typedef tr1::unordered_multimap<int, int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<std::pair<int, int> > > type;
typedef tr1::unordered_multimap<int, int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
for (unsigned int k = 0; k < kLoop; k++) {
type val1;
for (unsigned int i = 0; i < kElements; i++) {
@@ -379,6 +551,19 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multimap)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multimap_empty)
{
typedef tr1::unordered_multimap<int, int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif
#ifdef MSGPACK_HAS_STD_TR1_UNORDERED_SET
@@ -403,6 +588,18 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_set)
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_set_empty)
{
typedef tr1::unordered_set<int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multiset)
{
typedef tr1::unordered_multiset<int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<int> > type;
@@ -429,6 +626,19 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multiset)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multiset_empty)
{
typedef tr1::unordered_multiset<int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif
#if defined (MSGPACK_HAS_STD_UNORDERED_MAP) || defined (MSGPACK_HAS_STD_UNORDERED_SET)
@@ -469,6 +679,18 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_map)
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_map_empty)
{
typedef unordered_map<int, int, test::hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multimap)
{
typedef unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
@@ -498,6 +720,19 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_multimap)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multimap_empty)
{
typedef unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif
#ifdef MSGPACK_HAS_STD_UNORDERED_SET
@@ -523,6 +758,18 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_set)
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_set_empty)
{
typedef unordered_set<int, test::hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multiset)
{
typedef unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::allocator<int> > type;
@@ -549,4 +796,17 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_multiset)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multiset_empty)
{
typedef unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif

View File

@@ -76,6 +76,19 @@ TEST(MSGPACK_CPP11, simple_array)
}
}
TEST(MSGPACK_CPP11, simple_array_empty)
{
array<int, 0> val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::ARRAY);
array<int, 0> val2 = ret.get().as<array<int, 0> >();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_CPP11, simple_buffer_array_char)
{
for (unsigned int k = 0; k < kLoop; k++) {
@@ -93,6 +106,19 @@ TEST(MSGPACK_CPP11, simple_buffer_array_char)
}
}
TEST(MSGPACK_CPP11, simple_buffer_array_char_empty)
{
array<char, 0> val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::BIN);
array<char, 0> val2 = ret.get().as<array<char, 0> >();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
@@ -111,6 +137,20 @@ TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char)
}
}
TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char_empty)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
array<unsigned char, 0> val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::BIN);
array<unsigned char, 0> val2 = ret.get().as<array<unsigned char, 0> >();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
// strong typedefs
namespace test {
@@ -158,6 +198,18 @@ TEST(MSGPACK_STL, simple_buffer_forward_list)
}
}
TEST(MSGPACK_STL, simple_buffer_forward_list_empty)
{
using type = forward_list<int, test::allocator<int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_map)
{
using type = unordered_map<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
@@ -174,6 +226,18 @@ TEST(MSGPACK_STL, simple_buffer_unordered_map)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_map_empty)
{
using type = unordered_map<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_multimap)
{
using type = unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
@@ -194,6 +258,19 @@ TEST(MSGPACK_STL, simple_buffer_unordered_multimap)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_multimap_empty)
{
using type = unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_set)
{
using type = unordered_set<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
@@ -210,6 +287,18 @@ TEST(MSGPACK_STL, simple_buffer_unordered_set)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_set_empty)
{
using type = unordered_set<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_multiset)
{
using type = unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
@@ -226,6 +315,18 @@ TEST(MSGPACK_STL, simple_buffer_unordered_multiset)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_multiset_empty)
{
using type = unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_USER_DEFINED, simple_buffer_enum_class_member)
{
TestEnumClassMemberClass val1;

View File

@@ -45,7 +45,7 @@ const unsigned int kLoop = 1000;
if (it == vec.end()) goto out; \
msgpack::object obj = result.get(); \
vec_type::value_type val; \
obj.convert(&val); \
obj.convert(val); \
EXPECT_EQ(*it, val); \
++it; \
} \

View File

@@ -72,7 +72,7 @@ TEST(object, convert)
msgpack::unpack(ret, sbuf.data(), sbuf.size());
myclass m2;
ret.get().convert(&m2);
ret.get().convert(m2);
EXPECT_EQ(m1, m2);
}
@@ -294,7 +294,7 @@ TEST(object, construct_enum)
{
msgpack::object obj(elem);
EXPECT_EQ(msgpack::type::POSITIVE_INTEGER, obj.type);
EXPECT_EQ(elem, obj.via.u64);
EXPECT_EQ(static_cast<uint64_t>(elem), obj.via.u64);
}
#if !defined(MSGPACK_USE_CPP03)
@@ -312,7 +312,7 @@ TEST(object, construct_enum_outer)
{
msgpack::object obj(outer_enum::elem);
EXPECT_EQ(msgpack::type::POSITIVE_INTEGER, obj.type);
EXPECT_EQ(elem, obj.via.u64);
EXPECT_EQ(static_cast<uint64_t>(elem), obj.via.u64);
}
#if !defined(MSGPACK_USE_CPP03)

View File

@@ -203,7 +203,7 @@ TEST(object_with_zone, vector)
v1.push_back(i);
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<vector<int> >(), v1);
EXPECT_TRUE(obj.as<vector<int> >() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<vector<int> >().front(), 1);
}
@@ -219,7 +219,7 @@ TEST(object_with_zone, vector_char)
v1.push_back(static_cast<char>(i));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<vector<char> >(), v1);
EXPECT_TRUE(obj.as<vector<char> >() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<vector<char> >().front(), 1);
}
@@ -233,7 +233,7 @@ TEST(object_without_zone, vector_char)
for (unsigned int i = 1; i < kElements; i++)
v1.push_back(static_cast<char>(i));
msgpack::object obj(v1);
EXPECT_EQ(obj.as<vector<char> >(), v1);
EXPECT_TRUE(obj.as<vector<char> >() == v1);
v1.front() = 42;
// obj refer to v1
EXPECT_EQ(obj.as<vector<char> >().front(), 42);
@@ -251,7 +251,7 @@ TEST(object_with_zone, vector_unsigned_char)
v1.push_back(static_cast<unsigned char>(i));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<vector<unsigned char> >(), v1);
EXPECT_TRUE(obj.as<vector<unsigned char> >() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<vector<unsigned char> >().front(), 1);
}
@@ -266,7 +266,7 @@ TEST(object_without_zone, vector_unsigned_char)
for (unsigned int i = 1; i < kElements; i++)
v1.push_back(static_cast<unsigned char>(i));
msgpack::object obj(v1);
EXPECT_EQ(obj.as<vector<unsigned char> >(), v1);
EXPECT_TRUE(obj.as<vector<unsigned char> >() == v1);
v1.front() = 42;
// obj refer to v1
EXPECT_EQ(obj.as<vector<unsigned char> >().front(), 42);
@@ -283,7 +283,7 @@ TEST(object_with_zone, list)
v1.push_back(i);
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<list<int> >(), v1);
EXPECT_TRUE(obj.as<list<int> >() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<list<int> >().front(), 1);
}
@@ -299,7 +299,7 @@ TEST(object_with_zone, deque)
v1.push_back(i);
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<deque<int> >(), v1);
EXPECT_TRUE(obj.as<deque<int> >() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<deque<int> >().front(), 1);
}
@@ -355,12 +355,12 @@ TEST(object_with_zone, raw_ref)
msgpack::type::raw_ref v(s.data(), static_cast<uint32_t>(s.size()));
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<msgpack::type::raw_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::raw_ref>() == v);
s[0] = 'd';
// even if with_zone, not copied due to raw_ref
// Basically, the combination raw_ref and object::wit_zone
// is meaningless.
EXPECT_EQ(obj.as<msgpack::type::raw_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::raw_ref>() == v);
}
TEST(object_without_zone, raw_ref)
@@ -369,9 +369,9 @@ TEST(object_without_zone, raw_ref)
msgpack::type::raw_ref v(s.data(), static_cast<uint32_t>(s.size()));
msgpack::zone z;
msgpack::object obj(v);
EXPECT_EQ(obj.as<msgpack::type::raw_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::raw_ref>() == v);
s[0] = 'd';
EXPECT_EQ(obj.as<msgpack::type::raw_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::raw_ref>() == v);
}
// pair
@@ -381,7 +381,7 @@ TEST(object_with_zone, pair)
test_t v(1, "abc");
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<test_t>(), v);
EXPECT_TRUE(obj.as<test_t>() == v);
v.first = 42;
EXPECT_EQ(obj.as<test_t>().first, 1);
}
@@ -395,7 +395,7 @@ TEST(object_with_zone, set)
v1.insert(i);
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<set<int> >(), v1);
EXPECT_TRUE(obj.as<set<int> >() == v1);
}
}
@@ -408,7 +408,7 @@ TEST(object_with_zone, multiset)
v1.insert(i % (kElements / 2));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<multiset<int> >(), v1);
EXPECT_TRUE(obj.as<multiset<int> >() == v1);
}
}
@@ -422,7 +422,7 @@ TEST(object_with_zone, map)
v1.insert(std::make_pair(i, i*2));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<test_t >(), v1);
EXPECT_TRUE(obj.as<test_t >() == v1);
}
}
@@ -436,7 +436,7 @@ TEST(object_with_zone, multimap)
v1.insert(std::make_pair(i % (kElements / 2), i*2));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<test_t >(), v1);
EXPECT_TRUE(obj.as<test_t >() == v1);
}
}
@@ -687,7 +687,7 @@ TEST(object_with_zone, construct_enum)
msgpack::zone z;
msgpack::object obj(elem, z);
EXPECT_EQ(msgpack::type::POSITIVE_INTEGER, obj.type);
EXPECT_EQ(elem, obj.via.u64);
EXPECT_EQ(static_cast<uint64_t>(elem), obj.via.u64);
}
#if !defined(MSGPACK_USE_CPP03)
@@ -707,7 +707,7 @@ TEST(object_with_zone, construct_enum_outer)
msgpack::zone z;
msgpack::object obj(outer_enum::elem, z);
EXPECT_EQ(msgpack::type::POSITIVE_INTEGER, obj.type);
EXPECT_EQ(elem, obj.via.u64);
EXPECT_EQ(static_cast<uint64_t>(elem), obj.via.u64);
}
// User defined inheriting classes
@@ -825,7 +825,7 @@ TEST(object_with_zone, array)
v1[i] = rand();
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<test_t>(), v1);
EXPECT_TRUE(obj.as<test_t>() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<test_t>().front(), 1);
}
@@ -841,7 +841,7 @@ TEST(object_with_zone, array_char)
v1[i] = rand();
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<test_t>(), v1);
EXPECT_TRUE(obj.as<test_t>() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<test_t>().front(), 1);
}
@@ -856,7 +856,7 @@ TEST(object_without_zone, array_char)
for (unsigned int i = 1; i < kElements; i++)
v1[i] = rand();
msgpack::object obj(v1);
EXPECT_EQ(obj.as<test_t>(), v1);
EXPECT_TRUE(obj.as<test_t>() == v1);
v1.front() = 42;
// obj refer to v1
EXPECT_EQ(obj.as<test_t>().front(), 42);
@@ -874,7 +874,7 @@ TEST(object_with_zone, array_unsigned_char)
v1[i] = rand();
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<test_t>(), v1);
EXPECT_TRUE(obj.as<test_t>() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<test_t>().front(), 1);
}
@@ -890,7 +890,7 @@ TEST(object_without_zone, array_unsigned_char)
for (unsigned int i = 1; i < kElements; i++)
v1[i] = rand();
msgpack::object obj(v1);
EXPECT_EQ(obj.as<test_t>(), v1);
EXPECT_TRUE(obj.as<test_t>() == v1);
v1.front() = 42;
// obj refer to v1
EXPECT_EQ(obj.as<test_t>().front(), 42);
@@ -906,7 +906,7 @@ TEST(object_with_zone, forward_list)
v1.push_front(i);
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_EQ(obj.as<forward_list<int> >(), v1);
EXPECT_TRUE(obj.as<forward_list<int> >() == v1);
v1.front() = 42;
EXPECT_EQ(obj.as<forward_list<int> >().front(), static_cast<int>(kElements - 1));
}
@@ -918,7 +918,7 @@ TEST(object_with_zone, tuple)
test_t v(1, "abc", true);
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<test_t>(), v);
EXPECT_TRUE(obj.as<test_t>() == v);
}
TEST(object_with_zone, tuple_empty)
@@ -927,7 +927,7 @@ TEST(object_with_zone, tuple_empty)
test_t v;
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<test_t>(), v);
EXPECT_TRUE(obj.as<test_t>() == v);
}
#endif // !defined(MSGPACK_USE_CPP03)
@@ -937,8 +937,8 @@ TEST(object_with_zone, ext_empty)
msgpack::type::ext v;
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<msgpack::type::ext>(), v);
EXPECT_EQ(obj.as<msgpack::type::ext_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::ext>() == v);
EXPECT_TRUE(obj.as<msgpack::type::ext_ref>() == v);
}
TEST(object_with_zone, ext)
@@ -947,8 +947,8 @@ TEST(object_with_zone, ext)
for (int i = 0; i < 10; ++i) v.data()[i] = i;
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<msgpack::type::ext>(), v);
EXPECT_EQ(obj.as<msgpack::type::ext_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::ext>() == v);
EXPECT_TRUE(obj.as<msgpack::type::ext_ref>() == v);
}
TEST(object_with_zone, ext_from_buf)
@@ -957,8 +957,8 @@ TEST(object_with_zone, ext_from_buf)
msgpack::type::ext v(42, buf, sizeof(buf));
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<msgpack::type::ext>(), v);
EXPECT_EQ(obj.as<msgpack::type::ext_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::ext>() == v);
EXPECT_TRUE(obj.as<msgpack::type::ext_ref>() == v);
}
TEST(object_with_zone, ext_ref_empty)
@@ -966,8 +966,8 @@ TEST(object_with_zone, ext_ref_empty)
msgpack::type::ext_ref v;
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<msgpack::type::ext>(), v);
EXPECT_EQ(obj.as<msgpack::type::ext_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::ext>() == v);
EXPECT_TRUE(obj.as<msgpack::type::ext_ref>() == v);
}
TEST(object_with_zone, ext_ref_from_buf)
@@ -976,6 +976,6 @@ TEST(object_with_zone, ext_ref_from_buf)
msgpack::type::ext_ref v(buf, sizeof(buf));
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<msgpack::type::ext>(), v);
EXPECT_EQ(obj.as<msgpack::type::ext_ref>(), v);
EXPECT_TRUE(obj.as<msgpack::type::ext>() == v);
EXPECT_TRUE(obj.as<msgpack::type::ext_ref>() == v);
}

View File

@@ -26,7 +26,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::raw_ref rr2 = upd.get().as<msgpack::type::raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_RAW_REF, pack_unpack_8_l)
@@ -43,7 +43,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_8_l)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::raw_ref rr2 = upd.get().as<msgpack::type::raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_RAW_REF, pack_unpack_8_h)
@@ -61,7 +61,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_8_h)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::raw_ref rr2 = upd.get().as<msgpack::type::raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_RAW_REF, pack_unpack_16_l)
@@ -80,7 +80,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_16_l)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::raw_ref rr2 = upd.get().as<msgpack::type::raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_RAW_REF, pack_unpack_16_h)
@@ -99,7 +99,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_16_h)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::raw_ref rr2 = upd.get().as<msgpack::type::raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_RAW_REF, pack_unpack_32_l)
@@ -120,7 +120,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_32_l)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::raw_ref rr2 = upd.get().as<msgpack::type::raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_V4RAW_REF, pack_unpack)
@@ -139,7 +139,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::v4raw_ref rr2 = upd.get().as<msgpack::type::v4raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_l)
@@ -155,7 +155,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_l)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::v4raw_ref rr2 = upd.get().as<msgpack::type::v4raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_h)
@@ -172,7 +172,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_h)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::v4raw_ref rr2 = upd.get().as<msgpack::type::v4raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_V4RAW_REF, pack_unpack_16_l)
@@ -191,7 +191,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_16_l)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::v4raw_ref rr2 = upd.get().as<msgpack::type::v4raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_V4RAW_REF, pack_unpack_16_h)
@@ -210,7 +210,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_16_h)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::v4raw_ref rr2 = upd.get().as<msgpack::type::v4raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}
TEST(MSGPACK_V4RAW_REF, pack_unpack_32_l)
@@ -231,5 +231,5 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_32_l)
msgpack::unpacked upd;
msgpack::unpack(upd, ss.str().data(), ss.str().size());
msgpack::type::v4raw_ref rr2 = upd.get().as<msgpack::type::v4raw_ref>();
EXPECT_EQ(rr1, rr2);
EXPECT_TRUE(rr1 == rr2);
}

View File

@@ -149,13 +149,13 @@ public:
void msgpack_unpack(msgpack::object o)
{
msgpack::type::tuple<bool, msgpack::object> tuple;
o.convert(&tuple);
o.convert(tuple);
is_double = tuple.get<0>();
if (is_double)
tuple.get<1>().convert(&value.f);
tuple.get<1>().convert(value.f);
else
tuple.get<1>().convert(&value.i);
tuple.get<1>().convert(value.i);
}
};