xref: /aosp_15_r20/external/stg/reader_options.h (revision 9e3b08ae94a55201065475453d799e8b1378bea6)
1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- mode: C++ -*-
3 //
4 // Copyright 2023 Google LLC
5 //
6 // Licensed under the Apache License v2.0 with LLVM Exceptions (the
7 // "License"); you may not use this file except in compliance with the
8 // License.  You may obtain a copy of the License at
9 //
10 //     https://llvm.org/LICENSE.txt
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
18 // Author: Siddharth Nayyar
19 
20 #ifndef STG_READER_OPTIONS_H_
21 #define STG_READER_OPTIONS_H_
22 
23 #include <type_traits>
24 
25 namespace stg {
26 
27 struct ReadOptions {
28   enum Value {
29     TYPE_ROOTS = 1 << 0,
30   };
31 
32   using Bitset = std::underlying_type_t<Value>;
33 
34   ReadOptions() = default;
35   template <typename... Values>
ReadOptionsReadOptions36   explicit ReadOptions(Values... values) {
37     for (auto value : {values...}) {
38       Set(value);
39     }
40   }
41 
SetReadOptions42   void Set(Value other) {
43     bitset |= static_cast<Bitset>(other);
44   }
45 
TestReadOptions46   bool Test(Value other) const {
47     return static_cast<bool>(bitset & static_cast<Bitset>(other));
48   }
49 
50   Bitset bitset = 0;
51 };
52 
53 }  // namespace stg
54 
55 #endif  // STG_READER_OPTIONS_H_
56