Skip to content

Commit 252d66a

Browse files
committed
Merge branch 'master' of https://github.com/haneefmubarak/msgpack-c into general-repo-clean-up
2 parents b4eba4b + c71ce9e commit 252d66a

File tree

5 files changed

+205
-83
lines changed

5 files changed

+205
-83
lines changed

AUTHORS

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
1-
FURUHASHI Sadayuki <frsyuki _at_ users.sourceforge.jp>
1+
Authors in no particular order, as {name, github user, email}:
2+
3+
Original Author:
4+
Furuhashi Sadayuki frsyuki frsyuki <at> users <dot> sourceforge <dot> jp
5+
6+
7+
Takatoshi Kondo redboltz redboltz <at> gmail <dot> com
8+
Fuji Goro gfx gfuji <at> cpan <dot> org
9+
Tokuhiro Matsuno tokuhirom -
10+
Inada Naoki methane -
11+
Muga Nishizawa muga -
12+
Hideyuki Tanaka tanakh tanaka <dot> hideyuki <at> gmail <dot> com
13+
Nobuyuki Kubota nobu-k nobu <dot> k <dot> jp <plus> github <at> gmail <dot> com
14+
Makamaka Hannyaharamitu makamaka -
15+
Kazuki Ohta kzk kazuki <dot> ohta <at> gmail <dot> com
16+
Moriyoshi Koizumi moriyoshi mozo <at> mozo <dot> jp
17+
Kazuki Oikawa kazuki k <at> oikw <dot> org
18+
- advect -
19+
Damian Gryski dgryski damian <at> gryski <dot> com
20+
Taro L. Saito xerial leo <at> xerial <dot> org
21+
Haneef Mubarak haneefmubarak -
22+
Thiago de Arruda tarruda -
23+
Jakob Petsovits jpetso jpetso <at> gmx <dot> at
24+
Yuto Hayamizu hayamiz y <dot> hayamizu <at> gmail <dot> com
25+
Vladimir Volodko vvolodko -
26+
Nicolas Despres nicolasdespres nicolas <dot> despres <at> gmail <dot> com
27+
Dirkjan Bussink dbussink d <dot> bussink <at> gmail <dot> com
28+
Masahiro Nakagawa repeatedly repeatedly <at> gmail <dot> com
29+
Kenichi Aramaki firewood -
30+
Kazuho Oku kazuho kazuho <at> natadeco <dot> co
31+
Naoya Watabiki watabiki -
32+
Mizuno Hiroki mzp mzp <at> ocaml <dot> jp
33+
Eric Liang ericliang eric <dot> l <dot> 2046 <at> gmail <dot> com
34+
Kouhei Sutou kou kou <at> clear <dash> code <dot> com
35+
Dror Levin spatz -
36+
Keiji Muraishi kjim keiji <dot> muraishi <at> gmail <dot> com
37+
- tbeu -
38+
Hans Duedal duedal hd <at> onlinecity <dot> dk
39+
Paul Colomiets tailhook -
40+
Uli Kohler ulikoehler ukoehloer <at> btronik <dot> de
41+
Jens Alfke snej -
42+
Norio Kobota nori0428 nori <dot> 0428 <at> gmail <dot> com
43+
Hong Wu xunzhang xunzhangthu <at> gmail <dot> com
44+
Drew Crawford drewcrawford drew <at> sealedabstract <dot> com
45+
- mogemimi -
46+
Watson Song watsonsong watsonsong <at> foxmail <dot> com
47+
Felipe Oliveira Carvalho philix felipekde <at> gmail <dot> com
48+
- claws -
49+
- xanxys -
50+
Daiki Ueno ueno -
51+
- shafik -
52+
Brian Shirai brixen brixen <at> gmail <dot> com
53+
Scott Prager splinterofchaos splinterofchaos <at> gmail <dot> com
54+
Brian Ketelsen bketelsen bketelsen <at> gmail <dot> com
55+
Hideyuki Takei hideyuki takehide22 <at> gmail <dot> com
56+
- bajamircea -
57+
- cho45 cho45 <at> lowreal <dot> net
File renamed without changes.
File renamed without changes.

NOTICE

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 148 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,178 @@
1-
# Msgpack for C/C++
1+
`msgpack` for C/C++
2+
===================
3+
4+
Version 0.5.9 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c)
25

36
It's like JSON but small and fast.
47

