You are not logged in.
Pages: 1
I just made a simple class/unit/form generator tool.
Simply you create a CSV (E.g. MyObj.csv) file like so:
Code,RawUTF8,Edit,30
Desc,RawUTF8,Edit,512
ItemType,RawUTF8,ComboBox,30
Cost,Currency,Edit
LastCostD,TDateTime,DateEdit
VatCat,Integer,RadioGroup
Active,Boolean,CheckBox
Format:<Property/Field Name>,<Type>,<Control>[,RawUTF8 size for CDS]
And it will create units:
DataMyObj.pas (TSQLMyObj class)
MyObjFormU.pas (TMyObjForm class)
MyObjFormU.dfm
It will also make a TClientDataset on the form and add necessary fields to it, then create TDBxxxx versions of Controls specified (Edit=TDBEdit, etc) + code to get/set it from/to the TSQLMyObj class.
It is very immature and cannot handle Arrays, subobjects, etc. but it will at least create the bulk of your code and form.
Not intended to be full generator, just to create a skeleton of code/controls that you can copy to your project and edit normally from there on. Use RawUTF8 for unsupported types and just edit your code afterwards.
I'm not going to spend lots of more time on it soon, but I can see that in future:
More options like combobox/RadioButton listitems, MaskEdit, break a SET up into multiple CheckBoxes, and so on.
I might make the code generated 'template-able' so you can have different variations of forms that can be created (TObjectList-based instead of TClientdataset, HTML/JS/etc).
change name to CSV2ORM.
Can be found here:
ftp://ftp.true.co.za/TrueORMconv.zip
Last edited by AntonE (2014-07-24 22:05:35)
Offline
Great!
What do you think if we include it in the main source code repository?
We have the SQLite3\Samples\ThirdPartyDemos folder for this usage.
This won't be part of the official framework yet, since it is a work in progress, but it would benefit to be supplied within the main framework, on our repositories (both fossil and git).
I'm quite sure some other users would find it interesting, and perhaps add some features.
Thanks for sharing!
Online
I'd be honored, sure you can include it. But I think let me make some changes first, because as-is it's kind of scruffy to do just what I wanted quick and dirty.
I'll post back here if there's a bit more versatile version.
Regards
Offline
Updated version 1.1 can be found on:
ftp://ftp.true.co.za/CSV2ORM1_1.zip
I included the compiled binary so users can use/test if they don't have Jedi library to compile.
Now supports:
Multiple templates with multiple files for each template, e.g. a form generates .pas & .dfm file.
Template-code editing in app. (Need to install syntax highlighter )
Comes with sample templates & CSV, just run and test.
Can generate different code for fields/properties/controls that have size limits (Strings) by using [Size] & [!Size] tags in template.
Still scruffy but a lot more versatile.
If anyone want a specific feature or find bug, please let me know.
Regards
Basic explanation:
Create code like:
type TSQLMyObj = class(TSQLRecord)
private
[Fields]fMyName : MyType;[/Fields]
published
[Fields]property MyName : MyType read fMyName write fMyName;[/Fields]
end;
or
[Controls] object LabelMyName: TLabel
Left = 56
Top = MyTop
Width = 23
Height = 13
Alignment = taRightJustify
Caption = 'MyName'
end
object MyControlName: MyDBControl
Left = 84
Top = MyTop
Width = 121
Height = 21
DataField = 'MyName'
DataSource = DS
end[/Controls]
and it will expand to the properties/fields/controls you pass in CSV file.
It still needs a lot of changes but it's a good start and sufficient to create bulk of my repetitive code.
"MyObj" get replaced with your Object-name
"MyName" get replaced with property names, etc. See ReadMe file.
Last edited by AntonE (2014-07-28 08:20:49)
Offline
Nice!
I'm not a big fan of using CDS content as data source (due to the opaque data format), but it works.
Why not try to use our mustache template engine?
I've just included the source code to the SQLite3\Samples\ThirdPartyDemos folder of our repository.
See http://synopse.info/fossil/info/02f3aac603463a
BTW, what is ClientEngineU.pas unit?
Online
Hi Arnaud,
yes CDS is also painfully slow but I like the briefcase-model/changelog so I still use it for now.
ClientEngineU.pas is just a unit where I centralize client components, basically where TSQLRestClient descendant resides so users should just edit that code to point to their TSQLRestClient unit/component. I'll make next version better commented and generic. + included sample template should be changed to generate any different unit/form/file you want.
Can now also generate non-DB components so I should be able to write a similar Livebinding template if needed, instead of CDS/Datasource-based form.
I never really planned this project, so a complete re-think might be needed for it to be a serious/proper tool...
I never worked with Mustache and thought it is just for HTML/JS. I'll check it out some time and revamp this, thank you.
Best regards
AntonE
Last edited by AntonE (2014-07-28 10:16:36)
Offline
Please see
http://synopse.info/forum/viewtopic.php … 635#p11635
Where this is evolving into.
Offline
AntonE, please put your project in a github account
Offline
The project is already in our GitHub account.
Online
Pages: 1