OCILIB (C and C++ Driver for Oracle)  4.7.6
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Flags.hpp
1 /*
2  * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI)
3  *
4  * Website: http://www.ocilib.net
5  *
6  * Copyright (c) 2007-2023 Vincent ROGIER <vince.rogier@ocilib.net>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #pragma once
22 
23 #include "ocilibcpp/core.hpp"
24 
25 // ReSharper disable CppClangTidyCertOop54Cpp
26 
27 namespace ocilib
28 {
29  namespace core
30  {
31  template<class T>
32  Flags<T>::Flags() : _flags(static_cast<T>(0))
33  {
34  }
35 
36  template<class T>
37  Flags<T>::Flags(T flag) : _flags(flag)
38  {
39  }
40 
41  template<class T>
42  Flags<T>::Flags(const Flags& other) : _flags(other._flags)
43  {
44  }
45 
46  template<class T>
47  Flags<T>::Flags(unsigned int flag) : _flags(static_cast<T>(flag))
48  {
49  }
50 
51  template<class T>
52  Flags<T>& Flags<T>::operator = (const Flags<T>& other) noexcept
53  {
54  if (this != &other)
55  {
56  _flags = other._flags;
57  }
58 
59  return *this;
60  }
61 
62  template<class T>
63  Flags<T> Flags<T>::operator~ () const
64  {
65  return Flags<T>(~_flags);
66  }
67 
68  template<class T>
69  Flags<T> Flags<T>::operator | (const Flags& other) const
70  {
71  return Flags<T>(_flags | other._flags);
72  }
73 
74  template<class T>
75  Flags<T> Flags<T>::operator & (const Flags& other) const
76  {
77  return Flags<T>(_flags & other._flags);
78  }
79 
80  template<class T>
81  Flags<T> Flags<T>::operator ^ (const Flags& other) const
82  {
83  return Flags<T>(_flags ^ other._flags);
84  }
85 
86  template<class T>
87  Flags<T> Flags<T>::operator | (T other) const
88  {
89  return Flags<T>(_flags | other);
90  }
91 
92  template<class T>
93  Flags<T> Flags<T>::operator & (T other) const
94  {
95  return Flags<T>(_flags & other);
96  }
97 
98  template<class T>
99  Flags<T> Flags<T>::operator ^ (T other) const
100  {
101  return Flags<T>(_flags ^ other);
102  }
103 
104  template<class T>
105  Flags<T>& Flags<T>::operator |= (const Flags<T>& other)
106  {
107  _flags |= other._flags;
108  return *this;
109  }
110 
111  template<class T>
112  Flags<T>& Flags<T>::operator &= (const Flags<T>& other)
113  {
114  _flags &= other._flags;
115  return *this;
116  }
117 
118  template<class T>
119  Flags<T>& Flags<T>::operator ^= (const Flags<T>& other)
120  {
121  _flags ^= other._flags;
122  return *this;
123  }
124 
125  template<class T>
126  Flags<T>& Flags<T>::operator |= (T other)
127  {
128  _flags |= other;
129  return *this;
130  }
131 
132  template<class T>
133  Flags<T>& Flags<T>::operator &= (T other)
134  {
135  _flags &= other;
136  return *this;
137  }
138 
139  template<class T>
140  Flags<T>& Flags<T>::operator ^= (T other)
141  {
142  _flags ^= other;
143  return *this;
144  }
145 
146  template<class T>
147  bool Flags<T>::operator == (T other) const
148  {
149  return _flags == static_cast<unsigned int>(other);
150  }
151 
152  template<class T>
153  bool Flags<T>::operator == (const Flags& other) const
154  {
155  return _flags == other._flags;
156  }
157 
158  template<class T>
159  bool Flags<T>::IsSet(T other) const
160  {
161  return ((_flags & other) == _flags);
162  }
163 
164  template<class T>
165  unsigned int Flags<T>::GetValues() const
166  {
167  return _flags;
168  }
169  }
170 }
OCILIB ++ Namespace.