The SynCommons unit has been enhanced:
- new BinToBase64
and Base64ToBin
conversion
functions;
- new low-level RTTI functions for handling record types: RecordEquals,
RecordSave, RecordSaveLength, RecordLoad
;
- new TDynArray
object, which is a wrapper around any dynamic
array.
With TDynArray
, you can access any dynamic array (like
TIntegerDynArray = array of integer
) using TList
-like
properties and methods, e.g. Count, Add, Insert, Delete, Clear, IndexOf,
Find, Sort
and some new methods like LoadFromStream, SaveToStream,
LoadFrom
and SaveTo
which allow fast binary serialization
of any dynamic array, even containing strings or records - a
CreateOrderedIndex
method is also available to create individual
index according to the dynamic array content. You can also serialize the array
content into JSON, if you wish.
What I like with dynamic arrays is that they are reference-counted, don't
need any Create/try..finally...Free
code, and are well handled by
the Delphi compiler.
They are no replacement to a TCollection
nor a
TList
(which are the standard and efficient way of storing
class instances), but they are very handy way of having a list of content or a
dictionary at hand, with no class nor properties definition.
You can look at them like Python's list, tuples (via records handling) and
dictionaries (via Find
method), in pure Delphi. Our new methods
(about searching and serialization) allow most usage of those script-level
structures in your Delphi code.