nickbabcock / Pdoxcl2Sharp

A Paradox Interactive general file parser
MIT License
39 stars 13 forks source link

ValueWrite enum and the None option #7

Closed nickbabcock closed 11 years ago

nickbabcock commented 11 years ago

The ValueWrite enum is an enum that has the Flags attribute. Clients are encouraged to use bitwise operations to create combinations of the enum to get their desired result. The problem is that there is a None option for ValueWrite. What does it mean for a value to be None and Quoted, etc?

Ideally, a client shouldn't be allowed to specify None combined any other option.

nickbabcock commented 11 years ago

From Framework Design Guidelines

DO name the zero value of flag enums None. For a flag enum, the value must always mean “all flags are cleared.”

Thus the solution to reassign ValueWrite.None from 1 to 0. The other enum values should be decremented by a power of two.

If the client tries to execute ValueWrite.None | ValueWrite.Quote, the result is ValueWrite.Quote