From b20c80a28c6221f921046aebfe7cba034fe5f490 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Oct 2020 22:58:02 +0200 Subject: [PATCH] [users] Introduce class-scoped aliases for true and false for the bools This is somewhat experimental and weird; the idea is that bool arguments are a lot easier to understand if there are proper names attached, rather than "true" and "false". --- src/modules/users/Config.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/users/Config.h b/src/modules/users/Config.h index 384575ed4..853d65b5f 100644 --- a/src/modules/users/Config.h +++ b/src/modules/users/Config.h @@ -40,11 +40,17 @@ const NamedEnumTable< HostNameAction >& hostNameActionNames(); class GroupDescription { public: + // TODO: still too-weakly typed, add a macro to define strongly-typed bools + class MustExist : public std::true_type {}; + class CreateIfNeeded : public std::false_type {}; + class SystemGroup : public std::true_type {}; + class UserGroup : public std::false_type {}; + ///@brief An invalid, empty group GroupDescription() {} ///@brief A group with full details - GroupDescription( const QString& name, bool mustExistAlready = false, bool isSystem = false ) + GroupDescription( const QString& name, bool mustExistAlready = CreateIfNeeded{}, bool isSystem = UserGroup{} ) : m_name( name ) , m_isValid( !name.isEmpty() ) , m_mustAlreadyExist( mustExistAlready )