8+
Overview
9+
--------
10+
11+
[MessagePack](http://msgpack.org/) is an efficient binary serialization
12+
format, which lets you exchange data among multiple languages like JSON,
13+
except that it's faster and smaller. Small integers are encoded into a
14+
single byte while typical short strings require only one extra byte in
15+
addition to the strings themselves.
16+
17+
Example
18+
-------
19+
20+
In C:
21+
22+
```c
23+
#include <msgpack.h>
24+
#include <stdio.h>
25+
26+
int main(void)
27+
{
28+
/* msgpack::sbuffer is a simple buffer implementation. */
29+
msgpack_sbuffer sbuf;
30+
msgpack_sbuffer_init(&sbuf);
31+
32+
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
33+
msgpack_packer pk;
34+
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
35+
36+
msgpack_pack_array(&pk, 3);
37+
msgpack_pack_int(&pk, 1);
38+
msgpack_pack_true(&pk);
39+
msgpack_pack_str(&pk, 7);
40+
msgpack_pack_str_body(&pk, "example", 7);
41+
42+
/* deserialize the buffer into msgpack_object instance. */
43+
/* deserialized object is valid during the msgpack_zone instance alive. */
44+
msgpack_zone mempool;
45+
msgpack_zone_init(&mempool, 2048);
46+
47+
msgpack_object deserialized;
48+
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
49+
50+
/* print the deserialized object. */
51+
msgpack_object_print(stdout, deserialized);
52+
puts("");
53+
54+
msgpack_zone_destroy(&mempool);
55+
msgpack_sbuffer_destroy(&sbuf);
56+
57+
return 0;
58+
}
59+
```
60+
61+
See [`QUICKSTART-C.md`](./QUICKSTART-C.md) for more details.
62+
63+
In C++:
64+
65+
```c++
66+
#include <msgpack.hpp>
67+
#include <string>
68+
#include <iostream>
69+
#include <sstream>
70+
71+
int main(void)
72+
{
73+
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
574
6-
## Overview
75+
// serialize the object into the buffer.
76+
// any classes that implements write(const char*,size_t) can be a buffer.
77+
std::stringstream buffer;
78+
msgpack::pack(buffer, src);
779
8-
MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON. But it's faster and smaller. Small integers are encoded into a single byte, and typical short strings require only one extra byte in addition to the strings themselves.
80+
// send the buffer ...
81+
buffer.seekg(0);
982
83+
// deserialize the buffer into msgpack::object instance.
84+
std::string str(buffer.str());
1085
11-
## License
86+
msgpack::unpacked result;
1287
13-
Msgpack is Copyright (C) 2008-2014 FURUHASHI Sadayuki and licensed under the Apache License, Version 2.0 (the "License"). For details see the `COPYING` file in this directory.
88+
msgpack::unpack(result, str.data(), str.size());
1489
90+
// deserialized object is valid during the msgpack::unpacked instance alive.
91+
msgpack::object deserialized = result.get();
1592
16-
## Contributing
93+
// msgpack::object supports ostream.
94+
std::cout << deserialized << std::endl;
1795
18-
The source for msgpack-c is held at [msgpack-c](https://github.com/msgpack/msgpack-c) github.com site.
96+
// convert msgpack::object instance into the original type.
97+
// if the type is mismatched, it throws msgpack::type_error exception.
98+
msgpack::type::tuple<int, bool, std::string> dst;
99+
deserialized.convert(&dst);
19100
20-
To report an issue, use the [msgpack-c issue tracker](https://github.com/msgpack/msgpack-c/issues) at github.com.
101+
return 0;
102+
}
103+
```
21104

22-
## Version
23-
0.5.9 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c)
105+
See [`QUICKSTART-CPP.md`](./QUICKSTART-CPP.md) for more details.
24106

25-
## Using Msgpack
107+
Usage
108+
-----
26109

27-
### Header only library for C++
28-
When you use msgpack on C++03 and C++11, you just add msgpack-c/include to your include path. You don't need to link any msgpack libraries.
110+
### C++ Header Only Library
29111

30-
e.g.)
112+
When you use msgpack on C++03 and C++11, you can just add
113+
msgpack-c/include to your include path:
31114

32115
g++ -I msgpack-c/include your_source_file.cpp
33116

34-
If you want to use C version of msgpack, you need to build it. You can also install C and C++ version of msgpack.
117+
If you want to use C version of msgpack, you need to build it. You can
118+
also install the C and C++ versions of msgpack.
35119

36120
### Building and Installing
37121

38122
#### Install from git repository
39123

40124
##### Using autotools
41-
You will need gcc (4.1.0 or higher), autotools.
42125

43-
For C:
44-
C++03 and C:
126+
You will need:
45127

46-
$ git clone https://github.com/redboltz/msgpack-c/tree/cxx_separate
47-
$ cd msgpack-c
48-
$ ./bootstrap
49-
$ ./configure
50-
$ make
51-
$ sudo make install
128+
- `gcc >= 4.1.0` or `clang >= 3.3.0`
129+
- `autoconf >= 2.60`
130+
- `automake >= 1.10`
131+
- `libtool >= 2.2.4`
52132

