does anybody encounter a Limit on the number of items on Enumerated sets? I cannot put more than 32 items
does anybody encounter a Limit on the number of items on Enumerated sets? I cannot put more than 32 items
Edit:
Sample Code
type
TTablesDef = (tbl1,tbl2,...,tbl33,tbl34);
TTableSet = set of TTablesDef;
TSomeClass = class(TSomeClassAlso)
private
FTables : TTableSet;
public
procedure SomeMethod(someparam:dword) ;
constructor Create(someparam) : override;
destructor Destroy;
end;
procedure TSomeClass.SomeMethod(someparam:dword);
begin
FTables := TTableSet(someparam);
end;
Edit:
Sample Code
type
TTablesDef = (tbl1,tbl2,...,tbl33,tbl34);
TTableSet = set of TTablesDef;
TSomeClass = class(TSomeClassAlso)
private
FTables : TTableSet;
public
procedure SomeMethod(someparam:dword) ;
constructor Create(someparam) : override;
destructor Destroy;
end;
procedure TSomeClass.SomeMethod(someparam:dword);
begin
FTables := TTableSet(someparam);
end;
sets can have not more than 255 elements. 32 - is limit of RTTI.
ReplyDeletetype
TByteSet = set of 0..255;
var
TMySetVar: TByteSet; // compile
type
TComp =class(TComponent)
private
FF: TByteset;
procedure SetF(const Value: TByteset);
published
property F: TByteset read FF write SetF; // doesnt compile, because type Tbyteset does not have RTTI.
end;
The above poster is correct.
ReplyDeletehttp://docwiki.embarcadero.com/RADStudio/XE5/en/Structured_Types#Sets
Thanks for the replies, Any workaround?
ReplyDeleteUse a different data structure. You didn't post any code or mention what your using the set for. Perhaps it's not the most appropriate structure for the type of data you're working on.
ReplyDeleteJemer Garibay Workaround: Don't use RTTI for sets. :-)
ReplyDeleteI have a bunch of utility functions that can do bitwise modifications of 255-bit enumerated sets, load/store them as Hex, Etc. They will also work on smaller enumerated sets - the compiler scales sets to fit the number of defined enumerated flags.
You are welcome to the source code if you like.
I use encrypted enumerated sets to manage end-user privileges in my apps.
Edited post with the sample code
ReplyDelete