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
}
Each option is often called a "flag". We can combine flags using the bitwise | or |= operator:
We can test whether a flag is set using the bitwise & operator: