Reputation: 1779
I'm currently trying to work through the c++ basic tutorial for google Protocol Buffers. I'm not using the .proto files included in the tutorial, but the OpenStreetMap PBF file .proto definition files. I've also tested using the example provided in the tutorial but I'm seeing the same result.
I'm able to compile my .proto files successfully using the following command:
protoc -I=./doc/ --cpp_out=./src/mongosm/proto_messages/ ./doc/fileformat.proto
After referencing the correct header file, and trying to open it, the generated classes do not contain a ParseFromIstream method (including the compiled tutorial .proto classes).
I'm not sure if the tutorial is out of date or not, but I'm using v2.5.0 of the protocol buffers library.
Can someone please shed some light on why this might be happening, or how I can parse a file into a generated object?
Cheers, Justin
Upvotes: 2
Views: 1859
Reputation: 1
"Can someone please shed some light on why this might be happening, or how I can parse a file into a generated object?"
The ParseFromIstream()
method is implemented in the Message
base class, which is inherited by all of the generated classes. Thus it's not necessary the generator provides any code for it.
As from protobuf's documentation:
bool Message::ParseFromIstream( istream * input)
Parse a protocol buffer from a C++ istream.
If successful, the entire input will be consumed.
Upvotes: 1