Using C++ protobuf formatted structure in leveldb. set/get operations
Solution 1:
-
You need to serialize the protobuf message into a binary string, i.e.
SerilaizeToString
, and use thePut
method to write the binary string to LevelDB with a key. -
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
. -
Finally, you can get fields of the message.