JimmyCushnie / JECS

Jimmy's Epic Config System
Do What The F*ck You Want To Public License
154 stars 16 forks source link

Serialize/deserialize flag enums in a nice way #32

Open JimmyCushnie opened 3 years ago

JimmyCushnie commented 3 years ago
[Flags]
enum Flags
{
    None = 0,
    UnionJack = 1,
    USA = 2,
    Communist = 4,
    SouthKorea = 8,
}

// ...

var file = new DataFile("example");

var communistBritain = Flags.UnionJack | Flags.Communist;
file.Set("flags", communistBritain);

example.succ will contain the following:

flags: 5

It would be nicer if it contained something like this:

flags: UnionJack | Communist

or perhaps

flags: UnionJack, Communist

or maybe even

flags: UnionJack and Communist

Or maybe SUCC should support all three syntaxes, and the one that's used is a FileStyle setting.