Using C++ protobuf formatted structure in leveldb. set/get operations

Solution 1:

  1. You need to serialize the protobuf message into a binary string, i.e. SerilaizeToString, and use the Put method to write the binary string to LevelDB with a key.

  2. Then you can use the Get method to retrieve the binary value with the given key, and parse the binary string to a protobuf message, i.e. ParseFromString.

  3. Finally, you can get fields of the message.