`msgpack` for C/C++
===================
Version 2.0.0 (under development)[![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
It's like JSON but small and fast.
Overview
--------
[MessagePack](http://msgpack.org/) is an efficient binary serialization
format, which lets you exchange data among multiple languages like JSON,
except that it's faster and smaller. Small integers are encoded into a
single byte while typical short strings require only one extra byte in
addition to the strings themselves.
Example
-------
In C:
```c
#include <msgpack.h>
#include <stdio.h>
int main(void)
{
/* msgpack::sbuffer is a simple buffer implementation. */
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
msgpack_packer pk;
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
msgpack_pack_array(&pk, 3);
msgpack_pack_int(&pk, 1);
msgpack_pack_true(&pk);
msgpack_pack_str(&pk, 7);
msgpack_pack_str_body(&pk, "example", 7);
/* deserialize the buffer into msgpack_object instance. */
/* deserialized object is valid during the msgpack_zone instance alive. */
msgpack_zone mempool;
msgpack_zone_init(&mempool, 2048);
msgpack_object deserialized;
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
/* print the deserialized object. */
msgpack_object_print(stdout, deserialized);
puts("");
msgpack_zone_destroy(&mempool);
msgpack_sbuffer_destroy(&sbuf);
return 0;
}
```
See [`QUICKSTART-C.md`](./QUICKSTART-C.md) for more details.
In C++:
```c++
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
int main(void)
{
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
// serialize the object into the buffer.
// any classes that implements write(const char*,size_t) can be a buffer.
std::stringstream buffer;
msgpack::pack(buffer, src);
// send the buffer ...
buffer.seekg(0);
// deserialize the buffer into msgpack::object instance.
std::string str(buffer.str());
msgpack::object_handle oh =
msgpack::unpack(str.data(), str.size());
// deserialized object is valid during the msgpack::object_handle instance is alive.
msgpack::object deserialized = oh.get();
// msgpack::object supports ostream.
std::cout << deserialized << std::endl;
// convert msgpack::object instance into the original type.
// if the type is mismatched, it throws msgpack::type_error exception.
msgpack::type::tuple<int, bool, std::string> dst;
deserialized.convert(dst);
return 0;
}
```
See [`QUICKSTART-CPP.md`](./QUICKSTART-CPP.md) for more details.
Usage
-----
### C++ Header Only Library
When you use msgpack on C++03 and C++11, you can just add
msgpack-c/include to your include path:
g++ -I msgpack-c/include your_source_file.cpp
If you want to use C version of msgpack, you need to build it. You can
also install the C and C++ versions of msgpack.
### Building and Installing
#### Install from git repository
##### Using the Terminal (CLI)
You will need:
- `gcc >= 4.1.0`
- `cmake >= 2.8.0`
C and C++03:
$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ cmake .
$ make
$ sudo make install
If you want to setup C++11 version of msgpack instead,
execute the following commands:
$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ cmake -DMSGPACK_CXX11=ON .
$ sudo make install
#### GUI on Windows
Clone msgpack-c git repository.
$ git clone https://github.com/msgpack/msgpack-c.git
or using GUI git client.
e.g.) tortoise git https://code.google.com/p/tortoisegit/
1. Launch [cmake GUI client](http://www.cmake.org/cmake/resources/software.html).
2. Set 'Where is the source code:' text box and 'Where to build
the binaries:' text box.
3. Click 'Configure' button.
4. Choose your Visual Studio version.
5. Click 'Generate' button.
6. Open the created msgpack.sln on Visual Studio.
7. Build all.
### Documentation
You can get addtional information on the
[wiki](https://github.com/msgpack/msgpack-c/wiki).
Contributing
------------
`msgpack-c` is developed on GitHub at [msgpack/msgpack-c](https://github.com/msgpack/msgpack-c).
To report an issue or send a pull request, use the
[issue tracker](https://github.com/msgpack/msgpack-c/issues).
Here's the list of [great contributors](https://github.com/msgpack/msgpack-c/graphs/contributors).
License
-------
`msgpack-c` is licensed under the Boost Software License, Version 1.0. See
the [`LICENSE_1_0.txt`](./LICENSE_1_0.txt) file for details.
没有合适的资源?快使用搜索试试~ 我知道了~
MessagePack C++
共742个文件
hpp:492个
h:145个
cpp:58个
需积分: 33 15 下载量 179 浏览量
2016-10-10
11:16:17
上传
评论
收藏 804KB ZIP 举报
温馨提示
MessagePack is an efficient binary serialization format, which lets you exchange data among multiple languages like JSON, except that it's faster and smaller. Small integers are encoded into a single byte while typical short strings require only one extra byte in addition to the strings themselves.
资源推荐
资源详情
资源评论
收起资源包目录
MessagePack C++ (742个子文件)
objectc.c 17KB
unpack.c 16KB
vrefbuffer.c 6KB
zone.c 5KB
lib_buffer_unpack.c 4KB
user_buffer_unpack.c 2KB
simple_c.c 1KB
speed_test_uint64_array.c 713B
speed_test_uint32_array.c 660B
version.c 308B
Files.cmake 32KB
COPYING 200B
msgpack_c.cpp 40KB
msgpack_container.cpp 29KB
msgpack_cpp11.cpp 27KB
boost_variant.cpp 26KB
object_with_zone.cpp 26KB
msgpack_basic.cpp 17KB
limit.cpp 15KB
user_class.cpp 12KB
reference.cpp 12KB
object.cpp 11KB
pack_unpack.cpp 10KB
array_ref.cpp 9KB
raw.cpp 7KB
streaming.cpp 7KB
streaming_c.cpp 6KB
size_equal_only.cpp 6KB
reference_cpp11.cpp 6KB
carray.cpp 6KB
msgpack_vref.cpp 6KB
boost_fusion.cpp 6KB
boost_optional.cpp 4KB
msgpack_stream.cpp 4KB
container.cpp 4KB
visitor.cpp 4KB
msgpack_variant_mapbased.cpp 3KB
stream.cpp 3KB
class_non_intrusive.cpp 3KB
buffer.cpp 3KB
shared_ptr_cpp11.cpp 3KB
unique_ptr_cpp11.cpp 3KB
msgpack_tuple.cpp 3KB
class_intrusive.cpp 3KB
msgpack_variant_capitalize.cpp 3KB
map_based_versionup.cpp 3KB
speed_test_nested_array.cpp 3KB
pack_unpack_c.cpp 3KB
protocol.cpp 2KB
reference_wrapper_cpp11.cpp 2KB
class_intrusive_map.cpp 2KB
convert.cpp 2KB
zone.cpp 2KB
speed_test.cpp 2KB
protocol_new.cpp 2KB
iterator_cpp11.cpp 2KB
enum.cpp 2KB
custom.cpp 1KB
json.cpp 1KB
fixint.cpp 1KB
simple.cpp 1KB
boost_string_ref.cpp 1KB
non_def_con_class.cpp 1KB
reuse_zone.cpp 1019B
fixint_c.cpp 955B
cases.cpp 908B
version.cpp 652B
inc_adaptor_define.cpp 53B
multi_file2.cpp 38B
multi_file1.cpp 23B
Doxyfile 64KB
cpp03_zone.hpp.erb 8KB
cpp03_msgpack_tuple.hpp.erb 7KB
cpp03_define_map.hpp.erb 3KB
cpp03_define_array.hpp.erb 3KB
cpp03_msgpack_tuple_decl.hpp.erb 2KB
cpp03_define_array_decl.hpp.erb 1KB
cpp03_define_map_decl.hpp.erb 1KB
cpp03_zone_decl.hpp.erb 947B
.gitignore 733B
.gitmodules 242B
pack_template.h 23KB
unpack_template.h 17KB
unpack.h 8KB
endian.h 7KB
open.h 6KB
sysdep.h 6KB
zbuffer.h 5KB
pack.h 5KB
make.h 5KB
x86.h 4KB
zone.h 4KB
simd.h 4KB
vrefbuffer.h 3KB
versions.h 3KB
stdcpp.h 3KB
bsd.h 3KB
32.h 3KB
x86_amd.h 3KB
visualc.h 3KB
共 742 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
GeekyGuru
- 粉丝: 1586
- 资源: 1099
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- AIS2024 valid
- 最入门的爬虫代码 python.docx
- 爬虫零基础入门-爬取天气预报.pdf
- 最通俗易懂的 MongoDB 非结构化文档存储数据库教程.zip
- 以mongodb为数据库的订单物流小项目.zip
- 腾讯云-mongodb数据库, 项目部署.zip
- 腾讯 APIJSON 的 MongoDB 数据库插件.zip
- 理解非关系型数据库和关系型数据库的区别.zip
- 操作简单的Mongodb网页web管理工具,基于Spring Boot2.0支持mongodb集群.zip
- tms-mongodb-web,提供访问mongodb数据的REST API和可灵活扩展的mongodb web 客户端.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功