I would like to dynamically load and display into a TVirtualStringTree
, data from some different SQL tables. This mean that the header and the content of each column will contain each time different type of data.
My problem is how to optimize in regards of memory usage, the definition of the record and the pointer for this case.
My thinking was to do it like this:
type
TDataType = (dtUnknown, dtString, dtInteger, dtText, dtFloat, dtDateTime, dtDate, dtTime, dtBoolean);
TData = record
DataType: TDataType;
AsString: String;
AsInteger: Integer;
AsText: TStrings;
AsWord: Word;
AsDateTime: TDateTime;
AsDate: TDate;
AsTime: TTime;
AsBoolean: Boolean;
end;
TTreeData = array of TData;
PTreeData= ^TTreeData;
In practice only 2 fields from the record will contained data: DataType
(all the time) and a second field, depends by the DataType
defined (e.g AsString
, AsInteger
). Will be also the others fields allocated as memory when Node will be initialized? Also I don't like the fact the DataType
is allocated to each node. There must be a simple way to optimize this record.
Please some suggestions.