[…] You could store them as individual constants in a separate unit, eg: […]
I’m not a fan of
duplicating data. Per se, I like to create enumeration data types as often as possible, because they create
incompatibilites, i. e. I can use them as formal parameters and thus easily restrict the range of acceptable values.
I’d really rather write a conversion function, or even a simple type helper:
{$modeSwitch typeHelpers+}
type
table = (settingsMeta);
tableHelper = type helper for table
function asString(): string;
end;
function tableHelper.asString(): string;
begin
writeStr(asString, self);
asString := upCase(asString);
end;
It’s just a few lines of code. Then you can write
settingsMeta.asString. This will work fine for all table names that are
shorter than 127 characters (FPC’s limit for
significant characters in identifiers). This kind of implementation will “nicely” crash if you are attempting to convert the name of a “non‑existent”
table (e. g.
table(42).asString).