GG
|
#include <Flags.h>
Public Types | |
typedef std::set< FlagType > ::iterator | iterator |
typedef std::set< FlagType > ::const_iterator | const_iterator |
Static Public Member Functions | |
static FlagSpec & | instance () |
Exceptions | |
GG_ABSTRACT_EXCEPTION (Exception) | |
GG_CONCRETE_EXCEPTION (UnknownFlag, GG::FlagSpec, Exception) | |
GG_CONCRETE_EXCEPTION (UnknownString, GG::FlagSpec, Exception) |
Accessors | |
bool | contains (FlagType flag) const |
bool | permanent (FlagType flag) const |
const_iterator | find (FlagType flag) const |
const_iterator | begin () const |
const_iterator | end () const |
const std::string & | ToString (FlagType flag) const |
FlagType | FromString (const std::string &str) const |
Mutators | |
void | insert (FlagType flag, const std::string &name, bool permanent=false) |
bool | erase (FlagType flag) |
Additional Inherited Members |
A singleton that encapsulates the set of known flags of type FlagType.
New user-defined flags must be registered with FlagSpec in order to be used in Flags objects for operator~ to work properly with flags of type FlagType. FlagSpec is designed to be extensible. That is, it is understood that the flags used by GG may be insufficient for all subclasses that users may write, and FlagSpec allows authors of GG-derived classes to add flags. For instance, a subclass of Wnd may want to add a MINIMIZABLE flag. Doing so is as simple as declaring it and registering it with
FlagSpec<WndFlag>::instance.insert(MINIMIZABLE, "MINIMIZABLE")
. If user-defined subclasses and their associated user-defined flags are loaded in a runtime-loaded library, users should take care to erase them from the FlagSpec when the library is unloaded.
typedef std::set<FlagType>::iterator GG::FlagSpec< FlagType >::iterator |
typedef std::set<FlagType>::const_iterator GG::FlagSpec< FlagType >::const_iterator |
GG::FlagSpec< FlagType >::GG_ABSTRACT_EXCEPTION | ( | Exception | ) |
The base class for FlagSpec exceptions.
GG::FlagSpec< FlagType >::GG_CONCRETE_EXCEPTION | ( | UnknownFlag | , |
GG::FlagSpec< FlagType > | , | ||
Exception | |||
) |
Thrown when a flag-to-string conversion is requested for an unknown flag.
GG::FlagSpec< FlagType >::GG_CONCRETE_EXCEPTION | ( | UnknownString | , |
GG::FlagSpec< FlagType > | , | ||
Exception | |||
) |
Thrown when a string-to-flag conversion is requested for an unknown string.
|
static |
Returns the singelton instance of this class.
Referenced by GG::operator~().
|
inline |
|
inline |
|
inline |
|
inline |
Returns an iterator to the first flag in the FlagSpec.
Definition at line 190 of file Flags.h.
Referenced by GG::operator~().
|
inline |
Returns an iterator to one past the last flag in the FlagSpec.
Definition at line 193 of file Flags.h.
Referenced by GG::operator~().
|
inline |
|
inline |
|
inline |
|
inline |
Removes flag from the FlagSpec, returning whether the flag was actually removed or not. Permanent flags are not removed. The removal of flags will probably only be necessary in cases where flags were added for classes in a runtime-loaded DLL/shared library at DLL/shared library unload-time.