Access.h
Go to the documentation of this file.
1 /****
2  * Access.h
3  * Access control definitions
4  *
5  * Created on: 6 Jun 2018
6  *
7  * Copyright 2019 mikee47 <mike@sillyhouse.net>
8  *
9  * This file is part of the IFS Library
10  *
11  * This library is free software: you can redistribute it and/or modify it under the terms of the
12  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with this library.
19  * If not, see <https://www.gnu.org/licenses/>.
20  *
21  ****/
22 
23 #pragma once
24 
25 #include "UserRole.h"
26 
27 namespace IFS
28 {
29 /*
30  * Role-based Access Control List.
31  *
32  * We only require two entries to explicitly define read/write access.
33  */
34 struct ACL {
35  /* Minimum access permissions */
38 
39  bool operator==(const ACL& other) const
40  {
41  return other.readAccess == readAccess && other.writeAccess == writeAccess;
42  }
43 
44  bool operator!=(const ACL& other) const
45  {
46  return !operator==(other);
47  }
48 
49  String toString() const;
50 
51  operator String() const
52  {
53  return toString();
54  }
55 };
56 
57 static_assert(sizeof(ACL) == 2, "ACL is misaligned");
58 
66 
67 } // namespace IFS
68 
74 inline String toString(const IFS::ACL& acl)
75 {
76  return String(acl);
77 }
String toString(const IFS::ACL &acl)
Return a descriptive textual representation for an ACL.
Definition: Access.h:74
The String class.
Definition: WString.h:137
Definition: DirectoryTemplate.h:37
UserRole
Definition: UserRole.h:36
String getAclString(const IFS::ACL &acl)
Return a brief textual representation for an ACL Suitable for inclusion in a file listing.
Definition: Access.h:34
bool operator!=(const ACL &other) const
Definition: Access.h:44
UserRole writeAccess
Definition: Access.h:37
String toString() const
UserRole readAccess
Definition: Access.h:36
bool operator==(const ACL &other) const
Definition: Access.h:39