wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
flags.hpp File Reference

Flag-testing convenience for the binary formats' bit-mask enums. More...

#include <type_traits>
#include <utility>
Include dependency graph for flags.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  wowlib
namespace  wowlib::formats

Functions

template<typename E>
requires std::is_scoped_enum_v<E>
constexpr bool wowlib::formats::hasFlag (std::underlying_type_t< E > value, E flag)
 Whether flag bit flag is set in the raw binary value value.
template<typename E>
requires std::is_scoped_enum_v<E>
constexpr bool wowlib::formats::hasFlag (E value, E flag)
 Whether flag bit flag is set in the enum-typed field value value.
template<typename E>
requires std::is_scoped_enum_v<E>
constexpr void wowlib::formats::setFlag (E &value, E flag, bool on=true)
 Set (or clear) flag bit flag in the enum-typed field value.

Detailed Description

Flag-testing convenience for the binary formats' bit-mask enums.

Flag fields are typed as their scoped enums (GroupFlags, MaterialFlags, ... — each annotated [[=welder::flags]]); real files carry OR-combined bit values (and occasionally undocumented bits), which are legal values of a fixed-underlying-type enum but not named enumerators. hasFlag() tests a named bit against such a value without the call-site std::to_underlying noise; the raw-integer overload remains for the few fields whose bits stay packed into wider members (SMODoodadDef::nameAndFlags).

Definition in file flags.hpp.