My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads

Note: You might want to have a look at http://blog.synopse.info/post/2011/03/12/TDynArray-and-Record-compare/load/save-using-fast-RTTI - I haven't tried it yet, but it looks like more feature-rich and as I see it does support XE2 x64.


Currently there is only one unit in lib - uKBDynamic.

Tested on Delphi 2006/2009/XE. Extended RTTI (added in D2010) is NOT used at all (no need for this case).

TKBDynamic allows to save/load/get(binary)size/compare any dynamic type with only one line of code. This can be used for example to share data by any IPC mechanism.

Dynamic types can be for example:

  • String
  • array of String (or any type)
  • dynamic record (must contain at least one dynamic type)

In TestCase there is used type TTestRecord defined as:

  TTestRecord = record
    I: Integer;
    D: Double;
    U: UnicodeString;
    W: WideString;
    A: AnsiString;
    Options: TKBDynamicOptions;

    IA: array[0..2] of Integer;

    AI: TIntegerDynArray;
    AD: TDoubleDynArray;
    AU: array of UnicodeString;
    AW: TWideStringDynArray;
    AA: array of AnsiString;

    R: array of TTestRecord;
  end;

To save whole TTestRecord:

TKBDynamic.WriteTo(lStream, lTestRecord, TypeInfo(TTestRecord));

To load it back:

TKBDynamic.ReadFrom(lStream, lTestRecord, TypeInfo(TTestRecord));

See TestuKBDynamic.pas for more examples of usage.

Powered by Google Project Hosting