Takatoshi Kondo c2ca709d68 Added header files that use c++11 variadic templates instead of ruby code generation.
When the compiler configured to support C++11 (e.g. CXXFLAG contains -std=c++11 is given),
those files are used.
Decoupled unpacker and msgpack_unpacker.
This modification introduced C++11 dependency such as nullptr and unique_ptr.
I will support C++11 and C++03, finally.

Decoupled msgpack.hpp and msgpack.h.

Decoupled sbuffer from msgpack_sbuffer.

Decoupled vrefbuffer from msgpack_vrefbuffer.

Decoupled zbuffer from msgpack_zbuffer.

Added some z_stream initialization.

Removed unpack macros.

Removed CTX_CAST and CTX_REFERENCED.

Embed ctx_ as a member variable (not a pointer).

Modified zone free using C++ way.
2014-07-07 16:16:29 +09:00
2013-01-03 19:13:28 -08:00
2014-06-05 20:49:15 +00:00
2013-01-03 19:13:28 -08:00
2013-01-03 19:13:28 -08:00
2014-07-02 18:44:07 +09:00
2013-01-03 19:13:28 -08:00
2014-06-01 19:03:51 +00:00
2013-01-03 19:13:28 -08:00
2013-01-03 19:13:28 -08:00
2013-01-03 19:13:28 -08:00
2014-06-07 14:39:59 +00:00
2013-01-03 19:13:28 -08:00
2013-01-03 19:13:28 -08:00
2013-01-03 19:13:28 -08:00
2014-06-05 20:49:15 +00:00
2013-08-17 18:51:56 +09:00
2014-03-24 23:07:10 +09:00
2014-06-01 19:03:51 +00:00

Msgpack for C/C++

It's like JSON but small and fast.

Overview

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.

License

Msgpack is Copyright (C) 2008-2010 FURUHASHI Sadayuki and licensed under the Apache License, Version 2.0 (the "License"). For details see the COPYING file in this directory.

Contributing

The source for msgpack-c is held at msgpack-c github.com site.

To report an issue, use the msgpack-c issue tracker at github.com.

Using Msgpack

Building and Installing

Install from git repository

Using autotools

You will need gcc (4.1.0 or higher), autotools.

$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ ./bootstrap
$ ./configure
$ make
$ sudo make install

If you want to setup C++11 version of msgpack, execute the following command:

$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ ./bootstrap
$ ./configure CXXFLAGS="-std=c++11"

You need the compiler that fully supports C++11.

Using cmake

You will need gcc (4.1.0 or higher), cmake.

$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ cmake .
$ make

If you want to setup C++11 version of msgpack, execute the following command:

$ git clone https://github.com/msgpack/msgpack-c.git
$ cd msgpack-c
$ cmake -DMSGPACK_CXX11=ON .

You need the compiler that fully supports C++11.

Install from package

UNIX-like platform with ./configure

On typical UNIX-like platforms, download source package from Releases and run ./configure && make && make install. Example:

$ wget https://github.com/msgpack/msgpack-c/releases/download/cpp-0.5.9/msgpack-0.5.9.tar.gz
$ tar zxvf msgpack-0.5.9.tar.gz
$ cd msgpack-0.5.9
$ ./configure
$ make
$ sudo make install
FreeBSD with Ports Collection

On FreeBSD, you can use Ports Collection. Install net/msgpack package.

Gentoo Linux with Portage

On Gentoo Linux, you can use emerge. Install dev-libs/msgpack package.

Mac OS X with MacPorts

On Mac OS X, you can install MessagePack for C using MacPorts.

$ sudo port install msgpack

You might need to run sudo port selfupdate before installing to update the package repository.

You can also install via Homebrew.

$ sudo brew install msgpack
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/

Launch cmake GUI client. http://www.cmake.org/cmake/resources/software.html

Set 'Where is the source code:' text box and 'Where to build the binaries:' text box.

Click 'Configure' button.

Choose your Visual Studio version.

Click 'Generate' button.

Open the created msgpack.sln on Visual Studio.

Build all.

Linking with an Application

Include msgpack.hpp (or msgpack.h for C) in your application and link with libmsgpack. Here is a typical gcc link command:

g++ myapp.cpp -lmsgpack -o myapp

Code Example

#include <msgpack.hpp>
#include <vector>
#include <string>
#include <iostream>

int main() {
    // This is target object.
    std::vector<std::string> target;
    target.push_back("Hello,");
    target.push_back("World!");

    // Serialize it.
    msgpack::sbuffer sbuf;  // simple buffer
    msgpack::pack(&sbuf, target);

    // Deserialize the serialized data.
    msgpack::unpacked msg;    // includes memory pool and deserialized object
    msgpack::unpack(&msg, sbuf.data(), sbuf.size());
    msgpack::object obj = msg.get();

    // Print the deserialized object to stdout.
    std::cout << obj << std::endl;    // ["Hello," "World!"]

    // Convert the deserialized object to staticaly typed object.
    std::vector<std::string> result;
    obj.convert(&result);

    // If the type is mismatched, it throws msgpack::type_error.
    obj.as<int>();  // type is mismatched, msgpack::type_error is thrown
}

Quickstart Guides

For more detailed examples see QuickStart for C and QuickStart for C++.

Description
No description provided
Readme 97 MiB
Languages
Text 100%