OpenFlags.h
Go to the documentation of this file.
1 /****
2  * OpenFlags.h
3  *
4  * Created on: 31 Aug 2018
5  *
6  * Copyright 2019 mikee47 <mike@sillyhouse.net>
7  *
8  * This file is part of the IFS Library
9  *
10  * This library is free software: you can redistribute it and/or modify it under the terms of the
11  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with this library.
18  * If not, see <https://www.gnu.org/licenses/>.
19  *
20  ****/
21 
22 #pragma once
23 
24 #include "Types.h"
25 
26 namespace IFS
27 {
34 #define IFS_OPEN_FLAG_MAP(XX) \
35  XX(Append, "Append to file") \
36  XX(Truncate, "Create empty file") \
37  XX(Create, "Create new file if file doesn't exist") \
38  XX(Read, "Read access") \
39  XX(Write, "Write access") \
40  XX(NoFollow, "Don't follow symbolic links")
41 
42 enum class OpenFlag {
43 #define XX(_tag, _comment) _tag,
45 #undef XX
46  MAX
47 };
48 
49 // The set of flags
50 using OpenFlags = BitSet<uint8_t, OpenFlag, size_t(OpenFlag::MAX)>;
51 
52 inline constexpr OpenFlags operator|(OpenFlag a, OpenFlag b)
53 {
54  return OpenFlags(a) | b;
55 }
56 
57 } // namespace IFS
58 
#define IFS_OPEN_FLAG_MAP(XX)
File open flag.
Definition: OpenFlags.h:34
String toString(IFS::OpenFlag flag)
Get a descriptive string for a flag.
Manage a set of bit values using enumeration.
Definition: BitSet.h:45
The String class.
Definition: WString.h:137
Definition: DirectoryTemplate.h:37
OpenFlag
Definition: OpenFlags.h:42
XX(_tag, _comment)
constexpr OpenFlags operator|(OpenFlag a, OpenFlag b)
Definition: OpenFlags.h:52
BitSet< uint8_t, OpenFlag, size_t(OpenFlag::MAX)> OpenFlags
Definition: OpenFlags.h:50