fastest c++ serialization?

后端 未结 11 2424
花落未央
花落未央 2021-02-18 18:08

Good morning all,

I\'m searching for a very fast binary serialization technique for c++. I only need to serialize data contained in objects (no pointers etc.). I\'d like

11条回答
  •  -上瘾入骨i
    2021-02-18 18:29

    Well, if you want the fastest serialization possible, then you can just write your own serialization class and give it methods to serialize each of the POD types.

    The less safety you bring in, the faster it'll run and the harder it'll be to debug, however there is only a fixed number of built-in, so you could enumerate them.

    class Buffer
    {
    public:
      inline Buffer& operator<<(int i); // etc...
    private:
      std::deque mData;
    };
    

    I must admit I don't understand your problem:

    • What do you actually want to do with the serialized message ?
    • Are you saving it for later ?
    • Do you have to worry about forward / backward compatibility ?

    There might be better approaches that serialization.

提交回复
热议问题