delphi将*.proto转换为pascal工具
delphi将*.proto转换为pascal工具
*.proto是google protobuf的结构描述语言。
//protobuf模板文件 syntax="proto3"; package tables; //返回结果 message Res { int32 status = 1; string exception = 2; string message = 3; } //商品资料 message Goods { string goodsid = 1; string goodsname = 2; } //计量单位 message Units { string unitid = 1; string unitname = 2; } //主从表 message Tables { int32 status = 1; string exception = 2; string message = 3; repeated Goods Goodss = 4; repeated Units Unitss= 5; }
运行codegen.bat
自动生成pbTablesMessages.pas
{ Unit pbTablesMessages.pas } { Generated from tables.proto } { Package Tables } unit pbTablesMessages; interface uses Grijjy.ProtocolBuffers, SysUtils; { TRes } type TRes = record [Serialize(1)] Status : Integer; [Serialize(2)] Exception : String; [Serialize(3)] Message : String; end; { TGoods } type TGoods = record [Serialize(1)] Goodsid : String; [Serialize(2)] Goodsname : String; end; { TUnits } type TUnits = record [Serialize(1)] Unitid : String; [Serialize(2)] Unitname : String; end; { TTables } type TTables = record [Serialize(1)] Status : Integer; [Serialize(2)] Exception : String; [Serialize(3)] Message : String; [Serialize(4)] Goodss : TArray<TGoods>; [Serialize(5)] Unitss : TArray<TUnits>; end; implementation end.
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/16463061.html