Is it possible to serialize and deserialize a class in C++?

前端 未结 13 2669
我寻月下人不归
我寻月下人不归 2020-11-22 02:18

Is it possible to serialize and deserialize a class in C++?

I\'ve been using Java for 3 years now, and serialization / deserialization is fairly trivial in that lang

13条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 02:56

    If you want simple and best performance and don't care about backward data compatibility, try HPS, it's lightweight, much faster than Boost, etc, and much easier to use than Protobuf, etc.

    Example:

    std::vector data({22, 333, -4444});
    std::string serialized = hps::serialize_to_string(data);
    auto parsed = hps::parse_from_string>(serialized);
    

提交回复
热议问题