sqlite_protobuf
sqlite_protobuf copied to clipboard
Refactor protobuf_extract()
-
There are two switch statements that cover all different field types, one for returning a default value of an optional field that is not present, and one for returning the value of a field that is present. The latter is additionally verbose because it has to handle repeated vs non-repeated fields in each case.
-
The path traversal code will be useful for other functions like
protobuf_eachand so it should be re-usable. There could be a traversal function that accepts a serialized message and a path, and returns the sub-message and field descriptor and any error condition (e.g., index of bounds, intermediate path component does not exist, etc.).