The “flags” keyword

A very nice feature, I’ve already implemented, is the “flags” keyword. It’s similar to the “enum” keyword in common high-level languages.
But it automatically generates the values for each entry and has a namespace like the new C++11 “enum class” types.

In XièXiè you can write this:

flags ColorFlags {
    Red
    Green
    Blue
}

And it will generate this C++ code:

//! ColorFlags flags enumeration.
struct ColorFlags
{
    // --- Auto-generated flags --- //
    typedef unsigned char DataType;
    static const DataType None  = 0;
    static const DataType All   = ~0;
    // --- Custom flags --- //
    static const DataType Red   = (1 << 0);
    static const DataType Green = (1 << 1);
    static const DataType Blue  = (1 << 2);
};