20#ifndef ORES_VARIABILITY_DOMAIN_SYSTEM_FLAGS_HPP
21#define ORES_VARIABILITY_DOMAIN_SYSTEM_FLAGS_HPP
29#include <magic_enum/magic_enum.hpp>
90 std::string_view description;
103 .default_enabled =
true,
104 .description =
"Indicates whether the system is in bootstrap mode "
105 "(waiting for initial admin account)."
109 .default_enabled =
false,
110 .description =
"Controls whether user self-registration is allowed."
114 .default_enabled =
false,
115 .description =
"Controls whether new signups require admin authorization. "
116 "NOT YET IMPLEMENTED - enabling will cause signup to fail."
120 .default_enabled =
false,
121 .description =
"When enabled, disables strict password validation. "
122 "FOR TESTING/DEVELOPMENT ONLY."
136 return std::string(
"system.") + std::string(magic_enum::enum_name(flag));
145[[nodiscard]]
inline std::optional<system_flag>
from_flag_name(std::string_view name) {
146 constexpr std::string_view prefix =
"system.";
147 if (!name.starts_with(prefix)) {
151 auto enum_name = name.substr(prefix.size());
152 return magic_enum::enum_cast<system_flag>(enum_name);
161[[nodiscard]]
inline const system_flag_definition&
164 if (def.flag == flag)
168 throw std::logic_error(
"Definition for system_flag not found.");
Domain types for system variability.
Definition feature_flags.hpp:26
std::ostream & operator<<(std::ostream &s, const feature_flags &v)
Dumps the feature flags object to a stream in JSON format.
Definition feature_flags_json_io.cpp:29
const system_flag_definition & get_definition(system_flag flag)
Gets the definition for a system flag.
Definition system_flags.hpp:162
std::optional< system_flag > from_flag_name(std::string_view name)
Attempts to parse a database flag name to a system_flag enum.
Definition system_flags.hpp:145
constexpr std::array system_flag_definitions
Compile-time manifest of all system flags with their defaults.
Definition system_flags.hpp:100
system_flag
Enumeration of well-known system flags.
Definition system_flags.hpp:44
@ bootstrap_mode
Indicates whether the system is in bootstrap mode.
@ disable_password_validation
Controls whether password policy validation is disabled.
@ user_signups
Controls whether user self-registration is allowed.
@ signup_requires_authorization
Controls whether new signups require admin authorization.
std::string to_flag_name(system_flag flag)
Converts a system_flag enum value to its database name.
Definition system_flags.hpp:135
Metadata for a system flag including its default state and description.
Definition system_flags.hpp:87