delphi proto工具
delphi proto工具
1)编辑.proto
//protobuf模板文件
syntax="proto3";
package tables;
//返回结果
message Res {
bool ok = 1;
string err = 2;
}
//商品资料
message Goods {
string goodsid = 1;
string goodsname = 2;
}
//计量单位
message Units {
string unitid = 1;
string unitname = 2;
}
//主从表
message Tables {
repeated Goods Goodss = 1;
repeated Units Unitss= 2;
}
笔者有一个工具,可以将数据表自动生成.proto

2)使用工具将.proto生成pascal结构代码

{ Unit pbTablesMessages.pas }
{ Generated from tables.proto }
{ Package Tables }
unit pbTablesMessages;
interface
uses Grijjy.ProtocolBuffers, SysUtils;
{ TRes }
type
TRes = record
[Serialize(1)] Ok : Boolean;
[Serialize(2)] Err : 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)] Goodss : TArray<TGoods>;
[Serialize(2)] Unitss : TArray<TUnits>;
end;
implementation
end.
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/16455437.html

浙公网安备 33010602011771号