mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-21 15:51:44 +02:00
Compare commits
219 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b6803a5fec | ||
![]() |
210d3ce390 | ||
![]() |
a350e0714e | ||
![]() |
72757feae4 | ||
![]() |
fe2346efa1 | ||
![]() |
43ae287be3 | ||
![]() |
b804e12dec | ||
![]() |
99c221ad01 | ||
![]() |
3a615bcf44 | ||
![]() |
87863c1696 | ||
![]() |
45defd565a | ||
![]() |
f1726cef0d | ||
![]() |
8a788f3a48 | ||
![]() |
7710868556 | ||
![]() |
0b53833856 | ||
![]() |
43c643bab6 | ||
![]() |
ac64fcace8 | ||
![]() |
84ba0c7b4b | ||
![]() |
f79606d9ff | ||
![]() |
3aaadb9b12 | ||
![]() |
8a3a11f123 | ||
![]() |
32f1f0edf2 | ||
![]() |
5bd75905cb | ||
![]() |
eebdc007a9 | ||
![]() |
3aae588a6a | ||
![]() |
cb2dcb19b9 | ||
![]() |
c58a565366 | ||
![]() |
93b944eec4 | ||
![]() |
7340f1e9c8 | ||
![]() |
0a65c443a2 | ||
![]() |
bae6a8db57 | ||
![]() |
ddb320197a | ||
![]() |
dc51f6493b | ||
![]() |
c027909acc | ||
![]() |
2bd56533fa | ||
![]() |
c07452a7a2 | ||
![]() |
8701aeec30 | ||
![]() |
2c4f2b890e | ||
![]() |
f1acd78e54 | ||
![]() |
49d22b7d28 | ||
![]() |
96133c8dd9 | ||
![]() |
bd18a36dae | ||
![]() |
3fe630769e | ||
![]() |
2f80758889 | ||
![]() |
9f3efe9e54 | ||
![]() |
6e44edf290 | ||
![]() |
d28cbf32b9 | ||
![]() |
48d226e97c | ||
![]() |
64698e8e8c | ||
![]() |
e0d098641c | ||
![]() |
06f4b05487 | ||
![]() |
122fce5aee | ||
![]() |
e3f5281903 | ||
![]() |
88e94e3776 | ||
![]() |
95275ff16e | ||
![]() |
4cb938ed18 | ||
![]() |
5f3e62461e | ||
![]() |
ec239933db | ||
![]() |
de59b393c7 | ||
![]() |
b02371efe5 | ||
![]() |
f34289fdfd | ||
![]() |
584478a4f1 | ||
![]() |
700ec688f7 | ||
![]() |
a133c1d393 | ||
![]() |
6ba9a58648 | ||
![]() |
bb92d326c8 | ||
![]() |
1e13dadf1f | ||
![]() |
7b271c2af2 | ||
![]() |
c3f4e52bdb | ||
![]() |
458b4c0363 | ||
![]() |
f8dc0f0d04 | ||
![]() |
347658cdc1 | ||
![]() |
427a6e7313 | ||
![]() |
7f76a3caf0 | ||
![]() |
40539727e6 | ||
![]() |
30e56d0a45 | ||
![]() |
8eef2a245b | ||
![]() |
2bcfe2fdb0 | ||
![]() |
2b49e62b3c | ||
![]() |
bf70a36a1d | ||
![]() |
eb92058cf4 | ||
![]() |
423eaf25fb | ||
![]() |
280abe852c | ||
![]() |
c91307aaa1 | ||
![]() |
88ffd08087 | ||
![]() |
bd337129c6 | ||
![]() |
1f5cb86366 | ||
![]() |
0d39c577d8 | ||
![]() |
7e66dc28f0 | ||
![]() |
bec47a59f0 | ||
![]() |
064f854ddf | ||
![]() |
a05d92ae85 | ||
![]() |
1fdfde5d5f | ||
![]() |
b1620f1f6a | ||
![]() |
f789635ddc | ||
![]() |
f65c26e280 | ||
![]() |
579212996f | ||
![]() |
208595b262 | ||
![]() |
83a4b89818 | ||
![]() |
d46f220737 | ||
![]() |
b4db293181 | ||
![]() |
d1eac600e9 | ||
![]() |
7e758ca053 | ||
![]() |
db6d4f2003 | ||
![]() |
1ba46a30ce | ||
![]() |
5ece2ef2c7 | ||
![]() |
9513734040 | ||
![]() |
d452625ed1 | ||
![]() |
b02c6beb4d | ||
![]() |
06c2896def | ||
![]() |
724db8ed89 | ||
![]() |
fa48078a52 | ||
![]() |
d8ad85fa8c | ||
![]() |
cc3b895449 | ||
![]() |
384242e5eb | ||
![]() |
7a98138f27 | ||
![]() |
cd4e0bda57 | ||
![]() |
1ad2db0c42 | ||
![]() |
96a76a7a5c | ||
![]() |
bc964bd847 | ||
![]() |
12604b5c8e | ||
![]() |
7c67109396 | ||
![]() |
fd4e28f23d | ||
![]() |
2098062613 | ||
![]() |
22bc707035 | ||
![]() |
7ad743f2da | ||
![]() |
315bbd4b40 | ||
![]() |
288a6b2e31 | ||
![]() |
a0e4294b5a | ||
![]() |
64baa15f8e | ||
![]() |
354ee5b9a3 | ||
![]() |
2ddd79499c | ||
![]() |
7f0614e998 | ||
![]() |
150d74508e | ||
![]() |
8674c821c4 | ||
![]() |
10be66712d | ||
![]() |
2698cfc254 | ||
![]() |
333ee98ab2 | ||
![]() |
156e315394 | ||
![]() |
01fedf847b | ||
![]() |
56db4475f2 | ||
![]() |
f065c2a447 | ||
![]() |
ba4d8df63e | ||
![]() |
c00584281f | ||
![]() |
45a0124ede | ||
![]() |
ceb27348bd | ||
![]() |
1ad737ee08 | ||
![]() |
7024a1ec2c | ||
![]() |
ca4a425a52 | ||
![]() |
a502097fd0 | ||
![]() |
6b99a0c8b7 | ||
![]() |
1a3fcc3a22 | ||
![]() |
111739f8ce | ||
![]() |
f638e2186b | ||
![]() |
002376c678 | ||
![]() |
09a2f81b5f | ||
![]() |
ffcaaeb482 | ||
![]() |
bd511a4bd1 | ||
![]() |
684c5e0bb0 | ||
![]() |
8e74449181 | ||
![]() |
f2b788e51f | ||
![]() |
7214b4c73f | ||
![]() |
a7a78bde9b | ||
![]() |
c50fbe4ce9 | ||
![]() |
d7d28b6f24 | ||
![]() |
5ebed34376 | ||
![]() |
6871a82af7 | ||
![]() |
3f79968910 | ||
![]() |
2e10adabb1 | ||
![]() |
0411ef85e7 | ||
![]() |
28b6ee0db0 | ||
![]() |
3d0fa6043c | ||
![]() |
ee169c4eb5 | ||
![]() |
0aaf95608f | ||
![]() |
918e7edba4 | ||
![]() |
88338195c0 | ||
![]() |
e90231c865 | ||
![]() |
15d8bb6792 | ||
![]() |
20ef1f925b | ||
![]() |
89b8f4ee13 | ||
![]() |
304ff96d04 | ||
![]() |
10c1917f22 | ||
![]() |
d85e731ab4 | ||
![]() |
d431e25257 | ||
![]() |
3d82c2d651 | ||
![]() |
2cbaa3a7db | ||
![]() |
bfc6e45a2f | ||
![]() |
e8fa6c1aee | ||
![]() |
d49bec4e11 | ||
![]() |
004939e732 | ||
![]() |
09e8833d53 | ||
![]() |
9ed842c014 | ||
![]() |
99c4d37a39 | ||
![]() |
4df2bdecda | ||
![]() |
597cd63121 | ||
![]() |
a51f33c02f | ||
![]() |
88032f37e1 | ||
![]() |
a76911a72c | ||
![]() |
1bc27d72cc | ||
![]() |
a6599e5fb4 | ||
![]() |
791f55da35 | ||
![]() |
e58b00016b | ||
![]() |
b4fe698777 | ||
![]() |
e89045cfcd | ||
![]() |
c6e6dbc608 | ||
![]() |
e271cf2aed | ||
![]() |
53e4bb92fe | ||
![]() |
303c1000c2 | ||
![]() |
088ce946b9 | ||
![]() |
dc86adbf8e | ||
![]() |
ad0cae30ad | ||
![]() |
bf3e2abc9e | ||
![]() |
b7543e1386 | ||
![]() |
1f515b3ae7 | ||
![]() |
a933fa5892 | ||
![]() |
a07622c276 | ||
![]() |
c955727d8c | ||
![]() |
094b70213a | ||
![]() |
b4786711df |
121
.travis.yml
121
.travis.yml
@@ -1,5 +1,6 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
sudo: false
|
sudo: false
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- export BASE=`pwd`
|
- export BASE=`pwd`
|
||||||
@@ -9,8 +10,9 @@ install:
|
|||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then ./cmake-3.7.1-Linux-x86_64.sh --prefix=${BASE}/usr --skip-license; fi
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then ./cmake-3.7.1-Linux-x86_64.sh --prefix=${BASE}/usr --skip-license; fi
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export PATH="${BASE}/usr/bin:$PATH"; fi
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export PATH="${BASE}/usr/bin:$PATH"; fi
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export LD_LIBRARY_PATH="${BASE}/usr/lib:$LD_LIBRARY_PATH"; fi
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export LD_LIBRARY_PATH="${BASE}/usr/lib:$LD_LIBRARY_PATH"; fi
|
||||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-6" CC="gcc-6"; fi
|
- if [ "$CXX" == "g++" ]; then export CXX="g++-7" CC="gcc-7"; fi
|
||||||
- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
|
- if [ "$CXX" == "clang++" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then export CXX="clang++-5.0" CC="clang-5.0"; fi
|
||||||
|
- if [ "$CXX" == "g++" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then cd /usr/include/c++/$(g++ -v 2>&1 | grep version | awk '{print $3}')/bits; ln -s ../ext/atomicity.h .; cd ${BASE}/usr; fi
|
||||||
#gtest
|
#gtest
|
||||||
- wget https://github.com/google/googletest/archive/release-1.7.0.zip -O googletest-release-1.7.0.zip
|
- wget https://github.com/google/googletest/archive/release-1.7.0.zip -O googletest-release-1.7.0.zip
|
||||||
- unzip -q googletest-release-1.7.0.zip
|
- unzip -q googletest-release-1.7.0.zip
|
||||||
@@ -24,22 +26,24 @@ install:
|
|||||||
- mkdir -p ${BASE}/usr/lib
|
- mkdir -p ${BASE}/usr/lib
|
||||||
- mv *.a ${BASE}/usr/lib
|
- mv *.a ${BASE}/usr/lib
|
||||||
- cd ..
|
- cd ..
|
||||||
# valgrind
|
# valgrind
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then wget http://valgrind.org/downloads/valgrind-3.12.0.tar.bz2 && tar xjf valgrind-3.12.0.tar.bz2 && cd valgrind-3.12.0 && ./configure --prefix=${BASE}/usr > /dev/null && make -j3 > /dev/null && make install > /dev/null && cd ..; fi
|
- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$MSGPACK_FUZZ_REGRESSION" != "ON" ]; then wget http://valgrind.org/downloads/valgrind-3.12.0.tar.bz2 && tar xjf valgrind-3.12.0.tar.bz2 && cd valgrind-3.12.0 && ./configure --prefix=${BASE}/usr > /dev/null && make -j3 > /dev/null && make install > /dev/null && cd ..; fi
|
||||||
# boost
|
# boost
|
||||||
- if [ "$BOOST" == "ON" ]; then wget http://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.zip && unzip -q boost_1_63_0.zip && cd boost_1_63_0 && ./bootstrap.sh && ./b2 -j3 --prefix=${BASE}/usr --with-timer --with-chrono address-model=${ARCH} install > /dev/null && cd ..; fi
|
- if [ "$BOOST" == "ON" ] && [ "MSGPACK_FUZZ_REGRESSION" != "ON" ]; then wget http://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.zip && unzip -q boost_1_67_0.zip && cd boost_1_67_0 && ./bootstrap.sh && ./b2 -j3 --prefix=${BASE}/usr --with-chrono --with-context --with-system --with-timer address-model=${ARCH} install > /dev/null && cd ..; fi
|
||||||
|
- if [ "$MSGPACK_FUZZ_REGRESSION" == "ON" ]; then wget http://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.zip && unzip -q boost_1_67_0.zip && cd boost_1_67_0 && ./bootstrap.sh --with-toolset=clang && ./b2 clean && ./b2 -j$(nproc) --prefix=${BASE}/usr --with-system --with-filesystem address-model=${ARCH} install > /dev/null && cd ..; fi
|
||||||
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s /usr/include/x86_64-linux-gnu/zconf.h /usr/include; fi
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="1"
|
env: ACTION="ci/build_cmake.sh" CXX17="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="1"
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2" X3_PARSE="ON"
|
env: ACTION="ci/build_cmake.sh" CXX17="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="signed" API_VERSION="3"
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
env: ACTION="ci/build_cmake.sh" CXX17="ON" ARCH="64" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: ACTION="ci/build_cmake.sh" ARCH="64" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="2"
|
env: ACTION="ci/build_cmake.sh" ARCH="64" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||||
@@ -50,15 +54,14 @@ matrix:
|
|||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
- llvm-toolchain-trusty-5.0
|
||||||
- llvm-toolchain-precise
|
|
||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-5-multilib
|
- gcc-7-multilib
|
||||||
- g++-5-multilib
|
- g++-7-multilib
|
||||||
- bzip2
|
- bzip2
|
||||||
- clang-3.7
|
- clang-5.0
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
@@ -67,61 +70,60 @@ matrix:
|
|||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
- llvm-toolchain-trusty-5.0
|
||||||
- llvm-toolchain-precise
|
|
||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-5-multilib
|
- gcc-7-multilib
|
||||||
- g++-5-multilib
|
- g++-7-multilib
|
||||||
- lib32stdc++6-6-dbg
|
- lib32stdc++6-6-dbg
|
||||||
- lib32gcc1
|
- lib32gcc1
|
||||||
- libc6-i386
|
- libc6-i386
|
||||||
- lib32z1-dev
|
- lib32z1-dev
|
||||||
|
- zlib1g-dev
|
||||||
- bzip2
|
- bzip2
|
||||||
- clang-3.7
|
- clang-5.0
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2" X3_PARSE="ON"
|
env: ACTION="ci/build_cmake.sh" CXX17="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="signed" API_VERSION="3" X3_PARSE="ON"
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
- llvm-toolchain-trusty-5.0
|
||||||
- llvm-toolchain-precise
|
|
||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-5-multilib
|
- gcc-7-multilib
|
||||||
- g++-5-multilib
|
- g++-7-multilib
|
||||||
- bzip2
|
- bzip2
|
||||||
- clang-3.7
|
- clang-5.0
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="32" SHARED="OFF" CHAR_SIGN="unsigned" API_VERSION="2"
|
env: ACTION="ci/build_cmake.sh" CXX17="ON" ARCH="32" SHARED="OFF" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
- llvm-toolchain-trusty-5.0
|
||||||
- llvm-toolchain-precise
|
|
||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-5-multilib
|
- gcc-7-multilib
|
||||||
- g++-5-multilib
|
- g++-7-multilib
|
||||||
- lib32stdc++6-6-dbg
|
- lib32stdc++6-6-dbg
|
||||||
- lib32gcc1
|
- lib32gcc1
|
||||||
- libc6-i386
|
- libc6-i386
|
||||||
- lib32z1-dev
|
- lib32z1-dev
|
||||||
|
- zlib1g-dev
|
||||||
- bzip2
|
- bzip2
|
||||||
- clang-3.7
|
- clang-5.0
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
env: ACTION="ci/build_cmake.sh" CXX17="ON" ARCH="64" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
@@ -129,13 +131,13 @@ matrix:
|
|||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-6-multilib
|
- gcc-7-multilib
|
||||||
- g++-6-multilib
|
- g++-7-multilib
|
||||||
- bzip2
|
- bzip2
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="32" BOOST="ON" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="2" X3_PARSE="ON"
|
env: ACTION="ci/build_cmake.sh" CXX17="ON" ARCH="32" BOOST="ON" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="3" X3_PARSE="ON"
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
@@ -143,12 +145,13 @@ matrix:
|
|||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-6-multilib
|
- gcc-7-multilib
|
||||||
- g++-6-multilib
|
- g++-7-multilib
|
||||||
- lib32stdc++6-6-dbg
|
- lib32stdc++6-6-dbg
|
||||||
- lib32gcc1
|
- lib32gcc1
|
||||||
- libc6-i386
|
- libc6-i386
|
||||||
- lib32z1-dev
|
- lib32z1-dev
|
||||||
|
- zlib1g-dev
|
||||||
- bzip2
|
- bzip2
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
@@ -161,8 +164,8 @@ matrix:
|
|||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-6-multilib
|
- gcc-7-multilib
|
||||||
- g++-6-multilib
|
- g++-7-multilib
|
||||||
- bzip2
|
- bzip2
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
@@ -175,12 +178,13 @@ matrix:
|
|||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-6-multilib
|
- gcc-7-multilib
|
||||||
- g++-6-multilib
|
- g++-7-multilib
|
||||||
- lib32stdc++6-6-dbg
|
- lib32stdc++6-6-dbg
|
||||||
- lib32gcc1
|
- lib32gcc1
|
||||||
- libc6-i386
|
- libc6-i386
|
||||||
- lib32z1-dev
|
- lib32z1-dev
|
||||||
|
- zlib1g-dev
|
||||||
- bzip2
|
- bzip2
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
- os: linux
|
- os: linux
|
||||||
@@ -193,14 +197,43 @@ matrix:
|
|||||||
packages:
|
packages:
|
||||||
- g++-multilib
|
- g++-multilib
|
||||||
- gcc-multilib
|
- gcc-multilib
|
||||||
- gcc-6-multilib
|
- gcc-7-multilib
|
||||||
- g++-6-multilib
|
- g++-7-multilib
|
||||||
- lib32stdc++6-6-dbg
|
- lib32stdc++6-6-dbg
|
||||||
- lib32gcc1
|
- lib32gcc1
|
||||||
- libc6-i386
|
- libc6-i386
|
||||||
- lib32z1-dev
|
- lib32z1-dev
|
||||||
|
- zlib1g-dev
|
||||||
- bzip2
|
- bzip2
|
||||||
- libc6-dbg
|
- libc6-dbg
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
env: ACTION="ci/build_regression.sh" ARCH="64" SAN="UBSAN" MSGPACK_FUZZ_REGRESSION="ON"
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-trusty-5.0
|
||||||
|
packages:
|
||||||
|
- bzip2
|
||||||
|
- clang-5.0
|
||||||
|
script:
|
||||||
|
- CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}" GTEST_ROOT="${BASE}/gtest" BOOST_ROOT="${BASE}/boost" CTEST_OUTPUT_ON_FAILURE=1 MSGPACK_SAN="${SAN}" ci/build_regression.sh
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
env: ACTION="ci/build_regression.sh" ARCH="64" SAN="ASAN" MSGPACK_FUZZ_REGRESSION="ON"
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-trusty-5.0
|
||||||
|
packages:
|
||||||
|
- bzip2
|
||||||
|
- clang-5.0
|
||||||
|
script:
|
||||||
|
- CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}" GTEST_ROOT="${BASE}/gtest" BOOST_ROOT="${BASE}/boost" CTEST_OUTPUT_ON_FAILURE=1 MSGPACK_SAN="${SAN}" ci/build_regression.sh
|
||||||
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}/usr/lib:${BASE}/build" GTEST_ROOT="${BASE}/usr" BOOST_ROOT="${BASE}/usr" ${ACTION}
|
- CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}/usr/lib:${BASE}/build" GTEST_ROOT="${BASE}/usr" BOOST_ROOT="${BASE}/usr" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" ${ACTION}
|
||||||
|
- cat Files.cmake| grep ".*\.[h|hpp]" | perl -pe 's/ //g' | sort > tmp1 && find include -name "*.h" -o -name "*.hpp" | sort > tmp2 && diff tmp1 tmp2
|
||||||
|
74
CHANGELOG.md
74
CHANGELOG.md
@@ -1,3 +1,77 @@
|
|||||||
|
# 2018-08-10 version 3.1.0
|
||||||
|
|
||||||
|
* Improve documents (#687, #718)
|
||||||
|
* Add fuzzer support (#689)
|
||||||
|
* Fix msgpack::object union member access bug (#694)
|
||||||
|
* Improve cross platform configuration (#704)
|
||||||
|
* Fix out of range dereference bug of EXT (#705)
|
||||||
|
* Add timestamp support. std::chrono::system_clock::time_point is mapped to TIMESTAMP (#706)
|
||||||
|
* Add minimal timestamp support for C. The type `msgpack_timestamp` and the function `msgpack_object_to_timestamp()` are introduced (#707)
|
||||||
|
* Improve MSGPACK_DEFINE family name confliction probability (#710)
|
||||||
|
* Add no static-library build option (BUILD_SHARED_LIBS=ON) (#713, #717, #722)
|
||||||
|
* Add header only cmake target (#721)
|
||||||
|
* Add `std::byte` adaptor (#719)
|
||||||
|
* Remove some warnings (#720)
|
||||||
|
|
||||||
|
# 2018-05-12 version 3.0.1
|
||||||
|
|
||||||
|
* Add fuzz directory to release tar ball (#686)
|
||||||
|
* Add include file checking for X-Code (#683)
|
||||||
|
|
||||||
|
# 2018-05-09 version 3.0.0
|
||||||
|
|
||||||
|
## << breaking changes >>
|
||||||
|
|
||||||
|
* Change offset parameter updating rule. If parse error happens, offset is updated to the error position. (#639, #666)
|
||||||
|
|
||||||
|
## << other updates >>
|
||||||
|
|
||||||
|
* Improve cross platform configuration (#655, #677)
|
||||||
|
* Improve build system (#647)
|
||||||
|
* Improve user class adaptor (#645, #673)
|
||||||
|
* Improve msgpack::object visitation logic (#676)
|
||||||
|
* Remove some warnings (#641, 659)
|
||||||
|
* Add `->` and `*` operators to object_handle (#635)
|
||||||
|
* Improve CI environment (#631, #634, #643, #657, #662, #668)
|
||||||
|
* Improve documents (#630, #661)
|
||||||
|
* Refactoring (#670)
|
||||||
|
* Add OSS-Fuzz support (#672, #674, #675, #678)
|
||||||
|
|
||||||
|
# 2017-08-04 version 2.1.5
|
||||||
|
* Improve cross platform configuration (#624)
|
||||||
|
* Add boost asio examples (including zlib) (#610)
|
||||||
|
* Remove some warnings (#611)
|
||||||
|
* Fix unpack visitor to treat float32/64 correctly (#613)
|
||||||
|
* Improve documents (#616)
|
||||||
|
* Fix alignment problem on some platform (#617, #518)
|
||||||
|
* Fix conflict std::tuple, std::pair, and boost::fusion::sequence problem (#619)
|
||||||
|
|
||||||
|
# 2017-08-03 version 2.1.4 (Invalid)
|
||||||
|
* See https://github.com/msgpack/msgpack-c/issues/623
|
||||||
|
|
||||||
|
# 2017-06-15 version 2.1.3
|
||||||
|
* Improve build system (#603)
|
||||||
|
* Add C++17 adaptors `std::optional` and `std::string_view`. (#607, #608)
|
||||||
|
* Improve cross platform configuration (#601)
|
||||||
|
* Remove some warnings (#599, #602, #605)
|
||||||
|
|
||||||
|
# 2017-06-07 version 2.1.2
|
||||||
|
|
||||||
|
* Improve documents (#565)
|
||||||
|
* Fix empty map parse bug (#568)
|
||||||
|
* Improve build system (#569, #570, #572, #579, #591, #592)
|
||||||
|
* Remove some warnings (#574, #578, #586, #588)
|
||||||
|
* Improve cross platform configuration (#577, #582)
|
||||||
|
* Add cmake package config support (#580)
|
||||||
|
* Fix streaming unpack bug (#585)
|
||||||
|
|
||||||
|
# 2017-02-04 version 2.1.1
|
||||||
|
|
||||||
|
* Fix unpacker's buffer management bug (#561)
|
||||||
|
* Add boost string_view adaptor (#558)
|
||||||
|
* Remove some warnings (#557, #559)
|
||||||
|
* Improve coding style (#556)
|
||||||
|
|
||||||
# 2017-01-10 version 2.1.0
|
# 2017-01-10 version 2.1.0
|
||||||
|
|
||||||
## << breaking changes >>
|
## << breaking changes >>
|
||||||
|
241
CMakeLists.txt
241
CMakeLists.txt
@@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.6)
|
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12)
|
||||||
|
|
||||||
IF ((CMAKE_VERSION VERSION_GREATER 3.1) OR
|
IF ((CMAKE_VERSION VERSION_GREATER 3.1) OR
|
||||||
(CMAKE_VERSION VERSION_EQUAL 3.1))
|
(CMAKE_VERSION VERSION_EQUAL 3.1))
|
||||||
@@ -50,7 +50,15 @@ IF (MSGPACK_USE_X3_PARSE)
|
|||||||
ENDIF ()
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ELSE ()
|
ELSE ()
|
||||||
IF (MSGPACK_CXX11)
|
IF (MSGPACK_CXX17)
|
||||||
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
SET (CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
|
||||||
|
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
SET (CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
|
||||||
|
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
MESSAGE ( FATAL_ERROR "MSVC doesn't support C++17.")
|
||||||
|
ENDIF ()
|
||||||
|
ELSEIF (MSGPACK_CXX11)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
@@ -92,21 +100,20 @@ OPTION (MSGPACK_BUILD_EXAMPLES "Build msgpack examples." ON)
|
|||||||
|
|
||||||
IF (MSGPACK_BOOST)
|
IF (MSGPACK_BOOST)
|
||||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_BOOST ${CMAKE_CXX_FLAGS}")
|
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_BOOST ${CMAKE_CXX_FLAGS}")
|
||||||
ENDIF ()
|
SET (Boost_USE_MULTITHREADED ON)
|
||||||
|
SET (Boost_USE_STATIC_RUNTIME OFF)
|
||||||
SET (Boost_USE_STATIC_LIBS ON) # only find static libs
|
FIND_PACKAGE (Boost REQUIRED COMPONENTS chrono context system timer)
|
||||||
SET (Boost_USE_MULTITHREADED ON)
|
INCLUDE_DIRECTORIES (
|
||||||
SET (Boost_USE_STATIC_RUNTIME OFF)
|
${Boost_INCLUDE_DIRS}
|
||||||
FIND_PACKAGE (Boost COMPONENTS chrono context timer system)
|
)
|
||||||
IF (Boost_INCLUDE_DIRS)
|
LINK_DIRECTORIES (
|
||||||
INCLUDE_DIRECTORIES (
|
${Boost_LIBRARY_DIRS}
|
||||||
${Boost_INCLUDE_DIRS}
|
)
|
||||||
)
|
IF (MSGPACK_BOOST_DIR)
|
||||||
ENDIF ()
|
INCLUDE_DIRECTORIES (
|
||||||
IF (MSGPACK_BOOST_DIR)
|
${MSGPACK_BOOST_DIR}
|
||||||
INCLUDE_DIRECTORIES (
|
)
|
||||||
${MSGPACK_BOOST_DIR}
|
ENDIF ()
|
||||||
)
|
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (MSGPACK_CHAR_SIGN)
|
IF (MSGPACK_CHAR_SIGN)
|
||||||
@@ -117,7 +124,7 @@ ENDIF ()
|
|||||||
IF (MSGPACK_DEFAULT_API_VERSION)
|
IF (MSGPACK_DEFAULT_API_VERSION)
|
||||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_DEFAULT_API_VERSION=${MSGPACK_DEFAULT_API_VERSION} ${CMAKE_CXX_FLAGS}")
|
SET (CMAKE_CXX_FLAGS "-DMSGPACK_DEFAULT_API_VERSION=${MSGPACK_DEFAULT_API_VERSION} ${CMAKE_CXX_FLAGS}")
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_DEFAULT_API_VERSION=2 ${CMAKE_CXX_FLAGS}")
|
SET (CMAKE_CXX_FLAGS "-DMSGPACK_DEFAULT_API_VERSION=3 ${CMAKE_CXX_FLAGS}")
|
||||||
ENDIF ()
|
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)
|
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)
|
||||||
@@ -127,7 +134,7 @@ FOREACH (F ${PREDEF_FILES})
|
|||||||
FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost/${F} CONTENT)
|
FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost/${F} CONTENT)
|
||||||
STRING(REPLACE "BOOST_" "MSGPACK_" CONTENT ${CONTENT})
|
STRING(REPLACE "BOOST_" "MSGPACK_" CONTENT ${CONTENT})
|
||||||
STRING(REPLACE "boost/" "msgpack/" CONTENT ${CONTENT})
|
STRING(REPLACE "boost/" "msgpack/" CONTENT ${CONTENT})
|
||||||
FILE (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} ${CONTENT})
|
FILE (GENERATE OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} CONTENT ${CONTENT})
|
||||||
ENDFOREACH ()
|
ENDFOREACH ()
|
||||||
|
|
||||||
FILE (GLOB_RECURSE PREPROCESSOR_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost/*.hpp)
|
FILE (GLOB_RECURSE PREPROCESSOR_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost/*.hpp)
|
||||||
@@ -137,18 +144,46 @@ FOREACH (F ${PREPROCESSOR_FILES})
|
|||||||
FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost/${F} CONTENT)
|
FILE (READ ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/preprocessor/include/boost/${F} CONTENT)
|
||||||
STRING(REPLACE "BOOST_" "MSGPACK_" CONTENT ${CONTENT})
|
STRING(REPLACE "BOOST_" "MSGPACK_" CONTENT ${CONTENT})
|
||||||
STRING(REPLACE "boost/" "msgpack/" CONTENT ${CONTENT})
|
STRING(REPLACE "boost/" "msgpack/" CONTENT ${CONTENT})
|
||||||
FILE (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} ${CONTENT})
|
FILE (GENERATE OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} CONTENT ${CONTENT})
|
||||||
ENDFOREACH ()
|
ENDFOREACH ()
|
||||||
|
|
||||||
FIND_PACKAGE (GTest)
|
FIND_PACKAGE (GTest)
|
||||||
FIND_PACKAGE (ZLIB)
|
FIND_PACKAGE (ZLIB)
|
||||||
FIND_PACKAGE (Threads)
|
FIND_PACKAGE (Threads)
|
||||||
IF (GTEST_FOUND AND ZLIB_FOUND AND THREADS_FOUND)
|
IF (GTEST_FOUND AND ZLIB_FOUND AND THREADS_FOUND AND NOT "${MSGPACK_FUZZ_REGRESSION}" STREQUAL "ON")
|
||||||
OPTION (MSGPACK_BUILD_TESTS "Build msgpack tests." ON)
|
OPTION (MSGPACK_BUILD_TESTS "Build msgpack tests." ON)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (DEFINED BUILD_SHARED_LIBS)
|
||||||
|
IF (BUILD_SHARED_LIBS)
|
||||||
|
IF (DEFINED MSGPACK_ENABLE_SHARED AND NOT MSGPACK_ENABLE_SHARED)
|
||||||
|
MESSAGE(WARNING "MSGPACK_ENABLE_SHARED is overridden to ON by BUILD_SHARED_LIBS")
|
||||||
|
ENDIF ()
|
||||||
|
SET (MSGPACK_ENABLE_SHARED ON)
|
||||||
|
IF (DEFINED MSGPACK_ENABLE_STATIC AND MSGPACK_ENABLE_STATIC)
|
||||||
|
MESSAGE(WARNING "MSGPACK_ENABLE_STATIC is overridden to OFF by BUILD_SHARED_LIBS")
|
||||||
|
ENDIF ()
|
||||||
|
SET (MSGPACK_ENABLE_STATIC OFF)
|
||||||
|
ELSE ()
|
||||||
|
IF (DEFINED MSGPACK_ENABLE_SHARED AND MSGPACK_ENABLE_SHARED)
|
||||||
|
MESSAGE(WARNING "MSGPACK_ENABLE_SHARED is overridden to OFF by BUILD_SHARED_LIBS")
|
||||||
|
ENDIF ()
|
||||||
|
SET (MSGPACK_ENABLE_SHARED OFF)
|
||||||
|
IF (DEFINED MSGPACK_ENABLE_STATIC AND NOT MSGPACK_ENABLE_STATIC)
|
||||||
|
MESSAGE(WARNING "MSGPACK_ENABLE_STATIC is overridden to ON by BUILD_SHARED_LIBS")
|
||||||
|
ENDIF ()
|
||||||
|
SET (MSGPACK_ENABLE_STATIC ON)
|
||||||
|
ENDIF ()
|
||||||
|
ELSE ()
|
||||||
|
IF (NOT DEFINED MSGPACK_ENABLE_SHARED)
|
||||||
|
SET (MSGPACK_ENABLE_SHARED ON)
|
||||||
|
ENDIF ()
|
||||||
|
IF (NOT DEFINED MSGPACK_ENABLE_STATIC)
|
||||||
|
SET (MSGPACK_ENABLE_STATIC ON)
|
||||||
|
ENDIF ()
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
OPTION (MSGPACK_ENABLE_CXX "Enable C++ interface." ON)
|
OPTION (MSGPACK_ENABLE_CXX "Enable C++ interface." ON)
|
||||||
OPTION (MSGPACK_ENABLE_SHARED "Build shared libaries in addition to static libraries." ON)
|
|
||||||
|
|
||||||
INCLUDE (CheckCXXSourceCompiles)
|
INCLUDE (CheckCXXSourceCompiles)
|
||||||
CHECK_CXX_SOURCE_COMPILES ("
|
CHECK_CXX_SOURCE_COMPILES ("
|
||||||
@@ -174,34 +209,78 @@ CONFIGURE_FILE (
|
|||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES (
|
|
||||||
./
|
|
||||||
include/
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/include/
|
|
||||||
)
|
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED)
|
||||||
ADD_LIBRARY (msgpackc SHARED
|
ADD_LIBRARY (msgpackc SHARED
|
||||||
${msgpackc_SOURCES}
|
${msgpackc_SOURCES}
|
||||||
${msgpackc_HEADERS}
|
${msgpackc_HEADERS}
|
||||||
)
|
)
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
ADD_LIBRARY (msgpackc-static STATIC
|
|
||||||
${msgpackc_SOURCES}
|
|
||||||
${msgpackc_HEADERS}
|
|
||||||
)
|
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES (msgpackc-static PROPERTIES OUTPUT_NAME "msgpackc")
|
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
|
||||||
IF (MSVC)
|
|
||||||
SET_TARGET_PROPERTIES (msgpackc PROPERTIES IMPORT_SUFFIX "_import.lib")
|
|
||||||
ELSEIF (MINGW)
|
|
||||||
SET_TARGET_PROPERTIES (msgpackc PROPERTIES IMPORT_SUFFIX ".dll.a")
|
|
||||||
ENDIF ()
|
|
||||||
SET_TARGET_PROPERTIES (msgpackc PROPERTIES SOVERSION 2 VERSION 2.0.0)
|
SET_TARGET_PROPERTIES (msgpackc PROPERTIES SOVERSION 2 VERSION 2.0.0)
|
||||||
|
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (msgpackc
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (MSGPACK_ENABLE_CXX AND ((CMAKE_VERSION VERSION_GREATER 3.0) OR (CMAKE_VERSION VERSION_EQUAL 3.0)))
|
||||||
|
ADD_LIBRARY (msgpackc-cxx INTERFACE)
|
||||||
|
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (msgpackc-cxx
|
||||||
|
INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (MSGPACK_ENABLE_STATIC)
|
||||||
|
ADD_LIBRARY (msgpackc-static STATIC
|
||||||
|
${msgpackc_SOURCES}
|
||||||
|
${msgpackc_HEADERS}
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (msgpackc-static
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF (NOT MSGPACK_ENABLE_SHARED)
|
||||||
|
# Add alias for subdirectories
|
||||||
|
ADD_LIBRARY (msgpackc ALIAS msgpackc-static)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES (msgpackc-static PROPERTIES OUTPUT_NAME "msgpackc")
|
||||||
|
|
||||||
|
IF (MSGPACK_ENABLE_SHARED)
|
||||||
|
IF (MSVC)
|
||||||
|
SET_TARGET_PROPERTIES (msgpackc PROPERTIES IMPORT_SUFFIX "_import.lib")
|
||||||
|
ELSEIF (MINGW)
|
||||||
|
SET_TARGET_PROPERTIES (msgpackc PROPERTIES IMPORT_SUFFIX ".dll.a")
|
||||||
|
ENDIF ()
|
||||||
|
ENDIF ()
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
# enable regression testing
|
||||||
|
IF ("${MSGPACK_FUZZ_REGRESSION}" STREQUAL "ON" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_BOOST ${CMAKE_CXX_FLAGS}")
|
||||||
|
SET (Boost_USE_MULTITHREADED ON)
|
||||||
|
SET (Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
|
||||||
|
enable_testing ()
|
||||||
|
ADD_SUBDIRECTORY (fuzz)
|
||||||
|
SET (MSGPACK_BUILD_EXAMPLES OFF)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
|
||||||
IF (MSGPACK_BUILD_TESTS)
|
IF (MSGPACK_BUILD_TESTS)
|
||||||
ENABLE_TESTING ()
|
ENABLE_TESTING ()
|
||||||
# MEMORYCHECK_COMMAND_OPTIONS needs to place prior to CTEST_MEMORYCHECK_COMMAND
|
# MEMORYCHECK_COMMAND_OPTIONS needs to place prior to CTEST_MEMORYCHECK_COMMAND
|
||||||
@@ -213,16 +292,20 @@ ENDIF ()
|
|||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED)
|
||||||
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 -DPIC")
|
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra -DPIC")
|
||||||
|
ENDIF ()
|
||||||
|
IF (MSGPACK_ENABLE_STATIC)
|
||||||
|
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra" )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3" )
|
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED)
|
||||||
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
IF (MSGPACK_ENABLE_STATIC)
|
||||||
|
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||||
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
@@ -235,7 +318,12 @@ ENDIF ()
|
|||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC90" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC10")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC90" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC10")
|
||||||
SET_SOURCE_FILES_PROPERTIES(${msgpackc_SOURCES} PROPERTIES LANGUAGE CXX)
|
SET_SOURCE_FILES_PROPERTIES(${msgpackc_SOURCES} PROPERTIES LANGUAGE CXX)
|
||||||
ENDIF()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "sparc")
|
||||||
|
SET (CMAKE_C_FLAGS "-DMSGPACK_ZONE_ALIGN=8 ${CMAKE_C_FLAGS}")
|
||||||
|
SET (CMAKE_CXX_FLAGS "-DMSGPACK_ZONE_ALIGN=8 ${CMAKE_CXX_FLAGS}")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
IF (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
IF (NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||||
SET(CMAKE_INSTALL_BINDIR bin)
|
SET(CMAKE_INSTALL_BINDIR bin)
|
||||||
@@ -250,15 +338,26 @@ IF (MSGPACK_BUILD_EXAMPLES)
|
|||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED)
|
||||||
SET (MSGPACK_INSTALLTARGETS msgpackc msgpackc-static)
|
SET (MSGPACK_INSTALLTARGETS msgpackc)
|
||||||
ELSE()
|
|
||||||
SET (MSGPACK_INSTALLTARGETS msgpackc-static)
|
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
IF (MSGPACK_ENABLE_CXX AND ((CMAKE_VERSION VERSION_GREATER 3.0) OR (CMAKE_VERSION VERSION_EQUAL 3.0)))
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-cxx)
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
ENDIF ()
|
||||||
INSTALL (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|
||||||
|
IF (MSGPACK_ENABLE_STATIC)
|
||||||
|
LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-static)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} EXPORT msgpack-targets
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
)
|
||||||
|
FOREACH (file ${msgpackc_HEADERS})
|
||||||
|
GET_FILENAME_COMPONENT (dir ${file} PATH)
|
||||||
|
INSTALL (FILES ${file} DESTINATION ${CMAKE_INSTALL_PREFIX}/${dir})
|
||||||
|
ENDFOREACH ()
|
||||||
IF (NOT MSVC)
|
IF (NOT MSVC)
|
||||||
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/msgpack.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/msgpack.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
@@ -273,6 +372,7 @@ IF (DOXYGEN_FOUND)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "STRIP_FROM_PATH = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
)
|
)
|
||||||
IF (DOXYGEN_DOT_FOUND)
|
IF (DOXYGEN_DOT_FOUND)
|
||||||
LIST (APPEND Doxyfile_c_CONTENT
|
LIST (APPEND Doxyfile_c_CONTENT
|
||||||
@@ -291,6 +391,7 @@ IF (DOXYGEN_FOUND)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_cpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_cpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "STRIP_FROM_PATH = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
)
|
)
|
||||||
IF (DOXYGEN_DOT_FOUND)
|
IF (DOXYGEN_DOT_FOUND)
|
||||||
LIST (APPEND Doxyfile_cpp_CONTENT
|
LIST (APPEND Doxyfile_cpp_CONTENT
|
||||||
@@ -309,3 +410,39 @@ IF (DOXYGEN_FOUND)
|
|||||||
DEPENDS doxygen_c doxygen_cpp
|
DEPENDS doxygen_c doxygen_cpp
|
||||||
)
|
)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
INCLUDE (CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
SET (CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/msgpack")
|
||||||
|
|
||||||
|
WRITE_BASIC_PACKAGE_VERSION_FILE (
|
||||||
|
msgpack-config-version.cmake
|
||||||
|
VERSION ${VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
IF (NOT CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
EXPORT (EXPORT msgpack-targets
|
||||||
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/msgpack-targets.cmake"
|
||||||
|
)
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
|
CONFIGURE_PACKAGE_CONFIG_FILE (msgpack-config.cmake.in
|
||||||
|
msgpack-config.cmake
|
||||||
|
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL (EXPORT msgpack-targets
|
||||||
|
FILE
|
||||||
|
msgpack-targets.cmake
|
||||||
|
DESTINATION
|
||||||
|
"${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL (
|
||||||
|
FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/msgpack-config.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/msgpack-config-version.cmake"
|
||||||
|
DESTINATION
|
||||||
|
"${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
)
|
||||||
|
2
Doxyfile
2
Doxyfile
@@ -281,7 +281,7 @@ TYPEDEF_HIDES_STRUCT = NO
|
|||||||
# causing a significant performance penality.
|
# causing a significant performance penality.
|
||||||
# If the system has enough physical memory increasing the cache will improve the
|
# If the system has enough physical memory increasing the cache will improve the
|
||||||
# performance by keeping more symbols in memory. Note that the value works on
|
# performance by keeping more symbols in memory. Note that the value works on
|
||||||
# a logarithmic scale so increasing the size by one will rougly double the
|
# a logarithmic scale so increasing the size by one will roughly double the
|
||||||
# memory usage. The cache size is given by this formula:
|
# memory usage. The cache size is given by this formula:
|
||||||
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
|
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
|
||||||
# corresponding to a cache size of 2^16 = 65536 symbols
|
# corresponding to a cache size of 2^16 = 65536 symbols
|
||||||
|
76
Files.cmake
76
Files.cmake
@@ -142,6 +142,7 @@ LIST (APPEND msgpackc_HEADERS
|
|||||||
include/msgpack/predef/version_number.h
|
include/msgpack/predef/version_number.h
|
||||||
include/msgpack/sbuffer.h
|
include/msgpack/sbuffer.h
|
||||||
include/msgpack/sysdep.h
|
include/msgpack/sysdep.h
|
||||||
|
include/msgpack/timestamp.h
|
||||||
include/msgpack/unpack.h
|
include/msgpack/unpack.h
|
||||||
include/msgpack/unpack_define.h
|
include/msgpack/unpack_define.h
|
||||||
include/msgpack/unpack_template.h
|
include/msgpack/unpack_template.h
|
||||||
@@ -165,6 +166,7 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/adaptor/boost/msgpack_variant_decl.hpp
|
include/msgpack/adaptor/boost/msgpack_variant_decl.hpp
|
||||||
include/msgpack/adaptor/boost/optional.hpp
|
include/msgpack/adaptor/boost/optional.hpp
|
||||||
include/msgpack/adaptor/boost/string_ref.hpp
|
include/msgpack/adaptor/boost/string_ref.hpp
|
||||||
|
include/msgpack/adaptor/boost/string_view.hpp
|
||||||
include/msgpack/adaptor/carray.hpp
|
include/msgpack/adaptor/carray.hpp
|
||||||
include/msgpack/adaptor/char_ptr.hpp
|
include/msgpack/adaptor/char_ptr.hpp
|
||||||
include/msgpack/adaptor/check_container_size.hpp
|
include/msgpack/adaptor/check_container_size.hpp
|
||||||
@@ -172,6 +174,7 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/adaptor/cpp11/array.hpp
|
include/msgpack/adaptor/cpp11/array.hpp
|
||||||
include/msgpack/adaptor/cpp11/array_char.hpp
|
include/msgpack/adaptor/cpp11/array_char.hpp
|
||||||
include/msgpack/adaptor/cpp11/array_unsigned_char.hpp
|
include/msgpack/adaptor/cpp11/array_unsigned_char.hpp
|
||||||
|
include/msgpack/adaptor/cpp11/chrono.hpp
|
||||||
include/msgpack/adaptor/cpp11/forward_list.hpp
|
include/msgpack/adaptor/cpp11/forward_list.hpp
|
||||||
include/msgpack/adaptor/cpp11/reference_wrapper.hpp
|
include/msgpack/adaptor/cpp11/reference_wrapper.hpp
|
||||||
include/msgpack/adaptor/cpp11/shared_ptr.hpp
|
include/msgpack/adaptor/cpp11/shared_ptr.hpp
|
||||||
@@ -179,6 +182,11 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/adaptor/cpp11/unique_ptr.hpp
|
include/msgpack/adaptor/cpp11/unique_ptr.hpp
|
||||||
include/msgpack/adaptor/cpp11/unordered_map.hpp
|
include/msgpack/adaptor/cpp11/unordered_map.hpp
|
||||||
include/msgpack/adaptor/cpp11/unordered_set.hpp
|
include/msgpack/adaptor/cpp11/unordered_set.hpp
|
||||||
|
include/msgpack/adaptor/cpp17/byte.hpp
|
||||||
|
include/msgpack/adaptor/cpp17/carray_byte.hpp
|
||||||
|
include/msgpack/adaptor/cpp17/optional.hpp
|
||||||
|
include/msgpack/adaptor/cpp17/string_view.hpp
|
||||||
|
include/msgpack/adaptor/cpp17/vector_byte.hpp
|
||||||
include/msgpack/adaptor/define.hpp
|
include/msgpack/adaptor/define.hpp
|
||||||
include/msgpack/adaptor/define_decl.hpp
|
include/msgpack/adaptor/define_decl.hpp
|
||||||
include/msgpack/adaptor/deque.hpp
|
include/msgpack/adaptor/deque.hpp
|
||||||
@@ -213,6 +221,8 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/adaptor/vector_unsigned_char.hpp
|
include/msgpack/adaptor/vector_unsigned_char.hpp
|
||||||
include/msgpack/cpp_config.hpp
|
include/msgpack/cpp_config.hpp
|
||||||
include/msgpack/cpp_config_decl.hpp
|
include/msgpack/cpp_config_decl.hpp
|
||||||
|
include/msgpack/create_object_visitor.hpp
|
||||||
|
include/msgpack/create_object_visitor_decl.hpp
|
||||||
include/msgpack/fbuffer.hpp
|
include/msgpack/fbuffer.hpp
|
||||||
include/msgpack/fbuffer_decl.hpp
|
include/msgpack/fbuffer_decl.hpp
|
||||||
include/msgpack/gcc_atomic.hpp
|
include/msgpack/gcc_atomic.hpp
|
||||||
@@ -220,12 +230,16 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/iterator_decl.hpp
|
include/msgpack/iterator_decl.hpp
|
||||||
include/msgpack/meta.hpp
|
include/msgpack/meta.hpp
|
||||||
include/msgpack/meta_decl.hpp
|
include/msgpack/meta_decl.hpp
|
||||||
|
include/msgpack/null_visitor.hpp
|
||||||
|
include/msgpack/null_visitor_decl.hpp
|
||||||
include/msgpack/object.hpp
|
include/msgpack/object.hpp
|
||||||
include/msgpack/object_decl.hpp
|
include/msgpack/object_decl.hpp
|
||||||
include/msgpack/object_fwd.hpp
|
include/msgpack/object_fwd.hpp
|
||||||
include/msgpack/object_fwd_decl.hpp
|
include/msgpack/object_fwd_decl.hpp
|
||||||
include/msgpack/pack.hpp
|
include/msgpack/pack.hpp
|
||||||
include/msgpack/pack_decl.hpp
|
include/msgpack/pack_decl.hpp
|
||||||
|
include/msgpack/parse.hpp
|
||||||
|
include/msgpack/parse_decl.hpp
|
||||||
include/msgpack/parse_return.hpp
|
include/msgpack/parse_return.hpp
|
||||||
include/msgpack/preprocessor.hpp
|
include/msgpack/preprocessor.hpp
|
||||||
include/msgpack/preprocessor/arithmetic.hpp
|
include/msgpack/preprocessor/arithmetic.hpp
|
||||||
@@ -512,6 +526,7 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp
|
include/msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp
|
||||||
include/msgpack/v1/adaptor/boost/optional.hpp
|
include/msgpack/v1/adaptor/boost/optional.hpp
|
||||||
include/msgpack/v1/adaptor/boost/string_ref.hpp
|
include/msgpack/v1/adaptor/boost/string_ref.hpp
|
||||||
|
include/msgpack/v1/adaptor/boost/string_view.hpp
|
||||||
include/msgpack/v1/adaptor/carray.hpp
|
include/msgpack/v1/adaptor/carray.hpp
|
||||||
include/msgpack/v1/adaptor/char_ptr.hpp
|
include/msgpack/v1/adaptor/char_ptr.hpp
|
||||||
include/msgpack/v1/adaptor/check_container_size.hpp
|
include/msgpack/v1/adaptor/check_container_size.hpp
|
||||||
@@ -519,6 +534,7 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/v1/adaptor/cpp11/array.hpp
|
include/msgpack/v1/adaptor/cpp11/array.hpp
|
||||||
include/msgpack/v1/adaptor/cpp11/array_char.hpp
|
include/msgpack/v1/adaptor/cpp11/array_char.hpp
|
||||||
include/msgpack/v1/adaptor/cpp11/array_unsigned_char.hpp
|
include/msgpack/v1/adaptor/cpp11/array_unsigned_char.hpp
|
||||||
|
include/msgpack/v1/adaptor/cpp11/chrono.hpp
|
||||||
include/msgpack/v1/adaptor/cpp11/forward_list.hpp
|
include/msgpack/v1/adaptor/cpp11/forward_list.hpp
|
||||||
include/msgpack/v1/adaptor/cpp11/reference_wrapper.hpp
|
include/msgpack/v1/adaptor/cpp11/reference_wrapper.hpp
|
||||||
include/msgpack/v1/adaptor/cpp11/shared_ptr.hpp
|
include/msgpack/v1/adaptor/cpp11/shared_ptr.hpp
|
||||||
@@ -526,6 +542,11 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/v1/adaptor/cpp11/unique_ptr.hpp
|
include/msgpack/v1/adaptor/cpp11/unique_ptr.hpp
|
||||||
include/msgpack/v1/adaptor/cpp11/unordered_map.hpp
|
include/msgpack/v1/adaptor/cpp11/unordered_map.hpp
|
||||||
include/msgpack/v1/adaptor/cpp11/unordered_set.hpp
|
include/msgpack/v1/adaptor/cpp11/unordered_set.hpp
|
||||||
|
include/msgpack/v1/adaptor/cpp17/byte.hpp
|
||||||
|
include/msgpack/v1/adaptor/cpp17/carray_byte.hpp
|
||||||
|
include/msgpack/v1/adaptor/cpp17/optional.hpp
|
||||||
|
include/msgpack/v1/adaptor/cpp17/string_view.hpp
|
||||||
|
include/msgpack/v1/adaptor/cpp17/vector_byte.hpp
|
||||||
include/msgpack/v1/adaptor/define.hpp
|
include/msgpack/v1/adaptor/define.hpp
|
||||||
include/msgpack/v1/adaptor/define_decl.hpp
|
include/msgpack/v1/adaptor/define_decl.hpp
|
||||||
include/msgpack/v1/adaptor/deque.hpp
|
include/msgpack/v1/adaptor/deque.hpp
|
||||||
@@ -535,6 +556,7 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/v1/adaptor/detail/cpp03_define_map_decl.hpp
|
include/msgpack/v1/adaptor/detail/cpp03_define_map_decl.hpp
|
||||||
include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple.hpp
|
include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple.hpp
|
||||||
include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp
|
include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp
|
||||||
|
include/msgpack/v1/adaptor/detail/cpp11_convert_helper.hpp
|
||||||
include/msgpack/v1/adaptor/detail/cpp11_define_array.hpp
|
include/msgpack/v1/adaptor/detail/cpp11_define_array.hpp
|
||||||
include/msgpack/v1/adaptor/detail/cpp11_define_array_decl.hpp
|
include/msgpack/v1/adaptor/detail/cpp11_define_array_decl.hpp
|
||||||
include/msgpack/v1/adaptor/detail/cpp11_define_map.hpp
|
include/msgpack/v1/adaptor/detail/cpp11_define_map.hpp
|
||||||
@@ -626,31 +648,85 @@ IF (MSGPACK_ENABLE_CXX)
|
|||||||
include/msgpack/v2/adaptor/v4raw_decl.hpp
|
include/msgpack/v2/adaptor/v4raw_decl.hpp
|
||||||
include/msgpack/v2/cpp_config_decl.hpp
|
include/msgpack/v2/cpp_config_decl.hpp
|
||||||
include/msgpack/v2/create_object_visitor.hpp
|
include/msgpack/v2/create_object_visitor.hpp
|
||||||
|
include/msgpack/v2/create_object_visitor_decl.hpp
|
||||||
include/msgpack/v2/detail/cpp03_zone_decl.hpp
|
include/msgpack/v2/detail/cpp03_zone_decl.hpp
|
||||||
include/msgpack/v2/detail/cpp11_zone_decl.hpp
|
include/msgpack/v2/detail/cpp11_zone_decl.hpp
|
||||||
include/msgpack/v2/fbuffer_decl.hpp
|
include/msgpack/v2/fbuffer_decl.hpp
|
||||||
include/msgpack/v2/iterator_decl.hpp
|
include/msgpack/v2/iterator_decl.hpp
|
||||||
include/msgpack/v2/meta_decl.hpp
|
include/msgpack/v2/meta_decl.hpp
|
||||||
include/msgpack/v2/null_visitor.hpp
|
include/msgpack/v2/null_visitor.hpp
|
||||||
|
include/msgpack/v2/null_visitor_decl.hpp
|
||||||
include/msgpack/v2/object.hpp
|
include/msgpack/v2/object.hpp
|
||||||
include/msgpack/v2/object_decl.hpp
|
include/msgpack/v2/object_decl.hpp
|
||||||
include/msgpack/v2/object_fwd.hpp
|
include/msgpack/v2/object_fwd.hpp
|
||||||
include/msgpack/v2/object_fwd_decl.hpp
|
include/msgpack/v2/object_fwd_decl.hpp
|
||||||
include/msgpack/v2/pack_decl.hpp
|
include/msgpack/v2/pack_decl.hpp
|
||||||
include/msgpack/v2/parse.hpp
|
include/msgpack/v2/parse.hpp
|
||||||
|
include/msgpack/v2/parse_decl.hpp
|
||||||
include/msgpack/v2/parse_return.hpp
|
include/msgpack/v2/parse_return.hpp
|
||||||
include/msgpack/v2/sbuffer_decl.hpp
|
include/msgpack/v2/sbuffer_decl.hpp
|
||||||
include/msgpack/v2/unpack.hpp
|
include/msgpack/v2/unpack.hpp
|
||||||
include/msgpack/v2/unpack_decl.hpp
|
include/msgpack/v2/unpack_decl.hpp
|
||||||
include/msgpack/v2/vrefbuffer_decl.hpp
|
include/msgpack/v2/vrefbuffer_decl.hpp
|
||||||
include/msgpack/v2/x3_parse.hpp
|
include/msgpack/v2/x3_parse.hpp
|
||||||
|
include/msgpack/v2/x3_parse_decl.hpp
|
||||||
include/msgpack/v2/x3_unpack.hpp
|
include/msgpack/v2/x3_unpack.hpp
|
||||||
|
include/msgpack/v2/x3_unpack_decl.hpp
|
||||||
include/msgpack/v2/zbuffer_decl.hpp
|
include/msgpack/v2/zbuffer_decl.hpp
|
||||||
include/msgpack/v2/zone_decl.hpp
|
include/msgpack/v2/zone_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/adaptor_base.hpp
|
||||||
|
include/msgpack/v3/adaptor/adaptor_base_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/array_ref_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/boost/msgpack_variant_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/check_container_size_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/define_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/detail/cpp03_define_array_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/detail/cpp03_define_map_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/detail/cpp03_msgpack_tuple_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/detail/cpp11_define_array_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/detail/cpp11_define_map_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/detail/cpp11_msgpack_tuple_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/ext_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/fixint_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/int_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/map_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/msgpack_tuple_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/nil_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/raw_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/size_equal_only_decl.hpp
|
||||||
|
include/msgpack/v3/adaptor/v4raw_decl.hpp
|
||||||
|
include/msgpack/v3/cpp_config_decl.hpp
|
||||||
|
include/msgpack/v3/create_object_visitor_decl.hpp
|
||||||
|
include/msgpack/v3/detail/cpp03_zone_decl.hpp
|
||||||
|
include/msgpack/v3/detail/cpp11_zone_decl.hpp
|
||||||
|
include/msgpack/v3/fbuffer_decl.hpp
|
||||||
|
include/msgpack/v3/iterator_decl.hpp
|
||||||
|
include/msgpack/v3/meta_decl.hpp
|
||||||
|
include/msgpack/v3/null_visitor_decl.hpp
|
||||||
|
include/msgpack/v3/object_decl.hpp
|
||||||
|
include/msgpack/v3/object_fwd.hpp
|
||||||
|
include/msgpack/v3/object_fwd_decl.hpp
|
||||||
|
include/msgpack/v3/pack_decl.hpp
|
||||||
|
include/msgpack/v3/parse.hpp
|
||||||
|
include/msgpack/v3/parse_decl.hpp
|
||||||
|
include/msgpack/v3/parse_return.hpp
|
||||||
|
include/msgpack/v3/sbuffer_decl.hpp
|
||||||
|
include/msgpack/v3/unpack.hpp
|
||||||
|
include/msgpack/v3/unpack_decl.hpp
|
||||||
|
include/msgpack/v3/vrefbuffer_decl.hpp
|
||||||
|
include/msgpack/v3/x3_parse_decl.hpp
|
||||||
|
include/msgpack/v3/x3_unpack.hpp
|
||||||
|
include/msgpack/v3/x3_unpack_decl.hpp
|
||||||
|
include/msgpack/v3/zbuffer_decl.hpp
|
||||||
|
include/msgpack/v3/zone_decl.hpp
|
||||||
include/msgpack/version.hpp
|
include/msgpack/version.hpp
|
||||||
include/msgpack/versioning.hpp
|
include/msgpack/versioning.hpp
|
||||||
include/msgpack/vrefbuffer.hpp
|
include/msgpack/vrefbuffer.hpp
|
||||||
include/msgpack/vrefbuffer_decl.hpp
|
include/msgpack/vrefbuffer_decl.hpp
|
||||||
|
include/msgpack/x3_parse.hpp
|
||||||
|
include/msgpack/x3_parse_decl.hpp
|
||||||
|
include/msgpack/x3_unpack.hpp
|
||||||
|
include/msgpack/x3_unpack_decl.hpp
|
||||||
include/msgpack/zbuffer.hpp
|
include/msgpack/zbuffer.hpp
|
||||||
include/msgpack/zbuffer_decl.hpp
|
include/msgpack/zbuffer_decl.hpp
|
||||||
include/msgpack/zone.hpp
|
include/msgpack/zone.hpp
|
||||||
|
@@ -20,7 +20,7 @@ You might need to run `sudo port selfupdate` before installing to update the pac
|
|||||||
You can also install via Homebrew.
|
You can also install via Homebrew.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ sudo brew install msgpack
|
$ brew install msgpack
|
||||||
```
|
```
|
||||||
|
|
||||||
## FreeBSD with Ports Collection
|
## FreeBSD with Ports Collection
|
||||||
@@ -96,7 +96,7 @@ int main(void) {
|
|||||||
/* deserializes it. */
|
/* deserializes it. */
|
||||||
msgpack_unpacked msg;
|
msgpack_unpacked msg;
|
||||||
msgpack_unpacked_init(&msg);
|
msgpack_unpacked_init(&msg);
|
||||||
bool success = msgpack_unpack_next(&msg, buffer->data, buffer->size, NULL);
|
msgpack_unpack_return ret = msgpack_unpack_next(&msg, buffer->data, buffer->size, NULL);
|
||||||
|
|
||||||
/* prints the deserialized object. */
|
/* prints the deserialized object. */
|
||||||
msgpack_object obj = msg.data;
|
msgpack_object obj = msg.data;
|
||||||
@@ -137,7 +137,7 @@ int main(void) {
|
|||||||
/* deserializes it. */
|
/* deserializes it. */
|
||||||
msgpack_unpacked msg;
|
msgpack_unpacked msg;
|
||||||
msgpack_unpacked_init(&msg);
|
msgpack_unpacked_init(&msg);
|
||||||
bool success = msgpack_unpack_next(&msg, buffer->data, buffer->size, NULL);
|
msgpack_unpack_return ret = msgpack_unpack_next(&msg, buffer->data, buffer->size, NULL);
|
||||||
|
|
||||||
/* prints the deserialized object. */
|
/* prints the deserialized object. */
|
||||||
msgpack_object obj = msg.data;
|
msgpack_object obj = msg.data;
|
||||||
|
@@ -78,7 +78,7 @@ int main(void) {
|
|||||||
|
|
||||||
// now starts streaming deserialization.
|
// now starts streaming deserialization.
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
while(pac.next(&oh)) {
|
while(pac.next(oh)) {
|
||||||
std::cout << oh.get() << std::endl;
|
std::cout << oh.get() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
README.md
22
README.md
@@ -1,9 +1,9 @@
|
|||||||
`msgpack` for C/C++
|
`msgpack` for C/C++
|
||||||
===================
|
===================
|
||||||
|
|
||||||
Version 2.1.0 [](https://travis-ci.org/msgpack/msgpack-c) [](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
|
Version 3.1.0 [](https://travis-ci.org/msgpack/msgpack-c) [](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
|
||||||
|
|
||||||
It's like JSON but small and fast.
|
It's like JSON but smaller and faster.
|
||||||
|
|
||||||
Overview
|
Overview
|
||||||
--------
|
--------
|
||||||
@@ -11,7 +11,7 @@ Overview
|
|||||||
[MessagePack](http://msgpack.org/) is an efficient binary serialization
|
[MessagePack](http://msgpack.org/) is an efficient binary serialization
|
||||||
format, which lets you exchange data among multiple languages like JSON,
|
format, which lets you exchange data among multiple languages like JSON,
|
||||||
except that it's faster and smaller. Small integers are encoded into a
|
except that it's faster and smaller. Small integers are encoded into a
|
||||||
single byte while typical short strings require only one extra byte in
|
single byte and short strings require only one extra byte in
|
||||||
addition to the strings themselves.
|
addition to the strings themselves.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
@@ -97,6 +97,10 @@ int main(void)
|
|||||||
msgpack::type::tuple<int, bool, std::string> dst;
|
msgpack::type::tuple<int, bool, std::string> dst;
|
||||||
deserialized.convert(dst);
|
deserialized.convert(dst);
|
||||||
|
|
||||||
|
// or create the new instance
|
||||||
|
msgpack::type::tuple<int, bool, std::string> dst2 =
|
||||||
|
deserialized.as<msgpack::type::tuple<int, bool, std::string> >();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -108,7 +112,7 @@ Usage
|
|||||||
|
|
||||||
### C++ Header Only Library
|
### C++ Header Only Library
|
||||||
|
|
||||||
When you use msgpack on C++03 and C++11, you can just add
|
When you use msgpack on C++, you can just add
|
||||||
msgpack-c/include to your include path:
|
msgpack-c/include to your include path:
|
||||||
|
|
||||||
g++ -I msgpack-c/include your_source_file.cpp
|
g++ -I msgpack-c/include your_source_file.cpp
|
||||||
@@ -135,14 +139,18 @@ C and C++03:
|
|||||||
$ make
|
$ make
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
|
|
||||||
If you want to setup C++11 version of msgpack instead,
|
If you want to setup C++11 or C++17 version of msgpack instead,
|
||||||
execute the following commands:
|
execute the following commands:
|
||||||
|
|
||||||
$ git clone https://github.com/msgpack/msgpack-c.git
|
$ git clone https://github.com/msgpack/msgpack-c.git
|
||||||
$ cd msgpack-c
|
$ cd msgpack-c
|
||||||
$ cmake -DMSGPACK_CXX11=ON .
|
$ cmake -DMSGPACK_CXX[11|17]=ON .
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
|
|
||||||
|
`MSGPACK_CXX[11|17]` flags are not affected to installing files. Just switching test cases. All files are installed in every settings.
|
||||||
|
|
||||||
|
When you use the C part of `msgpack-c`, you need to build and link the library. By default, both static/shared libraries are built. If you want to build only static library, set `BUILD_SHARED_LIBS=OFF` to cmake. If you want to build only shared library, set `BUILD_SHARED_L
|
||||||
|
|
||||||
#### GUI on Windows
|
#### GUI on Windows
|
||||||
|
|
||||||
Clone msgpack-c git repository.
|
Clone msgpack-c git repository.
|
||||||
@@ -170,7 +178,7 @@ the binaries:' text box.
|
|||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
You can get addtional information on the
|
You can get additional information including the tutorial on the
|
||||||
[wiki](https://github.com/msgpack/msgpack-c/wiki).
|
[wiki](https://github.com/msgpack/msgpack-c/wiki).
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
|
24
appveyor.yml
24
appveyor.yml
@@ -1,15 +1,19 @@
|
|||||||
version: 2.1.0.{build}
|
version: 3.1.0.{build}
|
||||||
|
|
||||||
|
image:
|
||||||
|
- Visual Studio 2015
|
||||||
environment:
|
environment:
|
||||||
|
global:
|
||||||
|
BOOST_ROOT: C:\Libraries\boost_1_60_0
|
||||||
matrix:
|
matrix:
|
||||||
- cpp11: -DMSGPACK_CXX11=OFF
|
- cpp11: -DMSGPACK_CXX11=OFF
|
||||||
boost: -DMSGPACK_BOOST=ON
|
boost: -DMSGPACK_BOOST=OFF
|
||||||
msvc: '"Visual Studio 10 2010"'
|
msvc: '"Visual Studio 10 2010"'
|
||||||
- cpp11: -DMSGPACK_CXX11=OFF
|
- cpp11: -DMSGPACK_CXX11=OFF
|
||||||
boost: -DMSGPACK_BOOST=ON
|
boost: -DMSGPACK_BOOST=OFF
|
||||||
msvc: '"Visual Studio 11 2012"'
|
msvc: '"Visual Studio 11 2012"'
|
||||||
- cpp11: -DMSGPACK_CXX11=OFF
|
- cpp11: -DMSGPACK_CXX11=OFF
|
||||||
boost: -DMSGPACK_BOOST=ON
|
boost: -DMSGPACK_BOOST=OFF
|
||||||
msvc: '"Visual Studio 12 2013"'
|
msvc: '"Visual Studio 12 2013"'
|
||||||
- cpp11: -DMSGPACK_CXX11=ON
|
- cpp11: -DMSGPACK_CXX11=ON
|
||||||
boost: -DMSGPACK_BOOST=ON
|
boost: -DMSGPACK_BOOST=ON
|
||||||
@@ -33,10 +37,10 @@ build_script:
|
|||||||
- cmake --build . --config Release
|
- cmake --build . --config Release
|
||||||
- cd ..
|
- cd ..
|
||||||
- cd ..
|
- cd ..
|
||||||
- appveyor DownloadFile http://zlib.net/zlib-1.2.10.tar.gz -FileName zlib-1.2.10.tar.gz
|
- appveyor DownloadFile http://zlib.net/zlib-1.2.11.tar.gz -FileName zlib-1.2.11.tar.gz
|
||||||
- 7z x zlib-1.2.10.tar.gz > NUL
|
- 7z x zlib-1.2.11.tar.gz > NUL
|
||||||
- 7z x zlib-1.2.10.tar > NUL
|
- 7z x zlib-1.2.11.tar > NUL
|
||||||
- cd zlib-1.2.10
|
- cd zlib-1.2.11
|
||||||
- md build
|
- md build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake -G %msvc% ..
|
- cmake -G %msvc% ..
|
||||||
@@ -46,9 +50,9 @@ build_script:
|
|||||||
- cd ..
|
- cd ..
|
||||||
- md build
|
- md build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake -G %msvc% %cpp11% %boost% %x3_parse% -DMSGPACK_BOOST_DIR=C:\Libraries\\boost_1_60_0 -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.10\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.10 -DCMAKE_CXX_FLAGS='"/D_VARIADIC_MAX=10 /EHsc"' ..
|
- cmake -G %msvc% %cpp11% %boost% %x3_parse% -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.11\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.11 -DCMAKE_CXX_FLAGS='"/D_VARIADIC_MAX=10 /EHsc"' ..
|
||||||
- cmake --build . --config Release
|
- cmake --build . --config Release
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release;%APPVEYOR_BUILD_FOLDER%\zlib-1.2.10\build\Release;%APPVEYOR_BUILD_FOLDER%\build\release
|
- set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\googletest-release-1.7.0\build\Release;%APPVEYOR_BUILD_FOLDER%\zlib-1.2.11\build\Release;%APPVEYOR_BUILD_FOLDER%\build\release
|
||||||
- ctest -V
|
- ctest -V
|
||||||
|
@@ -23,7 +23,7 @@ else
|
|||||||
export BIT32="OFF"
|
export BIT32="OFF"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmake -DMSGPACK_CXX11=${CXX11} -DMSGPACK_32BIT=${BIT32} -DMSGPACK_BOOST=${BOOST} -DMSGPACK_ENABLE_SHARED=${SHARED} -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} -DMSGPACK_DEFAULT_API_VERSION=${API_VERSION} -DMSGPACK_USE_X3_PARSE=${X3_PARSE} ..
|
cmake -DMSGPACK_CXX11=${CXX11} -DMSGPACK_CXX17=${CXX17} -DMSGPACK_32BIT=${BIT32} -DMSGPACK_BOOST=${BOOST} -DBUILD_SHARED_LIBS=${SHARED} -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} -DMSGPACK_DEFAULT_API_VERSION=${API_VERSION} -DMSGPACK_USE_X3_PARSE=${X3_PARSE} ..
|
||||||
|
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $ret -ne 0 ]
|
if [ $ret -ne 0 ]
|
||||||
@@ -39,7 +39,7 @@ then
|
|||||||
exit $ret
|
exit $ret
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make test
|
ctest -VV
|
||||||
|
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ $ret -ne 0 ]
|
if [ $ret -ne 0 ]
|
||||||
|
49
ci/build_regression.sh
Executable file
49
ci/build_regression.sh
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mkdir -p build
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd build
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ARCH}" == "32" ]
|
||||||
|
then
|
||||||
|
echo "64 bit support required for regressions"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmake -DMSGPACK_FUZZ_REGRESSION="ON" -DMSGPACK_CXX11="ON" -DMSGPACK_BOOST=${BOOST} -DMSGPACK_SAN=${MSGPACK_SAN} -v ..
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
make test
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
@@ -66,14 +66,16 @@ struct define_array<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
|||||||
msgpack::object *ptr = o.via.array.ptr;
|
msgpack::object *ptr = o.via.array.ptr;
|
||||||
switch(size) {
|
switch(size) {
|
||||||
default:<%(i).downto(0) {|j|%>
|
default:<%(i).downto(0) {|j|%>
|
||||||
case <%=j+1%>: ptr[<%=j%>].convert(a<%=j%>);<%}%>
|
case <%=j+1%>: ptr[<%=j%>].convert(a<%=j%>);
|
||||||
|
// fallthrough
|
||||||
|
<%}%>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||||
{
|
{
|
||||||
o->type = msgpack::type::ARRAY;
|
o->type = msgpack::type::ARRAY;
|
||||||
o->via.array.ptr = static_cast<msgpack::object*>(z.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
|
o->via.array.ptr = static_cast<msgpack::object*>(z.allocate_align(sizeof(msgpack::object)*<%=i+1%>, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o->via.array.size = <%=i+1%>;
|
o->via.array.size = <%=i+1%>;
|
||||||
<%0.upto(i) {|j|%>
|
<%0.upto(i) {|j|%>
|
||||||
o->via.array.ptr[<%=j%>] = msgpack::object(a<%=j%>, z);<%}%>
|
o->via.array.ptr[<%=j%>] = msgpack::object(a<%=j%>, z);<%}%>
|
||||||
|
@@ -61,6 +61,7 @@ struct define_map<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
|||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
std::map<std::string, msgpack::object const*> kvmap;
|
std::map<std::string, msgpack::object const*> kvmap;
|
||||||
for (uint32_t i = 0; i < o.via.map.size; ++i) {
|
for (uint32_t i = 0; i < o.via.map.size; ++i) {
|
||||||
|
if (o.via.map.ptr[i].key.type != msgpack::type::STR) { throw msgpack::type_error(); }
|
||||||
kvmap.insert(
|
kvmap.insert(
|
||||||
std::map<std::string, msgpack::object const*>::value_type(
|
std::map<std::string, msgpack::object const*>::value_type(
|
||||||
std::string(
|
std::string(
|
||||||
@@ -82,7 +83,7 @@ struct define_map<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
|||||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||||
{
|
{
|
||||||
o->type = msgpack::type::MAP;
|
o->type = msgpack::type::MAP;
|
||||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*<%=(i+1)/2%>));
|
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*<%=(i+1)/2%>, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||||
o->via.map.size = <%=(i+1)/2%>;
|
o->via.map.size = <%=(i+1)/2%>;
|
||||||
<%0.step(i,2) {|j|%>
|
<%0.step(i,2) {|j|%>
|
||||||
o->via.map.ptr[<%=j/2%>].key = msgpack::object(a<%=j%>, z);
|
o->via.map.ptr[<%=j/2%>].key = msgpack::object(a<%=j%>, z);
|
||||||
|
@@ -207,7 +207,7 @@ struct object_with_zone<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> > {
|
|||||||
msgpack::object::with_zone& o,
|
msgpack::object::with_zone& o,
|
||||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) const {
|
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) const {
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
|
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*<%=i+1%>, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o.via.array.size = <%=i+1%>;
|
o.via.array.size = <%=i+1%>;
|
||||||
<%0.upto(i) {|j|%>
|
<%0.upto(i) {|j|%>
|
||||||
o.via.array.ptr[<%=j%>] = msgpack::object(v.template get<<%=j%>>(), o.zone);<%}%>
|
o.via.array.ptr[<%=j%>] = msgpack::object(v.template get<<%=j%>>(), o.zone);<%}%>
|
||||||
|
@@ -178,7 +178,9 @@ private:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static void object_delete(void* obj);
|
static void object_delete(void* obj);
|
||||||
|
|
||||||
void* allocate_expand(size_t size);
|
static char* get_aligned(char* ptr, size_t align);
|
||||||
|
|
||||||
|
char* allocate_expand(size_t size);
|
||||||
private:
|
private:
|
||||||
zone(const zone&);
|
zone(const zone&);
|
||||||
zone& operator=(const zone&);
|
zone& operator=(const zone&);
|
||||||
@@ -188,37 +190,42 @@ inline zone::zone(size_t chunk_size) /* throw() */ :m_chunk_size(chunk_size), m_
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void* zone::allocate_align(size_t size, size_t align)
|
inline char* zone::get_aligned(char* ptr, size_t align)
|
||||||
{
|
{
|
||||||
char* aligned =
|
return
|
||||||
reinterpret_cast<char*>(
|
reinterpret_cast<char*>(
|
||||||
reinterpret_cast<size_t>(
|
reinterpret_cast<size_t>(
|
||||||
(m_chunk_list.m_ptr + (align - 1))) / align * align);
|
(ptr + (align - 1))) / align * align);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* zone::allocate_align(size_t size, size_t align)
|
||||||
|
{
|
||||||
|
char* aligned = get_aligned(m_chunk_list.m_ptr, align);
|
||||||
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||||
if(m_chunk_list.m_free >= adjusted_size) {
|
if (m_chunk_list.m_free < adjusted_size) {
|
||||||
m_chunk_list.m_free -= adjusted_size;
|
size_t enough_size = size + align - 1;
|
||||||
m_chunk_list.m_ptr += adjusted_size;
|
char* ptr = allocate_expand(enough_size);
|
||||||
return aligned;
|
aligned = get_aligned(ptr, align);
|
||||||
|
adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||||
}
|
}
|
||||||
return reinterpret_cast<char*>(
|
m_chunk_list.m_free -= adjusted_size;
|
||||||
reinterpret_cast<size_t>(
|
m_chunk_list.m_ptr += adjusted_size;
|
||||||
allocate_expand(size + (align - 1))) / align * align);
|
return aligned;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void* zone::allocate_no_align(size_t size)
|
inline void* zone::allocate_no_align(size_t size)
|
||||||
{
|
{
|
||||||
if(m_chunk_list.m_free < size) {
|
|
||||||
return allocate_expand(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* ptr = m_chunk_list.m_ptr;
|
char* ptr = m_chunk_list.m_ptr;
|
||||||
|
if(m_chunk_list.m_free < size) {
|
||||||
|
ptr = allocate_expand(size);
|
||||||
|
}
|
||||||
m_chunk_list.m_free -= size;
|
m_chunk_list.m_free -= size;
|
||||||
m_chunk_list.m_ptr += size;
|
m_chunk_list.m_ptr += size;
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void* zone::allocate_expand(size_t size)
|
inline char* zone::allocate_expand(size_t size)
|
||||||
{
|
{
|
||||||
chunk_list* const cl = &m_chunk_list;
|
chunk_list* const cl = &m_chunk_list;
|
||||||
|
|
||||||
@@ -240,8 +247,8 @@ inline void* zone::allocate_expand(size_t size)
|
|||||||
|
|
||||||
c->m_next = cl->m_head;
|
c->m_next = cl->m_head;
|
||||||
cl->m_head = c;
|
cl->m_head = c;
|
||||||
cl->m_free = sz - size;
|
cl->m_free = sz;
|
||||||
cl->m_ptr = ptr + size;
|
cl->m_ptr = ptr;
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
@@ -300,7 +307,7 @@ inline std::size_t aligned_size(
|
|||||||
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
|
T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
|
||||||
{
|
{
|
||||||
void* x = allocate_align(sizeof(T));
|
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||||
try {
|
try {
|
||||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@@ -24,6 +24,14 @@
|
|||||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define MSGPACK_ZONE_ALIGNOF(type) __alignof(type)
|
||||||
|
#else
|
||||||
|
#define MSGPACK_ZONE_ALIGNOF(type) __alignof__(type)
|
||||||
|
#endif
|
||||||
|
// For a compiler that doesn't support __alignof__:
|
||||||
|
// #define MSGPACK_ZONE_ALIGNOF(type) MSGPACK_ZONE_ALIGN
|
||||||
|
|
||||||
<% GENERATION_LIMIT = 15 %>
|
<% GENERATION_LIMIT = 15 %>
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
@@ -3,6 +3,20 @@ IF (MSGPACK_BOOST)
|
|||||||
msgpack_variant_capitalize.cpp
|
msgpack_variant_capitalize.cpp
|
||||||
msgpack_variant_mapbased.cpp
|
msgpack_variant_mapbased.cpp
|
||||||
)
|
)
|
||||||
|
IF (MSGPACK_CXX11 OR MSGPACK_CXX17)
|
||||||
|
FIND_PACKAGE (Threads REQUIRED)
|
||||||
|
LIST (APPEND exec_PROGRAMS
|
||||||
|
asio_send_recv.cpp
|
||||||
|
)
|
||||||
|
IF (ZLIB_FOUND)
|
||||||
|
INCLUDE_DIRECTORIES (
|
||||||
|
${ZLIB_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
LIST (APPEND exec_PROGRAMS
|
||||||
|
asio_send_recv_zlib.cpp
|
||||||
|
)
|
||||||
|
ENDIF ()
|
||||||
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
FOREACH (source_file ${exec_PROGRAMS})
|
FOREACH (source_file ${exec_PROGRAMS})
|
||||||
@@ -11,8 +25,21 @@ FOREACH (source_file ${exec_PROGRAMS})
|
|||||||
${source_file_we}
|
${source_file_we}
|
||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||||
|
PRIVATE
|
||||||
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
|
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||||
|
${Boost_SYSTEM_LIBRARY}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
)
|
||||||
|
IF (ZLIB_FOUND)
|
||||||
|
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||||
|
${ZLIB_LIBRARIES}
|
||||||
|
)
|
||||||
|
ENDIF()
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
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 -g -O3")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
104
example/boost/asio_send_recv.cpp
Normal file
104
example/boost/asio_send_recv.cpp
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
// MessagePack for C++ example
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include <msgpack.hpp>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
boost::asio::io_service ios;
|
||||||
|
std::uint16_t const port = 12345;
|
||||||
|
|
||||||
|
// Server
|
||||||
|
std::size_t const window_size = 10;
|
||||||
|
boost::asio::ip::tcp::acceptor ac(ios, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port));
|
||||||
|
boost::asio::ip::tcp::socket ss(ios);
|
||||||
|
std::function<void()> do_accept;
|
||||||
|
std::function<void()> do_async_read_some;
|
||||||
|
|
||||||
|
msgpack::unpacker unp;
|
||||||
|
|
||||||
|
do_accept = [&] {
|
||||||
|
ac.async_accept(
|
||||||
|
ss,
|
||||||
|
[&]
|
||||||
|
(boost::system::error_code const& e) {
|
||||||
|
if (e) {
|
||||||
|
std::cout << __LINE__ << ":" << e.message() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unp.reserve_buffer(window_size);
|
||||||
|
do_async_read_some = [&] {
|
||||||
|
ss.async_read_some(
|
||||||
|
boost::asio::buffer(unp.buffer(), window_size),
|
||||||
|
[&](boost::system::error_code const& e, std::size_t bytes_transferred) {
|
||||||
|
if (e) {
|
||||||
|
std::cout << __LINE__ << ":" << e.message() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::cout << bytes_transferred << " bytes read." << std::endl;
|
||||||
|
unp.buffer_consumed(bytes_transferred);
|
||||||
|
msgpack::object_handle oh;
|
||||||
|
while (unp.next(oh)) {
|
||||||
|
std::cout << oh.get() << std::endl;
|
||||||
|
// In order to finish the program,
|
||||||
|
// return if one complete msgpack is processed.
|
||||||
|
// In actual server, don't return here.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
do_async_read_some();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
do_async_read_some();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
do_accept();
|
||||||
|
|
||||||
|
// Client
|
||||||
|
auto host = "localhost";
|
||||||
|
boost::asio::ip::tcp::resolver r(ios);
|
||||||
|
|
||||||
|
#if BOOST_VERSION < 106600
|
||||||
|
boost::asio::ip::tcp::resolver::query q(host, boost::lexical_cast<std::string>(port));
|
||||||
|
auto it = r.resolve(q);
|
||||||
|
boost::asio::ip::tcp::resolver::iterator end;
|
||||||
|
#else // BOOST_VERSION < 106600
|
||||||
|
auto eps = r.resolve(host, boost::lexical_cast<std::string>(port));
|
||||||
|
auto it = eps.begin();
|
||||||
|
auto end = eps.end();
|
||||||
|
#endif // BOOST_VERSION < 106600
|
||||||
|
|
||||||
|
boost::asio::ip::tcp::socket cs(ios);
|
||||||
|
boost::asio::async_connect(
|
||||||
|
cs,
|
||||||
|
it,
|
||||||
|
end,
|
||||||
|
[&]
|
||||||
|
(boost::system::error_code const& e, boost::asio::ip::tcp::resolver::iterator) {
|
||||||
|
if (e) {
|
||||||
|
std::cout << __LINE__ << ":" << e.message() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::cout << __LINE__ << ":client connected" << std::endl;
|
||||||
|
msgpack::sbuffer sb;
|
||||||
|
msgpack::pack(sb, std::make_tuple(42, false, "hello world", 12.3456));
|
||||||
|
write(cs, boost::asio::buffer(sb.data(), sb.size()));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Start
|
||||||
|
ios.run();
|
||||||
|
}
|
176
example/boost/asio_send_recv_zlib.cpp
Normal file
176
example/boost/asio_send_recv_zlib.cpp
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
// MessagePack for C++ example
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include <msgpack.hpp>
|
||||||
|
#include <msgpack/zbuffer.hpp>
|
||||||
|
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
void print(std::string const& buf) {
|
||||||
|
for (std::string::const_iterator it = buf.begin(), end = buf.end();
|
||||||
|
it != end;
|
||||||
|
++it) {
|
||||||
|
std::cout
|
||||||
|
<< std::setw(2)
|
||||||
|
<< std::hex
|
||||||
|
<< std::setfill('0')
|
||||||
|
<< (static_cast<int>(*it) & 0xff)
|
||||||
|
<< ' ';
|
||||||
|
}
|
||||||
|
std::cout << std::dec << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
boost::asio::io_service ios;
|
||||||
|
std::uint16_t const port = 12345;
|
||||||
|
|
||||||
|
int num_of_zlib_data = 2;
|
||||||
|
int idx_zlib_data = 0;
|
||||||
|
|
||||||
|
// Server
|
||||||
|
std::size_t const window_size = 11;
|
||||||
|
boost::asio::ip::tcp::acceptor ac(ios, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port));
|
||||||
|
boost::asio::ip::tcp::socket ss(ios);
|
||||||
|
std::function<void()> do_accept;
|
||||||
|
std::function<void()> do_async_read_some;
|
||||||
|
|
||||||
|
// zlib for decompress
|
||||||
|
z_stream strm;
|
||||||
|
auto zlib_init = [&] {
|
||||||
|
strm.zalloc = Z_NULL;
|
||||||
|
strm.zfree = Z_NULL;
|
||||||
|
strm.opaque = Z_NULL;
|
||||||
|
strm.next_in = Z_NULL;
|
||||||
|
{
|
||||||
|
int zret = inflateInit(&strm);
|
||||||
|
if (zret != Z_OK) {
|
||||||
|
std::cout << "Zlib inflateInit() error = " << zret << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
zlib_init();
|
||||||
|
std::vector<char> buf(4); // buf size
|
||||||
|
|
||||||
|
msgpack::unpacker unp;
|
||||||
|
|
||||||
|
do_accept = [&] {
|
||||||
|
ac.async_accept(
|
||||||
|
ss,
|
||||||
|
[&]
|
||||||
|
(boost::system::error_code const& e) {
|
||||||
|
if (e) {
|
||||||
|
std::cout << __LINE__ << ":" << e.message() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
do_async_read_some = [&] {
|
||||||
|
ss.async_read_some(
|
||||||
|
boost::asio::buffer(buf),
|
||||||
|
[&](boost::system::error_code const& e, std::size_t bytes_transferred) {
|
||||||
|
if (e) {
|
||||||
|
std::cout << __LINE__ << ":" << e.message() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::cout << bytes_transferred << " bytes read." << std::endl;
|
||||||
|
print(std::string(std::string(&buf[0], buf.size())));
|
||||||
|
strm.avail_in = bytes_transferred;
|
||||||
|
do {
|
||||||
|
strm.next_in = reinterpret_cast<unsigned char*>(&buf[0]) + (bytes_transferred - strm.avail_in);
|
||||||
|
int zret;
|
||||||
|
unp.reserve_buffer(window_size);
|
||||||
|
strm.avail_out = window_size;
|
||||||
|
strm.next_out = reinterpret_cast<unsigned char*>(unp.buffer());
|
||||||
|
do {
|
||||||
|
zret = inflate(&strm, Z_NO_FLUSH);
|
||||||
|
assert(zret != Z_STREAM_ERROR);
|
||||||
|
switch (zret) {
|
||||||
|
case Z_NEED_DICT:
|
||||||
|
zret = Z_DATA_ERROR;
|
||||||
|
// fall through
|
||||||
|
case Z_DATA_ERROR:
|
||||||
|
case Z_MEM_ERROR:
|
||||||
|
inflateEnd(&strm);
|
||||||
|
std::cout << "Zlib inflate() error = " << zret << std::endl;
|
||||||
|
std::exit(-1);
|
||||||
|
}
|
||||||
|
std::size_t decompressed_size = window_size - strm.avail_out;
|
||||||
|
std::cout << decompressed_size << " bytes decompressed." << std::endl;
|
||||||
|
unp.buffer_consumed(decompressed_size);
|
||||||
|
msgpack::object_handle oh;
|
||||||
|
while (unp.next(oh)) {
|
||||||
|
std::cout << oh.get() << std::endl;
|
||||||
|
}
|
||||||
|
} while (strm.avail_out == 0);
|
||||||
|
if (zret == Z_STREAM_END) {
|
||||||
|
inflateEnd(&strm);
|
||||||
|
std::cout << "Zlib decompress finished." << std::endl;
|
||||||
|
++idx_zlib_data;
|
||||||
|
if (idx_zlib_data == num_of_zlib_data) {
|
||||||
|
std::cout << "All zlib decompress finished." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
zlib_init();
|
||||||
|
}
|
||||||
|
} while (strm.avail_in != 0);
|
||||||
|
do_async_read_some();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
do_async_read_some();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
do_accept();
|
||||||
|
|
||||||
|
// Client
|
||||||
|
auto host = "localhost";
|
||||||
|
|
||||||
|
boost::asio::ip::tcp::resolver r(ios);
|
||||||
|
|
||||||
|
#if BOOST_VERSION < 106600
|
||||||
|
boost::asio::ip::tcp::resolver::query q(host, boost::lexical_cast<std::string>(port));
|
||||||
|
auto it = r.resolve(q);
|
||||||
|
boost::asio::ip::tcp::resolver::iterator end;
|
||||||
|
#else // BOOST_VERSION < 106600
|
||||||
|
auto eps = r.resolve(host, boost::lexical_cast<std::string>(port));
|
||||||
|
auto it = eps.begin();
|
||||||
|
auto end = eps.end();
|
||||||
|
#endif // BOOST_VERSION < 106600
|
||||||
|
|
||||||
|
boost::asio::ip::tcp::socket cs(ios);
|
||||||
|
boost::asio::async_connect(
|
||||||
|
cs,
|
||||||
|
it,
|
||||||
|
end,
|
||||||
|
[&]
|
||||||
|
(boost::system::error_code const& e, boost::asio::ip::tcp::resolver::iterator) {
|
||||||
|
if (e) {
|
||||||
|
std::cout << __LINE__ << ":" << e.message() << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::cout << __LINE__ << ":client connected" << std::endl;
|
||||||
|
for (int i = 0; i != num_of_zlib_data; ++i) {
|
||||||
|
msgpack::zbuffer zb;
|
||||||
|
msgpack::pack(zb, std::make_tuple(i, false, "hello world", 12.3456));
|
||||||
|
zb.flush(); // finalize zbuffer (don't forget it)
|
||||||
|
print(std::string(zb.data(), zb.size()));
|
||||||
|
write(cs, boost::asio::buffer(zb.data(), zb.size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Start
|
||||||
|
ios.run();
|
||||||
|
}
|
@@ -1,6 +1,8 @@
|
|||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED)
|
||||||
SET (MSGPACK_LIB msgpackc)
|
SET (MSGPACK_LIB msgpackc)
|
||||||
ELSE ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (MSGPACK_ENABLE_STATIC)
|
||||||
SET (MSGPACK_LIB msgpackc-static)
|
SET (MSGPACK_LIB msgpackc-static)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
@@ -23,7 +25,7 @@ FOREACH (source_file ${exec_PROGRAMS})
|
|||||||
${MSGPACK_LIB}
|
${MSGPACK_LIB}
|
||||||
)
|
)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
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 -g -O3")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
@@ -22,7 +22,7 @@ void test()
|
|||||||
|
|
||||||
msgpack_unpacked_init(&msg);
|
msgpack_unpacked_init(&msg);
|
||||||
|
|
||||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos) == MSGPACK_UNPACK_SUCCESS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_sbuffer_destroy(&buf);
|
msgpack_sbuffer_destroy(&buf);
|
||||||
|
@@ -23,7 +23,7 @@ void test()
|
|||||||
|
|
||||||
msgpack_unpacked_init(&msg);
|
msgpack_unpacked_init(&msg);
|
||||||
|
|
||||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos) == MSGPACK_UNPACK_SUCCESS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_sbuffer_destroy(&buf);
|
msgpack_sbuffer_destroy(&buf);
|
||||||
|
@@ -22,7 +22,7 @@ IF (NOT MSVC)
|
|||||||
)
|
)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (Boost_TIMER_LIBRARY AND Boost_CHRONO_LIBRARY AND Boost_SYSTEM_LIBRARY)
|
IF (MSGPACK_BOOST)
|
||||||
LIST (APPEND with_boost_lib_PROGRAMS
|
LIST (APPEND with_boost_lib_PROGRAMS
|
||||||
speed_test.cpp
|
speed_test.cpp
|
||||||
speed_test_nested_array.cpp
|
speed_test_nested_array.cpp
|
||||||
@@ -35,8 +35,12 @@ FOREACH (source_file ${exec_PROGRAMS})
|
|||||||
${source_file_we}
|
${source_file_we}
|
||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||||
|
PRIVATE
|
||||||
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
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 -g -O3")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||||
@@ -53,11 +57,15 @@ FOREACH (source_file ${with_pthread_PROGRAMS})
|
|||||||
${source_file_we}
|
${source_file_we}
|
||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||||
|
PRIVATE
|
||||||
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
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 -g -O3")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||||
@@ -78,6 +86,10 @@ FOREACH (source_file ${with_boost_lib_PROGRAMS})
|
|||||||
${source_file_we}
|
${source_file_we}
|
||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||||
|
PRIVATE
|
||||||
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||||
${Boost_TIMER_LIBRARY}
|
${Boost_TIMER_LIBRARY}
|
||||||
|
@@ -69,7 +69,7 @@ struct object_with_zone<my_class> {
|
|||||||
o.type = type::ARRAY;
|
o.type = type::ARRAY;
|
||||||
o.via.array.size = 2;
|
o.via.array.size = 2;
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(
|
o.via.array.ptr = static_cast<msgpack::object*>(
|
||||||
o.zone.allocate_align(sizeof(msgpack::object) * o.via.array.size));
|
o.zone.allocate_align(sizeof(msgpack::object) * o.via.array.size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o.via.array.ptr[0] = msgpack::object(v.get_name(), o.zone);
|
o.via.array.ptr[0] = msgpack::object(v.get_name(), o.zone);
|
||||||
o.via.array.ptr[1] = msgpack::object(v.get_age(), o.zone);
|
o.via.array.ptr[1] = msgpack::object(v.get_age(), o.zone);
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,12 @@ IF (MSGPACK_CXX11)
|
|||||||
${source_file_we}
|
${source_file_we}
|
||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||||
|
PRIVATE
|
||||||
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
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 -g -O3 ")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
IF (MSGPACK_USE_X3_PARSE)
|
IF (MSGPACK_USE_X3_PARSE AND MSGPACK_DEFAULT_API_VERSION VERSION_GREATER 1)
|
||||||
INCLUDE_DIRECTORIES (
|
INCLUDE_DIRECTORIES (
|
||||||
../include
|
../include
|
||||||
)
|
)
|
||||||
@@ -7,7 +7,7 @@ IF (MSGPACK_USE_X3_PARSE)
|
|||||||
unpack.cpp
|
unpack.cpp
|
||||||
parse.cpp
|
parse.cpp
|
||||||
)
|
)
|
||||||
IF (Boost_CONTEXT_LIBRARY AND Boost_SYSTEM_LIBRARY AND CMAKE_THREAD_LIBS_INIT)
|
IF (MSGPACK_BOOST)
|
||||||
LIST (APPEND with_boost_PROGRAMS
|
LIST (APPEND with_boost_PROGRAMS
|
||||||
stream_unpack.cpp
|
stream_unpack.cpp
|
||||||
)
|
)
|
||||||
@@ -18,8 +18,12 @@ IF (MSGPACK_USE_X3_PARSE)
|
|||||||
${source_file_we}
|
${source_file_we}
|
||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||||
|
PRIVATE
|
||||||
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
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 -g ")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
@@ -40,13 +44,17 @@ IF (MSGPACK_USE_X3_PARSE)
|
|||||||
${source_file_we}
|
${source_file_we}
|
||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||||
|
PRIVATE
|
||||||
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||||
|
)
|
||||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||||
${Boost_CONTEXT_LIBRARY}
|
${Boost_CONTEXT_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_SYSTEM_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
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 -g ")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
@@ -40,7 +40,13 @@ struct json_like_visitor : msgpack::v2::null_visitor {
|
|||||||
m_s += ss.str();
|
m_s += ss.str();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool visit_float(double v) {
|
bool visit_float32(float v) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << v;
|
||||||
|
m_s += ss.str();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool visit_float64(double v) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << v;
|
ss << v;
|
||||||
m_s += ss.str();
|
m_s += ss.str();
|
||||||
|
@@ -21,8 +21,17 @@
|
|||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/coroutine2/all.hpp>
|
#include <boost/coroutine2/all.hpp>
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||||
|
#endif // defined(__clang__)
|
||||||
|
|
||||||
#include <boost/spirit/home/support/multi_pass.hpp>
|
#include <boost/spirit/home/support/multi_pass.hpp>
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif // defined(__clang__)
|
||||||
|
|
||||||
namespace as = boost::asio;
|
namespace as = boost::asio;
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
|
43
fuzz/CMakeLists.txt
Normal file
43
fuzz/CMakeLists.txt
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
FIND_PACKAGE (GTest REQUIRED)
|
||||||
|
FIND_PACKAGE (ZLIB REQUIRED)
|
||||||
|
FIND_PACKAGE (Boost REQUIRED COMPONENTS system filesystem)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES (
|
||||||
|
${GTEST_INCLUDE_DIRS}
|
||||||
|
${ZLIB_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
LIST (APPEND check_PROGRAMS
|
||||||
|
regression_runner.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
LINK_DIRECTORIES (
|
||||||
|
${Boost_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
FOREACH (source_file ${check_PROGRAMS})
|
||||||
|
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
|
||||||
|
ADD_EXECUTABLE (
|
||||||
|
${source_file_we}
|
||||||
|
${source_file}
|
||||||
|
)
|
||||||
|
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||||
|
msgpackc
|
||||||
|
${GTEST_BOTH_LIBRARIES}
|
||||||
|
${ZLIB_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
)
|
||||||
|
ADD_TEST (${source_file_we} ${source_file_we})
|
||||||
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Wno-mismatched-tags -g")
|
||||||
|
IF ("${MSGPACK_SAN}" STREQUAL "ASAN")
|
||||||
|
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
|
||||||
|
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
|
||||||
|
ELSEIF ("${MSGPACK_SAN}" STREQUAL "UBSAN")
|
||||||
|
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
|
||||||
|
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
||||||
|
ENDIF()
|
||||||
|
ENDIF()
|
||||||
|
ENDFOREACH ()
|
50
fuzz/regression_runner.cpp
Normal file
50
fuzz/regression_runner.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "unpack_pack_fuzzer.cpp"
|
||||||
|
|
||||||
|
using ::testing::TestWithParam;
|
||||||
|
using ::testing::ValuesIn;
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<std::string> ListDirectory(const std::string& path) {
|
||||||
|
std::vector<std::string> v;
|
||||||
|
|
||||||
|
boost::filesystem::path p(path);
|
||||||
|
boost::filesystem::directory_iterator f{p};
|
||||||
|
|
||||||
|
if(boost::filesystem::is_directory(p)) {
|
||||||
|
while (f != boost::filesystem::directory_iterator{}) {
|
||||||
|
v.push_back((*f++).path().string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
class UnpackPackFuzzerRegressionTest : public ::testing::TestWithParam<std::string> {
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_P(UnpackPackFuzzerRegressionTest, Returns0) {
|
||||||
|
auto fpath = GetParam();
|
||||||
|
std::ifstream in(fpath, std::ifstream::binary);
|
||||||
|
if (!in) {
|
||||||
|
FAIL() << fpath << " not found";
|
||||||
|
}
|
||||||
|
in.seekg(0, in.end);
|
||||||
|
size_t length = in.tellg();
|
||||||
|
in.seekg(0, in.beg);
|
||||||
|
std::vector<char> bytes(length);
|
||||||
|
in.read(bytes.data(), bytes.size());
|
||||||
|
assert(in);
|
||||||
|
EXPECT_EQ(0, LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t *>(bytes.data()),
|
||||||
|
bytes.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(UnpackPackFuzzerRegressions,
|
||||||
|
UnpackPackFuzzerRegressionTest,
|
||||||
|
::testing::ValuesIn(ListDirectory("../../fuzz/unpack_pack_fuzzer_regressions")));
|
23
fuzz/unpack_pack_fuzzer.cpp
Normal file
23
fuzz/unpack_pack_fuzzer.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include <msgpack.hpp>
|
||||||
|
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
|
try {
|
||||||
|
// NOTE(derwolfe): by default the limits are set at 2^32-1 length. I'm
|
||||||
|
// setting these at far smaller values to avoid OOMs
|
||||||
|
const int test_limit = 1000;
|
||||||
|
msgpack::object_handle unpacked = msgpack::unpack(reinterpret_cast<const char *>(data),
|
||||||
|
size,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
msgpack::unpack_limit(test_limit,
|
||||||
|
test_limit,
|
||||||
|
test_limit,
|
||||||
|
test_limit,
|
||||||
|
test_limit,
|
||||||
|
test_limit));
|
||||||
|
msgpack::sbuffer sbuf;
|
||||||
|
msgpack::pack(sbuf, unpacked.get());
|
||||||
|
} catch (...) {
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
1
fuzz/unpack_pack_fuzzer_seed_corpus/EmptyArray
Normal file
1
fuzz/unpack_pack_fuzzer_seed_corpus/EmptyArray
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<EFBFBD>
|
1
fuzz/unpack_pack_fuzzer_seed_corpus/EmptyObject
Normal file
1
fuzz/unpack_pack_fuzzer_seed_corpus/EmptyObject
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<EFBFBD>
|
2
fuzz/unpack_pack_fuzzer_seed_corpus/ExcessiveNesting
Normal file
2
fuzz/unpack_pack_fuzzer_seed_corpus/ExcessiveNesting
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<EFBFBD><01><02><03><04><05><06><07><08> <09>
|
||||||
|
<EFBFBD><0B><0C>
|
BIN
fuzz/unpack_pack_fuzzer_seed_corpus/OpenWeatherMap
Normal file
BIN
fuzz/unpack_pack_fuzzer_seed_corpus/OpenWeatherMap
Normal file
Binary file not shown.
BIN
fuzz/unpack_pack_fuzzer_seed_corpus/WeatherUnderground
Normal file
BIN
fuzz/unpack_pack_fuzzer_seed_corpus/WeatherUnderground
Normal file
Binary file not shown.
@@ -11,7 +11,11 @@
|
|||||||
#include "msgpack/iterator.hpp"
|
#include "msgpack/iterator.hpp"
|
||||||
#include "msgpack/zone.hpp"
|
#include "msgpack/zone.hpp"
|
||||||
#include "msgpack/pack.hpp"
|
#include "msgpack/pack.hpp"
|
||||||
|
#include "msgpack/null_visitor.hpp"
|
||||||
|
#include "msgpack/parse.hpp"
|
||||||
#include "msgpack/unpack.hpp"
|
#include "msgpack/unpack.hpp"
|
||||||
|
#include "msgpack/x3_parse.hpp"
|
||||||
|
#include "msgpack/x3_unpack.hpp"
|
||||||
#include "msgpack/sbuffer.hpp"
|
#include "msgpack/sbuffer.hpp"
|
||||||
#include "msgpack/vrefbuffer.hpp"
|
#include "msgpack/vrefbuffer.hpp"
|
||||||
#include "msgpack/version.hpp"
|
#include "msgpack/version.hpp"
|
||||||
|
@@ -14,5 +14,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/adaptor_base.hpp"
|
#include "msgpack/v1/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/v2/adaptor/adaptor_base.hpp"
|
#include "msgpack/v2/adaptor/adaptor_base.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/adaptor_base.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_ADAPTOR_BASE_HPP
|
#endif // MSGPACK_ADAPTOR_BASE_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/adaptor_base_decl.hpp"
|
#include "msgpack/v1/adaptor/adaptor_base_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/adaptor_base_decl.hpp"
|
#include "msgpack/v2/adaptor/adaptor_base_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/adaptor_base_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_ADAPTOR_BASE_DECL_HPP
|
#endif // MSGPACK_ADAPTOR_BASE_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/array_ref_decl.hpp"
|
#include "msgpack/v1/adaptor/array_ref_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/array_ref_decl.hpp"
|
#include "msgpack/v2/adaptor/array_ref_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/array_ref_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_ARRAY_REF_DECL_HPP
|
#endif // MSGPACK_TYPE_ARRAY_REF_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp"
|
#include "msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/boost/msgpack_variant_decl.hpp"
|
#include "msgpack/v2/adaptor/boost/msgpack_variant_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/boost/msgpack_variant_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_DECL_HPP
|
#endif // MSGPACK_TYPE_BOOST_MSGPACK_VARIANT_DECL_HPP
|
||||||
|
15
include/msgpack/adaptor/boost/string_view.hpp
Normal file
15
include/msgpack/adaptor/boost/string_view.hpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_TYPE_BOOST_STRING_VIEW_HPP
|
||||||
|
#define MSGPACK_TYPE_BOOST_STRING_VIEW_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v1/adaptor/boost/string_view.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_TYPE_BOOST_STRING_VIEW_HPP
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/check_container_size_decl.hpp"
|
#include "msgpack/v1/adaptor/check_container_size_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/check_container_size_decl.hpp"
|
#include "msgpack/v2/adaptor/check_container_size_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/check_container_size_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_CHECK_CONTAINER_SIZE_DECL_HPP
|
#endif // MSGPACK_CHECK_CONTAINER_SIZE_DECL_HPP
|
||||||
|
16
include/msgpack/adaptor/cpp11/chrono.hpp
Normal file
16
include/msgpack/adaptor/cpp11/chrono.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MSGPACK_TYPE_CPP11_CHRONO_HPP
|
||||||
|
#define MSGPACK_TYPE_CPP11_CHRONO_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v1/adaptor/cpp11/chrono.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_TYPE_CPP11_CHRONO_HPP
|
16
include/msgpack/adaptor/cpp17/byte.hpp
Normal file
16
include/msgpack/adaptor/cpp17/byte.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MSGPACK_TYPE_CPP17_BYTE_HPP
|
||||||
|
#define MSGPACK_TYPE_CPP17_BYTE_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v1/adaptor/cpp17/byte.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_TYPE_CPP17_BYTE_HPP
|
16
include/msgpack/adaptor/cpp17/carray_byte.hpp
Normal file
16
include/msgpack/adaptor/cpp17/carray_byte.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MSGPACK_TYPE_CPP17_CARRAY_BYTE_HPP
|
||||||
|
#define MSGPACK_TYPE_CPP17_CARRAY_BYTE_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v1/adaptor/cpp17/carray_byte.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_TYPE_CPP17_CARRAY_BYTE_HPP
|
16
include/msgpack/adaptor/cpp17/optional.hpp
Normal file
16
include/msgpack/adaptor/cpp17/optional.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MSGPACK_TYPE_CPP17_OPTIONAL_HPP
|
||||||
|
#define MSGPACK_TYPE_CPP17_OPTIONAL_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v1/adaptor/cpp17/optional.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_TYPE_CPP17_OPTIONAL_HPP
|
16
include/msgpack/adaptor/cpp17/string_view.hpp
Normal file
16
include/msgpack/adaptor/cpp17/string_view.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MSGPACK_TYPE_CPP17_STRING_VIEW_HPP
|
||||||
|
#define MSGPACK_TYPE_CPP17_STRING_VIEW_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v1/adaptor/cpp17/string_view.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_TYPE_CPP17_STRING_VIEW_HPP
|
16
include/msgpack/adaptor/cpp17/vector_byte.hpp
Normal file
16
include/msgpack/adaptor/cpp17/vector_byte.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MSGPACK_TYPE_CPP17_VECTOR_BYTE_HPP
|
||||||
|
#define MSGPACK_TYPE_CPP17_VECTOR_BYTE_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v1/adaptor/cpp17/vector_byte.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_TYPE_CPP17_VECTOR_BYTE_HPP
|
@@ -27,18 +27,18 @@
|
|||||||
|
|
||||||
#define MSGPACK_DEFINE_ARRAY(...) \
|
#define MSGPACK_DEFINE_ARRAY(...) \
|
||||||
template <typename Packer> \
|
template <typename Packer> \
|
||||||
void msgpack_pack(Packer& pk) const \
|
void msgpack_pack(Packer& msgpack_pk) const \
|
||||||
{ \
|
{ \
|
||||||
msgpack::type::make_define_array(__VA_ARGS__).msgpack_pack(pk); \
|
msgpack::type::make_define_array(__VA_ARGS__).msgpack_pack(msgpack_pk); \
|
||||||
} \
|
} \
|
||||||
void msgpack_unpack(msgpack::object const& o) \
|
void msgpack_unpack(msgpack::object const& msgpack_o) \
|
||||||
{ \
|
{ \
|
||||||
msgpack::type::make_define_array(__VA_ARGS__).msgpack_unpack(o); \
|
msgpack::type::make_define_array(__VA_ARGS__).msgpack_unpack(msgpack_o); \
|
||||||
}\
|
}\
|
||||||
template <typename MSGPACK_OBJECT> \
|
template <typename MSGPACK_OBJECT> \
|
||||||
void msgpack_object(MSGPACK_OBJECT* o, msgpack::zone& z) const \
|
void msgpack_object(MSGPACK_OBJECT* msgpack_o, msgpack::zone& msgpack_z) const \
|
||||||
{ \
|
{ \
|
||||||
msgpack::type::make_define_array(__VA_ARGS__).msgpack_object(o, z); \
|
msgpack::type::make_define_array(__VA_ARGS__).msgpack_object(msgpack_o, msgpack_z); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MSGPACK_BASE_ARRAY(base) (*const_cast<base *>(static_cast<base const*>(this)))
|
#define MSGPACK_BASE_ARRAY(base) (*const_cast<base *>(static_cast<base const*>(this)))
|
||||||
@@ -62,24 +62,24 @@
|
|||||||
|
|
||||||
#define MSGPACK_DEFINE_MAP(...) \
|
#define MSGPACK_DEFINE_MAP(...) \
|
||||||
template <typename Packer> \
|
template <typename Packer> \
|
||||||
void msgpack_pack(Packer& pk) const \
|
void msgpack_pack(Packer& msgpack_pk) const \
|
||||||
{ \
|
{ \
|
||||||
msgpack::type::make_define_map \
|
msgpack::type::make_define_map \
|
||||||
MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \
|
MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \
|
||||||
.msgpack_pack(pk); \
|
.msgpack_pack(msgpack_pk); \
|
||||||
} \
|
} \
|
||||||
void msgpack_unpack(msgpack::object const& o) \
|
void msgpack_unpack(msgpack::object const& msgpack_o) \
|
||||||
{ \
|
{ \
|
||||||
msgpack::type::make_define_map \
|
msgpack::type::make_define_map \
|
||||||
MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \
|
MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \
|
||||||
.msgpack_unpack(o); \
|
.msgpack_unpack(msgpack_o); \
|
||||||
}\
|
}\
|
||||||
template <typename MSGPACK_OBJECT> \
|
template <typename MSGPACK_OBJECT> \
|
||||||
void msgpack_object(MSGPACK_OBJECT* o, msgpack::zone& z) const \
|
void msgpack_object(MSGPACK_OBJECT* msgpack_o, msgpack::zone& msgpack_z) const \
|
||||||
{ \
|
{ \
|
||||||
msgpack::type::make_define_map \
|
msgpack::type::make_define_map \
|
||||||
MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \
|
MSGPACK_DEFINE_MAP_IMPL(__VA_ARGS__) \
|
||||||
.msgpack_object(o, z); \
|
.msgpack_object(msgpack_o, msgpack_z); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MSGPACK_BASE_MAP(base) \
|
#define MSGPACK_BASE_MAP(base) \
|
||||||
@@ -94,32 +94,32 @@
|
|||||||
namespace adaptor { \
|
namespace adaptor { \
|
||||||
template<> \
|
template<> \
|
||||||
struct convert<enum_name> { \
|
struct convert<enum_name> { \
|
||||||
msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const { \
|
msgpack::object const& operator()(msgpack::object const& msgpack_o, enum_name& msgpack_v) const { \
|
||||||
msgpack::underlying_type<enum_name>::type tmp; \
|
msgpack::underlying_type<enum_name>::type tmp; \
|
||||||
msgpack::operator>>(o, tmp); \
|
msgpack::operator>>(msgpack_o, tmp); \
|
||||||
v = static_cast<enum_name>(tmp); \
|
msgpack_v = static_cast<enum_name>(tmp); \
|
||||||
return o; \
|
return msgpack_o; \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
template<> \
|
template<> \
|
||||||
struct object<enum_name> { \
|
struct object<enum_name> { \
|
||||||
void operator()(msgpack::object& o, const enum_name& v) const { \
|
void operator()(msgpack::object& msgpack_o, const enum_name& msgpack_v) const { \
|
||||||
msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(v); \
|
msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(msgpack_v); \
|
||||||
msgpack::operator<<(o, tmp); \
|
msgpack::operator<<(msgpack_o, tmp); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
template<> \
|
template<> \
|
||||||
struct object_with_zone<enum_name> { \
|
struct object_with_zone<enum_name> { \
|
||||||
void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \
|
void operator()(msgpack::object::with_zone& msgpack_o, const enum_name& msgpack_v) const { \
|
||||||
msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(v); \
|
msgpack::underlying_type<enum_name>::type tmp = static_cast<msgpack::underlying_type<enum_name>::type>(msgpack_v); \
|
||||||
msgpack::operator<<(o, tmp); \
|
msgpack::operator<<(msgpack_o, tmp); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
struct pack<enum_name> { \
|
struct pack<enum_name> { \
|
||||||
template <typename Stream> \
|
template <typename Stream> \
|
||||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& msgpack_o, const enum_name& msgpack_v) const { \
|
||||||
return msgpack::operator<<(o, static_cast<msgpack::underlying_type<enum_name>::type>(v)); \
|
return msgpack::operator<<(msgpack_o, static_cast<msgpack::underlying_type<enum_name>::type>(msgpack_v)); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
} \
|
} \
|
||||||
@@ -139,5 +139,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/define_decl.hpp"
|
#include "msgpack/v1/adaptor/define_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/define_decl.hpp"
|
#include "msgpack/v2/adaptor/define_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/define_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_DEFINE_DECL_HPP
|
#endif // MSGPACK_DEFINE_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/ext_decl.hpp"
|
#include "msgpack/v1/adaptor/ext_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/ext_decl.hpp"
|
#include "msgpack/v2/adaptor/ext_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/ext_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_EXT_DECL_HPP
|
#endif // MSGPACK_TYPE_EXT_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/fixint_decl.hpp"
|
#include "msgpack/v1/adaptor/fixint_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/fixint_decl.hpp"
|
#include "msgpack/v2/adaptor/fixint_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/fixint_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_FIXINT_DECL_HPP
|
#endif // MSGPACK_TYPE_FIXINT_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/int_decl.hpp"
|
#include "msgpack/v1/adaptor/int_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/int_decl.hpp"
|
#include "msgpack/v2/adaptor/int_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/int_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_INT_DECL_HPP
|
#endif // MSGPACK_TYPE_INT_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/map_decl.hpp"
|
#include "msgpack/v1/adaptor/map_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/map_decl.hpp"
|
#include "msgpack/v2/adaptor/map_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/map_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_MAP_DECL_HPP
|
#endif // MSGPACK_TYPE_MAP_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/msgpack_tuple_decl.hpp"
|
#include "msgpack/v1/adaptor/msgpack_tuple_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/msgpack_tuple_decl.hpp"
|
#include "msgpack/v2/adaptor/msgpack_tuple_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/msgpack_tuple_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_MSGPACK_TUPLE_DECL_HPP
|
#endif // MSGPACK_MSGPACK_TUPLE_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/nil_decl.hpp"
|
#include "msgpack/v1/adaptor/nil_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/nil_decl.hpp"
|
#include "msgpack/v2/adaptor/nil_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/nil_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_NIL_DECL_HPP
|
#endif // MSGPACK_TYPE_NIL_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/raw_decl.hpp"
|
#include "msgpack/v1/adaptor/raw_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/raw_decl.hpp"
|
#include "msgpack/v2/adaptor/raw_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/raw_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_RAW_DECL_HPP
|
#endif // MSGPACK_TYPE_RAW_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/size_equal_only_decl.hpp"
|
#include "msgpack/v1/adaptor/size_equal_only_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/size_equal_only_decl.hpp"
|
#include "msgpack/v2/adaptor/size_equal_only_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/size_equal_only_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_SIZE_EQUAL_ONLY_DECL_HPP
|
#endif // MSGPACK_TYPE_SIZE_EQUAL_ONLY_DECL_HPP
|
||||||
|
@@ -84,7 +84,7 @@ struct object_with_zone<MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>
|
|||||||
o.via.map.size = 0;
|
o.via.map.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||||
msgpack::object_kv* const pend = p + size;
|
msgpack::object_kv* const pend = p + size;
|
||||||
o.via.map.ptr = p;
|
o.via.map.ptr = p;
|
||||||
o.via.map.size = size;
|
o.via.map.size = size;
|
||||||
@@ -141,7 +141,7 @@ struct object_with_zone<MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Al
|
|||||||
o.via.map.size = 0;
|
o.via.map.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||||
msgpack::object_kv* const pend = p + size;
|
msgpack::object_kv* const pend = p + size;
|
||||||
o.via.map.ptr = p;
|
o.via.map.ptr = p;
|
||||||
o.via.map.size = size;
|
o.via.map.size = size;
|
||||||
|
@@ -82,7 +82,7 @@ struct object_with_zone<MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc>
|
|||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
@@ -136,7 +136,7 @@ struct object_with_zone<MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Al
|
|||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/adaptor/v4raw_decl.hpp"
|
#include "msgpack/v1/adaptor/v4raw_decl.hpp"
|
||||||
#include "msgpack/v2/adaptor/v4raw_decl.hpp"
|
#include "msgpack/v2/adaptor/v4raw_decl.hpp"
|
||||||
|
#include "msgpack/v3/adaptor/v4raw_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_V4RAW_DECL_HPP
|
#endif // MSGPACK_TYPE_V4RAW_DECL_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/cpp_config_decl.hpp"
|
#include "msgpack/v1/cpp_config_decl.hpp"
|
||||||
#include "msgpack/v2/cpp_config_decl.hpp"
|
#include "msgpack/v2/cpp_config_decl.hpp"
|
||||||
|
#include "msgpack/v3/cpp_config_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_CPP_CONFIG_DECL_HPP
|
#endif // MSGPACK_CPP_CONFIG_DECL_HPP
|
||||||
|
17
include/msgpack/create_object_visitor.hpp
Normal file
17
include/msgpack/create_object_visitor.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ deserializing routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_CREATE_OBJECT_VISITOR_HPP
|
||||||
|
#define MSGPACK_CREATE_OBJECT_VISITOR_HPP
|
||||||
|
|
||||||
|
#include "msgpack/create_object_visitor_decl.hpp"
|
||||||
|
|
||||||
|
#include "msgpack/v2/create_object_visitor.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_CREATE_OBJECT_VISITOR_HPP
|
16
include/msgpack/create_object_visitor_decl.hpp
Normal file
16
include/msgpack/create_object_visitor_decl.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ deserializing routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_CREATE_OBJECT_VISITOR_DECL_HPP
|
||||||
|
#define MSGPACK_CREATE_OBJECT_VISITOR_DECL_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v2/create_object_visitor_decl.hpp"
|
||||||
|
#include "msgpack/v3/create_object_visitor_decl.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_CREATE_OBJECT_VISITOR_DECL_HPP
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/fbuffer_decl.hpp"
|
#include "msgpack/v1/fbuffer_decl.hpp"
|
||||||
#include "msgpack/v2/fbuffer_decl.hpp"
|
#include "msgpack/v2/fbuffer_decl.hpp"
|
||||||
|
#include "msgpack/v3/fbuffer_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_FBUFFER_DECL_HPP
|
#endif // MSGPACK_FBUFFER_DECL_HPP
|
||||||
|
@@ -13,5 +13,6 @@
|
|||||||
|
|
||||||
#include <msgpack/v1/iterator_decl.hpp>
|
#include <msgpack/v1/iterator_decl.hpp>
|
||||||
#include <msgpack/v2/iterator_decl.hpp>
|
#include <msgpack/v2/iterator_decl.hpp>
|
||||||
|
#include <msgpack/v3/iterator_decl.hpp>
|
||||||
|
|
||||||
#endif // MSGPACK_V1_ITERATOR_DECL_HPP
|
#endif // MSGPACK_ITERATOR_DECL_HPP
|
||||||
|
@@ -13,5 +13,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/meta_decl.hpp"
|
#include "msgpack/v1/meta_decl.hpp"
|
||||||
#include "msgpack/v2/meta_decl.hpp"
|
#include "msgpack/v2/meta_decl.hpp"
|
||||||
|
#include "msgpack/v3/meta_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_META_DECL_HPP
|
#endif // MSGPACK_META_DECL_HPP
|
||||||
|
17
include/msgpack/null_visitor.hpp
Normal file
17
include/msgpack/null_visitor.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ deserializing routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_NULL_VISITOR_HPP
|
||||||
|
#define MSGPACK_NULL_VISITOR_HPP
|
||||||
|
|
||||||
|
#include "msgpack/null_visitor_decl.hpp"
|
||||||
|
|
||||||
|
#include "msgpack/v2/null_visitor.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_NULL_VISITOR_HPP
|
16
include/msgpack/null_visitor_decl.hpp
Normal file
16
include/msgpack/null_visitor_decl.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ deserializing routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_NULL_VISITOR_DECL_HPP
|
||||||
|
#define MSGPACK_NULL_VISITOR_DECL_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v2/null_visitor_decl.hpp"
|
||||||
|
#include "msgpack/v3/null_visitor_decl.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_NULL_VISITOR_DECL_HPP
|
@@ -13,5 +13,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/object_decl.hpp"
|
#include "msgpack/v1/object_decl.hpp"
|
||||||
#include "msgpack/v2/object_decl.hpp"
|
#include "msgpack/v2/object_decl.hpp"
|
||||||
|
#include "msgpack/v3/object_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_OBJECT_DECL_HPP
|
#endif // MSGPACK_OBJECT_DECL_HPP
|
||||||
|
@@ -15,5 +15,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/object_fwd.hpp"
|
#include "msgpack/v1/object_fwd.hpp"
|
||||||
#include "msgpack/v2/object_fwd.hpp"
|
#include "msgpack/v2/object_fwd.hpp"
|
||||||
|
#include "msgpack/v3/object_fwd.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_OBJECT_FWD_HPP
|
#endif // MSGPACK_OBJECT_FWD_HPP
|
||||||
|
@@ -13,5 +13,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/object_fwd_decl.hpp"
|
#include "msgpack/v1/object_fwd_decl.hpp"
|
||||||
#include "msgpack/v2/object_fwd_decl.hpp"
|
#include "msgpack/v2/object_fwd_decl.hpp"
|
||||||
|
#include "msgpack/v3/object_fwd_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_OBJECT_FWD_DECL_HPP
|
#endif // MSGPACK_OBJECT_FWD_DECL_HPP
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "pack_define.h"
|
#include "pack_define.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
|
#include "timestamp.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -98,6 +99,9 @@ static int msgpack_pack_bin_body(msgpack_packer* pk, const void* b, size_t l);
|
|||||||
static int msgpack_pack_ext(msgpack_packer* pk, size_t l, int8_t type);
|
static int msgpack_pack_ext(msgpack_packer* pk, size_t l, int8_t type);
|
||||||
static int msgpack_pack_ext_body(msgpack_packer* pk, const void* b, size_t l);
|
static int msgpack_pack_ext_body(msgpack_packer* pk, const void* b, size_t l);
|
||||||
|
|
||||||
|
static int msgpack_pack_timestamp(msgpack_packer* pk, const msgpack_timestamp* d);
|
||||||
|
|
||||||
|
MSGPACK_DLLEXPORT
|
||||||
int msgpack_pack_object(msgpack_packer* pk, msgpack_object d);
|
int msgpack_pack_object(msgpack_packer* pk, msgpack_object d);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/pack_decl.hpp"
|
#include "msgpack/v1/pack_decl.hpp"
|
||||||
#include "msgpack/v2/pack_decl.hpp"
|
#include "msgpack/v2/pack_decl.hpp"
|
||||||
|
#include "msgpack/v3/pack_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_PACK_DECL_HPP
|
#endif // MSGPACK_PACK_DECL_HPP
|
||||||
|
@@ -890,6 +890,34 @@ msgpack_pack_inline_func(_ext_body)(msgpack_pack_user x, const void* b, size_t l
|
|||||||
msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
|
msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msgpack_pack_inline_func(_timestamp)(msgpack_pack_user x, const msgpack_timestamp* d)
|
||||||
|
{
|
||||||
|
if ((((int64_t)d->tv_sec) >> 34) == 0) {
|
||||||
|
uint64_t data64 = ((uint64_t) d->tv_nsec << 34) | d->tv_sec;
|
||||||
|
if ((data64 & 0xffffffff00000000L) == 0) {
|
||||||
|
// timestamp 32
|
||||||
|
char buf[4];
|
||||||
|
uint32_t data32 = (uint32_t)data64;
|
||||||
|
msgpack_pack_ext(x, 4, -1);
|
||||||
|
_msgpack_store32(buf, data32);
|
||||||
|
msgpack_pack_append_buffer(x, buf, 4);
|
||||||
|
} else {
|
||||||
|
// timestamp 64
|
||||||
|
char buf[8];
|
||||||
|
msgpack_pack_ext(x, 8, -1);
|
||||||
|
_msgpack_store64(buf, data64);
|
||||||
|
msgpack_pack_append_buffer(x, buf, 8);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// timestamp 96
|
||||||
|
char buf[12];
|
||||||
|
_msgpack_store32(&buf[0], d->tv_nsec);
|
||||||
|
_msgpack_store64(&buf[4], d->tv_sec);
|
||||||
|
msgpack_pack_ext(x, 12, -1);
|
||||||
|
msgpack_pack_append_buffer(x, buf, 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#undef msgpack_pack_inline_func
|
#undef msgpack_pack_inline_func
|
||||||
#undef msgpack_pack_user
|
#undef msgpack_pack_user
|
||||||
#undef msgpack_pack_append_buffer
|
#undef msgpack_pack_append_buffer
|
||||||
|
18
include/msgpack/parse.hpp
Normal file
18
include/msgpack/parse.hpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ deserializing routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_PARSE_HPP
|
||||||
|
#define MSGPACK_PARSE_HPP
|
||||||
|
|
||||||
|
#include "msgpack/parse_decl.hpp"
|
||||||
|
|
||||||
|
#include "msgpack/v2/parse.hpp"
|
||||||
|
#include "msgpack/v3/parse.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_PARSE_HPP
|
16
include/msgpack/parse_decl.hpp
Normal file
16
include/msgpack/parse_decl.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ deserializing routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_PARSE_DECL_HPP
|
||||||
|
#define MSGPACK_PARSE_DECL_HPP
|
||||||
|
|
||||||
|
#include "msgpack/v2/parse_decl.hpp"
|
||||||
|
#include "msgpack/v3/parse_decl.hpp"
|
||||||
|
|
||||||
|
#endif // MSGPACK_PARSE_DECL_HPP
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/parse_return.hpp"
|
#include "msgpack/v1/parse_return.hpp"
|
||||||
#include "msgpack/v2/parse_return.hpp"
|
#include "msgpack/v2/parse_return.hpp"
|
||||||
|
#include "msgpack/v3/parse_return.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_PARSE_RETURN_HPP
|
#endif // MSGPACK_PARSE_RETURN_HPP
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/sbuffer_decl.hpp"
|
#include "msgpack/v1/sbuffer_decl.hpp"
|
||||||
#include "msgpack/v2/sbuffer_decl.hpp"
|
#include "msgpack/v2/sbuffer_decl.hpp"
|
||||||
|
#include "msgpack/v3/sbuffer_decl.hpp"
|
||||||
|
|
||||||
|
|
||||||
#endif // MSGPACK_SBUFFER_DECL_HPP
|
#endif // MSGPACK_SBUFFER_DECL_HPP
|
||||||
|
@@ -45,6 +45,9 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define _msgpack_atomic_counter_header <windows.h>
|
# define _msgpack_atomic_counter_header <windows.h>
|
||||||
|
# if !defined(WIN32_LEAN_AND_MEAN)
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif /* WIN32_LEAN_AND_MEAN */
|
||||||
typedef long _msgpack_atomic_counter_t;
|
typedef long _msgpack_atomic_counter_t;
|
||||||
# define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr)
|
# define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr)
|
||||||
# define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)
|
# define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)
|
||||||
@@ -74,7 +77,7 @@
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else /* _*/
|
#elif defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||||
|
|
||||||
#include <arpa/inet.h> /* __BYTE_ORDER */
|
#include <arpa/inet.h> /* __BYTE_ORDER */
|
||||||
# if defined(linux)
|
# if defined(linux)
|
||||||
@@ -85,34 +88,34 @@
|
|||||||
|
|
||||||
#if MSGPACK_ENDIAN_LITTLE_BYTE
|
#if MSGPACK_ENDIAN_LITTLE_BYTE
|
||||||
|
|
||||||
# ifdef _WIN32
|
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||||
# if defined(ntohs)
|
|
||||||
# define _msgpack_be16(x) ntohs(x)
|
# define _msgpack_be16(x) ntohs(x)
|
||||||
# elif defined(_byteswap_ushort) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
|
||||||
# define _msgpack_be16(x) ((uint16_t)_byteswap_ushort((unsigned short)x))
|
|
||||||
# else
|
|
||||||
# define _msgpack_be16(x) ( \
|
|
||||||
((((uint16_t)x) << 8) ) | \
|
|
||||||
((((uint16_t)x) >> 8) ) )
|
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# define _msgpack_be16(x) ntohs(x)
|
# if defined(ntohs)
|
||||||
|
# define _msgpack_be16(x) ntohs(x)
|
||||||
|
# elif defined(_byteswap_ushort) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||||
|
# define _msgpack_be16(x) ((uint16_t)_byteswap_ushort((unsigned short)x))
|
||||||
|
# else
|
||||||
|
# define _msgpack_be16(x) ( \
|
||||||
|
((((uint16_t)x) << 8) ) | \
|
||||||
|
((((uint16_t)x) >> 8) ) )
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef _WIN32
|
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||||
# if defined(ntohl)
|
# define _msgpack_be32(x) ntohl(x)
|
||||||
# define _msgpack_be32(x) ntohl(x)
|
|
||||||
# elif defined(_byteswap_ulong) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
|
||||||
# define _msgpack_be32(x) ((uint32_t)_byteswap_ulong((unsigned long)x))
|
|
||||||
# else
|
|
||||||
# define _msgpack_be32(x) \
|
|
||||||
( ((((uint32_t)x) << 24) ) | \
|
|
||||||
((((uint32_t)x) << 8) & 0x00ff0000U ) | \
|
|
||||||
((((uint32_t)x) >> 8) & 0x0000ff00U ) | \
|
|
||||||
((((uint32_t)x) >> 24) ) )
|
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# define _msgpack_be32(x) ntohl(x)
|
# if defined(ntohl)
|
||||||
|
# define _msgpack_be32(x) ntohl(x)
|
||||||
|
# elif defined(_byteswap_ulong) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||||
|
# define _msgpack_be32(x) ((uint32_t)_byteswap_ulong((unsigned long)x))
|
||||||
|
# else
|
||||||
|
# define _msgpack_be32(x) \
|
||||||
|
( ((((uint32_t)x) << 24) ) | \
|
||||||
|
((((uint32_t)x) << 8) & 0x00ff0000U ) | \
|
||||||
|
((((uint32_t)x) >> 8) & 0x0000ff00U ) | \
|
||||||
|
((((uint32_t)x) >> 24) ) )
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(_byteswap_uint64) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
# if defined(_byteswap_uint64) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||||
|
54
include/msgpack/timestamp.h
Normal file
54
include/msgpack/timestamp.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* MessagePack for C TimeStamp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 KONDO Takatoshi
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
#ifndef MSGPACK_TIMESTAMP_H
|
||||||
|
#define MSGPACK_TIMESTAMP_H
|
||||||
|
|
||||||
|
#include <msgpack/object.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct msgpack_timestamp {
|
||||||
|
int64_t tv_sec;
|
||||||
|
uint32_t tv_nsec;
|
||||||
|
} msgpack_timestamp;
|
||||||
|
|
||||||
|
static inline bool msgpack_object_to_timestamp(const msgpack_object* obj, msgpack_timestamp* ts) {
|
||||||
|
if (obj->type != MSGPACK_OBJECT_EXT) return false;
|
||||||
|
if (obj->via.ext.type != -1) return false;
|
||||||
|
switch (obj->via.ext.size) {
|
||||||
|
case 4:
|
||||||
|
ts->tv_nsec = 0;
|
||||||
|
_msgpack_load32(uint32_t, obj->via.ext.ptr, &ts->tv_sec);
|
||||||
|
return true;
|
||||||
|
case 8: {
|
||||||
|
uint64_t value;
|
||||||
|
_msgpack_load64(uint64_t, obj->via.ext.ptr, &value);
|
||||||
|
ts->tv_nsec = (uint32_t)(value >> 34);
|
||||||
|
ts->tv_sec = value & 0x00000003ffffffffL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case 12:
|
||||||
|
_msgpack_load32(uint32_t, obj->via.ext.ptr, &ts->tv_nsec);
|
||||||
|
_msgpack_load64(int64_t, obj->via.ext.ptr + 4, &ts->tv_sec);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* msgpack/timestamp.h */
|
@@ -34,6 +34,7 @@
|
|||||||
#include "adaptor/cpp11/array.hpp"
|
#include "adaptor/cpp11/array.hpp"
|
||||||
#include "adaptor/cpp11/array_char.hpp"
|
#include "adaptor/cpp11/array_char.hpp"
|
||||||
#include "adaptor/cpp11/array_unsigned_char.hpp"
|
#include "adaptor/cpp11/array_unsigned_char.hpp"
|
||||||
|
#include "adaptor/cpp11/chrono.hpp"
|
||||||
#include "adaptor/cpp11/forward_list.hpp"
|
#include "adaptor/cpp11/forward_list.hpp"
|
||||||
#include "adaptor/cpp11/reference_wrapper.hpp"
|
#include "adaptor/cpp11/reference_wrapper.hpp"
|
||||||
#include "adaptor/cpp11/shared_ptr.hpp"
|
#include "adaptor/cpp11/shared_ptr.hpp"
|
||||||
@@ -42,6 +43,18 @@
|
|||||||
#include "adaptor/cpp11/unordered_map.hpp"
|
#include "adaptor/cpp11/unordered_map.hpp"
|
||||||
#include "adaptor/cpp11/unordered_set.hpp"
|
#include "adaptor/cpp11/unordered_set.hpp"
|
||||||
|
|
||||||
|
#if MSGPACK_HAS_INCLUDE(<optional>)
|
||||||
|
#include "adaptor/cpp17/optional.hpp"
|
||||||
|
#endif // MSGPACK_HAS_INCLUDE(<optional>)
|
||||||
|
|
||||||
|
#if MSGPACK_HAS_INCLUDE(<string_view>)
|
||||||
|
#include "adaptor/cpp17/string_view.hpp"
|
||||||
|
#endif // MSGPACK_HAS_INCLUDE(<string_view>)
|
||||||
|
|
||||||
|
#include "adaptor/cpp17/byte.hpp"
|
||||||
|
#include "adaptor/cpp17/carray_byte.hpp"
|
||||||
|
#include "adaptor/cpp17/vector_byte.hpp"
|
||||||
|
|
||||||
#endif // defined(MSGPACK_USE_CPP03)
|
#endif // defined(MSGPACK_USE_CPP03)
|
||||||
|
|
||||||
#if defined(MSGPACK_USE_BOOST)
|
#if defined(MSGPACK_USE_BOOST)
|
||||||
@@ -50,5 +63,6 @@
|
|||||||
#include "adaptor/boost/msgpack_variant.hpp"
|
#include "adaptor/boost/msgpack_variant.hpp"
|
||||||
#include "adaptor/boost/optional.hpp"
|
#include "adaptor/boost/optional.hpp"
|
||||||
#include "adaptor/boost/string_ref.hpp"
|
#include "adaptor/boost/string_ref.hpp"
|
||||||
|
#include "adaptor/boost/string_view.hpp"
|
||||||
|
|
||||||
#endif // defined(MSGPACK_USE_BOOST)
|
#endif // defined(MSGPACK_USE_BOOST)
|
||||||
|
@@ -14,6 +14,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/unpack.hpp"
|
#include "msgpack/v1/unpack.hpp"
|
||||||
#include "msgpack/v2/unpack.hpp"
|
#include "msgpack/v2/unpack.hpp"
|
||||||
#include "msgpack/v2/x3_unpack.hpp"
|
#include "msgpack/v3/unpack.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_UNPACK_HPP
|
#endif // MSGPACK_UNPACK_HPP
|
||||||
|
@@ -12,5 +12,6 @@
|
|||||||
|
|
||||||
#include "msgpack/v1/unpack_decl.hpp"
|
#include "msgpack/v1/unpack_decl.hpp"
|
||||||
#include "msgpack/v2/unpack_decl.hpp"
|
#include "msgpack/v2/unpack_decl.hpp"
|
||||||
|
#include "msgpack/v3/unpack_decl.hpp"
|
||||||
|
|
||||||
#endif // MSGPACK_UNPACK_DECL_HPP
|
#endif // MSGPACK_UNPACK_DECL_HPP
|
||||||
|
@@ -236,6 +236,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
|||||||
|
|
||||||
_fixed_trail_again:
|
_fixed_trail_again:
|
||||||
++p;
|
++p;
|
||||||
|
// fallthrough
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if((size_t)(pe - p) < trail) { goto _out; }
|
if((size_t)(pe - p) < trail) { goto _out; }
|
||||||
|
@@ -253,20 +253,20 @@ struct object_with_zone<msgpack::type::array_ref<T> > {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
typename T::const_iterator it(v.data->begin());
|
typename T::const_iterator it(v.data->begin());
|
||||||
do {
|
do {
|
||||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||||
*p = msgpack::object(*it, o.zone);
|
*p = msgpack::object(*it, o.zone);
|
||||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||||
++p;
|
++p;
|
||||||
++it;
|
++it;
|
||||||
} while(p < pend);
|
} while(p < pend);
|
||||||
@@ -280,7 +280,7 @@ struct object_with_zone<msgpack::type::array_ref<T[N]> > {
|
|||||||
if (!v.data) { throw msgpack::type_error(); }
|
if (!v.data) { throw msgpack::type_error(); }
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
#include "msgpack/meta.hpp"
|
#include "msgpack/meta.hpp"
|
||||||
|
|
||||||
|
#include "msgpack/adaptor/pair.hpp"
|
||||||
|
|
||||||
#if !defined (MSGPACK_USE_CPP03)
|
#if !defined (MSGPACK_USE_CPP03)
|
||||||
#include "msgpack/adaptor/cpp11/tuple.hpp"
|
#include "msgpack/adaptor/cpp11/tuple.hpp"
|
||||||
#endif // #if !defined (MSGPACK_USE_CPP03)
|
#endif // #if !defined (MSGPACK_USE_CPP03)
|
||||||
@@ -34,13 +36,54 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|||||||
|
|
||||||
namespace adaptor {
|
namespace adaptor {
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_std_pair {
|
||||||
|
static bool const value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
struct is_std_pair<std::pair<T, U> > {
|
||||||
|
static bool const value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined(MSGPACK_USE_CPP03)
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_std_tuple {
|
||||||
|
static bool const value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
struct is_std_tuple<std::tuple<Args...>> {
|
||||||
|
static bool const value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(MSGPACK_USE_CPP03)
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_seq_no_pair_no_tuple {
|
||||||
|
static bool const value =
|
||||||
|
boost::fusion::traits::is_sequence<T>::value
|
||||||
|
&&
|
||||||
|
!is_std_pair<T>::value
|
||||||
|
#if !defined (MSGPACK_USE_CPP03)
|
||||||
|
&&
|
||||||
|
!is_std_tuple<T>::value
|
||||||
|
#endif // !defined (MSGPACK_USE_CPP03)
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
#if !defined (MSGPACK_USE_CPP03)
|
#if !defined (MSGPACK_USE_CPP03)
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct as<
|
struct as<
|
||||||
T,
|
T,
|
||||||
typename msgpack::enable_if<
|
typename msgpack::enable_if<
|
||||||
boost::fusion::traits::is_sequence<T>::value &&
|
detail::is_seq_no_pair_no_tuple<T>::value &&
|
||||||
boost::mpl::fold<
|
boost::mpl::fold<
|
||||||
T,
|
T,
|
||||||
boost::mpl::bool_<true>,
|
boost::mpl::bool_<true>,
|
||||||
@@ -82,7 +125,7 @@ struct as<
|
|||||||
#endif // !defined (MSGPACK_USE_CPP03)
|
#endif // !defined (MSGPACK_USE_CPP03)
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct convert<T, typename msgpack::enable_if<boost::fusion::traits::is_sequence<T>::value>::type > {
|
struct convert<T, typename msgpack::enable_if<detail::is_seq_no_pair_no_tuple<T>::value>::type > {
|
||||||
msgpack::object const& operator()(msgpack::object const& o, T& v) const {
|
msgpack::object const& operator()(msgpack::object const& o, T& v) const {
|
||||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
if (o.via.array.size != checked_get_container_size(boost::fusion::size(v))) {
|
if (o.via.array.size != checked_get_container_size(boost::fusion::size(v))) {
|
||||||
@@ -106,7 +149,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct pack<T, typename msgpack::enable_if<boost::fusion::traits::is_sequence<T>::value>::type > {
|
struct pack<T, typename msgpack::enable_if<detail::is_seq_no_pair_no_tuple<T>::value>::type > {
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const T& v) const {
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const T& v) const {
|
||||||
uint32_t size = checked_get_container_size(boost::fusion::size(v));
|
uint32_t size = checked_get_container_size(boost::fusion::size(v));
|
||||||
@@ -128,11 +171,11 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct object_with_zone<T, typename msgpack::enable_if<boost::fusion::traits::is_sequence<T>::value>::type > {
|
struct object_with_zone<T, typename msgpack::enable_if<detail::is_seq_no_pair_no_tuple<T>::value>::type > {
|
||||||
void operator()(msgpack::object::with_zone& o, const T& v) const {
|
void operator()(msgpack::object::with_zone& o, const T& v) const {
|
||||||
uint32_t size = checked_get_container_size(boost::fusion::size(v));
|
uint32_t size = checked_get_container_size(boost::fusion::size(v));
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
boost::fusion::for_each(v, with_zone_imp(o, count));
|
boost::fusion::for_each(v, with_zone_imp(o, count));
|
||||||
|
87
include/msgpack/v1/adaptor/boost/string_view.hpp
Normal file
87
include/msgpack/v1/adaptor/boost/string_view.hpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_V1_TYPE_BOOST_STRING_VIEW_HPP
|
||||||
|
#define MSGPACK_V1_TYPE_BOOST_STRING_VIEW_HPP
|
||||||
|
|
||||||
|
#include <boost/version.hpp>
|
||||||
|
#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 61
|
||||||
|
|
||||||
|
#include "msgpack/versioning.hpp"
|
||||||
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
|
#include <boost/utility/string_view.hpp>
|
||||||
|
|
||||||
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<boost::string_view> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, boost::string_view& v) const {
|
||||||
|
switch (o.type) {
|
||||||
|
case msgpack::type::BIN:
|
||||||
|
v = boost::string_view(o.via.bin.ptr, o.via.bin.size);
|
||||||
|
break;
|
||||||
|
case msgpack::type::STR:
|
||||||
|
v = boost::string_view(o.via.str.ptr, o.via.str.size);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw msgpack::type_error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct pack<boost::string_view> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const boost::string_view& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
o.pack_str(size);
|
||||||
|
o.pack_str_body(v.data(), size);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object<boost::string_view> {
|
||||||
|
void operator()(msgpack::object& o, const boost::string_view& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
o.type = msgpack::type::STR;
|
||||||
|
o.via.str.ptr = v.data();
|
||||||
|
o.via.str.size = size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<boost::string_view> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const boost::string_view& v) const {
|
||||||
|
static_cast<msgpack::object&>(o) << v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
|
#endif // (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
|
||||||
|
|
||||||
|
#endif // MSGPACK_V1_TYPE_BOOST_STRING_VIEW_HPP
|
@@ -101,7 +101,7 @@ struct pack<char[N]> {
|
|||||||
char const* p = v;
|
char const* p = v;
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
||||||
uint32_t adjusted_size = p2 ? p2 - p : size;
|
uint32_t adjusted_size = p2 ? static_cast<uint32_t>(p2 - p) : size;
|
||||||
o.pack_str(adjusted_size);
|
o.pack_str(adjusted_size);
|
||||||
o.pack_str_body(p, adjusted_size);
|
o.pack_str_body(p, adjusted_size);
|
||||||
return o;
|
return o;
|
||||||
@@ -115,7 +115,7 @@ struct pack<const char[N]> {
|
|||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
char const* p = v;
|
char const* p = v;
|
||||||
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
||||||
uint32_t adjusted_size = p2 ? p2 - p : size;
|
uint32_t adjusted_size = p2 ? static_cast<uint32_t>(p2 - p) : size;
|
||||||
o.pack_str(adjusted_size);
|
o.pack_str(adjusted_size);
|
||||||
o.pack_str_body(p, adjusted_size);
|
o.pack_str_body(p, adjusted_size);
|
||||||
return o;
|
return o;
|
||||||
@@ -151,7 +151,7 @@ struct object_with_zone<T[N]> {
|
|||||||
void operator()(msgpack::object::with_zone& o, const T(&v)[N]) const {
|
void operator()(msgpack::object::with_zone& o, const T(&v)[N]) const {
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
msgpack::object* ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object) * size));
|
msgpack::object* ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object) * size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o.via.array.ptr = ptr;
|
o.via.array.ptr = ptr;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
const T* pv = v;
|
const T* pv = v;
|
||||||
@@ -167,9 +167,9 @@ struct object_with_zone<char[N]> {
|
|||||||
char const* p = v;
|
char const* p = v;
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
||||||
uint32_t adjusted_size = p2 ? p2 - p : size;
|
uint32_t adjusted_size = p2 ? static_cast<uint32_t>(p2 - p) : size;
|
||||||
o.type = msgpack::type::STR;
|
o.type = msgpack::type::STR;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(adjusted_size));
|
char* ptr = static_cast<char*>(o.zone.allocate_align(adjusted_size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||||
o.via.str.ptr = ptr;
|
o.via.str.ptr = ptr;
|
||||||
o.via.str.size = adjusted_size;
|
o.via.str.size = adjusted_size;
|
||||||
std::memcpy(ptr, p, adjusted_size);
|
std::memcpy(ptr, p, adjusted_size);
|
||||||
@@ -182,9 +182,9 @@ struct object_with_zone<const char[N]> {
|
|||||||
char const* p = v;
|
char const* p = v;
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
||||||
uint32_t adjusted_size = p2 ? p2 - p : size;
|
uint32_t adjusted_size = p2 ? static_cast<uint32_t>(p2 - p) : size;
|
||||||
o.type = msgpack::type::STR;
|
o.type = msgpack::type::STR;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(adjusted_size));
|
char* ptr = static_cast<char*>(o.zone.allocate_align(adjusted_size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||||
o.via.str.ptr = ptr;
|
o.via.str.ptr = ptr;
|
||||||
o.via.str.size = adjusted_size;
|
o.via.str.size = adjusted_size;
|
||||||
std::memcpy(ptr, p, adjusted_size);
|
std::memcpy(ptr, p, adjusted_size);
|
||||||
@@ -196,7 +196,7 @@ struct object_with_zone<unsigned char[N]> {
|
|||||||
void operator()(msgpack::object::with_zone& o, const unsigned char(&v)[N]) const {
|
void operator()(msgpack::object::with_zone& o, const unsigned char(&v)[N]) const {
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
o.type = msgpack::type::BIN;
|
o.type = msgpack::type::BIN;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||||
o.via.bin.ptr = ptr;
|
o.via.bin.ptr = ptr;
|
||||||
o.via.bin.size = size;
|
o.via.bin.size = size;
|
||||||
std::memcpy(ptr, v, size);
|
std::memcpy(ptr, v, size);
|
||||||
@@ -208,7 +208,7 @@ struct object_with_zone<const unsigned char[N]> {
|
|||||||
void operator()(msgpack::object::with_zone& o, const unsigned char(&v)[N]) const {
|
void operator()(msgpack::object::with_zone& o, const unsigned char(&v)[N]) const {
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
o.type = msgpack::type::BIN;
|
o.type = msgpack::type::BIN;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||||
o.via.bin.ptr = ptr;
|
o.via.bin.ptr = ptr;
|
||||||
o.via.bin.size = size;
|
o.via.bin.size = size;
|
||||||
std::memcpy(ptr, v, size);
|
std::memcpy(ptr, v, size);
|
||||||
@@ -221,7 +221,7 @@ struct object<char[N]> {
|
|||||||
char const* p = v;
|
char const* p = v;
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
||||||
uint32_t adjusted_size = p2 ? p2 - p : size;
|
uint32_t adjusted_size = p2 ? static_cast<uint32_t>(p2 - p) : size;
|
||||||
o.type = msgpack::type::STR;
|
o.type = msgpack::type::STR;
|
||||||
o.via.str.ptr = p;
|
o.via.str.ptr = p;
|
||||||
o.via.str.size = adjusted_size;
|
o.via.str.size = adjusted_size;
|
||||||
@@ -234,7 +234,7 @@ struct object<const char[N]> {
|
|||||||
char const* p = v;
|
char const* p = v;
|
||||||
uint32_t size = checked_get_container_size(N);
|
uint32_t size = checked_get_container_size(N);
|
||||||
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
char const* p2 = static_cast<char const*>(std::memchr(p, '\0', size));
|
||||||
uint32_t adjusted_size = p2 ? p2 - p : size;
|
uint32_t adjusted_size = p2 ? static_cast<uint32_t>(p2 - p) : size;
|
||||||
o.type = msgpack::type::STR;
|
o.type = msgpack::type::STR;
|
||||||
o.via.str.ptr = p;
|
o.via.str.ptr = p;
|
||||||
o.via.str.size = adjusted_size;
|
o.via.str.size = adjusted_size;
|
||||||
|
@@ -41,7 +41,7 @@ struct object_with_zone<const char*> {
|
|||||||
void operator()(msgpack::object::with_zone& o, const char* v) const {
|
void operator()(msgpack::object::with_zone& o, const char* v) const {
|
||||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
o.type = msgpack::type::STR;
|
o.type = msgpack::type::STR;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||||
o.via.str.ptr = ptr;
|
o.via.str.ptr = ptr;
|
||||||
o.via.str.size = size;
|
o.via.str.size = size;
|
||||||
std::memcpy(ptr, v, size);
|
std::memcpy(ptr, v, size);
|
||||||
|
@@ -119,7 +119,7 @@ struct object_with_zone<std::array<T, N>> {
|
|||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||||
|
@@ -45,6 +45,13 @@ struct convert<std::array<char, N>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<std::array<char, 0>> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, std::array<char, 0>&) const {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
struct pack<std::array<char, N>> {
|
struct pack<std::array<char, N>> {
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@@ -72,7 +79,7 @@ struct object_with_zone<std::array<char, N>> {
|
|||||||
void operator()(msgpack::object::with_zone& o, const std::array<char, N>& v) const {
|
void operator()(msgpack::object::with_zone& o, const std::array<char, N>& v) const {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.type = msgpack::type::BIN;
|
o.type = msgpack::type::BIN;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||||
o.via.bin.ptr = ptr;
|
o.via.bin.ptr = ptr;
|
||||||
o.via.bin.size = size;
|
o.via.bin.size = size;
|
||||||
std::memcpy(ptr, v.data(), size);
|
std::memcpy(ptr, v.data(), size);
|
||||||
|
@@ -45,6 +45,13 @@ struct convert<std::array<unsigned char, N>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<std::array<unsigned char, 0>> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, std::array<unsigned char, 0>&) const {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
struct pack<std::array<unsigned char, N>> {
|
struct pack<std::array<unsigned char, N>> {
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
@@ -72,7 +79,7 @@ struct object_with_zone<std::array<unsigned char, N>> {
|
|||||||
void operator()(msgpack::object::with_zone& o, const std::array<unsigned char, N>& v) const {
|
void operator()(msgpack::object::with_zone& o, const std::array<unsigned char, N>& v) const {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.type = msgpack::type::BIN;
|
o.type = msgpack::type::BIN;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||||
o.via.bin.ptr = ptr;
|
o.via.bin.ptr = ptr;
|
||||||
o.via.bin.size = size;
|
o.via.bin.size = size;
|
||||||
std::memcpy(ptr, v.data(), size);
|
std::memcpy(ptr, v.data(), size);
|
||||||
|
215
include/msgpack/v1/adaptor/cpp11/chrono.hpp
Normal file
215
include/msgpack/v1/adaptor/cpp11/chrono.hpp
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef MSGPACK_V1_TYPE_CPP11_CHRONO_HPP
|
||||||
|
#define MSGPACK_V1_TYPE_CPP11_CHRONO_HPP
|
||||||
|
|
||||||
|
#include "msgpack/versioning.hpp"
|
||||||
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct as<std::chrono::system_clock::time_point> {
|
||||||
|
typename std::chrono::system_clock::time_point operator()(msgpack::object const& o) const {
|
||||||
|
if(o.type != msgpack::type::EXT) { throw msgpack::type_error(); }
|
||||||
|
if(o.via.ext.type() != -1) { throw msgpack::type_error(); }
|
||||||
|
std::chrono::system_clock::time_point tp;
|
||||||
|
switch(o.via.ext.size) {
|
||||||
|
case 4: {
|
||||||
|
uint32_t sec;
|
||||||
|
_msgpack_load32(uint32_t, o.via.ext.data(), &sec);
|
||||||
|
tp += std::chrono::seconds(sec);
|
||||||
|
} break;
|
||||||
|
case 8: {
|
||||||
|
uint64_t value;
|
||||||
|
_msgpack_load64(uint64_t, o.via.ext.data(), &value);
|
||||||
|
uint32_t nanosec = static_cast<uint32_t>(value >> 34);
|
||||||
|
uint64_t sec = value & 0x00000003ffffffffL;
|
||||||
|
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
|
||||||
|
std::chrono::nanoseconds(nanosec));
|
||||||
|
tp += std::chrono::seconds(sec);
|
||||||
|
} break;
|
||||||
|
case 12: {
|
||||||
|
uint32_t nanosec;
|
||||||
|
_msgpack_load32(uint32_t, o.via.ext.data(), &nanosec);
|
||||||
|
int64_t sec;
|
||||||
|
_msgpack_load64(int64_t, o.via.ext.data() + 4, &sec);
|
||||||
|
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
|
||||||
|
std::chrono::nanoseconds(nanosec));
|
||||||
|
tp += std::chrono::seconds(sec);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
throw msgpack::type_error();
|
||||||
|
}
|
||||||
|
return tp;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<std::chrono::system_clock::time_point> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, std::chrono::system_clock::time_point& v) const {
|
||||||
|
if(o.type != msgpack::type::EXT) { throw msgpack::type_error(); }
|
||||||
|
if(o.via.ext.type() != -1) { throw msgpack::type_error(); }
|
||||||
|
std::chrono::system_clock::time_point tp;
|
||||||
|
switch(o.via.ext.size) {
|
||||||
|
case 4: {
|
||||||
|
uint32_t sec;
|
||||||
|
_msgpack_load32(uint32_t, o.via.ext.data(), &sec);
|
||||||
|
tp += std::chrono::seconds(sec);
|
||||||
|
v = tp;
|
||||||
|
} break;
|
||||||
|
case 8: {
|
||||||
|
uint64_t value;
|
||||||
|
_msgpack_load64(uint64_t, o.via.ext.data(), &value);
|
||||||
|
uint32_t nanosec = static_cast<uint32_t>(value >> 34);
|
||||||
|
uint64_t sec = value & 0x00000003ffffffffL;
|
||||||
|
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
|
||||||
|
std::chrono::nanoseconds(nanosec));
|
||||||
|
tp += std::chrono::seconds(sec);
|
||||||
|
v = tp;
|
||||||
|
} break;
|
||||||
|
case 12: {
|
||||||
|
uint32_t nanosec;
|
||||||
|
_msgpack_load32(uint32_t, o.via.ext.data(), &nanosec);
|
||||||
|
int64_t sec;
|
||||||
|
_msgpack_load64(int64_t, o.via.ext.data() + 4, &sec);
|
||||||
|
tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(
|
||||||
|
std::chrono::nanoseconds(nanosec));
|
||||||
|
tp += std::chrono::seconds(sec);
|
||||||
|
v = tp;
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
throw msgpack::type_error();
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct pack<std::chrono::system_clock::time_point> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::chrono::system_clock::time_point& v) const {
|
||||||
|
int64_t count = static_cast<int64_t>(v.time_since_epoch().count());
|
||||||
|
|
||||||
|
int64_t nano_num =
|
||||||
|
std::chrono::system_clock::duration::period::ratio::num *
|
||||||
|
(1000000000 / std::chrono::system_clock::duration::period::ratio::den);
|
||||||
|
|
||||||
|
int64_t nanosec = count % (1000000000 / nano_num) * nano_num;
|
||||||
|
int64_t sec = 0;
|
||||||
|
if (nanosec < 0) {
|
||||||
|
nanosec = 1000000000 + nanosec;
|
||||||
|
--sec;
|
||||||
|
}
|
||||||
|
sec += count
|
||||||
|
* std::chrono::system_clock::duration::period::ratio::num
|
||||||
|
/ std::chrono::system_clock::duration::period::ratio::den;
|
||||||
|
if ((sec >> 34) == 0) {
|
||||||
|
uint64_t data64 = (nanosec << 34) | sec;
|
||||||
|
if ((data64 & 0xffffffff00000000L) == 0) {
|
||||||
|
// timestamp 32
|
||||||
|
o.pack_ext(4, -1);
|
||||||
|
uint32_t data32 = static_cast<uint32_t>(data64);
|
||||||
|
char buf[4];
|
||||||
|
_msgpack_store32(buf, data32);
|
||||||
|
o.pack_ext_body(buf, 4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// timestamp 64
|
||||||
|
o.pack_ext(8, -1);
|
||||||
|
char buf[8];
|
||||||
|
_msgpack_store64(buf, data64);
|
||||||
|
o.pack_ext_body(buf, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// timestamp 96
|
||||||
|
o.pack_ext(12, -1);
|
||||||
|
char buf[12];
|
||||||
|
_msgpack_store32(&buf[0], static_cast<uint32_t>(nanosec));
|
||||||
|
_msgpack_store64(&buf[4], sec);
|
||||||
|
o.pack_ext_body(buf, 12);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<std::chrono::system_clock::time_point> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::chrono::system_clock::time_point& v) const {
|
||||||
|
int64_t count = static_cast<int64_t>(v.time_since_epoch().count());
|
||||||
|
|
||||||
|
int64_t nano_num =
|
||||||
|
std::chrono::system_clock::duration::period::ratio::num *
|
||||||
|
(1000000000 / std::chrono::system_clock::duration::period::ratio::den);
|
||||||
|
|
||||||
|
int64_t nanosec = count % (1000000000 / nano_num) * nano_num;
|
||||||
|
int64_t sec = 0;
|
||||||
|
if (nanosec < 0) {
|
||||||
|
nanosec = 1000000000 + nanosec;
|
||||||
|
--sec;
|
||||||
|
}
|
||||||
|
sec += count
|
||||||
|
* std::chrono::system_clock::duration::period::ratio::num
|
||||||
|
/ std::chrono::system_clock::duration::period::ratio::den;
|
||||||
|
if ((sec >> 34) == 0) {
|
||||||
|
uint64_t data64 = (nanosec << 34) | sec;
|
||||||
|
if ((data64 & 0xffffffff00000000L) == 0) {
|
||||||
|
// timestamp 32
|
||||||
|
o.type = msgpack::type::EXT;
|
||||||
|
o.via.ext.size = 4;
|
||||||
|
char* p = static_cast<char*>(o.zone.allocate_no_align(o.via.ext.size + 1));
|
||||||
|
p[0] = -1;
|
||||||
|
uint32_t data32 = static_cast<uint32_t>(data64);
|
||||||
|
_msgpack_store32(&p[1], data32);
|
||||||
|
o.via.ext.ptr = p;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// timestamp 64
|
||||||
|
o.type = msgpack::type::EXT;
|
||||||
|
o.via.ext.size = 8;
|
||||||
|
char* p = static_cast<char*>(o.zone.allocate_no_align(o.via.ext.size + 1));
|
||||||
|
p[0] = -1;
|
||||||
|
_msgpack_store64(&p[1], data64);
|
||||||
|
o.via.ext.ptr = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// timestamp 96
|
||||||
|
o.type = msgpack::type::EXT;
|
||||||
|
o.via.ext.size = 12;
|
||||||
|
char* p = static_cast<char*>(o.zone.allocate_no_align(o.via.ext.size + 1));
|
||||||
|
p[0] = -1;
|
||||||
|
_msgpack_store32(&p[1], static_cast<uint32_t>(nanosec));
|
||||||
|
_msgpack_store64(&p[1 + 4], sec);
|
||||||
|
o.via.ext.ptr = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
|
#endif // MSGPACK_V1_TYPE_CPP11_CHRONO_HPP
|
@@ -76,7 +76,7 @@ struct object_with_zone<std::forward_list<T, Alloc>> {
|
|||||||
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(
|
msgpack::object* p = static_cast<msgpack::object*>(
|
||||||
o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||||
}
|
}
|
||||||
|
@@ -158,7 +158,7 @@ struct object_with_zone<std::tuple<Args...>> {
|
|||||||
std::tuple<Args...> const& v) const {
|
std::tuple<Args...> const& v) const {
|
||||||
uint32_t size = checked_get_container_size(sizeof...(Args));
|
uint32_t size = checked_get_container_size(sizeof...(Args));
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ struct object_with_zone<std::unordered_map<K, V, Hash, Compare, Alloc>> {
|
|||||||
o.via.map.size = 0;
|
o.via.map.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||||
msgpack::object_kv* const pend = p + size;
|
msgpack::object_kv* const pend = p + size;
|
||||||
o.via.map.ptr = p;
|
o.via.map.ptr = p;
|
||||||
o.via.map.size = size;
|
o.via.map.size = size;
|
||||||
@@ -155,7 +155,7 @@ struct object_with_zone<std::unordered_multimap<K, V, Hash, Compare, Alloc>> {
|
|||||||
o.via.map.size = 0;
|
o.via.map.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||||
msgpack::object_kv* const pend = p + size;
|
msgpack::object_kv* const pend = p + size;
|
||||||
o.via.map.ptr = p;
|
o.via.map.ptr = p;
|
||||||
o.via.map.size = size;
|
o.via.map.size = size;
|
||||||
|
@@ -78,7 +78,7 @@ struct object_with_zone<std::unordered_set<Key, Hash, Compare, Alloc>> {
|
|||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
@@ -147,7 +147,7 @@ struct object_with_zone<std::unordered_multiset<Key, Hash, Compare, Alloc>> {
|
|||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user