This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 定義済みのクラス | |
public class MyClass { | |
public int mem1; | |
} | |
// いまの生成方法 | |
public class MyClass_$$_Enhanced extends MyClass implements MessagePackable { | |
public void messagePack(Packer pk) { | |
pk.packArray(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// org.msgpack.Packer クラス | |
public Packer pack(Object o) throws IOException { | |
if(o == null) { | |
return packNil(); | |
} else if(o instanceof String) { | |
byte[] b = ((String)o).getBytes("UTF-8"); | |
packRaw(b.length); | |
return packRawBody(b); | |
} else if(o instanceof MessagePackable) { | |
((MessagePackable)o).messagePack(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package serializers.thrift; | |
import java.io.IOException; | |
import org.msgpack.Packer; | |
import org.msgpack.Unpacker; | |
import org.msgpack.MessagePackable; | |
import org.msgpack.MessageUnpackable; | |
import org.msgpack.MessageConvertable; | |
import org.msgpack.MessageTypeException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MessagePackerインタフェース | |
public interface MessagePacker { | |
public void pack(Packer into, Object target) throws IOException; | |
} | |
// MessageConverterインタフェース | |
public interface MessageConverter { | |
public void convert(Object into, MessagePackObject from) throws TypeException; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tempalteインタフェース | |
public interface Tempalte { | |
public Object convert(MessagePackObject from); | |
} | |
// 標準提供のテンプレート群(コンテナ型) | |
public class ListTemplate { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// カスタムシリアライザ(自分をシリアライズ):直接使うことはまず無い | |
public interface MessagePackable { | |
public void messagePack(Packer); | |
} | |
// カスタムデシリアライザ(自分にマージ):直接使うことはまず無い | |
public interface MessageUnpackable { | |
public void messageUnpack(Unpacker); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tr1/functional> | |
#include <vector> | |
#include <string> | |
#include <iostream> | |
#include <exception> | |
namespace ebus { | |
using std::tr1::bind; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 既に定義されているクラス | |
// ライブラリから提供されていて変更できない | |
// or 他のモジュールのクラスなので変更したくない | |
public static class ProvidedClass { | |
public String name; | |
public String nickname; | |
public int age = -1; | |
} | |
// ↑これをシリアライズしたいとき... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test0 { | |
public: | |
int even; | |
}; | |
class Test1 { | |
public: | |
int member0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MessagePack for C/C++ を Visual Studio でコンパイルできないことがある問題の修正パッチの検証! | |
1. msgpack-0.5.4をダウンロードする | |
http://downloads.sourceforge.net/project/msgpack/msgpack/cpp/msgpack-0.5.4.tar.gz | |
2. インストールする | |
(msgpack_vc8.vcproj ファイルを開いてバッチビルドする) | |
3. プログラムをコンパイルしてみる | |
4. エラーが出たら、sysdep.hを差し替えてコンパイルしてみる | |
5. エラーが出なくなったら成功! 差し替えてもエラーが出たら失敗orz |