序列化.NET,在C ++反序列化

序列化.NET,在C ++反序列化

问题描述:

我有一个序列化的二进制格式对象的.NET应用程序。
这个对象是由几个字段的结构。

I have a .NET application which serializes an object in binary format. this object is a struct consisting of a few fields.

我要反序列化,并在C ++应用程序中使用这个对象。
我不知道,如果有对C ++的序列化库,谷歌搜索也没有翻起来了。

I must deserialize and use this object in a C++ application. I have no idea if there are any serialization libraries for C++, a google search hasn't turned up much.

什么是实现这一目标的最快方法?

What is the quickest way to accomplish this?

感谢。
Roey

Thanks in advance. Roey.

更新:
我一直在使用protobuf网连载,在我的.NET应用程序,相对容易。
我也得到protobuf网产生的.proto文件,并使用GetProto()命令。
在.proto文件,我的GUID领域得到一种bcl.guid,但C ++编译器protoc.exe不知道如何解释它们!
是什么我该怎么做?

Update : I have serialized using Protobuf-net , in my .NET application, with relative ease. I also get the .proto file that protobuf-net generated, using GetProto() command. In the .proto file, my GUID fields get a type of "bcl.guid", but C++ protoc.exe compiler does not know how to interpret them! What do I do with this?

如果您使用的是的BinaryFormatter ,那么这将是不可能的。不要去那里...

If you are using BinaryFormatter, then it will be virtually impossible. Don't go there...

协议缓冲区是的设计的可移植,跨平台和版本容错(所以不会当你添加新的字段等)发生爆炸。谷歌提供的C ++版本,并有免费提供的几个C#版本(包括我自己) - 在这里看到的完整列表

Protocol buffers is designed to be portable, cross platform and version-tolerant (so it won't explode when you add new fields etc). Google provide the C++ version, and there are several C# versions freely available (including my own) - see here for the full list.

小,速度快,容易的。

注意protobuf网韩元V1 T处理结构的直接的(你需要一个DTO类),但V2(很快)的确实的已经测试结构的支持。

Note that the v1 of protobuf-net won't handle structs directly (you'll need a DTO class), but v2 (very soon) does have tested struct support.