53-
For C++11:
133+
The build steps below are for C and C++03. If compiling for C++11,
134+
add `-std=c++11` to the environmental variable `CXXFLAGS` with
135+
`export CXXFLAGS="$CXXFLAGS -std=c++11"` prior to following the
136+
directions below.
54137

55-
$ git clone https://github.com/msgpack/msgpack-c.git
56-
$ cd msgpack-c
57-
$ ./bootstrap
58-
$ ./configure CXXFLAGS="-std=c++11"
59-
$ make
60-
$ sudo make install
138+
```bash
139+
$ git clone https://github.com/msgpack/msgpack-c
140+
$ cd msgpack-c
141+
$ ./bootstrap
142+
$ ./configure
143+
$ make
144+
```
61145

62-
You need the compiler that fully supports C++11.
146+
You can install the resulting library like this:
63147

148+
```bash
149+
$ sudo make install
150+
```
64151
##### Using cmake
65152

66-
###### CUI
153+
###### Using the Terminal (CLI)
154+
155+
You will need:
67156

68-
You will need gcc (4.1.0 or higher), cmake.
157+
- `gcc >= 4.1.0`
158+
- `cmake >= 2.8.0`
159+
160+
C and C++03:
69161

70162
$ git clone https://github.com/msgpack/msgpack-c.git
71163
$ cd msgpack-c
72164
$ cmake .
73165
$ make
74166
$ sudo make install
75167

76-
If you want to setup C++11 version of msgpack, execute the following command:
168+
If you want to setup C++11 version of msgpack instead,
169+
execute the following commands:
77170

78171
$ git clone https://github.com/msgpack/msgpack-c.git
79172
$ cd msgpack-c
80173
$ cmake -DMSGPACK_CXX11=ON .
81174
$ sudo make install
82175

83-
You need the compiler that fully supports C++11.
84-
85176
##### GUI on Windows
86177

87178
Clone msgpack-c git repository.
@@ -92,56 +183,35 @@ or using GUI git client.
92183

93184
e.g.) tortoise git https://code.google.com/p/tortoisegit/
94185

95-
1. Launch cmake GUI client. http://www.cmake.org/cmake/resources/software.html
96-
97-
1. Set 'Where is the source code:' text box and 'Where to build the binaries:' text box.
98-
99-
1. Click 'Configure' button.
100-
101-
1. Choose your Visual Studio version.
102-
103-
1. Click 'Generate' button.
104-
105-
1. Open the created msgpack.sln on Visual Studio.
106-
107-
1. Build all.
186+
1. Launch [cmake GUI client](http://www.cmake.org/cmake/resources/software.html).
108187

109-
### Code Example
188+
2. Set 'Where is the source code:' text box and 'Where to build
189+
the binaries:' text box.
110190

111-
#include <msgpack.hpp>
112-
#include <vector>
113-
#include <string>
114-
#include <iostream>
191+
3. Click 'Configure' button.
115192

116-
int main() {
117-
// This is target object.
118-
std::vector<std::string> target;
119-
target.push_back("Hello,");
120-
target.push_back("World!");
193+
4. Choose your Visual Studio version.
121194

122-
// Serialize it.
123-
msgpack::sbuffer sbuf; // simple buffer
124-
msgpack::pack(&sbuf, target);
195+
5. Click 'Generate' button.
125196

126-
// Deserialize the serialized data.
127-
msgpack::unpacked msg; // includes memory pool and deserialized object
128-
msgpack::unpack(msg, sbuf.data(), sbuf.size());
129-
msgpack::object obj = msg.get();
197+
6. Open the created msgpack.sln on Visual Studio.
130198

131-
// Print the deserialized object to stdout.
132-
std::cout << obj << std::endl; // ["Hello," "World!"]
199+
7. Build all.
133200

134-
// Convert the deserialized object to staticaly typed object.
135-
std::vector<std::string> result;
136-
obj.convert(&result);
201+
### Documentation
137202

138-
// If the type is mismatched, it throws msgpack::type_error.
139-
obj.as<int>(); // type is mismatched, msgpack::type_error is thrown
140-
}
203+
You can get addtional information on the
204+
[wiki](https://github.com/msgpack/msgpack-c/wiki/cpp_overview).
141205

142-
### Documents
206+
Contributing
207+
------------
143208

144-
You can get addtional information on the wiki:
209+
`msgpack-c` is developed on GitHub at [msgpack/msgpack-c](https://github.com/msgpack/msgpack-c).
210+
To report an issue or send a pull request, use the
211+
[issue tracker](https://github.com/msgpack/msgpack-c/issues).
145212

146-
https://github.com/msgpack/msgpack-c/wiki/cpp_overview
213+
License
214+
-------
147215

216+
`msgpack-c` is licensed under the Apache License Version 2.0. See
217+
the [`LICENSE`](./LICENSE) file for details.

0 commit comments

Comments
 (0)