A group of DMFlag objects that can be safely OR'ed together to form a meaningful value. More...
#include <serverstructs.h>
Public Member Functions | |
DMFlagsSection (const QString &internalName) | |
Creates DMFlags section with same user-displayable and internal names. More... | |
DMFlagsSection (const QString &internalName, const QString &name) | |
Creates DMFlags section with different user-displayable and internal names. More... | |
void | add (const DMFlag &flag) |
Append a new DMFlag to this section. More... | |
unsigned | combineValues () const |
Logical OR of all DMFlag::value() results in this collection. More... | |
DMFlagsSection | copyEmpty () const |
Copies section maintaining its properties but removing all flags. More... | |
int | count () const |
Number of DMFlag objects inside the collection. More... | |
const QString & | internalName () const |
bool | isEmpty () const |
Does this section contain any dmflag? More... | |
const QString & | name () const |
User-displayable name of this section, ex. "Compatibility flags". More... | |
DMFlagsSection & | operator<< (const DMFlag &flag) |
Stream input operator that appends DMFlag to the collection, same as add(). More... | |
const DMFlag & | operator[] (int index) const |
Access DMFlag at specific index with '[]' operator. More... | |
DMFlag & | operator[] (int index) |
DMFlagsSection | removed (const DMFlagsSection &removals) const |
Returns a copy of this list with specified DMFlags removed. More... | |
Static Public Member Functions | |
static QList< DMFlagsSection > | removedBySection (const QList< DMFlagsSection > &original, const QList< DMFlagsSection > &removals) |
Matches sections by internalName() and calls removed() on them. More... | |
A group of DMFlag objects that can be safely OR'ed together to form a meaningful value.
This object is safe to copy. If you need to clone the section but omit the DMFlag definitions stored within it, use copyEmpty() method instead.
DMFlagsSection uses two names - name() for human-readable purposes and internalName() for identification within the system. name() should normally be wrapped in a QObject::tr() call. It's also allowed to only specify the 'internal' name and the human-readable name will be the same. The 'internal' name is expected to stay the same between versions of Doomseeker as it will be used in configuration files that should be usable for extended period of time (years) without being resaved. The human-readable name can be changed at whim.
Each section in a plugin should have an unique internalName().
The 'internal' name should be as friendly to any underlying Operating System as possible. Using only lower-case letters and digits is enforced. If plugin specifies invalid characters in the 'internal' name, the proper format will be coerced; all invalid characters will be removed and all letters lowercased. The human-readable name(), when not specified explicitly, will use the specified 'internal' name, but will have all original characters intact. What's forbidden is wrapping the 'internal' name in a QObject::tr() call. Unfortunately, Doomseeker has no means to detect whether string is translated or not, so the responsibility to ensure that it isn't falls on the author of the plugin. It is very important to pay attention to this as the plugin may appear to work correctly at first but break in certain cases only, for example when user saves game configurations while using one language translation and tries to load them when using another.
Some call examples:
Definition at line 136 of file serverstructs.h.
DMFlagsSection::DMFlagsSection | ( | const QString & | internalName | ) |
Creates DMFlags section with same user-displayable and internal names.
Definition at line 114 of file serverstructs.cpp.
DMFlagsSection::DMFlagsSection | ( | const QString & | internalName, |
const QString & | name | ||
) |
Creates DMFlags section with different user-displayable and internal names.
Definition at line 120 of file serverstructs.cpp.
void DMFlagsSection::add | ( | const DMFlag & | flag | ) |
Append a new DMFlag to this section.
Note that conflicting DMFlags will still be accepted here, as no check are performed. Objects added here affect results of combineValues().
Definition at line 130 of file serverstructs.cpp.
unsigned DMFlagsSection::combineValues | ( | ) | const |
Logical OR of all DMFlag::value() results in this collection.
Invalid DMFlag objects, if present in the collection, do not affect the output of this operation.
Definition at line 135 of file serverstructs.cpp.
DMFlagsSection DMFlagsSection::copyEmpty | ( | ) | const |
Copies section maintaining its properties but removing all flags.
Definition at line 145 of file serverstructs.cpp.
int DMFlagsSection::count | ( | ) | const |
Number of DMFlag objects inside the collection.
Definition at line 152 of file serverstructs.cpp.
const QString & DMFlagsSection::internalName | ( | ) | const |
Name | used for internal identification purposes. |
This name must be unique within given plugin.
Definition at line 157 of file serverstructs.cpp.
bool DMFlagsSection::isEmpty | ( | ) | const |
Does this section contain any dmflag?
Definition at line 162 of file serverstructs.cpp.
const QString & DMFlagsSection::name | ( | ) | const |
User-displayable name of this section, ex. "Compatibility flags".
Definition at line 167 of file serverstructs.cpp.
|
inline |
Stream input operator that appends DMFlag to the collection, same as add().
Definition at line 223 of file serverstructs.h.
const DMFlag & DMFlagsSection::operator[] | ( | int | index | ) | const |
Access DMFlag at specific index with '[]' operator.
Definition at line 172 of file serverstructs.cpp.
DMFlagsSection DMFlagsSection::removed | ( | const DMFlagsSection & | removals | ) | const |
Returns a copy of this list with specified DMFlags removed.
Removal is determined basing on DMFlag::value() comparison.
removals | List of DMFlags to remove. |
Definition at line 207 of file serverstructs.cpp.
|
static |
Matches sections by internalName() and calls removed() on them.
Sections that are emptied are also returned as empty sections.
Definition at line 182 of file serverstructs.cpp.