|
15 | 15 |
|
16 | 16 | #include <string> |
17 | 17 | #include <memory> |
18 | | -#include <climits> // For INT_MAX |
19 | 18 |
|
20 | 19 | // Forward declarations to avoid inclusion of <sqlite3.h> in a header |
21 | 20 | struct sqlite3_stmt; |
@@ -79,11 +78,11 @@ class Column |
79 | 78 | #endif |
80 | 79 |
|
81 | 80 | /// Return the integer value of the column. |
82 | | - int getInt() const noexcept; |
| 81 | + int32_t getInt() const noexcept; |
83 | 82 | /// Return the 32bits unsigned integer value of the column (note that SQLite3 does not support unsigned 64bits). |
84 | | - unsigned getUInt() const noexcept; |
| 83 | + uint32_t getUInt() const noexcept; |
85 | 84 | /// Return the 64bits integer value of the column (note that SQLite3 does not support unsigned 64bits). |
86 | | - long long getInt64() const noexcept; |
| 85 | + int64_t getInt64() const noexcept; |
87 | 86 | /// Return the double (64bits float) value of the column |
88 | 87 | double getDouble() const noexcept; |
89 | 88 | /** |
@@ -160,62 +159,39 @@ class Column |
160 | 159 | return getBytes (); |
161 | 160 | } |
162 | 161 |
|
163 | | - /// Inline cast operator to char |
| 162 | + /// Inline cast operators to basic types |
164 | 163 | operator char() const |
165 | 164 | { |
166 | 165 | return static_cast<char>(getInt()); |
167 | 166 | } |
168 | | - /// Inline cast operator to unsigned char |
169 | | - operator unsigned char() const |
| 167 | + operator int8_t() const |
170 | 168 | { |
171 | | - return static_cast<unsigned char>(getInt()); |
| 169 | + return static_cast<int8_t>(getInt()); |
172 | 170 | } |
173 | | - /// Inline cast operator to short |
174 | | - operator short() const |
| 171 | + operator uint8_t() const |
175 | 172 | { |
176 | | - return static_cast<short>(getInt()); |
| 173 | + return static_cast<uint8_t>(getInt()); |
177 | 174 | } |
178 | | - /// Inline cast operator to unsigned short |
179 | | - operator unsigned short() const |
| 175 | + operator int16_t() const |
180 | 176 | { |
181 | | - return static_cast<unsigned short>(getInt()); |
| 177 | + return static_cast<int16_t>(getInt()); |
182 | 178 | } |
183 | | - |
184 | | - /// Inline cast operator to int |
185 | | - operator int() const |
| 179 | + operator uint16_t() const |
186 | 180 | { |
187 | | - return getInt(); |
188 | | - } |
189 | | - /// Inline cast operator to 32bits unsigned integer |
190 | | - operator unsigned int() const |
191 | | - { |
192 | | - return getUInt(); |
| 181 | + return static_cast<uint16_t>(getInt()); |
193 | 182 | } |
194 | | -#if (LONG_MAX == INT_MAX) // 4 bytes "long" type means the data model is ILP32 or LLP64 (Win64 Visual C++ and MinGW) |
195 | | - /// Inline cast operator to 32bits long |
196 | | - operator long() const |
| 183 | + operator int32_t() const |
197 | 184 | { |
198 | 185 | return getInt(); |
199 | 186 | } |
200 | | - /// Inline cast operator to 32bits unsigned long |
201 | | - operator unsigned long() const |
| 187 | + operator uint32_t() const |
202 | 188 | { |
203 | 189 | return getUInt(); |
204 | 190 | } |
205 | | -#else // 8 bytes "long" type means the data model is LP64 (Most Unix-like, Windows when using Cygwin; z/OS) |
206 | | - /// Inline cast operator to 64bits long when the data model of the system is LP64 (Linux 64 bits...) |
207 | | - operator long() const |
208 | | - { |
209 | | - return getInt64(); |
210 | | - } |
211 | | -#endif |
212 | | - |
213 | | - /// Inline cast operator to 64bits integer |
214 | | - operator long long() const |
| 191 | + operator int64_t() const |
215 | 192 | { |
216 | 193 | return getInt64(); |
217 | 194 | } |
218 | | - /// Inline cast operator to double |
219 | 195 | operator double() const |
220 | 196 | { |
221 | 197 | return getDouble(); |
|
0 commit comments