mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-21 15:51:44 +02:00
Compare commits
183 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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 | ||
![]() |
c0bf8b3aff | ||
![]() |
5be2757216 | ||
![]() |
c6c31dc5cd | ||
![]() |
c704d4bfab | ||
![]() |
4466bda819 | ||
![]() |
4623654996 | ||
![]() |
84ad9a2634 | ||
![]() |
9b141fa9b6 | ||
![]() |
6a1fa2e0fc | ||
![]() |
c55f778198 | ||
![]() |
b4f2acb945 | ||
![]() |
7e139125e2 | ||
![]() |
9d37316b44 | ||
![]() |
364fc0daf6 | ||
![]() |
f24201f71f | ||
![]() |
9a113bb0ca | ||
![]() |
2674e34769 | ||
![]() |
c5c3de8f61 | ||
![]() |
0b7cabd322 | ||
![]() |
22780a6808 | ||
![]() |
4ec0fdf207 | ||
![]() |
85a0404d8c | ||
![]() |
ce67c8ed35 | ||
![]() |
1893a8e31e | ||
![]() |
dc8c253577 | ||
![]() |
9c77a0f24a | ||
![]() |
61c053d37e | ||
![]() |
04b549a46b | ||
![]() |
4a1db60af8 | ||
![]() |
55b51c506f | ||
![]() |
a97c00e463 | ||
![]() |
e61cd76310 | ||
![]() |
c30962da25 | ||
![]() |
6b7becdef0 | ||
![]() |
cfa1ab38cc | ||
![]() |
2f34d22bf5 | ||
![]() |
401460b7d9 | ||
![]() |
03b770fdf2 | ||
![]() |
d3cd07987b | ||
![]() |
b4786711df | ||
![]() |
ccc9ac5538 | ||
![]() |
1df97bc37b | ||
![]() |
8d09b7090d | ||
![]() |
2a7335ae90 | ||
![]() |
e7eae65ab7 | ||
![]() |
4e663609ca | ||
![]() |
98820ec6c7 | ||
![]() |
baea172cc9 | ||
![]() |
e9e31a2899 | ||
![]() |
8ffb619031 | ||
![]() |
a3ed6274c2 | ||
![]() |
f795e5d568 | ||
![]() |
87ff7e4ccc | ||
![]() |
da46fb1ef7 | ||
![]() |
b90bcf3c11 | ||
![]() |
c1f19c0e47 | ||
![]() |
d9a77e220a | ||
![]() |
894547582b | ||
![]() |
3a87cc8826 | ||
![]() |
6177038fcf | ||
![]() |
25259dc705 | ||
![]() |
5d69c22bf9 | ||
![]() |
a9caff538e | ||
![]() |
9a2bb0c972 | ||
![]() |
7191a3b014 | ||
![]() |
b82b58f184 | ||
![]() |
73af452ed8 | ||
![]() |
95b31d0d16 | ||
![]() |
c73d9a9dab | ||
![]() |
0164c1efe2 | ||
![]() |
48abfe7aa1 | ||
![]() |
8105c33f9d | ||
![]() |
237cf888d8 | ||
![]() |
b9bc9d4195 | ||
![]() |
aa790ba785 | ||
![]() |
1da0539a00 | ||
![]() |
d7a656523b | ||
![]() |
f573fd6a26 | ||
![]() |
4fa661a63d | ||
![]() |
2e4de8b65c |
269
.travis.yml
269
.travis.yml
@@ -1,103 +1,206 @@
|
||||
language: cpp
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
cache:
|
||||
- apt
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
os:
|
||||
- osx
|
||||
- linux
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository -y ppa:h-rayflood/llvm-upper; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update; fi
|
||||
sudo: false
|
||||
|
||||
install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq gcc-4.8-multilib g++-4.8-multilib; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --allow-unauthenticated -qq clang-3.6; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y lib32gcc1; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y libc6-i386; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y lib32z1-dev; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y lib32stdc++6; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y bzip2; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y libc6-dbg; fi
|
||||
- wget https://googletest.googlecode.com/files/gtest-1.7.0.zip
|
||||
- wget http://valgrind.org/downloads/valgrind-3.10.1.tar.bz2 && tar xjf valgrind-3.10.1.tar.bz2 && cd valgrind-3.10.1 && ./configure && make && sudo make install && cd ..
|
||||
|
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew unlink boost; fi
|
||||
- if [ "$BOOST" == "boost" ]; then wget http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.zip && unzip -q boost_1_58_0.zip && cd boost_1_58_0 && ./bootstrap.sh && ./b2 --with-timer --with-chrono address-model="$ARCH" > /dev/null && sudo ./b2 --with-timer --with-chrono address-model="$ARCH" install > /dev/null && cd ..; fi
|
||||
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then unzip -q gtest-1.7.0.zip && cd gtest-1.7.0 && sudo cp -r include/gtest /usr/local/include && g++ src/gtest-all.cc -I. -Iinclude -c && g++ src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mv *.a /usr/local/lib && g++ -m32 src/gtest-all.cc -I. -Iinclude -c && g++ -m32 src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mkdir /usr/local/lib32 && sudo mv *.a /usr/local/lib32 && cd ..; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then unzip -q gtest-1.7.0.zip && cd gtest-1.7.0 && sudo cp -r include/gtest /usr/local/include && clang++ src/gtest-all.cc -I. -Iinclude -c && g++ src/gtest_main.cc -I. -Iinclude -c && ar -rv libgtest.a gtest-all.o && ar -rv libgtest_main.a gtest_main.o && sudo mv *.a /usr/local/lib && cd ..; fi
|
||||
|
||||
env:
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned" API_VERSION="1"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" CHAR_SIGN="signed" API_VERSION="2"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="signed" API_VERSION="2"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="signed" API_VERSION="2"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="1"
|
||||
- ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="2"
|
||||
|
||||
before_script:
|
||||
- export PATH=/usr/local/bin:$PATH && rm -rf install
|
||||
- export BASE=`pwd`
|
||||
- mkdir ${BASE}/usr
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then wget --no-check-certificate https://cmake.org/files/v3.7/cmake-3.7.1-Linux-x86_64.sh -O cmake-3.7.1-Linux-x86_64.sh; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then chmod a+x cmake-3.7.1-Linux-x86_64.sh; 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 LD_LIBRARY_PATH="${BASE}/usr/lib:$LD_LIBRARY_PATH"; fi
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-6" CC="gcc-6"; fi
|
||||
- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then export CXX="clang++-3.9" CC="clang-3.9"; fi
|
||||
#gtest
|
||||
- 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
|
||||
- cd googletest-release-1.7.0
|
||||
- $CXX -m${ARCH} src/gtest-all.cc -I. -Iinclude -c
|
||||
- $CXX -m${ARCH} src/gtest_main.cc -I. -Iinclude -c
|
||||
- ar -rv libgtest.a gtest-all.o
|
||||
- ar -rv libgtest_main.a gtest_main.o
|
||||
- mkdir -p ${BASE}/usr/include
|
||||
- cp -r include/gtest ${BASE}/usr/include
|
||||
- mkdir -p ${BASE}/usr/lib
|
||||
- mv *.a ${BASE}/usr/lib
|
||||
- cd ..
|
||||
# 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
|
||||
# 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-chrono --with-context --with-system --with-timer address-model=${ARCH} install > /dev/null && cd ..; fi
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
include:
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="1"
|
||||
- os: osx
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="1"
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
||||
- os: osx
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" CHAR_SIGN="signed" API_VERSION="2"
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
||||
- os: osx
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
- os: osx
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
- os: osx
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="2"
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned" API_VERSION="1"
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" CHAR_SIGN="signed" API_VERSION="2"
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="signed" API_VERSION="2"
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="" BOOST_INC="" SHARED="OFF" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" ARCH="64" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="signed" API_VERSION="2"
|
||||
env: ACTION="ci/build_cmake.sh" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="1"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
- llvm-toolchain-precise
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-5-multilib
|
||||
- g++-5-multilib
|
||||
- bzip2
|
||||
- clang-3.9
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
env: ACTION="ci/build_cmake.sh" ARCH="32" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
- llvm-toolchain-precise
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-5-multilib
|
||||
- g++-5-multilib
|
||||
- lib32stdc++6-6-dbg
|
||||
- lib32gcc1
|
||||
- libc6-i386
|
||||
- lib32z1-dev
|
||||
- bzip2
|
||||
- clang-3.9
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp11" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" BOOST="ON" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2" X3_PARSE="ON"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
- llvm-toolchain-precise
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-5-multilib
|
||||
- g++-5-multilib
|
||||
- bzip2
|
||||
- clang-3.9
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="64" LIBPATH="/usr/local/lib" BOOST="" BOOST_INC="" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="32" SHARED="OFF" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
- llvm-toolchain-precise
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-5-multilib
|
||||
- g++-5-multilib
|
||||
- lib32stdc++6-6-dbg
|
||||
- lib32gcc1
|
||||
- libc6-i386
|
||||
- lib32z1-dev
|
||||
- bzip2
|
||||
- clang-3.9
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="1"
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" CXX11="ON" ARCH="64" SHARED="ON" CHAR_SIGN="signed" API_VERSION="2"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-6-multilib
|
||||
- g++-6-multilib
|
||||
- bzip2
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: ACTION="ci/build_cmake.sh" VERSION="cpp03" ARCH="32" LIBPATH="/usr/local/lib32" BOOST="boost" BOOST_INC="/usr/local/boost" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="2"
|
||||
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"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-6-multilib
|
||||
- g++-6-multilib
|
||||
- lib32stdc++6-6-dbg
|
||||
- lib32gcc1
|
||||
- libc6-i386
|
||||
- lib32z1-dev
|
||||
- bzip2
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" ARCH="64" SHARED="ON" CHAR_SIGN="unsigned" API_VERSION="2"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-6-multilib
|
||||
- g++-6-multilib
|
||||
- bzip2
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" ARCH="32" BOOST="ON" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="1"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-6-multilib
|
||||
- g++-6-multilib
|
||||
- lib32stdc++6-6-dbg
|
||||
- lib32gcc1
|
||||
- libc6-i386
|
||||
- lib32z1-dev
|
||||
- bzip2
|
||||
- libc6-dbg
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: ACTION="ci/build_cmake.sh" ARCH="32" BOOST="ON" SHARED="OFF" CHAR_SIGN="signed" API_VERSION="2"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-multilib
|
||||
- gcc-multilib
|
||||
- gcc-6-multilib
|
||||
- g++-6-multilib
|
||||
- lib32stdc++6-6-dbg
|
||||
- lib32gcc1
|
||||
- libc6-i386
|
||||
- lib32z1-dev
|
||||
- bzip2
|
||||
- libc6-dbg
|
||||
|
||||
script:
|
||||
- git clean -xdf && CMAKE_LIBRARY_PATH=${LIBPATH} ${ACTION} ${VERSION} ${ARCH} ${BOOST} ${BOOST_INC} ${CHAR_SIGN}
|
||||
- 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}
|
||||
|
65
CHANGELOG.md
65
CHANGELOG.md
@@ -1,3 +1,68 @@
|
||||
# 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
|
||||
|
||||
## << breaking changes >>
|
||||
|
||||
* Fix object internal data type is float if msgpack format is float32 (#531)
|
||||
|
||||
## << recommended changes >>
|
||||
|
||||
* Add `FLOAT64` type. Please use it instead of `DOUBLE` (#531)
|
||||
* Add `FLOAT32` type. Please use it instead of `FLOAT` (#531)
|
||||
|
||||
## << other updates >>
|
||||
|
||||
* Add iterator based parse/unpack function(experimental) (#553)
|
||||
* Add `[[deprecated]]` attribute for C++14 (#552)
|
||||
* Fix `msgpack_unpack()` return code (#548)
|
||||
* Fix integer overflow (#547, #549, #550)
|
||||
* Add example codes (#542)
|
||||
* Add MSGPACK_NVP. You can use not only variable name but also any strings (#535)
|
||||
* Fix and Improve build system (#532, #545)
|
||||
* Fix `gcc_atomic.hpp` include path (#529, #530)
|
||||
* Improve CI environment (#526)
|
||||
* Improve documents (#524)
|
||||
* Add msgpack_unpacker_next_with_size() function (#515)
|
||||
* Fix `as()` applying condition (#511)
|
||||
* Fix fbuffer write (#504)
|
||||
* Add gcc bug workaround (#499)
|
||||
* Improve object print (#497, #500, #505, #533)
|
||||
* Remove some warnings (#495, #506, #508, #513, #528, #538, #545)
|
||||
|
||||
# 2016-06-25 version 2.0.0
|
||||
|
||||
## << breaking changes >>
|
||||
|
139
CMakeLists.txt
139
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
|
||||
(CMAKE_VERSION VERSION_EQUAL 3.1))
|
||||
@@ -21,7 +21,6 @@ SET (exec_prefix "\${prefix}")
|
||||
SET (libdir "\${exec_prefix}/lib")
|
||||
SET (includedir "\${prefix}/include")
|
||||
SET (GNUCXX_STD_SUPPORT_VERSION "4.3")
|
||||
SET (GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION "4.4")
|
||||
|
||||
OPTION (MSGPACK_CXX11 "Using c++11 compiler" OFF)
|
||||
OPTION (MSGPACK_32BIT "32bit compile" OFF)
|
||||
@@ -39,7 +38,27 @@ IF (APPLE)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF (MSGPACK_CXX11)
|
||||
IF (MSGPACK_USE_X3_PARSE)
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_X3_PARSE -std=c++14 ${CMAKE_CXX_FLAGS}")
|
||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_X3_PARSE -std=c++14 ${CMAKE_CXX_FLAGS}")
|
||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_X3_PARSE ${CMAKE_CXX_FLAGS}")
|
||||
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
|
||||
MESSAGE ( FATAL_ERROR "MSVC doesn't support C++14.")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ELSE ()
|
||||
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")
|
||||
SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
@@ -53,16 +72,17 @@ ELSE ()
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_STD_SUPPORT_VERSION}) OR
|
||||
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_STD_SUPPORT_VERSION}))
|
||||
SET (CMAKE_CXX_FLAGS "-std=c++03 ${CMAKE_CXX_FLAGS}")
|
||||
SET (CMAKE_CXX_FLAGS "-std=c++98 ${CMAKE_CXX_FLAGS}")
|
||||
ENDIF ()
|
||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET (CMAKE_CXX_FLAGS "-std=c++03 ${CMAKE_CXX_FLAGS}")
|
||||
SET (CMAKE_CXX_FLAGS "-std=c++98 ${CMAKE_CXX_FLAGS}")
|
||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18)
|
||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_CPP03 ${CMAKE_CXX_FLAGS}")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF (MSGPACK_32BIT)
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
@@ -76,16 +96,25 @@ IF (MSGPACK_32BIT)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
OPTION (MSGPACK_BUILD_EXAMPLES "Build msgpack examples." ON)
|
||||
|
||||
IF (MSGPACK_BOOST)
|
||||
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_BOOST ${CMAKE_CXX_FLAGS}")
|
||||
SET (Boost_USE_STATIC_LIBS ON) # only find static libs
|
||||
SET (Boost_USE_MULTITHREADED ON)
|
||||
SET (Boost_USE_STATIC_RUNTIME OFF)
|
||||
FIND_PACKAGE (Boost COMPONENTS chrono timer system)
|
||||
FIND_PACKAGE (Boost REQUIRED COMPONENTS chrono context system timer)
|
||||
INCLUDE_DIRECTORIES (
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
LINK_DIRECTORIES (
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
IF (MSGPACK_BOOST_DIR)
|
||||
INCLUDE_DIRECTORIES (
|
||||
${MSGPACK_BOOST_DIR}
|
||||
)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF (MSGPACK_CHAR_SIGN)
|
||||
SET (CMAKE_C_FLAGS "-f${MSGPACK_CHAR_SIGN}-char ${CMAKE_C_FLAGS}")
|
||||
@@ -105,7 +134,7 @@ FOREACH (F ${PREDEF_FILES})
|
||||
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})
|
||||
FILE (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} ${CONTENT})
|
||||
FILE (GENERATE OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} CONTENT ${CONTENT})
|
||||
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)
|
||||
@@ -115,7 +144,7 @@ FOREACH (F ${PREPROCESSOR_FILES})
|
||||
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})
|
||||
FILE (WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} ${CONTENT})
|
||||
FILE (GENERATE OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/msgpack/${F} CONTENT ${CONTENT})
|
||||
ENDFOREACH ()
|
||||
|
||||
FIND_PACKAGE (GTest)
|
||||
@@ -124,7 +153,6 @@ FIND_PACKAGE (Threads)
|
||||
IF (GTEST_FOUND AND ZLIB_FOUND AND THREADS_FOUND)
|
||||
OPTION (MSGPACK_BUILD_TESTS "Build msgpack tests." ON)
|
||||
ENDIF ()
|
||||
OPTION (MSGPACK_BUILD_EXAMPLES "Build msgpack examples." ON)
|
||||
|
||||
OPTION (MSGPACK_ENABLE_CXX "Enable C++ interface." ON)
|
||||
OPTION (MSGPACK_ENABLE_SHARED "Build shared libaries in addition to static libraries." ON)
|
||||
@@ -153,17 +181,20 @@ CONFIGURE_FILE (
|
||||
@ONLY
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES (
|
||||
./
|
||||
include/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/
|
||||
)
|
||||
|
||||
IF (MSGPACK_ENABLE_SHARED)
|
||||
ADD_LIBRARY (msgpackc SHARED
|
||||
${msgpackc_SOURCES}
|
||||
${msgpackc_HEADERS}
|
||||
)
|
||||
|
||||
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 ()
|
||||
|
||||
ADD_LIBRARY (msgpackc-static STATIC
|
||||
@@ -171,6 +202,20 @@ ADD_LIBRARY (msgpackc-static STATIC
|
||||
${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)
|
||||
@@ -204,16 +249,6 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
|
||||
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
|
||||
IF (MSGPACK_ENABLE_SHARED)
|
||||
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
@@ -226,6 +261,11 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC90" OR "${CMAKE_CXX_COMPILER_ID}" S
|
||||
SET_SOURCE_FILES_PROPERTIES(${msgpackc_SOURCES} PROPERTIES LANGUAGE CXX)
|
||||
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)
|
||||
SET(CMAKE_INSTALL_BINDIR bin)
|
||||
ENDIF ()
|
||||
@@ -244,10 +284,15 @@ ELSE()
|
||||
SET (MSGPACK_INSTALLTARGETS msgpackc-static)
|
||||
ENDIF ()
|
||||
|
||||
INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} EXPORT msgpack-targets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
INSTALL (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
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)
|
||||
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/msgpack.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
ENDIF ()
|
||||
@@ -298,3 +343,39 @@ IF (DOXYGEN_FOUND)
|
||||
DEPENDS doxygen_c doxygen_cpp
|
||||
)
|
||||
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}"
|
||||
)
|
||||
|
18
Files.cmake
18
Files.cmake
@@ -153,7 +153,7 @@ LIST (APPEND msgpackc_HEADERS
|
||||
include/msgpack/zone.h
|
||||
)
|
||||
IF (MSGPACK_ENABLE_CXX)
|
||||
LIST (APPEND msgpack_HEADERS
|
||||
LIST (APPEND msgpackc_HEADERS
|
||||
include/msgpack.hpp
|
||||
include/msgpack/adaptor/adaptor_base.hpp
|
||||
include/msgpack/adaptor/adaptor_base_decl.hpp
|
||||
@@ -165,6 +165,7 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/adaptor/boost/msgpack_variant_decl.hpp
|
||||
include/msgpack/adaptor/boost/optional.hpp
|
||||
include/msgpack/adaptor/boost/string_ref.hpp
|
||||
include/msgpack/adaptor/boost/string_view.hpp
|
||||
include/msgpack/adaptor/carray.hpp
|
||||
include/msgpack/adaptor/char_ptr.hpp
|
||||
include/msgpack/adaptor/check_container_size.hpp
|
||||
@@ -179,6 +180,8 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/adaptor/cpp11/unique_ptr.hpp
|
||||
include/msgpack/adaptor/cpp11/unordered_map.hpp
|
||||
include/msgpack/adaptor/cpp11/unordered_set.hpp
|
||||
include/msgpack/adaptor/cpp17/optional.hpp
|
||||
include/msgpack/adaptor/cpp17/string_view.hpp
|
||||
include/msgpack/adaptor/define.hpp
|
||||
include/msgpack/adaptor/define_decl.hpp
|
||||
include/msgpack/adaptor/deque.hpp
|
||||
@@ -226,6 +229,7 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/object_fwd_decl.hpp
|
||||
include/msgpack/pack.hpp
|
||||
include/msgpack/pack_decl.hpp
|
||||
include/msgpack/parse_return.hpp
|
||||
include/msgpack/preprocessor.hpp
|
||||
include/msgpack/preprocessor/arithmetic.hpp
|
||||
include/msgpack/preprocessor/arithmetic/add.hpp
|
||||
@@ -500,6 +504,7 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/type.hpp
|
||||
include/msgpack/unpack.hpp
|
||||
include/msgpack/unpack_decl.hpp
|
||||
include/msgpack/unpack_exception.hpp
|
||||
include/msgpack/v1/adaptor/adaptor_base.hpp
|
||||
include/msgpack/v1/adaptor/adaptor_base_decl.hpp
|
||||
include/msgpack/v1/adaptor/array_ref.hpp
|
||||
@@ -510,6 +515,7 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/v1/adaptor/boost/msgpack_variant_decl.hpp
|
||||
include/msgpack/v1/adaptor/boost/optional.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/char_ptr.hpp
|
||||
include/msgpack/v1/adaptor/check_container_size.hpp
|
||||
@@ -524,6 +530,8 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/v1/adaptor/cpp11/unique_ptr.hpp
|
||||
include/msgpack/v1/adaptor/cpp11/unordered_map.hpp
|
||||
include/msgpack/v1/adaptor/cpp11/unordered_set.hpp
|
||||
include/msgpack/v1/adaptor/cpp17/optional.hpp
|
||||
include/msgpack/v1/adaptor/cpp17/string_view.hpp
|
||||
include/msgpack/v1/adaptor/define.hpp
|
||||
include/msgpack/v1/adaptor/define_decl.hpp
|
||||
include/msgpack/v1/adaptor/deque.hpp
|
||||
@@ -586,11 +594,13 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/v1/object_fwd_decl.hpp
|
||||
include/msgpack/v1/pack.hpp
|
||||
include/msgpack/v1/pack_decl.hpp
|
||||
include/msgpack/v1/parse_return.hpp
|
||||
include/msgpack/v1/preprocessor.hpp
|
||||
include/msgpack/v1/sbuffer.hpp
|
||||
include/msgpack/v1/sbuffer_decl.hpp
|
||||
include/msgpack/v1/unpack.hpp
|
||||
include/msgpack/v1/unpack_decl.hpp
|
||||
include/msgpack/v1/unpack_exception.hpp
|
||||
include/msgpack/v1/version.hpp
|
||||
include/msgpack/v1/versioning.hpp
|
||||
include/msgpack/v1/vrefbuffer.hpp
|
||||
@@ -621,20 +631,26 @@ IF (MSGPACK_ENABLE_CXX)
|
||||
include/msgpack/v2/adaptor/size_equal_only_decl.hpp
|
||||
include/msgpack/v2/adaptor/v4raw_decl.hpp
|
||||
include/msgpack/v2/cpp_config_decl.hpp
|
||||
include/msgpack/v2/create_object_visitor.hpp
|
||||
include/msgpack/v2/detail/cpp03_zone_decl.hpp
|
||||
include/msgpack/v2/detail/cpp11_zone_decl.hpp
|
||||
include/msgpack/v2/fbuffer_decl.hpp
|
||||
include/msgpack/v2/iterator_decl.hpp
|
||||
include/msgpack/v2/meta_decl.hpp
|
||||
include/msgpack/v2/null_visitor.hpp
|
||||
include/msgpack/v2/object.hpp
|
||||
include/msgpack/v2/object_decl.hpp
|
||||
include/msgpack/v2/object_fwd.hpp
|
||||
include/msgpack/v2/object_fwd_decl.hpp
|
||||
include/msgpack/v2/pack_decl.hpp
|
||||
include/msgpack/v2/parse.hpp
|
||||
include/msgpack/v2/parse_return.hpp
|
||||
include/msgpack/v2/sbuffer_decl.hpp
|
||||
include/msgpack/v2/unpack.hpp
|
||||
include/msgpack/v2/unpack_decl.hpp
|
||||
include/msgpack/v2/vrefbuffer_decl.hpp
|
||||
include/msgpack/v2/x3_parse.hpp
|
||||
include/msgpack/v2/x3_unpack.hpp
|
||||
include/msgpack/v2/zbuffer_decl.hpp
|
||||
include/msgpack/v2/zone_decl.hpp
|
||||
include/msgpack/version.hpp
|
||||
|
@@ -96,7 +96,7 @@ int main(void) {
|
||||
/* deserializes it. */
|
||||
msgpack_unpacked 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. */
|
||||
msgpack_object obj = msg.data;
|
||||
@@ -137,7 +137,7 @@ int main(void) {
|
||||
/* deserializes it. */
|
||||
msgpack_unpacked 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. */
|
||||
msgpack_object obj = msg.data;
|
||||
|
@@ -78,7 +78,7 @@ int main(void) {
|
||||
|
||||
// now starts streaming deserialization.
|
||||
msgpack::object_handle oh;
|
||||
while(pac.next(&oh)) {
|
||||
while(pac.next(oh)) {
|
||||
std::cout << oh.get() << std::endl;
|
||||
}
|
||||
|
||||
|
35
README.md
35
README.md
@@ -1,7 +1,7 @@
|
||||
`msgpack` for C/C++
|
||||
===================
|
||||
|
||||
Version 2.0.0 (under development)[](https://travis-ci.org/msgpack/msgpack-c) [](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
|
||||
Version 2.1.5 [](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.
|
||||
|
||||
@@ -120,36 +120,7 @@ also install the C and C++ versions of msgpack.
|
||||
|
||||
#### Install from git repository
|
||||
|
||||
##### Using autotools
|
||||
|
||||
You will need:
|
||||
|
||||
- `gcc >= 4.1.0` or `clang >= 3.3.0`
|
||||
- `autoconf >= 2.60`
|
||||
- `automake >= 1.10`
|
||||
- `libtool >= 2.2.4`
|
||||
|
||||
The build steps below are for C and C++03. If compiling for C++11,
|
||||
add `-std=c++11` to the environmental variable `CXXFLAGS` with
|
||||
`export CXXFLAGS="$CXXFLAGS -std=c++11"` prior to following the
|
||||
directions below.
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/msgpack/msgpack-c
|
||||
$ cd msgpack-c
|
||||
$ ./bootstrap
|
||||
$ ./configure
|
||||
$ make
|
||||
```
|
||||
|
||||
You can install the resulting library like this:
|
||||
|
||||
```bash
|
||||
$ sudo make install
|
||||
```
|
||||
##### Using cmake
|
||||
|
||||
###### Using the Terminal (CLI)
|
||||
##### Using the Terminal (CLI)
|
||||
|
||||
You will need:
|
||||
|
||||
@@ -172,7 +143,7 @@ execute the following commands:
|
||||
$ cmake -DMSGPACK_CXX11=ON .
|
||||
$ sudo make install
|
||||
|
||||
##### GUI on Windows
|
||||
#### GUI on Windows
|
||||
|
||||
Clone msgpack-c git repository.
|
||||
|
||||
|
30
appveyor.yml
30
appveyor.yml
@@ -1,15 +1,19 @@
|
||||
version: 2.0.0.{build}
|
||||
version: 2.1.5.{build}
|
||||
|
||||
image:
|
||||
- Visual Studio 2015
|
||||
environment:
|
||||
global:
|
||||
BOOST_ROOT: C:\Libraries\boost_1_60_0
|
||||
matrix:
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
msvc: '"Visual Studio 10 2010"'
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
msvc: '"Visual Studio 11 2012"'
|
||||
- cpp11: -DMSGPACK_CXX11=OFF
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
msvc: '"Visual Studio 12 2013"'
|
||||
- cpp11: -DMSGPACK_CXX11=ON
|
||||
boost: -DMSGPACK_BOOST=ON
|
||||
@@ -24,19 +28,19 @@ environment:
|
||||
boost: -DMSGPACK_BOOST=OFF
|
||||
msvc: '"Visual Studio 14 2015"'
|
||||
build_script:
|
||||
- appveyor DownloadFile http://googletest.googlecode.com/files/gtest-1.7.0.zip -FileName gtest-1.7.0.zip
|
||||
- 7z x gtest-1.7.0.zip > NUL
|
||||
- cd gtest-1.7.0
|
||||
- appveyor DownloadFile https://github.com/google/googletest/archive/release-1.7.0.zip -FileName googletest-release-1.7.0.zip
|
||||
- 7z x googletest-release-1.7.0.zip > NUL
|
||||
- cd googletest-release-1.7.0
|
||||
- md build
|
||||
- cd build
|
||||
- cmake -G %msvc% -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=/D_VARIADIC_MAX=10 ..
|
||||
- cmake --build . --config Release
|
||||
- cd ..
|
||||
- cd ..
|
||||
- appveyor DownloadFile http://zlib.net/zlib-1.2.8.tar.gz -FileName zlib-1.2.8.tar.gz
|
||||
- 7z x zlib-1.2.8.tar.gz > NUL
|
||||
- 7z x zlib-1.2.8.tar > NUL
|
||||
- cd zlib-1.2.8
|
||||
- appveyor DownloadFile http://zlib.net/zlib-1.2.11.tar.gz -FileName zlib-1.2.11.tar.gz
|
||||
- 7z x zlib-1.2.11.tar.gz > NUL
|
||||
- 7z x zlib-1.2.11.tar > NUL
|
||||
- cd zlib-1.2.11
|
||||
- md build
|
||||
- cd build
|
||||
- cmake -G %msvc% ..
|
||||
@@ -46,9 +50,9 @@ build_script:
|
||||
- cd ..
|
||||
- md build
|
||||
- cd build
|
||||
- cmake -G %msvc% %cpp11% %boost% -DMSGPACK_BOOST_DIR=C:\Libraries\\boost_1_60_0 -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 -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
|
||||
|
||||
test_script:
|
||||
- set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release;%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\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
|
||||
|
@@ -16,42 +16,14 @@ then
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
if [ $1 = "cpp11" ]
|
||||
if [ "${ARCH}" == "32" ]
|
||||
then
|
||||
cpp11="-DMSGPACK_CXX11=ON"
|
||||
export BIT32="ON"
|
||||
else
|
||||
cpp11=""
|
||||
export BIT32="OFF"
|
||||
fi
|
||||
|
||||
if [ $2 = "32" ]
|
||||
then
|
||||
bit32="-DMSGPACK_32BIT=ON"
|
||||
else
|
||||
bit32=""
|
||||
fi
|
||||
|
||||
if [ $3 = "boost" ]
|
||||
then
|
||||
boost="-DMSGPACK_BOOST=ON"
|
||||
else
|
||||
boost=""
|
||||
fi
|
||||
|
||||
if [ "$4" != "" ]
|
||||
then
|
||||
boost_dir="-DMSGPACK_BOOST_DIR=$4"
|
||||
else
|
||||
boost_dir=""
|
||||
fi
|
||||
|
||||
if [ "$5" = "OFF" ]
|
||||
then
|
||||
shared="-DMSGPACK_ENABLE_SHARED=OFF"
|
||||
else
|
||||
shared=""
|
||||
fi
|
||||
|
||||
cmake $cpp11 $bit32 $boost $boost_dir $shared -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} -DMSGPACK_DEFAULT_API_VERSION=${API_VERSION} ..
|
||||
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} ..
|
||||
|
||||
ret=$?
|
||||
if [ $ret -ne 0 ]
|
||||
@@ -83,7 +55,7 @@ then
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
if [ "$2" != "32" ]
|
||||
if [ "${ARCH}" != "32" ] && [ `uname` = "Linux" ]
|
||||
then
|
||||
ctest -T memcheck | tee memcheck.log
|
||||
|
||||
|
@@ -66,14 +66,16 @@ struct define_array<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
||||
msgpack::object *ptr = o.via.array.ptr;
|
||||
switch(size) {
|
||||
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
|
||||
{
|
||||
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%>;
|
||||
<%0.upto(i) {|j|%>
|
||||
o->via.array.ptr[<%=j%>] = msgpack::object(a<%=j%>, z);<%}%>
|
||||
|
@@ -82,7 +82,7 @@ struct define_map<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
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%>;
|
||||
<%0.step(i,2) {|j|%>
|
||||
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,
|
||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) const {
|
||||
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%>;
|
||||
<%0.upto(i) {|j|%>
|
||||
o.via.array.ptr[<%=j%>] = msgpack::object(v.template get<<%=j%>>(), o.zone);<%}%>
|
||||
|
@@ -178,7 +178,9 @@ private:
|
||||
template <typename T>
|
||||
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:
|
||||
zone(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<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);
|
||||
if(m_chunk_list.m_free >= adjusted_size) {
|
||||
if (m_chunk_list.m_free < adjusted_size) {
|
||||
size_t enough_size = size + align - 1;
|
||||
char* ptr = allocate_expand(enough_size);
|
||||
aligned = get_aligned(ptr, align);
|
||||
adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||
}
|
||||
m_chunk_list.m_free -= adjusted_size;
|
||||
m_chunk_list.m_ptr += adjusted_size;
|
||||
return aligned;
|
||||
}
|
||||
return reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
allocate_expand(size + (align - 1))) / align * align);
|
||||
}
|
||||
|
||||
inline void* zone::allocate_no_align(size_t size)
|
||||
{
|
||||
if(m_chunk_list.m_free < size) {
|
||||
return allocate_expand(size);
|
||||
}
|
||||
|
||||
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_ptr += size;
|
||||
|
||||
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;
|
||||
|
||||
@@ -240,8 +247,8 @@ inline void* zone::allocate_expand(size_t size)
|
||||
|
||||
c->m_next = cl->m_head;
|
||||
cl->m_head = c;
|
||||
cl->m_free = sz - size;
|
||||
cl->m_ptr = ptr + size;
|
||||
cl->m_free = sz;
|
||||
cl->m_ptr = ptr;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -300,7 +307,7 @@ inline std::size_t aligned_size(
|
||||
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
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 {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
|
@@ -24,6 +24,14 @@
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||
#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 %>
|
||||
namespace msgpack {
|
||||
|
||||
|
@@ -2,3 +2,4 @@ ADD_SUBDIRECTORY (c)
|
||||
ADD_SUBDIRECTORY (cpp03)
|
||||
ADD_SUBDIRECTORY (cpp11)
|
||||
ADD_SUBDIRECTORY (boost)
|
||||
ADD_SUBDIRECTORY (x3)
|
||||
|
@@ -3,6 +3,20 @@ IF (MSGPACK_BOOST)
|
||||
msgpack_variant_capitalize.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 ()
|
||||
|
||||
FOREACH (source_file ${exec_PROGRAMS})
|
||||
@@ -11,6 +25,19 @@ FOREACH (source_file ${exec_PROGRAMS})
|
||||
${source_file_we}
|
||||
${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")
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3")
|
||||
ENDIF ()
|
||||
@@ -19,13 +46,6 @@ FOREACH (source_file ${exec_PROGRAMS})
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
|
||||
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
95
example/boost/asio_send_recv.cpp
Normal file
95
example/boost/asio_send_recv.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
// 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);
|
||||
boost::asio::ip::tcp::resolver::query q(host, boost::lexical_cast<std::string>(port));
|
||||
auto it = r.resolve(q);
|
||||
boost::asio::ip::tcp::socket cs(ios);
|
||||
boost::asio::async_connect(
|
||||
cs,
|
||||
|
||||
it,
|
||||
[&]
|
||||
(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();
|
||||
}
|
165
example/boost/asio_send_recv_zlib.cpp
Normal file
165
example/boost/asio_send_recv_zlib.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
// 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);
|
||||
boost::asio::ip::tcp::resolver::query q(host, boost::lexical_cast<std::string>(port));
|
||||
auto it = r.resolve(q);
|
||||
boost::asio::ip::tcp::socket cs(ios);
|
||||
boost::asio::async_connect(
|
||||
cs,
|
||||
it,
|
||||
[&]
|
||||
(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,9 @@
|
||||
INCLUDE_DIRECTORIES (
|
||||
../include
|
||||
)
|
||||
IF (MSGPACK_ENABLE_SHARED)
|
||||
SET (MSGPACK_LIB msgpackc)
|
||||
ELSE ()
|
||||
SET (MSGPACK_LIB msgpackc-static)
|
||||
ENDIF ()
|
||||
|
||||
|
||||
LIST (APPEND exec_PROGRAMS
|
||||
lib_buffer_unpack.c
|
||||
@@ -17,7 +20,7 @@ FOREACH (source_file ${exec_PROGRAMS})
|
||||
${source_file}
|
||||
)
|
||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||
msgpackc
|
||||
${MSGPACK_LIB}
|
||||
)
|
||||
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")
|
||||
@@ -27,13 +30,6 @@ FOREACH (source_file ${exec_PROGRAMS})
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
|
||||
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
@@ -22,7 +22,7 @@ void test()
|
||||
|
||||
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);
|
||||
|
@@ -23,7 +23,7 @@ void test()
|
||||
|
||||
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);
|
||||
|
@@ -2,6 +2,8 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define UNPACKED_BUFFER_SIZE 2048
|
||||
|
||||
void prepare(msgpack_sbuffer* sbuf) {
|
||||
msgpack_packer pk;
|
||||
|
||||
@@ -27,6 +29,7 @@ void unpack(char const* buf, size_t len) {
|
||||
size_t off = 0;
|
||||
msgpack_unpack_return ret;
|
||||
int i = 0;
|
||||
char unpacked_buffer[UNPACKED_BUFFER_SIZE];
|
||||
msgpack_unpacked_init(&result);
|
||||
ret = msgpack_unpack_next(&result, buf, len, &off);
|
||||
while (ret == MSGPACK_UNPACK_SUCCESS) {
|
||||
@@ -36,6 +39,8 @@ void unpack(char const* buf, size_t len) {
|
||||
printf("Object no %d:\n", ++i);
|
||||
msgpack_object_print(stdout, obj);
|
||||
printf("\n");
|
||||
msgpack_object_print_buffer(unpacked_buffer, UNPACKED_BUFFER_SIZE, obj);
|
||||
printf("%s\n", unpacked_buffer);
|
||||
/* If you want to allocate something on the zone, you can use zone. */
|
||||
/* msgpack_zone* zone = result.zone; */
|
||||
/* The lifetime of the obj and the zone, */
|
||||
|
@@ -23,13 +23,11 @@ IF (NOT MSVC)
|
||||
ENDIF ()
|
||||
|
||||
IF (MSGPACK_BOOST)
|
||||
IF (NOT MSVC)
|
||||
LIST (APPEND with_boost_lib_PROGRAMS
|
||||
speed_test.cpp
|
||||
speed_test_nested_array.cpp
|
||||
)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
FOREACH (source_file ${exec_PROGRAMS})
|
||||
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
|
||||
@@ -37,6 +35,10 @@ FOREACH (source_file ${exec_PROGRAMS})
|
||||
${source_file_we}
|
||||
${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")
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3")
|
||||
ENDIF ()
|
||||
@@ -55,11 +57,15 @@ FOREACH (source_file ${with_pthread_PROGRAMS})
|
||||
${source_file_we}
|
||||
${source_file}
|
||||
)
|
||||
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
)
|
||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||
pthread
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
)
|
||||
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 -pthread")
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3")
|
||||
ENDIF ()
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
@@ -80,6 +86,10 @@ FOREACH (source_file ${with_boost_lib_PROGRAMS})
|
||||
${source_file_we}
|
||||
${source_file}
|
||||
)
|
||||
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
)
|
||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||
${Boost_TIMER_LIBRARY}
|
||||
@@ -100,13 +110,6 @@ FOREACH (source_file ${with_boost_lib_PROGRAMS})
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
|
||||
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
@@ -69,7 +69,7 @@ struct object_with_zone<my_class> {
|
||||
o.type = type::ARRAY;
|
||||
o.via.array.size = 2;
|
||||
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[1] = msgpack::object(v.get_age(), o.zone);
|
||||
}
|
||||
|
@@ -8,12 +8,22 @@ IF (MSGPACK_CXX11)
|
||||
non_def_con_class.cpp
|
||||
)
|
||||
|
||||
IF ("${MSGPACK_DEFAULT_API_VERSION}" GREATER "1")
|
||||
LIST (APPEND exec_PROGRAMS
|
||||
socket_stream_example.cpp
|
||||
)
|
||||
ENDIF ()
|
||||
|
||||
FOREACH (source_file ${exec_PROGRAMS})
|
||||
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
|
||||
ADD_EXECUTABLE (
|
||||
${source_file_we}
|
||||
${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")
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g -O3 ")
|
||||
ENDIF ()
|
||||
@@ -22,13 +32,6 @@ IF (MSGPACK_CXX11)
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
IF ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}) OR
|
||||
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL ${GNUCXX_NO_MISMATCHED_TAGS_SUPPORT_VERSION}))
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
157
example/cpp11/socket_stream_example.cpp
Normal file
157
example/cpp11/socket_stream_example.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <msgpack.hpp>
|
||||
|
||||
struct json_like_visitor : msgpack::v2::null_visitor {
|
||||
json_like_visitor(std::string& s):m_s(s), m_ref(false) {} // m_ref is false by default
|
||||
|
||||
bool visit_nil() {
|
||||
m_s += "null";
|
||||
return true;
|
||||
}
|
||||
bool visit_boolean(bool v) {
|
||||
if (v) m_s += "true";
|
||||
else m_s += "false";
|
||||
return true;
|
||||
}
|
||||
bool visit_positive_integer(uint64_t v) {
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
m_s += ss.str();
|
||||
return true;
|
||||
}
|
||||
bool visit_negative_integer(int64_t v) {
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
m_s += ss.str();
|
||||
return true;
|
||||
}
|
||||
bool visit_str(const char* v, uint32_t size) {
|
||||
// I omit escape process.
|
||||
m_s += '"' + std::string(v, size) + '"';
|
||||
return true;
|
||||
}
|
||||
bool start_array(uint32_t /*num_elements*/) {
|
||||
m_s += "[";
|
||||
return true;
|
||||
}
|
||||
bool end_array_item() {
|
||||
m_s += ",";
|
||||
return true;
|
||||
}
|
||||
bool end_array() {
|
||||
m_s.erase(m_s.size() - 1, 1); // remove the last ','
|
||||
m_s += "]";
|
||||
return true;
|
||||
}
|
||||
bool start_map(uint32_t /*num_kv_pairs*/) {
|
||||
m_s += "{";
|
||||
return true;
|
||||
}
|
||||
bool end_map_key() {
|
||||
m_s += ":";
|
||||
return true;
|
||||
}
|
||||
bool end_map_value() {
|
||||
m_s += ",";
|
||||
return true;
|
||||
}
|
||||
bool end_map() {
|
||||
m_s.erase(m_s.size() - 1, 1); // remove the last ','
|
||||
m_s += "}";
|
||||
return true;
|
||||
}
|
||||
void parse_error(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
std::cerr << "parse error"<<std::endl;
|
||||
}
|
||||
void insufficient_bytes(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
std::cout << "insufficient bytes"<<std::endl;
|
||||
}
|
||||
std::string& m_s;
|
||||
|
||||
// These two functions are required by parser.
|
||||
void set_referenced(bool ref) { m_ref = ref; }
|
||||
bool referenced() const { return m_ref; }
|
||||
bool m_ref;
|
||||
};
|
||||
|
||||
struct do_nothing {
|
||||
void operator()(char* /*buffer*/) {
|
||||
}
|
||||
};
|
||||
|
||||
class json_like_printer : public msgpack::parser<json_like_printer, do_nothing>,
|
||||
public json_like_visitor {
|
||||
typedef parser<json_like_printer, do_nothing> parser_t;
|
||||
public:
|
||||
json_like_printer(std::size_t initial_buffer_size = MSGPACK_UNPACKER_INIT_BUFFER_SIZE)
|
||||
:parser_t(do_nothing_, initial_buffer_size),
|
||||
json_like_visitor(json_str_) {
|
||||
}
|
||||
|
||||
json_like_visitor& visitor() { return *this; }
|
||||
void print() { std::cout << json_str_ << std::endl; json_str_.clear();}
|
||||
private:
|
||||
do_nothing do_nothing_;
|
||||
std::string json_str_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ref_buffer {
|
||||
ref_buffer(T& t):t(t) {}
|
||||
void write(char const* ptr, std::size_t len) {
|
||||
if (len > t.buffer_capacity()) {
|
||||
t.reserve_buffer(len - t.buffer_capacity());
|
||||
}
|
||||
std::memcpy(t.buffer(), ptr, len);
|
||||
t.buffer_consumed(len);
|
||||
}
|
||||
T& t;
|
||||
};
|
||||
|
||||
#define BUFFERING_SIZE_MAX 100
|
||||
|
||||
//simulates streamed content (a socket for example)
|
||||
bool produce( std::stringstream & ss, char* buff, std::size_t& size)
|
||||
{
|
||||
ss.read(buff, BUFFERING_SIZE_MAX);
|
||||
size = static_cast<std::size_t>(ss.gcount());
|
||||
return (size > 0);
|
||||
}
|
||||
|
||||
//shows how you can treat data
|
||||
void consume( const char* buff, const std::size_t size,
|
||||
ref_buffer<json_like_printer> & rb,
|
||||
json_like_printer & jp
|
||||
)
|
||||
{
|
||||
rb.write(buff,size);
|
||||
while( jp.next() )
|
||||
{
|
||||
//here we print the data, you could do any wanted processing
|
||||
jp.print();
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
std::vector<std::vector<int>> vvi1 { { 1,2,3,4,5}, { 6,7,8,9,10} };
|
||||
std::vector<std::vector<int>> vvi2 { { 11,12,13,14,15}, { 16,17,18,19,20} };
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
msgpack::pack(ss, vvi1);
|
||||
msgpack::pack(ss, vvi2);
|
||||
|
||||
char buffer[BUFFERING_SIZE_MAX];
|
||||
std::size_t size = 0;
|
||||
|
||||
json_like_printer jp(1); // set initial buffer size explicitly
|
||||
ref_buffer<json_like_printer> rb(jp);
|
||||
|
||||
while( produce(ss,buffer,size) )
|
||||
{
|
||||
consume(buffer, size, rb, jp);
|
||||
}
|
||||
|
||||
}
|
72
example/x3/CMakeLists.txt
Normal file
72
example/x3/CMakeLists.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
IF (MSGPACK_USE_X3_PARSE)
|
||||
INCLUDE_DIRECTORIES (
|
||||
../include
|
||||
)
|
||||
|
||||
LIST (APPEND exec_PROGRAMS
|
||||
unpack.cpp
|
||||
parse.cpp
|
||||
)
|
||||
IF (MSGPACK_BOOST)
|
||||
LIST (APPEND with_boost_PROGRAMS
|
||||
stream_unpack.cpp
|
||||
)
|
||||
ENDIF ()
|
||||
FOREACH (source_file ${exec_PROGRAMS})
|
||||
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
|
||||
ADD_EXECUTABLE (
|
||||
${source_file_we}
|
||||
${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")
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wall -Wextra -Werror -g ")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
ELSE ()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDFOREACH ()
|
||||
FOREACH (source_file ${with_boost_PROGRAMS})
|
||||
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
|
||||
ADD_EXECUTABLE (
|
||||
${source_file_we}
|
||||
${source_file}
|
||||
)
|
||||
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
)
|
||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||
${Boost_CONTEXT_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
)
|
||||
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 ")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||
ENDIF ()
|
||||
|
||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
ELSE ()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
ENDFOREACH ()
|
||||
ENDIF ()
|
125
example/x3/parse.cpp
Normal file
125
example/x3/parse.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
// 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 <iostream>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
// MSGPACK_USE_X3_PARSE should be defined before including msgpack.hpp
|
||||
// It usually defined as a compiler option as -DMSGPACK_USE_X3_PARSE.
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
struct json_like_visitor : msgpack::v2::null_visitor {
|
||||
json_like_visitor(std::string& s):m_s(s) {}
|
||||
|
||||
bool visit_nil() {
|
||||
m_s += "null";
|
||||
return true;
|
||||
}
|
||||
bool visit_boolean(bool v) {
|
||||
if (v) m_s += "true";
|
||||
else m_s += "false";
|
||||
return true;
|
||||
}
|
||||
bool visit_positive_integer(uint64_t v) {
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
m_s += ss.str();
|
||||
return true;
|
||||
}
|
||||
bool visit_negative_integer(int64_t v) {
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
m_s += ss.str();
|
||||
return true;
|
||||
}
|
||||
bool visit_float32(float v) {
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
m_s += ss.str();
|
||||
return true;
|
||||
}
|
||||
bool visit_float64(double v) {
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
m_s += ss.str();
|
||||
return true;
|
||||
}
|
||||
bool visit_str(const char* v, uint32_t size) {
|
||||
m_s += '"' + std::string(v, size) + '"';
|
||||
return true;
|
||||
}
|
||||
bool start_array(uint32_t /*num_elements*/) {
|
||||
m_s += "[";
|
||||
return true;
|
||||
}
|
||||
bool end_array_item() {
|
||||
m_s += ",";
|
||||
return true;
|
||||
}
|
||||
bool end_array() {
|
||||
m_s.erase(m_s.size() - 1, 1); // remove the last ','
|
||||
m_s += "]";
|
||||
return true;
|
||||
}
|
||||
bool start_map(uint32_t /*num_kv_pairs*/) {
|
||||
m_s += "{";
|
||||
return true;
|
||||
}
|
||||
bool end_map_key() {
|
||||
m_s += ":";
|
||||
return true;
|
||||
}
|
||||
bool end_map_value() {
|
||||
m_s += ",";
|
||||
return true;
|
||||
}
|
||||
bool end_map() {
|
||||
m_s.erase(m_s.size() - 1, 1); // remove the last ','
|
||||
m_s += "}";
|
||||
return true;
|
||||
}
|
||||
void parse_error(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
}
|
||||
void insufficient_bytes(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
}
|
||||
std::string& m_s;
|
||||
};
|
||||
|
||||
int main() {
|
||||
std::stringstream ss;
|
||||
std::map<std::string, std::vector<int>> v1 {
|
||||
{ "ABC", { 1, 2, 3 } },
|
||||
{ "DEFG", { 4, 5 } }
|
||||
};
|
||||
std::vector<std::string> v2 {
|
||||
"HIJ", "KLM", "NOP"
|
||||
};
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::pack(ss, v2);
|
||||
|
||||
std::string const& buf = ss.str();
|
||||
auto it = buf.begin();
|
||||
auto end = buf.end();
|
||||
{
|
||||
std::string str;
|
||||
bool ret = msgpack::parse(it, end, json_like_visitor(str));
|
||||
// it is updated here.
|
||||
assert(ret);
|
||||
std::cout << str << std::endl;
|
||||
}
|
||||
{
|
||||
std::string str;
|
||||
bool ret = msgpack::parse(it, end, json_like_visitor(str));
|
||||
// it is updated here.
|
||||
assert(ret);
|
||||
std::cout << str << std::endl;
|
||||
}
|
||||
}
|
248
example/x3/stream_unpack.cpp
Normal file
248
example/x3/stream_unpack.cpp
Normal file
@@ -0,0 +1,248 @@
|
||||
// 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 <iostream>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
#include <thread>
|
||||
|
||||
// MSGPACK_USE_X3_PARSE should be defined before including msgpack.hpp
|
||||
// It usually defined as a compiler option as -DMSGPACK_USE_X3_PARSE.
|
||||
|
||||
//#define MSGPACK_USE_X3_PARSE
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
#include <boost/asio.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>
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // defined(__clang__)
|
||||
|
||||
namespace as = boost::asio;
|
||||
namespace x3 = boost::spirit::x3;
|
||||
namespace coro2 = boost::coroutines2;
|
||||
|
||||
using pull_type = coro2::asymmetric_coroutine<std::shared_ptr<std::vector<char>>>::pull_type;
|
||||
|
||||
// iterator fetching data from coroutine2.
|
||||
class buffered_iterator : public std::iterator<std::input_iterator_tag, char> {
|
||||
public:
|
||||
using pointer_t = typename iterator::pointer;
|
||||
using reference_t = typename iterator::reference;
|
||||
|
||||
explicit buffered_iterator(pull_type& source) noexcept
|
||||
: source_{ &source } {
|
||||
fetch_();
|
||||
}
|
||||
buffered_iterator() = default;
|
||||
|
||||
bool operator==(buffered_iterator const& other) const noexcept {
|
||||
if (!other.source_ && !source_ && !other.buf_ && !buf_) return true;
|
||||
return other.it_ == it_;
|
||||
}
|
||||
|
||||
bool operator!=(buffered_iterator const& other) const noexcept {
|
||||
return !(other == *this);
|
||||
}
|
||||
|
||||
buffered_iterator & operator++() {
|
||||
increment_();
|
||||
return * this;
|
||||
}
|
||||
|
||||
buffered_iterator operator++(int) = delete;
|
||||
|
||||
reference_t operator*() noexcept {
|
||||
return *it_;
|
||||
}
|
||||
|
||||
pointer_t operator->() noexcept {
|
||||
return std::addressof(*it_);
|
||||
}
|
||||
|
||||
private:
|
||||
void fetch_() noexcept {
|
||||
BOOST_ASSERT( nullptr != source_);
|
||||
if (*source_) {
|
||||
buf_ = source_->get();
|
||||
it_ = buf_->begin();
|
||||
}
|
||||
else {
|
||||
source_ = nullptr;
|
||||
buf_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void increment_() {
|
||||
BOOST_ASSERT( nullptr != source_);
|
||||
BOOST_ASSERT(*source_);
|
||||
if (++it_ == buf_->end()) {
|
||||
(*source_)();
|
||||
fetch_();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
pull_type* source_{ nullptr };
|
||||
std::shared_ptr<std::vector<char>> buf_;
|
||||
std::vector<char>::iterator it_;
|
||||
};
|
||||
|
||||
// session class that corresponding to each client
|
||||
class session : public std::enable_shared_from_this<session> {
|
||||
public:
|
||||
session(as::ip::tcp::socket socket)
|
||||
: socket_(std::move(socket)) {
|
||||
}
|
||||
|
||||
void start() {
|
||||
sink_ = std::make_shared<coro2::asymmetric_coroutine<std::shared_ptr<std::vector<char>>>::push_type>(
|
||||
[&, this](pull_type& source) {
|
||||
// *1 is started when the first sink is called.
|
||||
|
||||
std::cout << "session started" << std::endl;
|
||||
do_read();
|
||||
source();
|
||||
|
||||
// use buffered_iterator here
|
||||
// b is incremented in msgpack::unpack() and fetch data from sink
|
||||
// via coroutine2 mechanism
|
||||
auto b = boost::spirit::make_default_multi_pass(buffered_iterator(source));
|
||||
auto e = boost::spirit::make_default_multi_pass(buffered_iterator());
|
||||
|
||||
// This is usually an infinity look, but for test, loop is finished when
|
||||
// two message pack data is processed.
|
||||
for (int i = 0; i != 2; ++i) {
|
||||
auto oh = msgpack::unpack(b, e);
|
||||
std::cout << oh.get() << std::endl;
|
||||
}
|
||||
}
|
||||
);
|
||||
// send dummy data to start *1
|
||||
(*sink_)({});
|
||||
}
|
||||
|
||||
private:
|
||||
void do_read() {
|
||||
std::cout << "session do_read() is called" << std::endl;
|
||||
auto self(shared_from_this());
|
||||
auto data = std::make_shared<std::vector<char>>(static_cast<std::size_t>(max_length));
|
||||
socket_.async_read_some(
|
||||
boost::asio::buffer(*data),
|
||||
[this, self, data]
|
||||
(boost::system::error_code ec, std::size_t length) {
|
||||
if (!ec) {
|
||||
data->resize(length);
|
||||
(*sink_)(data);
|
||||
do_read();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
as::ip::tcp::socket socket_;
|
||||
static constexpr std::size_t const max_length = 1024;
|
||||
std::shared_ptr<coro2::asymmetric_coroutine<std::shared_ptr<std::vector<char>>>::push_type> sink_;
|
||||
};
|
||||
|
||||
class server {
|
||||
public:
|
||||
server(
|
||||
as::io_service& ios,
|
||||
std::uint16_t port)
|
||||
: acceptor_(ios, as::ip::tcp::endpoint(as::ip::tcp::v4(), port)),
|
||||
socket_(ios) {
|
||||
do_accept();
|
||||
std::cout << "server start accept" << std::endl;
|
||||
ios.run();
|
||||
}
|
||||
|
||||
private:
|
||||
void do_accept() {
|
||||
acceptor_.async_accept(
|
||||
socket_,
|
||||
[this](boost::system::error_code ec) {
|
||||
if (!ec) {
|
||||
std::make_shared<session>(std::move(socket_))->start();
|
||||
}
|
||||
// for test, only one session is accepted.
|
||||
// do_accept();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
as::ip::tcp::acceptor acceptor_;
|
||||
as::ip::tcp::socket socket_;
|
||||
};
|
||||
|
||||
int main() {
|
||||
std::thread srv(
|
||||
[]{
|
||||
boost::asio::io_service ios;
|
||||
server s(ios, 12345);
|
||||
}
|
||||
);
|
||||
|
||||
std::thread cli(
|
||||
[]{
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
std::cout << "client start" << std::endl;
|
||||
|
||||
std::stringstream ss;
|
||||
std::map<std::string, std::vector<int>> v1 {
|
||||
{ "ABC", { 1, 2, 3 } },
|
||||
{ "DEFG", { 4, 5 } }
|
||||
};
|
||||
std::vector<std::string> v2 {
|
||||
"HIJ", "KLM", "NOP"
|
||||
};
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::pack(ss, v2);
|
||||
|
||||
auto send_data = ss.str();
|
||||
|
||||
boost::asio::io_service ios;
|
||||
as::ip::tcp::resolver::query q("127.0.0.1", "12345");
|
||||
as::ip::tcp::resolver r(ios);
|
||||
auto it = r.resolve(q);
|
||||
|
||||
std::cout << "client connect" << std::endl;
|
||||
as::ip::tcp::socket s(ios);
|
||||
as::connect(s, it);
|
||||
|
||||
|
||||
std::size_t const size = 5;
|
||||
std::size_t rest = send_data.size();
|
||||
std::size_t index = 0;
|
||||
while (rest != 0) {
|
||||
std::cout << "client send data" << std::endl;
|
||||
auto send_size = size < rest ? size : rest;
|
||||
as::write(s, as::buffer(&send_data[index], send_size));
|
||||
rest -= send_size;
|
||||
index += send_size;
|
||||
std::cout << "client wait" << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
cli.join();
|
||||
std::cout << "client joinded" << std::endl;
|
||||
srv.join();
|
||||
std::cout << "server joinded" << std::endl;
|
||||
}
|
43
example/x3/unpack.cpp
Normal file
43
example/x3/unpack.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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 <iostream>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
// MSGPACK_USE_X3_PARSE should be defined before including msgpack.hpp
|
||||
// It usually defined as a compiler option as -DMSGPACK_USE_X3_PARSE.
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
int main() {
|
||||
std::stringstream ss;
|
||||
std::map<std::string, std::vector<int>> v1 {
|
||||
{ "ABC", { 1, 2, 3 } },
|
||||
{ "DEFG", { 4, 5 } }
|
||||
};
|
||||
std::vector<std::string> v2 {
|
||||
"HIJ", "KLM", "NOP"
|
||||
};
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::pack(ss, v2);
|
||||
|
||||
std::string const& buf = ss.str();
|
||||
auto it = buf.begin();
|
||||
auto end = buf.end();
|
||||
{
|
||||
auto oh = msgpack::unpack(it, end);
|
||||
// it is updated here.
|
||||
assert(v1 == (oh.get().as<std::map<std::string, std::vector<int>>>()));
|
||||
}
|
||||
{
|
||||
auto oh = msgpack::unpack(it, end);
|
||||
assert(v2 == oh.get().as<std::vector<std::string>>());
|
||||
}
|
||||
}
|
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
|
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
|
@@ -42,6 +42,7 @@
|
||||
}
|
||||
|
||||
#define MSGPACK_BASE_ARRAY(base) (*const_cast<base *>(static_cast<base const*>(this)))
|
||||
#define MSGPACK_NVP(name, value) (name) (value)
|
||||
|
||||
#define MSGPACK_DEFINE_MAP_EACH_PROC(r, data, elem) \
|
||||
MSGPACK_PP_IF( \
|
||||
|
@@ -84,7 +84,7 @@ struct object_with_zone<MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
@@ -25,7 +25,7 @@ extern "C" {
|
||||
|
||||
static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
|
||||
{
|
||||
return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
|
||||
return (len == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#ifndef MSGPACK_GCC_ATOMIC_HPP
|
||||
#define MSGPACK_GCC_ATOMIC_HPP
|
||||
|
||||
#ifdef ENABLE_GCC_CXX_ATOMIC
|
||||
#if defined(__GNUC__) && ((__GNUC__*10 + __GNUC_MINOR__) < 41)
|
||||
|
||||
#include "msgpack/gcc_atomic.h"
|
||||
@@ -28,6 +27,5 @@ int _msgpack_sync_incr_and_fetch(volatile _msgpack_atomic_counter_t* ptr)
|
||||
}
|
||||
|
||||
#endif // old gcc workaround
|
||||
#endif // ENABLE_GCC_CXX_ATOMIC
|
||||
|
||||
#endif /* gcc_atomic.hpp */
|
||||
|
@@ -29,6 +29,8 @@ typedef enum {
|
||||
MSGPACK_OBJECT_BOOLEAN = 0x01,
|
||||
MSGPACK_OBJECT_POSITIVE_INTEGER = 0x02,
|
||||
MSGPACK_OBJECT_NEGATIVE_INTEGER = 0x03,
|
||||
MSGPACK_OBJECT_FLOAT32 = 0x0a,
|
||||
MSGPACK_OBJECT_FLOAT64 = 0x04,
|
||||
MSGPACK_OBJECT_FLOAT = 0x04,
|
||||
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
|
||||
MSGPACK_OBJECT_DOUBLE = MSGPACK_OBJECT_FLOAT, /* obsolete */
|
||||
@@ -98,6 +100,9 @@ typedef struct msgpack_object_kv {
|
||||
MSGPACK_DLLEXPORT
|
||||
void msgpack_object_print(FILE* out, msgpack_object o);
|
||||
|
||||
MSGPACK_DLLEXPORT
|
||||
int msgpack_object_print_buffer(char *buffer, size_t buffer_size, msgpack_object o);
|
||||
|
||||
MSGPACK_DLLEXPORT
|
||||
bool msgpack_object_equal(const msgpack_object x, const msgpack_object y);
|
||||
|
||||
|
16
include/msgpack/parse_return.hpp
Normal file
16
include/msgpack/parse_return.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// MessagePack for C++ deserializing 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_PARSE_RETURN_HPP
|
||||
#define MSGPACK_PARSE_RETURN_HPP
|
||||
|
||||
#include "msgpack/v1/parse_return.hpp"
|
||||
#include "msgpack/v2/parse_return.hpp"
|
||||
|
||||
#endif // MSGPACK_PARSE_RETURN_HPP
|
@@ -14,6 +14,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
||||
# define snprintf(buf, len, format,...) _snprintf_s(buf, len, len, format, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
@@ -40,15 +45,18 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
# 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;
|
||||
# define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr)
|
||||
# define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)
|
||||
#elif defined(__GNUC__) && ((__GNUC__*10 + __GNUC_MINOR__) < 41)
|
||||
|
||||
# if defined(__cplusplus)
|
||||
# define _msgpack_atomic_counter_header "gcc_atomic.hpp"
|
||||
# define _msgpack_atomic_counter_header "msgpack/gcc_atomic.hpp"
|
||||
# else
|
||||
# define _msgpack_atomic_counter_header "gcc_atomic.h"
|
||||
# define _msgpack_atomic_counter_header "msgpack/gcc_atomic.h"
|
||||
# endif
|
||||
|
||||
#else
|
||||
@@ -69,7 +77,7 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#else /* _*/
|
||||
#elif defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||
|
||||
#include <arpa/inet.h> /* __BYTE_ORDER */
|
||||
# if defined(linux)
|
||||
@@ -80,7 +88,9 @@
|
||||
|
||||
#if MSGPACK_ENDIAN_LITTLE_BYTE
|
||||
|
||||
# ifdef _WIN32
|
||||
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||
# define _msgpack_be16(x) ntohs(x)
|
||||
# else
|
||||
# if defined(ntohs)
|
||||
# define _msgpack_be16(x) ntohs(x)
|
||||
# elif defined(_byteswap_ushort) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||
@@ -90,11 +100,11 @@
|
||||
((((uint16_t)x) << 8) ) | \
|
||||
((((uint16_t)x) >> 8) ) )
|
||||
# endif
|
||||
# else
|
||||
# define _msgpack_be16(x) ntohs(x)
|
||||
# endif
|
||||
|
||||
# ifdef _WIN32
|
||||
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||
# define _msgpack_be32(x) ntohl(x)
|
||||
# else
|
||||
# if defined(ntohl)
|
||||
# define _msgpack_be32(x) ntohl(x)
|
||||
# elif defined(_byteswap_ulong) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||
@@ -106,8 +116,6 @@
|
||||
((((uint32_t)x) >> 8) & 0x0000ff00U ) | \
|
||||
((((uint32_t)x) >> 24) ) )
|
||||
# endif
|
||||
# else
|
||||
# define _msgpack_be32(x) ntohl(x)
|
||||
# endif
|
||||
|
||||
# if defined(_byteswap_uint64) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||
|
@@ -42,6 +42,13 @@
|
||||
#include "adaptor/cpp11/unordered_map.hpp"
|
||||
#include "adaptor/cpp11/unordered_set.hpp"
|
||||
|
||||
#if __cplusplus >= 201703
|
||||
|
||||
#include "adaptor/cpp17/optional.hpp"
|
||||
#include "adaptor/cpp17/string_view.hpp"
|
||||
|
||||
#endif // __cplusplus >= 201703
|
||||
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#if defined(MSGPACK_USE_BOOST)
|
||||
@@ -50,5 +57,6 @@
|
||||
#include "adaptor/boost/msgpack_variant.hpp"
|
||||
#include "adaptor/boost/optional.hpp"
|
||||
#include "adaptor/boost/string_ref.hpp"
|
||||
#include "adaptor/boost/string_view.hpp"
|
||||
|
||||
#endif // defined(MSGPACK_USE_BOOST)
|
||||
|
@@ -146,6 +146,18 @@ static inline void msgpack_unpacker_buffer_consumed(msgpack_unpacker* mpac, si
|
||||
MSGPACK_DLLEXPORT
|
||||
msgpack_unpack_return msgpack_unpacker_next(msgpack_unpacker* mpac, msgpack_unpacked* pac);
|
||||
|
||||
/**
|
||||
* Deserializes one object and set the number of parsed bytes involved.
|
||||
* Returns true if it successes. Otherwise false is returned.
|
||||
* @param mpac pointer to an initialized msgpack_unpacker object.
|
||||
* @param result pointer to an initialized msgpack_unpacked object.
|
||||
* @param p_bytes pointer to variable that will be set with the number of parsed bytes.
|
||||
*/
|
||||
MSGPACK_DLLEXPORT
|
||||
msgpack_unpack_return msgpack_unpacker_next_with_size(msgpack_unpacker* mpac,
|
||||
msgpack_unpacked* result,
|
||||
size_t *p_bytes);
|
||||
|
||||
/**
|
||||
* Initializes a msgpack_unpacked object.
|
||||
* The initialized object must be destroyed by msgpack_unpacked_destroy(msgpack_unpacker*).
|
||||
@@ -267,4 +279,3 @@ static inline msgpack_zone* msgpack_unpacked_release_zone(msgpack_unpacked* resu
|
||||
#endif
|
||||
|
||||
#endif /* msgpack/unpack.h */
|
||||
|
||||
|
@@ -14,5 +14,6 @@
|
||||
|
||||
#include "msgpack/v1/unpack.hpp"
|
||||
#include "msgpack/v2/unpack.hpp"
|
||||
#include "msgpack/v2/x3_unpack.hpp"
|
||||
|
||||
#endif // MSGPACK_UNPACK_HPP
|
||||
|
15
include/msgpack/unpack_exception.hpp
Normal file
15
include/msgpack/unpack_exception.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// MessagePack for C++ deserializing 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_UNPACK_EXCEPTION_HPP
|
||||
#define MSGPACK_UNPACK_EXCEPTION_HPP
|
||||
|
||||
#include "msgpack/v1/unpack_exception.hpp"
|
||||
|
||||
#endif // MSGPACK_UNPACK_EXCEPTION_HPP
|
@@ -109,14 +109,17 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
int ret;
|
||||
|
||||
#define push_simple_value(func) \
|
||||
if(msgpack_unpack_callback(func)(user, &obj) < 0) { goto _failed; } \
|
||||
ret = msgpack_unpack_callback(func)(user, &obj); \
|
||||
if(ret < 0) { goto _failed; } \
|
||||
goto _push
|
||||
#define push_fixed_value(func, arg) \
|
||||
if(msgpack_unpack_callback(func)(user, arg, &obj) < 0) { goto _failed; } \
|
||||
ret = msgpack_unpack_callback(func)(user, arg, &obj); \
|
||||
if(ret < 0) { goto _failed; } \
|
||||
goto _push
|
||||
#define push_variable_value(func, base, pos, len) \
|
||||
if(msgpack_unpack_callback(func)(user, \
|
||||
(const char*)base, (const char*)pos, len, &obj) < 0) { goto _failed; } \
|
||||
ret = msgpack_unpack_callback(func)(user, \
|
||||
(const char*)base, (const char*)pos, len, &obj); \
|
||||
if(ret < 0) { goto _failed; } \
|
||||
goto _push
|
||||
|
||||
#define again_fixed_trail(_cs, trail_len) \
|
||||
@@ -130,33 +133,16 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
goto _fixed_trail_again
|
||||
|
||||
#define start_container(func, count_, ct_) \
|
||||
if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \
|
||||
if(msgpack_unpack_callback(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
|
||||
if(top >= MSGPACK_EMBED_STACK_SIZE) { \
|
||||
ret = MSGPACK_UNPACK_NOMEM_ERROR; \
|
||||
goto _failed; \
|
||||
} /* FIXME */ \
|
||||
ret = msgpack_unpack_callback(func)(user, count_, &stack[top].obj); \
|
||||
if(ret < 0) { goto _failed; } \
|
||||
if((count_) == 0) { obj = stack[top].obj; goto _push; } \
|
||||
stack[top].ct = ct_; \
|
||||
stack[top].count = count_; \
|
||||
++top; \
|
||||
/*printf("container %d count %d stack %d\n",stack[top].obj,count_,top);*/ \
|
||||
/*printf("stack push %d\n", top);*/ \
|
||||
/* FIXME \
|
||||
if(top >= stack_size) { \
|
||||
if(stack_size == MSGPACK_EMBED_STACK_SIZE) { \
|
||||
size_t csize = sizeof(msgpack_unpack_struct(_stack)) * MSGPACK_EMBED_STACK_SIZE; \
|
||||
size_t nsize = csize * 2; \
|
||||
msgpack_unpack_struct(_stack)* tmp = (msgpack_unpack_struct(_stack)*)malloc(nsize); \
|
||||
if(tmp == NULL) { goto _failed; } \
|
||||
memcpy(tmp, ctx->stack, csize); \
|
||||
ctx->stack = stack = tmp; \
|
||||
ctx->stack_size = stack_size = MSGPACK_EMBED_STACK_SIZE * 2; \
|
||||
} else { \
|
||||
size_t nsize = sizeof(msgpack_unpack_struct(_stack)) * ctx->stack_size * 2; \
|
||||
msgpack_unpack_struct(_stack)* tmp = (msgpack_unpack_struct(_stack)*)realloc(ctx->stack, nsize); \
|
||||
if(tmp == NULL) { goto _failed; } \
|
||||
ctx->stack = stack = tmp; \
|
||||
ctx->stack_size = stack_size = stack_size * 2; \
|
||||
} \
|
||||
} \
|
||||
*/ \
|
||||
goto _header_again
|
||||
|
||||
#define NEXT_CS(p) \
|
||||
@@ -231,6 +217,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
case 0xdf: // map 32
|
||||
again_fixed_trail(NEXT_CS(p), 2u << (((unsigned int)*p) & 0x01));
|
||||
default:
|
||||
ret = MSGPACK_UNPACK_PARSE_ERROR;
|
||||
goto _failed;
|
||||
}
|
||||
SWITCH_RANGE(0xa0, 0xbf) // FixStr
|
||||
@@ -241,6 +228,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
start_container(_map, ((unsigned int)*p) & 0x0f, MSGPACK_CT_MAP_KEY);
|
||||
|
||||
SWITCH_RANGE_DEFAULT
|
||||
ret = MSGPACK_UNPACK_PARSE_ERROR;
|
||||
goto _failed;
|
||||
SWITCH_RANGE_END
|
||||
// end MSGPACK_CS_HEADER
|
||||
@@ -248,6 +236,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
|
||||
_fixed_trail_again:
|
||||
++p;
|
||||
// fallthrough
|
||||
|
||||
default:
|
||||
if((size_t)(pe - p) < trail) { goto _out; }
|
||||
@@ -384,6 +373,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
}
|
||||
|
||||
default:
|
||||
ret = MSGPACK_UNPACK_PARSE_ERROR;
|
||||
goto _failed;
|
||||
}
|
||||
}
|
||||
@@ -393,7 +383,8 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
c = &stack[top-1];
|
||||
switch(c->ct) {
|
||||
case MSGPACK_CT_ARRAY_ITEM:
|
||||
if(msgpack_unpack_callback(_array_item)(user, &c->obj, obj) < 0) { goto _failed; }
|
||||
ret = msgpack_unpack_callback(_array_item)(user, &c->obj, obj); \
|
||||
if(ret < 0) { goto _failed; }
|
||||
if(--c->count == 0) {
|
||||
obj = c->obj;
|
||||
--top;
|
||||
@@ -406,7 +397,8 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
c->ct = MSGPACK_CT_MAP_VALUE;
|
||||
goto _header_again;
|
||||
case MSGPACK_CT_MAP_VALUE:
|
||||
if(msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj) < 0) { goto _failed; }
|
||||
ret = msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj); \
|
||||
if(ret < 0) { goto _failed; }
|
||||
if(--c->count == 0) {
|
||||
obj = c->obj;
|
||||
--top;
|
||||
@@ -417,6 +409,7 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
goto _header_again;
|
||||
|
||||
default:
|
||||
ret = MSGPACK_UNPACK_PARSE_ERROR;
|
||||
goto _failed;
|
||||
}
|
||||
|
||||
@@ -436,7 +429,6 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
||||
|
||||
_failed:
|
||||
/*printf("** FAILED **\n"); */
|
||||
ret = -1;
|
||||
goto _end;
|
||||
|
||||
_out:
|
||||
|
@@ -253,20 +253,20 @@ struct object_with_zone<msgpack::type::array_ref<T> > {
|
||||
}
|
||||
else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
typename T::const_iterator it(v.data->begin());
|
||||
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 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);
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#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;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -280,7 +280,7 @@ struct object_with_zone<msgpack::type::array_ref<T[N]> > {
|
||||
if (!v.data) { throw msgpack::type_error(); }
|
||||
o.type = msgpack::type::ARRAY;
|
||||
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;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
#include "msgpack/meta.hpp"
|
||||
|
||||
#include "msgpack/adaptor/pair.hpp"
|
||||
|
||||
#if !defined (MSGPACK_USE_CPP03)
|
||||
#include "msgpack/adaptor/cpp11/tuple.hpp"
|
||||
#endif // #if !defined (MSGPACK_USE_CPP03)
|
||||
@@ -34,18 +36,59 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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)
|
||||
|
||||
template <typename T>
|
||||
struct as<
|
||||
T,
|
||||
typename msgpack::enable_if<
|
||||
boost::fusion::traits::is_sequence<T>::value &&
|
||||
detail::is_seq_no_pair_no_tuple<T>::value &&
|
||||
boost::mpl::fold<
|
||||
T,
|
||||
boost::mpl::bool_<true>,
|
||||
boost::mpl::if_ <
|
||||
boost::mpl::and_<
|
||||
boost::mpl::or_<
|
||||
boost::mpl::_1,
|
||||
msgpack::has_as<boost::mpl::_2>
|
||||
>,
|
||||
@@ -82,7 +125,7 @@ struct as<
|
||||
#endif // !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
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 {
|
||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if (o.via.array.size != checked_get_container_size(boost::fusion::size(v))) {
|
||||
@@ -106,7 +149,7 @@ private:
|
||||
};
|
||||
|
||||
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>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const T& v) const {
|
||||
uint32_t size = checked_get_container_size(boost::fusion::size(v));
|
||||
@@ -128,11 +171,11 @@ private:
|
||||
};
|
||||
|
||||
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 {
|
||||
uint32_t size = checked_get_container_size(boost::fusion::size(v));
|
||||
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;
|
||||
uint32_t count = 0;
|
||||
boost::fusion::for_each(v, with_zone_imp(o, count));
|
||||
|
@@ -47,7 +47,7 @@ struct basic_variant :
|
||||
bool, // BOOL
|
||||
int64_t, // NEGATIVE_INTEGER
|
||||
uint64_t, // POSITIVE_INTEGER
|
||||
double, // FLOAT
|
||||
double, // FLOAT32, FLOAT64
|
||||
std::string, // STR
|
||||
#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
|
||||
boost::string_ref, // STR
|
||||
@@ -66,7 +66,7 @@ struct basic_variant :
|
||||
bool, // BOOL
|
||||
int64_t, // NEGATIVE_INTEGER
|
||||
uint64_t, // POSITIVE_INTEGER
|
||||
double, // FLOAT
|
||||
double, // FLOAT32, FLOAT64
|
||||
std::string, // STR
|
||||
#if (BOOST_VERSION / 100000) >= 1 && ((BOOST_VERSION / 100) % 1000) >= 53
|
||||
boost::string_ref, // STR
|
||||
@@ -286,7 +286,8 @@ struct as<type::basic_variant<STR, BIN, EXT> > {
|
||||
return o.as<uint64_t>();
|
||||
case type::NEGATIVE_INTEGER:
|
||||
return o.as<int64_t>();
|
||||
case type::FLOAT:
|
||||
case type::FLOAT32:
|
||||
case type::FLOAT64:
|
||||
return o.as<double>();
|
||||
case type::STR:
|
||||
return o.as<STR>();
|
||||
@@ -326,7 +327,8 @@ struct convert<type::basic_variant<STR, BIN, EXT> > {
|
||||
case type::NEGATIVE_INTEGER:
|
||||
v = o.as<int64_t>();
|
||||
break;
|
||||
case type::FLOAT:
|
||||
case type::FLOAT32:
|
||||
case type::FLOAT64:
|
||||
v = o.as<double>();
|
||||
break;
|
||||
case type::STR:
|
||||
|
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;
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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_body(p, adjusted_size);
|
||||
return o;
|
||||
@@ -115,7 +115,7 @@ struct pack<const char[N]> {
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
char const* p = v;
|
||||
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_body(p, adjusted_size);
|
||||
return o;
|
||||
@@ -151,7 +151,7 @@ struct object_with_zone<T[N]> {
|
||||
void operator()(msgpack::object::with_zone& o, const T(&v)[N]) const {
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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.size = size;
|
||||
const T* pv = v;
|
||||
@@ -167,9 +167,9 @@ struct object_with_zone<char[N]> {
|
||||
char const* p = v;
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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;
|
||||
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.size = adjusted_size;
|
||||
std::memcpy(ptr, p, adjusted_size);
|
||||
@@ -182,9 +182,9 @@ struct object_with_zone<const char[N]> {
|
||||
char const* p = v;
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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;
|
||||
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.size = 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 {
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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.size = 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 {
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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.size = size;
|
||||
std::memcpy(ptr, v, size);
|
||||
@@ -221,7 +221,7 @@ struct object<char[N]> {
|
||||
char const* p = v;
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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.via.str.ptr = p;
|
||||
o.via.str.size = adjusted_size;
|
||||
@@ -234,7 +234,7 @@ struct object<const char[N]> {
|
||||
char const* p = v;
|
||||
uint32_t size = checked_get_container_size(N);
|
||||
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.via.str.ptr = p;
|
||||
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 {
|
||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||
o.type = msgpack::type::STR;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
o.via.str.ptr = ptr;
|
||||
o.via.str.size = size;
|
||||
std::memcpy(ptr, v, size);
|
||||
|
@@ -119,7 +119,7 @@ struct object_with_zone<std::array<T, N>> {
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* 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.ptr = p;
|
||||
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>
|
||||
struct pack<std::array<char, N>> {
|
||||
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 {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
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.size = 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>
|
||||
struct pack<std::array<unsigned char, N>> {
|
||||
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 {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
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.size = size;
|
||||
std::memcpy(ptr, v.data(), size);
|
||||
|
@@ -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()));
|
||||
o.via.array.size = size;
|
||||
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;
|
||||
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||
}
|
||||
|
@@ -109,7 +109,7 @@ struct StdTupleConverter<Tuple, 0> {
|
||||
namespace adaptor {
|
||||
|
||||
template <typename... Args>
|
||||
struct as<std::tuple<Args...>, typename std::enable_if<msgpack::all_of<msgpack::has_as, Args...>::value>::type> {
|
||||
struct as<std::tuple<Args...>, typename std::enable_if<msgpack::any_of<msgpack::has_as, Args...>::value>::type> {
|
||||
std::tuple<Args...> operator()(
|
||||
msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
@@ -158,7 +158,7 @@ struct object_with_zone<std::tuple<Args...>> {
|
||||
std::tuple<Args...> const& v) const {
|
||||
uint32_t size = checked_get_container_size(sizeof...(Args));
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = size;
|
||||
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ namespace adaptor {
|
||||
template <typename K, typename V, typename Hash, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
std::unordered_map<K, V, Hash, Compare, Alloc>,
|
||||
typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
|
||||
typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
|
||||
std::unordered_map<K, V, Hash, Compare, Alloc> operator()(msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
@@ -81,7 +81,7 @@ struct object_with_zone<std::unordered_map<K, V, Hash, Compare, Alloc>> {
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
@@ -100,7 +100,7 @@ struct object_with_zone<std::unordered_map<K, V, Hash, Compare, Alloc>> {
|
||||
template <typename K, typename V, typename Hash, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
std::unordered_multimap<K, V, Hash, Compare, Alloc>,
|
||||
typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
|
||||
typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
|
||||
std::unordered_multimap<K, V, Hash, Compare, Alloc> operator()(msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
@@ -155,7 +155,7 @@ struct object_with_zone<std::unordered_multimap<K, V, Hash, Compare, Alloc>> {
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
90
include/msgpack/v1/adaptor/cpp17/optional.hpp
Normal file
90
include/msgpack/v1/adaptor/cpp17/optional.hpp
Normal file
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// 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_OPTIONAL_HPP
|
||||
#define MSGPACK_V1_TYPE_OPTIONAL_HPP
|
||||
|
||||
#if __cplusplus >= 201703
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
struct as<std::optional<T>, typename std::enable_if<msgpack::has_as<T>::value>::type> {
|
||||
std::optional<T> operator()(msgpack::object const& o) const {
|
||||
if(o.is_nil()) return std::nullopt;
|
||||
return o.as<T>();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
struct convert<std::optional<T> > {
|
||||
msgpack::object const& operator()(msgpack::object const& o, std::optional<T>& v) const {
|
||||
if(o.is_nil()) v = std::nullopt;
|
||||
else {
|
||||
T t;
|
||||
msgpack::adaptor::convert<T>()(o, t);
|
||||
v = t;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct pack<std::optional<T> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::optional<T>& v) const {
|
||||
if (v) o.pack(*v);
|
||||
else o.pack_nil();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct object<std::optional<T> > {
|
||||
void operator()(msgpack::object& o, const std::optional<T>& v) const {
|
||||
if (v) msgpack::adaptor::object<T>()(o, *v);
|
||||
else o.type = msgpack::type::NIL;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct object_with_zone<std::optional<T> > {
|
||||
void operator()(msgpack::object::with_zone& o, const std::optional<T>& v) const {
|
||||
if (v) msgpack::adaptor::object_with_zone<T>()(o, *v);
|
||||
else o.type = msgpack::type::NIL;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // __cplusplus >= 201703
|
||||
|
||||
#endif // MSGPACK_V1_TYPE_OPTIONAL_HPP
|
86
include/msgpack/v1/adaptor/cpp17/string_view.hpp
Normal file
86
include/msgpack/v1/adaptor/cpp17/string_view.hpp
Normal file
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// 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_STRING_VIEW_HPP
|
||||
#define MSGPACK_V1_TYPE_STRING_VIEW_HPP
|
||||
|
||||
#if __cplusplus >= 201703
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct convert<std::string_view> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, std::string_view& v) const {
|
||||
switch (o.type) {
|
||||
case msgpack::type::BIN:
|
||||
v = std::string_view(o.via.bin.ptr, o.via.bin.size);
|
||||
break;
|
||||
case msgpack::type::STR:
|
||||
v = std::string_view(o.via.str.ptr, o.via.str.size);
|
||||
break;
|
||||
default:
|
||||
throw msgpack::type_error();
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<std::string_view> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::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<std::string_view> {
|
||||
void operator()(msgpack::object& o, const std::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<std::string_view> {
|
||||
void operator()(msgpack::object::with_zone& o, const std::string_view& v) const {
|
||||
static_cast<msgpack::object&>(o) << v;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // __cplusplus >= 201703
|
||||
|
||||
#endif // MSGPACK_V1_TYPE_STRING_VIEW_HPP
|
@@ -83,7 +83,7 @@ struct object_with_zone<std::deque<T, Alloc> > {
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -83,7 +83,7 @@ struct define_map<A0, A1> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*1));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*1, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 1;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -142,7 +142,7 @@ struct define_map<A0, A1, A2, A3> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*2));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*2, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 2;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -215,7 +215,7 @@ struct define_map<A0, A1, A2, A3, A4, A5> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*3));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*3, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 3;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -302,7 +302,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*4));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*4, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 4;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -403,7 +403,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*5));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*5, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 5;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -518,7 +518,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*6));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*6, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 6;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -647,7 +647,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13> {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*7));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*7, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 7;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -790,7 +790,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*8));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*8, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 8;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -947,7 +947,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*9));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*9, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 9;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -1118,7 +1118,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*10));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*10, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 10;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -1303,7 +1303,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*11));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*11, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 11;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -1502,7 +1502,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*12));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*12, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 12;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -1715,7 +1715,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*13));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*13, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 13;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -1942,7 +1942,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*14));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*14, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 14;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -2183,7 +2183,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*15));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*15, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 15;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
@@ -2438,7 +2438,7 @@ struct define_map<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A1
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*16));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*16, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = 16;
|
||||
|
||||
o->via.map.ptr[0].key = msgpack::object(a0, z);
|
||||
|
@@ -13506,7 +13506,7 @@ struct object_with_zone<type::tuple<A0> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*1));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*1, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 1;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13519,7 +13519,7 @@ struct object_with_zone<type::tuple<A0, A1> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*2));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*2, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 2;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13533,7 +13533,7 @@ struct object_with_zone<type::tuple<A0, A1, A2> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*3));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*3, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 3;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13548,7 +13548,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*4));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*4, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 4;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13564,7 +13564,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*5));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*5, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 5;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13581,7 +13581,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*6));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*6, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 6;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13599,7 +13599,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*7));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*7, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 7;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13618,7 +13618,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*8));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*8, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 8;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13638,7 +13638,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*9));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*9, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 9;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13659,7 +13659,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*10));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*10, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 10;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13681,7 +13681,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*11));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*11, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 11;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13704,7 +13704,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*12));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*12, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 12;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13728,7 +13728,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*13));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*13, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 13;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13753,7 +13753,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*14));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*14, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 14;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13779,7 +13779,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*15));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*15, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 15;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13806,7 +13806,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*16));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*16, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 16;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13834,7 +13834,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*17));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*17, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 17;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13863,7 +13863,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*18));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*18, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 18;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13893,7 +13893,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*19));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*19, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 19;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13924,7 +13924,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*20));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*20, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 20;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13956,7 +13956,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*21));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*21, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 21;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -13989,7 +13989,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*22));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*22, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 22;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14023,7 +14023,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*23));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*23, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 23;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14058,7 +14058,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*24));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*24, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 24;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14094,7 +14094,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*25));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*25, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 25;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14131,7 +14131,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*26));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*26, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 26;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14169,7 +14169,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*27));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*27, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 27;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14208,7 +14208,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*28));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*28, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 28;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14248,7 +14248,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*29));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*29, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 29;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14289,7 +14289,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*30));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*30, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 30;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14331,7 +14331,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*31));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*31, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 31;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
@@ -14374,7 +14374,7 @@ struct object_with_zone<type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10,
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*32));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*32, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = 32;
|
||||
|
||||
o.via.array.ptr[0] = msgpack::object(v.template get<0>(), o.zone);
|
||||
|
@@ -77,7 +77,7 @@ struct define_array {
|
||||
void msgpack_object(msgpack::object* o, msgpack::zone& z) const
|
||||
{
|
||||
o->type = msgpack::type::ARRAY;
|
||||
o->via.array.ptr = static_cast<msgpack::object*>(z.allocate_align(sizeof(msgpack::object)*sizeof...(Args)));
|
||||
o->via.array.ptr = static_cast<msgpack::object*>(z.allocate_align(sizeof(msgpack::object)*sizeof...(Args), MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o->via.array.size = sizeof...(Args);
|
||||
|
||||
define_array_imp<std::tuple<Args&...>, sizeof...(Args)>::object(o, z, a);
|
||||
|
@@ -83,7 +83,7 @@ struct define_map {
|
||||
{
|
||||
static_assert(sizeof...(Args) % 2 == 0, "");
|
||||
o->type = msgpack::type::MAP;
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*sizeof...(Args)/2));
|
||||
o->via.map.ptr = static_cast<msgpack::object_kv*>(z.allocate_align(sizeof(msgpack::object_kv)*sizeof...(Args)/2, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
o->via.map.size = sizeof...(Args) / 2;
|
||||
|
||||
define_map_imp<std::tuple<Args&...>, sizeof...(Args)>::object(o, z, a);
|
||||
|
@@ -146,7 +146,7 @@ struct MsgpackTupleConverter<Tuple, 0> {
|
||||
namespace adaptor {
|
||||
|
||||
template <typename... Args>
|
||||
struct as<msgpack::type::tuple<Args...>, typename std::enable_if<msgpack::all_of<msgpack::has_as, Args...>::value>::type> {
|
||||
struct as<msgpack::type::tuple<Args...>, typename std::enable_if<msgpack::any_of<msgpack::has_as, Args...>::value>::type> {
|
||||
msgpack::type::tuple<Args...> operator()(
|
||||
msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
@@ -203,7 +203,7 @@ template <typename... Args>
|
||||
msgpack::object::with_zone& o,
|
||||
msgpack::type::tuple<Args...> const& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*sizeof...(Args)));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*sizeof...(Args), MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = sizeof...(Args);
|
||||
MsgpackTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
}
|
||||
|
@@ -104,7 +104,7 @@ struct object_with_zone<msgpack::type::ext> {
|
||||
// size limit has already been checked at ext's constructor
|
||||
uint32_t size = v.size();
|
||||
o.type = msgpack::type::EXT;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size + 1));
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size + 1, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
o.via.ext.ptr = ptr;
|
||||
o.via.ext.size = size;
|
||||
ptr[0] = static_cast<char>(v.type());
|
||||
|
@@ -27,7 +27,7 @@ namespace adaptor {
|
||||
template <>
|
||||
struct convert<float> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, float& v) const {
|
||||
if(o.type == msgpack::type::FLOAT) {
|
||||
if(o.type == msgpack::type::FLOAT32 || o.type == msgpack::type::FLOAT64) {
|
||||
v = static_cast<float>(o.via.f64);
|
||||
}
|
||||
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||
@@ -56,7 +56,7 @@ struct pack<float> {
|
||||
template <>
|
||||
struct convert<double> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, double& v) const {
|
||||
if(o.type == msgpack::type::FLOAT) {
|
||||
if(o.type == msgpack::type::FLOAT32 || o.type == msgpack::type::FLOAT64) {
|
||||
v = o.via.f64;
|
||||
}
|
||||
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||
@@ -85,7 +85,7 @@ struct pack<double> {
|
||||
template <>
|
||||
struct object<float> {
|
||||
void operator()(msgpack::object& o, float v) const {
|
||||
o.type = msgpack::type::FLOAT;
|
||||
o.type = msgpack::type::FLOAT32;
|
||||
o.via.f64 = static_cast<double>(v);
|
||||
}
|
||||
};
|
||||
@@ -93,7 +93,7 @@ struct object<float> {
|
||||
template <>
|
||||
struct object<double> {
|
||||
void operator()(msgpack::object& o, double v) const {
|
||||
o.type = msgpack::type::FLOAT;
|
||||
o.type = msgpack::type::FLOAT64;
|
||||
o.via.f64 = v;
|
||||
}
|
||||
};
|
||||
|
@@ -81,7 +81,7 @@ struct object_with_zone<std::list<T, Alloc> > {
|
||||
}
|
||||
else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
@@ -48,7 +48,7 @@ namespace adaptor {
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
type::assoc_vector<K, V, Compare, Alloc>,
|
||||
typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
|
||||
typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
|
||||
type::assoc_vector<K, V, Compare, Alloc> operator()(msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
type::assoc_vector<K, V, Compare, Alloc> v;
|
||||
@@ -109,7 +109,7 @@ struct object_with_zone<type::assoc_vector<K, V, Compare, Alloc> > {
|
||||
}
|
||||
else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
@@ -129,7 +129,7 @@ struct object_with_zone<type::assoc_vector<K, V, Compare, Alloc> > {
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
std::map<K, V, Compare, Alloc>,
|
||||
typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
|
||||
typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
|
||||
std::map<K, V, Compare, Alloc> operator()(msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
@@ -195,21 +195,21 @@ struct object_with_zone<std::map<K, V, Compare, Alloc> > {
|
||||
else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
typename std::map<K, V, Compare, Alloc>::const_iterator it(v.begin());
|
||||
do {
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#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->key = msgpack::object(it->first, o.zone);
|
||||
p->val = msgpack::object(it->second, o.zone);
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#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;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
@@ -222,7 +222,7 @@ struct object_with_zone<std::map<K, V, Compare, Alloc> > {
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
std::multimap<K, V, Compare, Alloc>,
|
||||
typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
|
||||
typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
|
||||
std::multimap<K, V, Compare, Alloc> operator()(msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
@@ -288,7 +288,7 @@ struct object_with_zone<std::multimap<K, V, Compare, Alloc> > {
|
||||
}
|
||||
else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
|
@@ -28,7 +28,7 @@ namespace adaptor {
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct as<std::pair<T1, T2>,
|
||||
typename std::enable_if<msgpack::all_of<msgpack::has_as, T1, T2>::value>::type> {
|
||||
typename std::enable_if<msgpack::any_of<msgpack::has_as, T1, T2>::value>::type> {
|
||||
std::pair<T1, T2> operator()(msgpack::object const& o) const {
|
||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if (o.via.array.size != 2) { throw msgpack::type_error(); }
|
||||
@@ -64,7 +64,7 @@ template <typename T1, typename T2>
|
||||
struct object_with_zone<std::pair<T1, T2> > {
|
||||
void operator()(msgpack::object::with_zone& o, const std::pair<T1, T2>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*2));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*2, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = 2;
|
||||
p[0] = msgpack::object(v.first, o.zone);
|
||||
|
@@ -87,7 +87,7 @@ struct object_with_zone<std::set<T, Compare, Alloc> > {
|
||||
}
|
||||
else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
@@ -163,7 +163,7 @@ struct object_with_zone<std::multiset<T, Compare, Alloc> > {
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
@@ -69,7 +69,7 @@ struct object_with_zone<std::string> {
|
||||
void operator()(msgpack::object::with_zone& o, const std::string& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
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.size = size;
|
||||
std::memcpy(ptr, v.data(), v.size());
|
||||
|
@@ -84,7 +84,7 @@ struct object_with_zone<MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||
msgpack::object_kv* 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;
|
||||
o.via.map.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
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;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
@@ -89,20 +89,20 @@ struct object_with_zone<std::vector<T, Alloc> > {
|
||||
}
|
||||
else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
typename std::vector<T, Alloc>::const_iterator it(v.begin());
|
||||
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 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);
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#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;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
|
@@ -65,7 +65,7 @@ struct object_with_zone<std::vector<bool, Alloc> > {
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
|
@@ -32,27 +32,27 @@ struct convert<std::vector<char, Alloc> > {
|
||||
case msgpack::type::BIN:
|
||||
v.resize(o.via.bin.size);
|
||||
if (o.via.bin.size != 0) {
|
||||
#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 ignored "-Wmaybe-uninitialized"
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
}
|
||||
break;
|
||||
case msgpack::type::STR:
|
||||
v.resize(o.via.str.size);
|
||||
if (o.via.str.size != 0) {
|
||||
#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 ignored "-Wmaybe-uninitialized"
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -96,7 +96,7 @@ struct object_with_zone<std::vector<char, Alloc> > {
|
||||
o.type = msgpack::type::BIN;
|
||||
o.via.bin.size = size;
|
||||
if (size != 0) {
|
||||
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;
|
||||
std::memcpy(ptr, &v.front(), size);
|
||||
}
|
||||
|
@@ -32,27 +32,27 @@ struct convert<std::vector<unsigned char, Alloc> > {
|
||||
case msgpack::type::BIN:
|
||||
v.resize(o.via.bin.size);
|
||||
if (o.via.bin.size != 0) {
|
||||
#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 ignored "-Wmaybe-uninitialized"
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
}
|
||||
break;
|
||||
case msgpack::type::STR:
|
||||
v.resize(o.via.str.size);
|
||||
if (o.via.str.size != 0) {
|
||||
#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 ignored "-Wmaybe-uninitialized"
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
|
||||
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -96,7 +96,7 @@ struct object_with_zone<std::vector<unsigned char, Alloc> > {
|
||||
o.type = msgpack::type::BIN;
|
||||
o.via.bin.size = size;
|
||||
if (size != 0) {
|
||||
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;
|
||||
std::memcpy(ptr, &v.front(), size);
|
||||
}
|
||||
|
@@ -126,4 +126,10 @@ template<class T> struct is_pointer : detail::is_pointer_helper<typename remove_
|
||||
|
||||
#endif // MSGPACK_USE_CPP03
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
#define MSGPACK_DEPRECATED(msg) [[deprecated(msg)]]
|
||||
#else // __cplusplus >= 201402L
|
||||
#define MSGPACK_DEPRECATED(msg)
|
||||
#endif // __cplusplus >= 201402L
|
||||
|
||||
#endif // MSGPACK_V1_CPP_CONFIG_HPP
|
||||
|
@@ -223,7 +223,9 @@ private:
|
||||
template <typename T>
|
||||
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:
|
||||
zone(const zone&);
|
||||
zone& operator=(const zone&);
|
||||
@@ -233,37 +235,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<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);
|
||||
if(m_chunk_list.m_free >= adjusted_size) {
|
||||
if (m_chunk_list.m_free < adjusted_size) {
|
||||
size_t enough_size = size + align - 1;
|
||||
char* ptr = allocate_expand(enough_size);
|
||||
aligned = get_aligned(ptr, align);
|
||||
adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||
}
|
||||
m_chunk_list.m_free -= adjusted_size;
|
||||
m_chunk_list.m_ptr += adjusted_size;
|
||||
return aligned;
|
||||
}
|
||||
return reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
allocate_expand(size + (align - 1))) / align * align);
|
||||
}
|
||||
|
||||
inline void* zone::allocate_no_align(size_t size)
|
||||
{
|
||||
if(m_chunk_list.m_free < size) {
|
||||
return allocate_expand(size);
|
||||
}
|
||||
|
||||
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_ptr += size;
|
||||
|
||||
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;
|
||||
|
||||
@@ -285,8 +292,8 @@ inline void* zone::allocate_expand(size_t size)
|
||||
|
||||
c->m_next = cl->m_head;
|
||||
cl->m_head = c;
|
||||
cl->m_free = sz - size;
|
||||
cl->m_ptr = ptr + size;
|
||||
cl->m_free = sz;
|
||||
cl->m_ptr = ptr;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -345,7 +352,7 @@ inline std::size_t aligned_size(
|
||||
template <typename T>
|
||||
T* zone::allocate()
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -364,7 +371,7 @@ T* zone::allocate()
|
||||
template <typename T, typename A1>
|
||||
T* zone::allocate(A1 a1)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -383,7 +390,7 @@ T* zone::allocate(A1 a1)
|
||||
template <typename T, typename A1, typename A2>
|
||||
T* zone::allocate(A1 a1, A2 a2)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -402,7 +409,7 @@ T* zone::allocate(A1 a1, A2 a2)
|
||||
template <typename T, typename A1, typename A2, typename A3>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -421,7 +428,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3)
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -440,7 +447,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -459,7 +466,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -478,7 +485,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -497,7 +504,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -516,7 +523,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -535,7 +542,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -554,7 +561,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -573,7 +580,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -592,7 +599,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -611,7 +618,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
@@ -630,7 +637,7 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14, A15 a15)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
|
@@ -24,6 +24,14 @@
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||
#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
|
||||
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
|
@@ -184,7 +184,6 @@ public:
|
||||
|
||||
void swap(zone& o);
|
||||
|
||||
|
||||
static void* operator new(std::size_t size)
|
||||
{
|
||||
void* p = ::malloc(size);
|
||||
@@ -220,44 +219,51 @@ private:
|
||||
template <typename T>
|
||||
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);
|
||||
};
|
||||
|
||||
inline zone::zone(size_t chunk_size) noexcept:m_chunk_size(chunk_size), m_chunk_list(m_chunk_size)
|
||||
{
|
||||
}
|
||||
|
||||
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<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);
|
||||
if(m_chunk_list.m_free >= adjusted_size) {
|
||||
if (m_chunk_list.m_free < adjusted_size) {
|
||||
size_t enough_size = size + align - 1;
|
||||
char* ptr = allocate_expand(enough_size);
|
||||
aligned = get_aligned(ptr, align);
|
||||
adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||
}
|
||||
m_chunk_list.m_free -= adjusted_size;
|
||||
m_chunk_list.m_ptr += adjusted_size;
|
||||
return aligned;
|
||||
}
|
||||
return reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
allocate_expand(size + (align - 1))) / align * align);
|
||||
}
|
||||
|
||||
inline void* zone::allocate_no_align(size_t size)
|
||||
{
|
||||
if(m_chunk_list.m_free < size) {
|
||||
return allocate_expand(size);
|
||||
}
|
||||
|
||||
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_ptr += size;
|
||||
|
||||
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;
|
||||
|
||||
@@ -279,8 +285,8 @@ inline void* zone::allocate_expand(size_t size)
|
||||
|
||||
c->m_next = cl->m_head;
|
||||
cl->m_head = c;
|
||||
cl->m_free = sz - size;
|
||||
cl->m_ptr = ptr + size;
|
||||
cl->m_free = sz;
|
||||
cl->m_ptr = ptr;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -329,7 +335,7 @@ inline void zone::undo_allocate(size_t size)
|
||||
template <typename T, typename... Args>
|
||||
T* zone::allocate(Args... args)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
void* x = allocate_align(sizeof(T), MSGPACK_ZONE_ALIGNOF(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
|
@@ -26,6 +26,14 @@
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||
#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
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
|
@@ -21,11 +21,17 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<bool...values> struct all_of_imp
|
||||
: std::is_same<bool_pack<values..., true>, bool_pack<true, values...>>{};
|
||||
|
||||
template<bool...values> struct any_of_imp {
|
||||
static const bool value = !std::is_same<bool_pack<values..., false>, bool_pack<false, values...>>::value;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<std::size_t... Is> struct seq {};
|
||||
|
@@ -28,11 +28,16 @@ template<bool...> struct bool_pack;
|
||||
|
||||
template<bool...values> struct all_of_imp;
|
||||
|
||||
template<bool...values> struct any_of_imp;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<template <class> class T, class... U>
|
||||
using all_of = detail::all_of_imp<T<U>::value...>;
|
||||
|
||||
template<template <class> class T, class... U>
|
||||
using any_of = detail::any_of_imp<(T<U>::value)...>;
|
||||
|
||||
template<std::size_t... Is> struct seq;
|
||||
|
||||
template<std::size_t N, std::size_t... Is>
|
||||
|
@@ -60,7 +60,6 @@ public:
|
||||
) :
|
||||
m_obj(obj), m_zone(msgpack::move(z)) { }
|
||||
|
||||
// obsolete
|
||||
void set(msgpack::object const& obj)
|
||||
{ m_obj = obj; }
|
||||
|
||||
@@ -141,13 +140,17 @@ inline std::size_t aligned_zone_size(msgpack::object const& obj) {
|
||||
std::size_t s = 0;
|
||||
switch (obj.type) {
|
||||
case msgpack::type::ARRAY:
|
||||
s += sizeof(msgpack::object) * obj.via.array.size;
|
||||
s += msgpack::aligned_size(
|
||||
sizeof(msgpack::object) * obj.via.array.size,
|
||||
MSGPACK_ZONE_ALIGNOF(msgpack::object));
|
||||
for (uint32_t i = 0; i < obj.via.array.size; ++i) {
|
||||
s += msgpack::aligned_zone_size(obj.via.array.ptr[i]);
|
||||
}
|
||||
break;
|
||||
case msgpack::type::MAP:
|
||||
s += sizeof(msgpack::object_kv) * obj.via.map.size;
|
||||
s += msgpack::aligned_size(
|
||||
sizeof(msgpack::object_kv) * obj.via.map.size,
|
||||
MSGPACK_ZONE_ALIGNOF(msgpack::object_kv));
|
||||
for (uint32_t i = 0; i < obj.via.map.size; ++i) {
|
||||
s += msgpack::aligned_zone_size(obj.via.map.ptr[i].key);
|
||||
s += msgpack::aligned_zone_size(obj.via.map.ptr[i].val);
|
||||
@@ -155,13 +158,14 @@ inline std::size_t aligned_zone_size(msgpack::object const& obj) {
|
||||
break;
|
||||
case msgpack::type::EXT:
|
||||
s += msgpack::aligned_size(
|
||||
detail::add_ext_type_size<sizeof(std::size_t)>(obj.via.ext.size));
|
||||
detail::add_ext_type_size<sizeof(std::size_t)>(obj.via.ext.size),
|
||||
MSGPACK_ZONE_ALIGNOF(char));
|
||||
break;
|
||||
case msgpack::type::STR:
|
||||
s += msgpack::aligned_size(obj.via.str.size);
|
||||
s += msgpack::aligned_size(obj.via.str.size, MSGPACK_ZONE_ALIGNOF(char));
|
||||
break;
|
||||
case msgpack::type::BIN:
|
||||
s += msgpack::aligned_size(obj.via.bin.size);
|
||||
s += msgpack::aligned_size(obj.via.bin.size, MSGPACK_ZONE_ALIGNOF(char));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -257,7 +261,11 @@ struct pack<msgpack::object> {
|
||||
o.pack_int64(v.via.i64);
|
||||
return o;
|
||||
|
||||
case msgpack::type::FLOAT:
|
||||
case msgpack::type::FLOAT32:
|
||||
o.pack_float(static_cast<float>(v.via.f64));
|
||||
return o;
|
||||
|
||||
case msgpack::type::FLOAT64:
|
||||
o.pack_double(v.via.f64);
|
||||
return o;
|
||||
|
||||
@@ -311,12 +319,13 @@ struct object_with_zone<msgpack::object> {
|
||||
case msgpack::type::BOOLEAN:
|
||||
case msgpack::type::POSITIVE_INTEGER:
|
||||
case msgpack::type::NEGATIVE_INTEGER:
|
||||
case msgpack::type::FLOAT:
|
||||
case msgpack::type::FLOAT32:
|
||||
case msgpack::type::FLOAT64:
|
||||
std::memcpy(&o.via, &v.via, sizeof(v.via));
|
||||
return;
|
||||
|
||||
case msgpack::type::STR: {
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.str.size));
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.str.size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
o.via.str.ptr = ptr;
|
||||
o.via.str.size = v.via.str.size;
|
||||
std::memcpy(ptr, v.via.str.ptr, v.via.str.size);
|
||||
@@ -324,7 +333,7 @@ struct object_with_zone<msgpack::object> {
|
||||
}
|
||||
|
||||
case msgpack::type::BIN: {
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.bin.size));
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.bin.size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
o.via.bin.ptr = ptr;
|
||||
o.via.bin.size = v.via.bin.size;
|
||||
std::memcpy(ptr, v.via.bin.ptr, v.via.bin.size);
|
||||
@@ -332,7 +341,7 @@ struct object_with_zone<msgpack::object> {
|
||||
}
|
||||
|
||||
case msgpack::type::EXT: {
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.ext.size + 1));
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.ext.size + 1, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
o.via.ext.ptr = ptr;
|
||||
o.via.ext.size = v.via.ext.size;
|
||||
std::memcpy(ptr, v.via.ext.ptr, v.via.ext.size + 1);
|
||||
@@ -340,7 +349,7 @@ struct object_with_zone<msgpack::object> {
|
||||
}
|
||||
|
||||
case msgpack::type::ARRAY:
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object) * v.via.array.size));
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object) * v.via.array.size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
o.via.array.size = v.via.array.size;
|
||||
for (msgpack::object
|
||||
* po(o.via.array.ptr),
|
||||
@@ -353,7 +362,7 @@ struct object_with_zone<msgpack::object> {
|
||||
return;
|
||||
|
||||
case msgpack::type::MAP:
|
||||
o.via.map.ptr = (msgpack::object_kv*)o.zone.allocate_align(sizeof(msgpack::object_kv) * v.via.map.size);
|
||||
o.via.map.ptr = (msgpack::object_kv*)o.zone.allocate_align(sizeof(msgpack::object_kv) * v.via.map.size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv));
|
||||
o.via.map.size = v.via.map.size;
|
||||
for(msgpack::object_kv
|
||||
* po(o.via.map.ptr),
|
||||
@@ -395,7 +404,6 @@ class define : public Type {
|
||||
public:
|
||||
typedef Type msgpack_type;
|
||||
typedef define<Type> define_type;
|
||||
|
||||
define() {}
|
||||
define(const msgpack_type& v) : msgpack_type(v) {}
|
||||
|
||||
@@ -438,7 +446,8 @@ inline bool operator==(const msgpack::object& x, const msgpack::object& y)
|
||||
case msgpack::type::NEGATIVE_INTEGER:
|
||||
return x.via.i64 == y.via.i64;
|
||||
|
||||
case msgpack::type::FLOAT:
|
||||
case msgpack::type::FLOAT32:
|
||||
case msgpack::type::FLOAT64:
|
||||
return x.via.f64 == y.via.f64;
|
||||
|
||||
case msgpack::type::STR:
|
||||
@@ -698,7 +707,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const ms
|
||||
o.pack_int64(v.via.i64);
|
||||
return o;
|
||||
|
||||
case msgpack::type::FLOAT:
|
||||
case msgpack::type::FLOAT32:
|
||||
o.pack_float(v.via.f64);
|
||||
return o;
|
||||
|
||||
case msgpack::type::FLOAT64:
|
||||
o.pack_double(v.via.f64);
|
||||
return o;
|
||||
|
||||
@@ -766,7 +779,8 @@ inline std::ostream& operator<< (std::ostream& s, const msgpack::object& o)
|
||||
s << o.via.i64;
|
||||
break;
|
||||
|
||||
case msgpack::type::FLOAT:
|
||||
case msgpack::type::FLOAT32:
|
||||
case msgpack::type::FLOAT64:
|
||||
s << o.via.f64;
|
||||
break;
|
||||
|
||||
@@ -802,7 +816,9 @@ inline std::ostream& operator<< (std::ostream& s, const msgpack::object& o)
|
||||
default: {
|
||||
unsigned int code = static_cast<unsigned int>(c);
|
||||
if (code < 0x20 || code == 0x7f) {
|
||||
std::ios::fmtflags flags(s.flags());
|
||||
s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (code & 0xff);
|
||||
s.flags(flags);
|
||||
}
|
||||
else {
|
||||
s << c;
|
||||
|
@@ -85,14 +85,17 @@ void operator<< (msgpack::object& o, const msgpack_object& v);
|
||||
|
||||
// obsolete
|
||||
template <typename T>
|
||||
MSGPACK_DEPRECATED("please use member function version of object::convert(T&)")
|
||||
void convert(T& v, msgpack::object const& o);
|
||||
|
||||
// obsolete
|
||||
template <typename Stream, typename T>
|
||||
MSGPACK_DEPRECATED("please use member function version of packer::pack(const T&)")
|
||||
void pack(msgpack::packer<Stream>& o, const T& v);
|
||||
|
||||
// obsolete
|
||||
template <typename Stream, typename T>
|
||||
MSGPACK_DEPRECATED("please use member function version of packer::pack(const T&)")
|
||||
void pack_copy(msgpack::packer<Stream>& o, T v);
|
||||
|
||||
template <typename Stream>
|
||||
|
@@ -78,6 +78,7 @@ struct object {
|
||||
uint64_t u64;
|
||||
int64_t i64;
|
||||
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
|
||||
MSGPACK_DEPRECATED("please use f64 instead")
|
||||
double dec; // obsolete
|
||||
#endif // MSGPACK_USE_LEGACY_NAME_AS_FLOAT
|
||||
double f64;
|
||||
@@ -157,6 +158,7 @@ struct object {
|
||||
* @return The pointer of `v`.
|
||||
*/
|
||||
template <typename T>
|
||||
MSGPACK_DEPRECATED("please use reference version instead")
|
||||
typename msgpack::enable_if<
|
||||
msgpack::is_pointer<T>::value,
|
||||
T
|
||||
@@ -214,6 +216,7 @@ struct object {
|
||||
* @param z The pointer to the zone that is used by the object.
|
||||
*/
|
||||
template <typename T>
|
||||
MSGPACK_DEPRECATED("please use zone reference version instead of the pointer version")
|
||||
object(const T& v, msgpack::zone* z);
|
||||
|
||||
template <typename T>
|
||||
|
@@ -30,9 +30,11 @@ namespace type {
|
||||
BOOLEAN = MSGPACK_OBJECT_BOOLEAN,
|
||||
POSITIVE_INTEGER = MSGPACK_OBJECT_POSITIVE_INTEGER,
|
||||
NEGATIVE_INTEGER = MSGPACK_OBJECT_NEGATIVE_INTEGER,
|
||||
FLOAT32 = MSGPACK_OBJECT_FLOAT32,
|
||||
FLOAT64 = MSGPACK_OBJECT_FLOAT64,
|
||||
FLOAT = MSGPACK_OBJECT_FLOAT,
|
||||
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
|
||||
DOUBLE = MSGPACK_OBJECT_DOUBLE, // obsolete
|
||||
DOUBLE = MSGPACK_DEPRECATED("please use FLOAT64 instead") MSGPACK_OBJECT_DOUBLE, // obsolete
|
||||
#endif // MSGPACK_USE_LEGACY_NAME_AS_FLOAT
|
||||
STR = MSGPACK_OBJECT_STR,
|
||||
BIN = MSGPACK_OBJECT_BIN,
|
||||
|
36
include/msgpack/v1/parse_return.hpp
Normal file
36
include/msgpack/v1/parse_return.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// MessagePack for C++ deserializing routine
|
||||
//
|
||||
// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#ifndef MSGPACK_V1_PARSE_RETURN_HPP
|
||||
#define MSGPACK_V1_PARSE_RETURN_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
|
||||
// for internal use
|
||||
typedef enum {
|
||||
PARSE_SUCCESS = 2,
|
||||
PARSE_EXTRA_BYTES = 1,
|
||||
PARSE_CONTINUE = 0,
|
||||
PARSE_PARSE_ERROR = -1
|
||||
} parse_return;
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_V1_PARSE_RETURN_HPP
|
@@ -14,12 +14,12 @@
|
||||
#include "msgpack/unpack_decl.hpp"
|
||||
#include "msgpack/object.hpp"
|
||||
#include "msgpack/zone.hpp"
|
||||
#include "msgpack/unpack_exception.hpp"
|
||||
#include "msgpack/unpack_define.h"
|
||||
#include "msgpack/cpp_config.hpp"
|
||||
#include "msgpack/sysdep.h"
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
#include <atomic>
|
||||
@@ -39,96 +39,6 @@ namespace msgpack {
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
struct unpack_error : public std::runtime_error {
|
||||
explicit unpack_error(const std::string& msg)
|
||||
:std::runtime_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit unpack_error(const char* msg):
|
||||
std::runtime_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct parse_error : public unpack_error {
|
||||
explicit parse_error(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit parse_error(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct insufficient_bytes : public unpack_error {
|
||||
explicit insufficient_bytes(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit insufficient_bytes(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct size_overflow : public unpack_error {
|
||||
explicit size_overflow(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit size_overflow(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct array_size_overflow : public size_overflow {
|
||||
array_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
array_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct map_size_overflow : public size_overflow {
|
||||
map_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
map_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct str_size_overflow : public size_overflow {
|
||||
str_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
str_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct bin_size_overflow : public size_overflow {
|
||||
bin_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
bin_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ext_size_overflow : public size_overflow {
|
||||
ext_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
ext_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct depth_size_overflow : public size_overflow {
|
||||
depth_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
depth_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
class unpack_user {
|
||||
@@ -184,10 +94,10 @@ inline void unpack_int64(int64_t d, msgpack::object& o)
|
||||
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
|
||||
|
||||
inline void unpack_float(float d, msgpack::object& o)
|
||||
{ o.type = msgpack::type::FLOAT; o.via.f64 = d; }
|
||||
{ o.type = msgpack::type::FLOAT32; o.via.f64 = d; }
|
||||
|
||||
inline void unpack_double(double d, msgpack::object& o)
|
||||
{ o.type = msgpack::type::FLOAT; o.via.f64 = d; }
|
||||
{ o.type = msgpack::type::FLOAT64; o.via.f64 = d; }
|
||||
|
||||
inline void unpack_nil(msgpack::object& o)
|
||||
{ o.type = msgpack::type::NIL; }
|
||||
@@ -203,7 +113,11 @@ struct unpack_array {
|
||||
if (n > u.limit().array()) throw msgpack::array_size_overflow("array size overflow");
|
||||
o.type = msgpack::type::ARRAY;
|
||||
o.via.array.size = 0;
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(u.zone().allocate_align(n*sizeof(msgpack::object)));
|
||||
size_t size = n*sizeof(msgpack::object);
|
||||
if (size / sizeof(msgpack::object) != n) {
|
||||
throw msgpack::array_size_overflow("array size overflow");
|
||||
}
|
||||
o.via.array.ptr = static_cast<msgpack::object*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -221,7 +135,11 @@ struct unpack_map {
|
||||
if (n > u.limit().map()) throw msgpack::map_size_overflow("map size overflow");
|
||||
o.type = msgpack::type::MAP;
|
||||
o.via.map.size = 0;
|
||||
o.via.map.ptr = static_cast<msgpack::object_kv*>(u.zone().allocate_align(n*sizeof(msgpack::object_kv)));
|
||||
size_t size = n*sizeof(msgpack::object_kv);
|
||||
if (size / sizeof(msgpack::object_kv) != n) {
|
||||
throw msgpack::map_size_overflow("map size overflow");
|
||||
}
|
||||
o.via.map.ptr = static_cast<msgpack::object_kv*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -246,7 +164,7 @@ inline void unpack_str(unpack_user& u, const char* p, uint32_t l, msgpack::objec
|
||||
}
|
||||
else {
|
||||
if (l > u.limit().str()) throw msgpack::str_size_overflow("str size overflow");
|
||||
char* tmp = static_cast<char*>(u.zone().allocate_align(l));
|
||||
char* tmp = static_cast<char*>(u.zone().allocate_align(l, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
std::memcpy(tmp, p, l);
|
||||
o.via.str.ptr = tmp;
|
||||
}
|
||||
@@ -262,7 +180,7 @@ inline void unpack_bin(unpack_user& u, const char* p, uint32_t l, msgpack::objec
|
||||
}
|
||||
else {
|
||||
if (l > u.limit().bin()) throw msgpack::bin_size_overflow("bin size overflow");
|
||||
char* tmp = static_cast<char*>(u.zone().allocate_align(l));
|
||||
char* tmp = static_cast<char*>(u.zone().allocate_align(l, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
std::memcpy(tmp, p, l);
|
||||
o.via.bin.ptr = tmp;
|
||||
}
|
||||
@@ -278,7 +196,7 @@ inline void unpack_ext(unpack_user& u, const char* p, std::size_t l, msgpack::ob
|
||||
}
|
||||
else {
|
||||
if (l > u.limit().ext()) throw msgpack::ext_size_overflow("ext size overflow");
|
||||
char* tmp = static_cast<char*>(u.zone().allocate_align(l));
|
||||
char* tmp = static_cast<char*>(u.zone().allocate_align(l, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
std::memcpy(tmp, p, l);
|
||||
o.via.ext.ptr = tmp;
|
||||
}
|
||||
@@ -1003,6 +921,7 @@ public:
|
||||
* This function is obsolete. Use the reference inteface version of next() function instead of
|
||||
* the pointer interface version.
|
||||
*/
|
||||
MSGPACK_DEPRECATED("please use reference version instead")
|
||||
bool next(msgpack::object_handle* result);
|
||||
|
||||
/// Unpack one msgpack::object.
|
||||
@@ -1416,7 +1335,7 @@ inline void unpacker::remove_nonparsed_buffer()
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline unpack_return
|
||||
inline parse_return
|
||||
unpack_imp(const char* data, std::size_t len, std::size_t& off,
|
||||
msgpack::zone& result_zone, msgpack::object& result, bool& referenced,
|
||||
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR,
|
||||
@@ -1426,7 +1345,7 @@ unpack_imp(const char* data, std::size_t len, std::size_t& off,
|
||||
|
||||
if(len <= noff) {
|
||||
// FIXME
|
||||
return UNPACK_CONTINUE;
|
||||
return PARSE_CONTINUE;
|
||||
}
|
||||
|
||||
detail::context ctx(f, user_data, limit);
|
||||
@@ -1438,23 +1357,23 @@ unpack_imp(const char* data, std::size_t len, std::size_t& off,
|
||||
|
||||
int e = ctx.execute(data, len, noff);
|
||||
if(e < 0) {
|
||||
return UNPACK_PARSE_ERROR;
|
||||
return PARSE_PARSE_ERROR;
|
||||
}
|
||||
|
||||
referenced = ctx.user().referenced();
|
||||
off = noff;
|
||||
|
||||
if(e == 0) {
|
||||
return UNPACK_CONTINUE;
|
||||
return PARSE_CONTINUE;
|
||||
}
|
||||
|
||||
result = ctx.data();
|
||||
|
||||
if(noff < len) {
|
||||
return UNPACK_EXTRA_BYTES;
|
||||
return PARSE_EXTRA_BYTES;
|
||||
}
|
||||
|
||||
return UNPACK_SUCCESS;
|
||||
return PARSE_SUCCESS;
|
||||
}
|
||||
|
||||
} // detail
|
||||
@@ -1471,19 +1390,19 @@ inline msgpack::object_handle unpack(
|
||||
msgpack::unique_ptr<msgpack::zone> z(new msgpack::zone);
|
||||
referenced = false;
|
||||
std::size_t noff = off;
|
||||
unpack_return ret = detail::unpack_imp(
|
||||
parse_return ret = detail::unpack_imp(
|
||||
data, len, noff, *z, obj, referenced, f, user_data, limit);
|
||||
|
||||
switch(ret) {
|
||||
case UNPACK_SUCCESS:
|
||||
case PARSE_SUCCESS:
|
||||
off = noff;
|
||||
return msgpack::object_handle(obj, msgpack::move(z));
|
||||
case UNPACK_EXTRA_BYTES:
|
||||
case PARSE_EXTRA_BYTES:
|
||||
off = noff;
|
||||
return msgpack::object_handle(obj, msgpack::move(z));
|
||||
case UNPACK_CONTINUE:
|
||||
case PARSE_CONTINUE:
|
||||
throw msgpack::insufficient_bytes("insufficient bytes");
|
||||
case UNPACK_PARSE_ERROR:
|
||||
case PARSE_PARSE_ERROR:
|
||||
default:
|
||||
throw msgpack::parse_error("parse error");
|
||||
}
|
||||
@@ -1528,23 +1447,23 @@ inline void unpack(
|
||||
msgpack::unique_ptr<msgpack::zone> z(new msgpack::zone);
|
||||
referenced = false;
|
||||
std::size_t noff = off;
|
||||
unpack_return ret = detail::unpack_imp(
|
||||
parse_return ret = detail::unpack_imp(
|
||||
data, len, noff, *z, obj, referenced, f, user_data, limit);
|
||||
|
||||
switch(ret) {
|
||||
case UNPACK_SUCCESS:
|
||||
case PARSE_SUCCESS:
|
||||
off = noff;
|
||||
result.set(obj);
|
||||
result.zone() = msgpack::move(z);
|
||||
return;
|
||||
case UNPACK_EXTRA_BYTES:
|
||||
case PARSE_EXTRA_BYTES:
|
||||
off = noff;
|
||||
result.set(obj);
|
||||
result.zone() = msgpack::move(z);
|
||||
return;
|
||||
case UNPACK_CONTINUE:
|
||||
case PARSE_CONTINUE:
|
||||
throw msgpack::insufficient_bytes("insufficient bytes");
|
||||
case UNPACK_PARSE_ERROR:
|
||||
case PARSE_PARSE_ERROR:
|
||||
default:
|
||||
throw msgpack::parse_error("parse error");
|
||||
}
|
||||
@@ -1591,19 +1510,19 @@ inline msgpack::object unpack(
|
||||
msgpack::object obj;
|
||||
std::size_t noff = off;
|
||||
referenced = false;
|
||||
unpack_return ret = detail::unpack_imp(
|
||||
parse_return ret = detail::unpack_imp(
|
||||
data, len, noff, z, obj, referenced, f, user_data, limit);
|
||||
|
||||
switch(ret) {
|
||||
case UNPACK_SUCCESS:
|
||||
case PARSE_SUCCESS:
|
||||
off = noff;
|
||||
return obj;
|
||||
case UNPACK_EXTRA_BYTES:
|
||||
case PARSE_EXTRA_BYTES:
|
||||
off = noff;
|
||||
return obj;
|
||||
case UNPACK_CONTINUE:
|
||||
case PARSE_CONTINUE:
|
||||
throw msgpack::insufficient_bytes("insufficient bytes");
|
||||
case UNPACK_PARSE_ERROR:
|
||||
case PARSE_PARSE_ERROR:
|
||||
default:
|
||||
throw msgpack::parse_error("parse error");
|
||||
}
|
||||
@@ -1643,6 +1562,7 @@ inline msgpack::object unpack(
|
||||
|
||||
// obsolete
|
||||
// pointer version
|
||||
MSGPACK_DEPRECATED("please use reference version instead")
|
||||
inline void unpack(
|
||||
msgpack::object_handle* result,
|
||||
const char* data, std::size_t len, std::size_t* off, bool* referenced,
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include "msgpack/zone.hpp"
|
||||
#include "msgpack/cpp_config.hpp"
|
||||
#include "msgpack/sysdep.h"
|
||||
#include "msgpack/parse_return.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
@@ -433,17 +434,9 @@ void unpack(
|
||||
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
|
||||
|
||||
|
||||
// for internal use
|
||||
typedef enum {
|
||||
UNPACK_SUCCESS = 2,
|
||||
UNPACK_EXTRA_BYTES = 1,
|
||||
UNPACK_CONTINUE = 0,
|
||||
UNPACK_PARSE_ERROR = -1
|
||||
} unpack_return;
|
||||
|
||||
namespace detail {
|
||||
|
||||
unpack_return
|
||||
parse_return
|
||||
unpack_imp(const char* data, std::size_t len, std::size_t& off,
|
||||
msgpack::zone& result_zone, msgpack::object& result, bool& referenced,
|
||||
unpack_reference_func f, void* user_data,
|
||||
|
122
include/msgpack/v1/unpack_exception.hpp
Normal file
122
include/msgpack/v1/unpack_exception.hpp
Normal file
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// MessagePack for C++ deserializing routine
|
||||
//
|
||||
// Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#ifndef MSGPACK_V1_UNPACK_EXCEPTION_HPP
|
||||
#define MSGPACK_V1_UNPACK_EXCEPTION_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
struct unpack_error : public std::runtime_error {
|
||||
explicit unpack_error(const std::string& msg)
|
||||
:std::runtime_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit unpack_error(const char* msg):
|
||||
std::runtime_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct parse_error : public unpack_error {
|
||||
explicit parse_error(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit parse_error(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct insufficient_bytes : public unpack_error {
|
||||
explicit insufficient_bytes(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit insufficient_bytes(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct size_overflow : public unpack_error {
|
||||
explicit size_overflow(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit size_overflow(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct array_size_overflow : public size_overflow {
|
||||
array_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
array_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct map_size_overflow : public size_overflow {
|
||||
map_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
map_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct str_size_overflow : public size_overflow {
|
||||
str_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
str_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct bin_size_overflow : public size_overflow {
|
||||
bin_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
bin_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ext_size_overflow : public size_overflow {
|
||||
ext_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
ext_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct depth_size_overflow : public size_overflow {
|
||||
depth_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
depth_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
||||
#endif // MSGPACK_V1_UNPACK_EXCEPTION_HPP
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MessagePack for C++ zero-copy buffer implementation
|
||||
//
|
||||
// Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
// Copyright (C) 2008-2017 FURUHASHI Sadayuki and KONDO Takatoshi
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
#ifndef _WIN32
|
||||
#if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||
#include <sys/uio.h>
|
||||
#else
|
||||
struct iovec {
|
||||
|
249
include/msgpack/v2/create_object_visitor.hpp
Normal file
249
include/msgpack/v2/create_object_visitor.hpp
Normal file
@@ -0,0 +1,249 @@
|
||||
//
|
||||
// MessagePack for C++ deserializing 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_V2_CREATE_OBJECT_VISITOR_HPP
|
||||
#define MSGPACK_V2_CREATE_OBJECT_VISITOR_HPP
|
||||
|
||||
#include "msgpack/unpack_decl.hpp"
|
||||
#include "msgpack/unpack_exception.hpp"
|
||||
#include "msgpack/v2/null_visitor.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v2) {
|
||||
/// @endcond
|
||||
|
||||
namespace detail {
|
||||
|
||||
class create_object_visitor : public msgpack::v2::null_visitor {
|
||||
public:
|
||||
create_object_visitor(unpack_reference_func f, void* user_data, unpack_limit const& limit)
|
||||
:m_func(f), m_user_data(user_data), m_limit(limit) {
|
||||
m_stack.reserve(MSGPACK_EMBED_STACK_SIZE);
|
||||
m_stack.push_back(&m_obj);
|
||||
}
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
create_object_visitor(create_object_visitor&& other)
|
||||
:m_func(other.m_func),
|
||||
m_user_data(other.m_user_data),
|
||||
m_limit(std::move(other.m_limit)),
|
||||
m_stack(std::move(other.m_stack)),
|
||||
m_zone(other.m_zone),
|
||||
m_referenced(other.m_referenced) {
|
||||
other.m_zone = MSGPACK_NULLPTR;
|
||||
m_stack[0] = &m_obj;
|
||||
}
|
||||
create_object_visitor& operator=(create_object_visitor&& other) {
|
||||
this->~create_object_visitor();
|
||||
new (this) create_object_visitor(std::move(other));
|
||||
return *this;
|
||||
}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
void init() {
|
||||
m_stack.resize(1);
|
||||
m_obj = msgpack::object();
|
||||
m_stack[0] = &m_obj;
|
||||
}
|
||||
msgpack::object const& data() const
|
||||
{
|
||||
return m_obj;
|
||||
}
|
||||
msgpack::zone const& zone() const { return *m_zone; }
|
||||
msgpack::zone& zone() { return *m_zone; }
|
||||
void set_zone(msgpack::zone& zone) { m_zone = &zone; }
|
||||
bool referenced() const { return m_referenced; }
|
||||
void set_referenced(bool referenced) { m_referenced = referenced; }
|
||||
// visit functions
|
||||
bool visit_nil() {
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::NIL;
|
||||
return true;
|
||||
}
|
||||
bool visit_boolean(bool v) {
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::BOOLEAN;
|
||||
obj->via.boolean = v;
|
||||
return true;
|
||||
}
|
||||
bool visit_positive_integer(uint64_t v) {
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::POSITIVE_INTEGER;
|
||||
obj->via.u64 = v;
|
||||
return true;
|
||||
}
|
||||
bool visit_negative_integer(int64_t v) {
|
||||
msgpack::object* obj = m_stack.back();
|
||||
if(v >= 0) {
|
||||
obj->type = msgpack::type::POSITIVE_INTEGER;
|
||||
obj->via.u64 = v;
|
||||
}
|
||||
else {
|
||||
obj->type = msgpack::type::NEGATIVE_INTEGER;
|
||||
obj->via.i64 = v;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool visit_float32(float v) {
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::FLOAT32;
|
||||
obj->via.f64 = v;
|
||||
return true;
|
||||
}
|
||||
bool visit_float64(double v) {
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::FLOAT64;
|
||||
obj->via.f64 = v;
|
||||
return true;
|
||||
}
|
||||
bool visit_str(const char* v, uint32_t size) {
|
||||
if (size > m_limit.str()) throw msgpack::str_size_overflow("str size overflow");
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::STR;
|
||||
if (m_func && m_func(obj->type, size, m_user_data)) {
|
||||
obj->via.str.ptr = v;
|
||||
set_referenced(true);
|
||||
}
|
||||
else {
|
||||
char* tmp = static_cast<char*>(zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
std::memcpy(tmp, v, size);
|
||||
obj->via.str.ptr = tmp;
|
||||
}
|
||||
obj->via.str.size = size;
|
||||
return true;
|
||||
}
|
||||
bool visit_bin(const char* v, uint32_t size) {
|
||||
if (size > m_limit.bin()) throw msgpack::bin_size_overflow("bin size overflow");
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::BIN;
|
||||
if (m_func && m_func(obj->type, size, m_user_data)) {
|
||||
obj->via.bin.ptr = v;
|
||||
set_referenced(true);
|
||||
}
|
||||
else {
|
||||
char* tmp = static_cast<char*>(zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
std::memcpy(tmp, v, size);
|
||||
obj->via.bin.ptr = tmp;
|
||||
}
|
||||
obj->via.bin.size = size;
|
||||
return true;
|
||||
}
|
||||
bool visit_ext(const char* v, uint32_t size) {
|
||||
if (size > m_limit.ext()) throw msgpack::ext_size_overflow("ext size overflow");
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::EXT;
|
||||
if (m_func && m_func(obj->type, size, m_user_data)) {
|
||||
obj->via.ext.ptr = v;
|
||||
set_referenced(true);
|
||||
}
|
||||
else {
|
||||
char* tmp = static_cast<char*>(zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(char)));
|
||||
std::memcpy(tmp, v, size);
|
||||
obj->via.ext.ptr = tmp;
|
||||
}
|
||||
obj->via.ext.size = static_cast<uint32_t>(size - 1);
|
||||
return true;
|
||||
}
|
||||
bool start_array(uint32_t num_elements) {
|
||||
if (num_elements > m_limit.array()) throw msgpack::array_size_overflow("array size overflow");
|
||||
if (m_stack.size() > m_limit.depth()) throw msgpack::depth_size_overflow("depth size overflow");
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::ARRAY;
|
||||
obj->via.array.size = num_elements;
|
||||
if (num_elements == 0) {
|
||||
obj->via.array.ptr = MSGPACK_NULLPTR;
|
||||
}
|
||||
else {
|
||||
size_t size = num_elements*sizeof(msgpack::object);
|
||||
if (size / sizeof(msgpack::object) != num_elements) {
|
||||
throw msgpack::array_size_overflow("array size overflow");
|
||||
}
|
||||
obj->via.array.ptr =
|
||||
static_cast<msgpack::object*>(m_zone->allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||
}
|
||||
m_stack.push_back(obj->via.array.ptr);
|
||||
return true;
|
||||
}
|
||||
bool start_array_item() {
|
||||
return true;
|
||||
}
|
||||
bool end_array_item() {
|
||||
++m_stack.back();
|
||||
return true;
|
||||
}
|
||||
bool end_array() {
|
||||
m_stack.pop_back();
|
||||
return true;
|
||||
}
|
||||
bool start_map(uint32_t num_kv_pairs) {
|
||||
if (num_kv_pairs > m_limit.map()) throw msgpack::map_size_overflow("map size overflow");
|
||||
if (m_stack.size() > m_limit.depth()) throw msgpack::depth_size_overflow("depth size overflow");
|
||||
msgpack::object* obj = m_stack.back();
|
||||
obj->type = msgpack::type::MAP;
|
||||
obj->via.map.size = num_kv_pairs;
|
||||
if (num_kv_pairs == 0) {
|
||||
obj->via.map.ptr = MSGPACK_NULLPTR;
|
||||
}
|
||||
else {
|
||||
size_t size = num_kv_pairs*sizeof(msgpack::object_kv);
|
||||
if (size / sizeof(msgpack::object_kv) != num_kv_pairs) {
|
||||
throw msgpack::map_size_overflow("map size overflow");
|
||||
}
|
||||
obj->via.map.ptr =
|
||||
static_cast<msgpack::object_kv*>(m_zone->allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||
}
|
||||
m_stack.push_back(reinterpret_cast<msgpack::object*>(obj->via.map.ptr));
|
||||
return true;
|
||||
}
|
||||
bool start_map_key() {
|
||||
return true;
|
||||
}
|
||||
bool end_map_key() {
|
||||
++m_stack.back();
|
||||
return true;
|
||||
}
|
||||
bool start_map_value() {
|
||||
return true;
|
||||
}
|
||||
bool end_map_value() {
|
||||
++m_stack.back();
|
||||
return true;
|
||||
}
|
||||
bool end_map() {
|
||||
m_stack.pop_back();
|
||||
return true;
|
||||
}
|
||||
void parse_error(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
throw msgpack::parse_error("parse error");
|
||||
}
|
||||
void insufficient_bytes(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
throw msgpack::insufficient_bytes("insufficient bytes");
|
||||
}
|
||||
private:
|
||||
public:
|
||||
unpack_reference_func m_func;
|
||||
void* m_user_data;
|
||||
unpack_limit m_limit;
|
||||
msgpack::object m_obj;
|
||||
std::vector<msgpack::object*> m_stack;
|
||||
msgpack::zone* m_zone;
|
||||
bool m_referenced;
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v2)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_V2_CREATE_OBJECT_VISITOR_HPP
|
@@ -27,10 +27,14 @@ using v1::detail::bool_pack;
|
||||
|
||||
using v1::detail::all_of_imp;
|
||||
|
||||
using v1::detail::any_of_imp;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
using v1::all_of;
|
||||
|
||||
using v1::any_of;
|
||||
|
||||
using v1::seq;
|
||||
|
||||
using v1::gen_seq;
|
||||
|
97
include/msgpack/v2/null_visitor.hpp
Normal file
97
include/msgpack/v2/null_visitor.hpp
Normal file
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// MessagePack for C++ deserializing 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_V2_NULL_VISITOR_HPP
|
||||
#define MSGPACK_V2_NULL_VISITOR_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/cpp_config.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v2) {
|
||||
/// @endcond
|
||||
|
||||
struct null_visitor {
|
||||
bool visit_nil() {
|
||||
return true;
|
||||
}
|
||||
bool visit_boolean(bool /*v*/) {
|
||||
return true;
|
||||
}
|
||||
bool visit_positive_integer(uint64_t /*v*/) {
|
||||
return true;
|
||||
}
|
||||
bool visit_negative_integer(int64_t /*v*/) {
|
||||
return true;
|
||||
}
|
||||
bool visit_float32(float /*v*/) {
|
||||
return true;
|
||||
}
|
||||
bool visit_float64(double /*v*/) {
|
||||
return true;
|
||||
}
|
||||
bool visit_str(const char* /*v*/, uint32_t /*size*/) {
|
||||
return true;
|
||||
}
|
||||
bool visit_bin(const char* /*v*/, uint32_t /*size*/) {
|
||||
return true;
|
||||
}
|
||||
bool visit_ext(const char* /*v*/, uint32_t /*size*/) {
|
||||
return true;
|
||||
}
|
||||
bool start_array(uint32_t /*num_elements*/) {
|
||||
return true;
|
||||
}
|
||||
bool start_array_item() {
|
||||
return true;
|
||||
}
|
||||
bool end_array_item() {
|
||||
return true;
|
||||
}
|
||||
bool end_array() {
|
||||
return true;
|
||||
}
|
||||
bool start_map(uint32_t /*num_kv_pairs*/) {
|
||||
return true;
|
||||
}
|
||||
bool start_map_key() {
|
||||
return true;
|
||||
}
|
||||
bool end_map_key() {
|
||||
return true;
|
||||
}
|
||||
bool start_map_value() {
|
||||
return true;
|
||||
}
|
||||
bool end_map_value() {
|
||||
return true;
|
||||
}
|
||||
bool end_map() {
|
||||
return true;
|
||||
}
|
||||
void parse_error(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
}
|
||||
void insufficient_bytes(size_t /*parsed_offset*/, size_t /*error_offset*/) {
|
||||
}
|
||||
bool referenced() const {
|
||||
return false;
|
||||
}
|
||||
void set_referenced(bool /*referenced*/) {
|
||||
}
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v2)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_V2_NULL_VISITOR_HPP
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user