UserRole.h
Go to the documentation of this file.
1 
22 #pragma once
23 
24 #include "Types.h"
25 
26 namespace IFS
27 {
28 // Access Control level
29 #define IFS_USER_ROLE_MAP(XX) \
30  XX(None, -, "No assigned role") \
31  XX(Guest, g, "User-type access without authentication") \
32  XX(User, u, "Normal user") \
33  XX(Manager, m, "Perform restricted system functions, reset user passwords, etc.") \
34  XX(Admin, a, "Full access")
35 
36 enum class UserRole : uint8_t {
37 #define XX(_tag, _char, _comment) _tag,
39 #undef XX
40  MAX
41 };
42 
50 UserRole getUserRole(const char* str, UserRole defaultRole);
51 
52 inline UserRole getUserRole(const String& str, UserRole defaultRole)
53 {
54  return getUserRole(str.c_str(), defaultRole);
55 }
58 /*
59  * @brief Get the character code representing the given access type
60  * @param role
61  * @retval char
62  */
63 char getChar(UserRole role);
64 
65 /*
66  * @brief Return the access type corresponding to the given code.
67  * @param code
68  * @param defaultRole Returned if code isn't recognised
69  * @retval UserRole
70  */
71 UserRole getUserRole(char code, UserRole defaultRole);
72 
73 } // namespace IFS
74 
75 /*
76  * Get the string representation for the given access type.
77  */
char getChar(UserRole role)
XX(_tag, _char, _comment)
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:641
#define str(s)
Definition: testrunner.h:124
Actually maxmimum value + 1...
The String class.
Definition: WString.h:136
Definition: DirectoryTemplate.h:36
UserRole
Definition: UserRole.h:36
String toString(IFS::UserRole role)
#define IFS_USER_ROLE_MAP(XX)
Definition: UserRole.h:29
UserRole getUserRole(const char *str, UserRole defaultRole)