GEOS
InputFlags.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_DATAREPOSITORY_INPUTFLAGS_HPP_
21 #define GEOS_DATAREPOSITORY_INPUTFLAGS_HPP_
22 
23 #include "common/DataTypes.hpp"
24 #include "common/logger/Logger.hpp"
25 
26 namespace geos
27 {
28 
29 namespace dataRepository
30 {
31 
37 enum class InputFlags : integer
38 {
39  INVALID,
40  FALSE,
41  OPTIONAL,
43  REQUIRED,
45  PROBLEM_ROOT,
46 };
47 
53 inline InputFlags IntToInputFlag( int const val )
54 {
56  switch( val )
57  {
58  case 0:
59  {
60  rval = InputFlags::FALSE;
61  break;
62  }
63  case 1:
64  {
65  rval = InputFlags::OPTIONAL;
66  break;
67  }
68  case 2:
69  {
70  rval = InputFlags::REQUIRED;
71  break;
72  }
73  default:
74  {
75  GEOS_ERROR( "Invalid integer conversion to InputFlag" );
76  }
77  }
78  return rval;
79 }
80 
86 inline int InputFlagToInt( InputFlags const val )
87 {
88  return static_cast< int >(val);
89 }
90 
91 
97 inline string InputFlagToString( InputFlags const val )
98 {
99  string rval;
100  switch( val )
101  {
102  case InputFlags::INVALID:
103  {
104  rval = "INVALID";
105  break;
106  }
107  case InputFlags::FALSE:
108  {
109  rval = "FALSE";
110  break;
111  }
113  {
114  rval = "OPTIONAL";
115  break;
116  }
118  {
119  rval = "OPTIONAL_NONUNIQUE";
120  break;
121  }
123  {
124  rval = "REQUIRED";
125  break;
126  }
128  {
129  rval = "REQUIRED_NONUNIQUE";
130  break;
131  }
133  {
134  rval = "PROBLEM_ROOT";
135  break;
136  }
137  }
138  return rval;
139 }
140 
147 inline bool operator==( InputFlags const left, InputFlags const right )
148 {
149  return static_cast< int >(left) == static_cast< int >(right);
150 }
151 
155 inline bool operator!=( InputFlags const left, InputFlags const right )
156 {
157  return static_cast< int >(left) != static_cast< int >(right);
158 }
159 
163 inline bool operator<( InputFlags const left, InputFlags const right )
164 {
165  return static_cast< int >(left) < static_cast< int >(right);
166 }
167 
171 inline bool operator>( InputFlags const left, InputFlags const right )
172 {
173  return static_cast< int >(left) > static_cast< int >(right);
174 }
175 
179 inline bool operator<=( InputFlags const left, InputFlags const right )
180 {
181  return static_cast< int >(left) <= static_cast< int >(right);
182 }
183 
187 inline bool operator>=( InputFlags const left, InputFlags const right )
188 {
189  return static_cast< int >(left) >= static_cast< int >(right);
190 }
191 }
192 
193 
194 } /* namespace geos */
195 
196 
197 
198 #endif /* GEOS_DATAREPOSITORY_INPUTFLAGS_HPP_ */
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:157
bool operator>(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:171
InputFlags IntToInputFlag(int const val)
Convert integer value to InputFlags.
Definition: InputFlags.hpp:53
@ OPTIONAL_NONUNIQUE
Optional in input, may be repeated.
@ OPTIONAL
Optional in input.
@ PROBLEM_ROOT
Root of the hierarchy.
@ FALSE
Not read from input.
@ REQUIRED_NONUNIQUE
Required in input, may be repeated.
@ REQUIRED
Required in input.
bool operator!=(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:155
bool operator<=(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:179
bool operator>=(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:187
bool operator==(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:147
int InputFlagToInt(InputFlags const val)
Convert InputFlags to int.
Definition: InputFlags.hpp:86
bool operator<(InputFlags const left, InputFlags const right)
Comparison operator for InputFlags enumeration.
Definition: InputFlags.hpp:163
string InputFlagToString(InputFlags const val)
Convert an InputFlags value to a string.
Definition: InputFlags.hpp:97
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82