System.TypInfo.TPropInfo has two function members (at least in D-XE3):
function NameFld: TTypeInfoFieldAccessor; inline;
function Tail: PPropInfo; inline;
I cannot find any documentation for them or any examples of their use. What are they for and how can they be used? (Hope that qualifies as one question.)
The NameFld function returns the name of a property as a
TTypeInfoFieldAccessor
.This allows you to do the following:
The TTypeInfoFieldAccessor stores the name of a property in a shortstring internally.
Because the NextGen compiler does not support shortstrings, a
PByte
type is used.(I guess the author did not want to litter the source with ifdefs and ripped out the PShortstring references)
The input of
Tail
is a PByte pointing to length field of the internal shortstring.Here's the source code for tail.
Because shortstrings are not null terminated, you cannot do a simple "loop until the null char is found" kind of loop.
Therefore a loop from start to tail can employed to transfer the shortstring into a normal string.
Strangely enough in the actual RTL sourcecode the length byte is used everywhere instead of the
tail
function; so it looks like a leftover.It would have made more sense to include a
size
function and rip out thetail
.