The goal is to control which types of users can perform which operations at the user interface level. This code has been in place for a while; I just want to improve it a bit. The file I'm trying to improve should probably be automatically generated, but it will be too large to modify, so I'm looking for a simpler solution.
The file we will call PermissionBits.hhas the following sequence:
namespace XYZPermissionBits
{
SCU64 XYZ_OP_A = 1UI64 << 0;
SCU64 XYZ_OP_B = 1UI64 << 1;
SCU64 XYZ_OP_C = 1UI64 << 2;
SCU64 XYZ_OP_C = 1UI64 << 3;
SCU64 XYZ_OP_D = 1UI64 << 4;
SCU64 XYZ_OP_E = 1UI64 << 5;
SCU64 XYZ_OP_F = 1UI64 << 6;
SCU64 XYZ_OP_G = 1UI64 << 7;
SCU64 XYZ_OP_H = 1UI64 << 8;
SCU64 XYZ_OP_I = 1UI64 << 9;
SCU64 XYZ_OP_J = 1UI64 << 10;
SCU64 XYZ_OP_K = 1UI64 << 11;
SCU64 XYZ_OP_L = 1UI64 << 12;
}
Even with the 1UI64 << <numBits>;shortcut, there are still problems, because encoders create flags with duplicate values, make typos, etc.
Ideally, I need a macro that can be nicely formatted and looks like this:
BITFIELDS_FOR_NAMESPACE(
XYZPermissionBits,
XYZ_OP_A,
XYZ_OP_B,
XYZ_OP_C,
XYZ_OP_D,
XYZ_OP_E,
XYZ_OP_F,
XYZ_OP_G,
XYZ_OP_H,
XYZ_OP_I,
XYZ_OP_J,
XYZ_OP_K,
XYZ_OP_L
)
, 2 65 - namespace name + 64 flags. , , ? ?