[fpc-devel] TRegistry and Unicode

Bart bartjunk64 at gmail.com
Sat Mar 16 16:32:07 CET 2019


On Wed, Mar 13, 2019 at 6:51 PM Michael Van Canneyt
<michael at freepascal.org> wrote:

> What you could do is
>
> TUniCodestringArray = Array of UniCodeString;
>
> Function GetKeyNames : TUniCodestringArray;
> Function GetValueNames : TUniCodestringArray;
>
> The TStringList versions can call these and do the conversion.

I have already declared TUnicodeStringArray in the Registry unit and
use it for Read/WriteStringList.

I was about to implement GetKeyNames/GetValueNames this way, but hit a snag.
The type TUnicodeStringArray must then be know to the XMLReg unit as
well, since these functions call TXMLRegistry functions (in
non-windows implementation).
I can declare the type there as well, but for the compiler these will
be 2 different types.

Also I need conversion from TStrings to/from TUnicodeStringArray more then once.
I made them private methods of TRegistry, but I could use them in
XMLReg unit as well.
It is not absolutely necessary, but would make for better code maintenance.

XMLReg could have Registry in it's uses clause (must be in Interface section).
Registry has uses XMLReg in th eimplementation section.

I have some recollection that we rather would not do it that way,
because the compiler does not like it very much?
The alternative would be to define TUnicodeStringArray either
somewhere in RTL or in a new unit that both Registry and XMLReg unit
use.
(And then probably re-declare it in at least TRegistry (type
TUnicodeStringArray = NewUnit.TUnicodeStringArray), so you can use the
type in your program.)

Which way to go?

-- 
Bart



More information about the fpc-devel mailing list