diff --git a/src/PermissionManager.h b/src/PermissionManager.h index 8280c15..11e92a7 100644 --- a/src/PermissionManager.h +++ b/src/PermissionManager.h @@ -832,6 +832,21 @@ namespace ts { return false; } + /** + * Set the permission value to zero if the permission hasn't been set. + * This could be used to check if a client could do an action on another client + * but the client requires at least some power. + * @return + */ + constexpr auto& zero_if_unset() { + if(!this->has_value) { + this->has_value = true; + this->value = 0; + } + + return *this; + } + inline bool operator==(const PermissionFlaggedValue& other) const { return other.value == this->value && other.has_value == this->has_value; } inline bool operator!=(const PermissionFlaggedValue& other) const { return !(*this == other); } };