You are not logged in.
Pages: 1
Hi,
since I'm using Delphi 7 Personal which has no tools for class autocompletion, I had to write my own pseudo-meta-language tool.
It simply works by specifying fields one by one like following:
name:str
age:int
weight:float
the result is complete class declaration code, including class name, private variables and published properties.
additionally each field might be marked with ";r" and/or ";w" flags which will cause the generator to use getter and/or setter respectively for specific field.
for example
Name:str
Surname:str
Phone:str;r;w
Age:int;r
Weight:float
results in
TSQLPerson = class(TSQLRecord)
private
fName: UTF8String;
fSurname: UTF8String;
fPhone: UTF8String;
fAge: integer;
fWeight: float;
function GetPhone():UTF8String;
procedure SetPhone(const AValue: UTF8String);
function GetAge():integer;
published
property Name: UTF8String read fName write fName;
property Surname: UTF8String read fSurname write fSurname;
property Phone: UTF8String read GetPhone write SetPhone;
property Age: integer read GetAge write fAge;
property Weight: float read fWeight write fWeight;
end;
function TSQLPerson.GetPhone():UTF8String;
begin
result:= fPhone;
end;
procedure TSQLPerson.SetPhone(const AValue: UTF8String);
begin
fPhone:= AValue;
end;
function TSQLPerson.GetAge():integer;
begin
result:= fAge;
end;
the tool has also ability to parse back from Delphi class declaration to meta-language, but it'll work correctly only if the code follows the pattern used for code generation (private variable: fFieldName, setters / getters: Get/SetFieldName etc etc)
Here's the link (binary + source):
Offline
Very nice!
You should certainly generate RawUTF8 instead of UTF8String, for proper UTF-8 handling.
Thanks for your input!
I'm thinking also of a similar generator, but for reverse engenering of a Database instead: from an existing DB, in whatever format (thanks to OleDB drivers of our mORMot), some mapping classes will be generated.
Offline
You should certainly generate RawUTF8 instead of UTF8String, for proper UTF-8 handling.
indeed, my bad.
I'm thinking also of a similar generator, but for reverse engenering of a Database instead: from an existing DB, in whatever format (thanks to OleDB drivers of our mORMot), some mapping classes will be generated.
well, I guess you're quite busy developing mORMot, maybe I could take care of creating such a basic tool?
Yet, I don't think current version of SynOleDB is able to handle such a thing
// BTW, SynOleDB uses OleDB which breaks the compatibility with D7PE, since OleDB is not a part of PE version
Last edited by migajek (2011-06-23 12:11:56)
Offline
BTW, SynOleDB uses OleDB which breaks the compatibility with D7PE, since OleDB is not a part of PE version
This is good to know: I'll therefore import all OleDB needed interfaces into our unit, so that it will compile.
Are ActiveX and ComObj units part of PE version?
Offline
Are ActiveX and ComObj units part of PE version?
yes, both are available.
Offline
code.google.com cannot access in china , may i get this tool on github ?
Last edited by linbren (2017-08-16 02:50:07)
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
@linbren, I think it's been included in the official mORMot package: https://github.com/synopse/mORMot/tree/ … qlite-demo
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
thans to @edwinsn .
however , it seem too much rough to be a tool .
Windows 7 64bit. Delphi XE10.2 Professional.
Offline
Pages: 1