Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-07

How to use Google Protocol Buffer

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis

To connect to a server, I need to use Google's Protocol Buffer format.

The only workable parser to convert the protocol definition file to pascal reader/writer source code is:

the ProtoBufCodeGen in
https://github.com/fundamentalslib/fundamentals5/releases

Still, there is no documentation on how to call the generated codes.

For example, it generated these:

procedure RequestRecordInit(var A: TRequestRecord);
procedure RequestRecordFinalise(var A: TRequestRecord);
function  pbEncodeDataRequestRecord(var Buf; const BufSize: Integer;
const A: TRequestRecord): Integer;
function  pbDecodeValueRequestRecord(const Buf; const BufSize: Integer;
var Value: TRequestRecord): Integer;
function  pbEncodeFieldRequestRecord(var Buf; const BufSize: Integer;
const FieldNum: Integer; const A: TRequestRecord): Integer;
procedure pbDecodeFieldRequestRecord(const Field:
TpbProtoBufDecodeField; var Value: TRequestRecord);

I could call pbEncodeDataRequestRecord to convert the TRequestRecord to a stream of byte and store in the Buf
but there is not a routine to convert it back from a stream of bytes to the TRequestRecord.

The only seemingly useful routine pbDecodeValueRequestRecord, when called with the Buf generated by pbEncodeDataRequestRecord will raise exception "Invalid buffer "

Any help?

Dennis

Reply by email