I have a few flags:
None = 0
HR = 1
HD = 2,
DT = 4,
Fl = 8
..
etc.
I want to create a function in which I enter some flag, say: 6.
The return must be HDDT, since 2 | 4 = 6. It can also happen that three or more flags are combined or just one. for example: 7 = 1 | 2 | 4 => HRHDDT.
How to return a completed string depending on the flag value?
In my case, the enumeration has much more entries, which would make the simple expression really uncomfortable, because I would have to cover hundreds of cases.
Is there any smart solution?
Kyu96 source
share