impagina / core

An experimental layout engine based on Scribus code.
GNU General Public License v2.0
5 stars 0 forks source link

track which options are active in styles and settings #27

Open aoloe opened 10 years ago

aoloe commented 10 years ago
enum FindOption {
    NoOptions      = 0x00000000,
    WildcardSyntax = 0x00000001,
    CaseSensitive  = 0x00000002,
    SearchBackward = 0x00000004,
    WrapAround     = 0x00000008
};

Each option is often called a "flag". We can combine flags using the bitwise | or |= operator:

int options = NoOptions;
if (wilcardSyntaxCheckBox->isChecked())
    options |= WildcardSyntax;
if (caseSensitiveCheckBox->isChecked())
    options |= CaseSensitive;
if (searchBackwardCheckBox->isChecked())
    options |= SearchBackwardSyntax;
if (wrapAroundCheckBox->isChecked())
    options |= WrapAround;

We can test whether a flag is set using the bitwise & operator:

if (options & CaseSensitive) {
    // case-sensitive search
}