Пример #1
0
bool ParseFromIstreamWithDescriptorPool(google::protobuf::FileDescriptorProto& proto, std::istream* input)
{
    google::protobuf::io::IstreamInputStream zero_copy_input(input);
    google::protobuf::io::CodedInputStream decoder(&zero_copy_input);
    decoder.SetExtensionRegistry(google::protobuf::DescriptorPool::generated_pool(), google::protobuf::MessageFactory::generated_factory());
    return proto.ParseFromCodedStream(&decoder) && decoder.ConsumedEntireMessage() && input->eof();
}
Пример #2
0
bool parseBigMessageFromIstream(google::protobuf::Message *message, std::istream *input)
{
    google::protobuf::io::IstreamInputStream zero_copy_input(input);
    google::protobuf::io::CodedInputStream decoder(&zero_copy_input);
    const auto maxLimit = std::numeric_limits<int>::max();
    decoder.SetTotalBytesLimit(maxLimit, -1);
	const bool isParsed = message->ParseFromCodedStream(&decoder);
    const bool isConsumedEntireMessage = decoder.ConsumedEntireMessage();
    const bool isEof = input->eof();
    return isParsed && isConsumedEntireMessage && isEof;
}