NDEVR
API Documentation
BaseValues.hpp
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: BaseValues
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/LibAssert.h>
35#include <limits>
36#include <cinttypes>
37#include <type_traits>
38namespace NDEVR
39{
45 {};
46
51 typedef int8_t sint01;
52
58 typedef int16_t sint02;
59
65 typedef int32_t sint04;
66
72 typedef int64_t sint08;
73
81 typedef uint8_t uint01;
82
89 typedef uint16_t uint02;
90
97 typedef uint32_t uint04;
98
107 typedef uint64_t uint08;
108
128 typedef float fltp04;
129
150 typedef double fltp08;
151
155 template<class t_enum_type>
156 struct eint04
157 {
158 static_assert(std::is_enum_v<t_enum_type>);
159 t_enum_type v;
160 constexpr eint04(t_enum_type e)
161 : v(e)
162 {
163 }
164 constexpr operator uint04() const { return static_cast<uint04>(static_cast<std::underlying_type_t<t_enum_type>>(v)); }
165 constexpr operator t_enum_type() const { return v; }
166 };
167 template<class t_enum_type>
168 struct eint01
169 {
170 static_assert(std::is_enum_v<t_enum_type>);
171 t_enum_type v;
172 constexpr eint01(t_enum_type e)
173 : v(e)
174 {
175 }
176 constexpr operator uint01() const { return static_cast<uint01>(static_cast<std::underlying_type_t<t_enum_type>>(v)); }
177 constexpr operator t_enum_type() const { return v; }
178 };
183 typedef wchar_t wchar;
184
194 {
195 X = 0
196 , A = 0
197 , Y = 1
198 , B = 1
199 , Z = 2
200 , C = 2
201 , W = 3
202 , D = 3
203 };
204
209 {
210 LAT = 0,
211 LON = 1,
212 ALT = 2
213 };
214
221
223 {
224 MIN = 0
225 , MAX = 1
226 };
227
238 {
239 e_outside = 0//Outside means completely outside the other shape, not touching the boundary.
240 , e_inside//Entirely inside (but may touch the boundary) of the shape.
241 , e_mixed//The shape is neither completely inside or outside the shape.
242 };
243
249 {
250 e_nearest_neighbor
251 , e_linear
252 , e_bicubic
253 };
254
259 template<class t_type>
260 struct Constant
261 {
262 static const t_type Invalid; //The reserved Invalid value of the object, typically 0xFF...
263 static const t_type Min; //The minimum value the object type can take on.
264 static const t_type Max; //The maximum value the object type can take on.
265 };
266
267 template<> constexpr const bool Constant<bool>::Invalid = false;
268 template<> constexpr const bool Constant<bool>::Max = true;
269 template<> constexpr const bool Constant<bool>::Min = false;
270
271 template<> constexpr const sint01 Constant<sint01>::Invalid = -128;
272 template<> constexpr const sint01 Constant<sint01>::Max = 127;
273 template<> constexpr const sint01 Constant<sint01>::Min = -127;
274
275 template<> constexpr const uint01 Constant<uint01>::Invalid = 255;
276 template<> constexpr const uint01 Constant<uint01>::Max = 254;
277 template<> constexpr const uint01 Constant<uint01>::Min = 0;
278
279 template<> constexpr const sint02 Constant<sint02>::Invalid = -32768;
280 template<> constexpr const sint02 Constant<sint02>::Max = 32767;
281 template<> constexpr const sint02 Constant<sint02>::Min = -32767;
282
283 template<> constexpr const uint02 Constant<uint02>::Invalid = 65535;
284 template<> constexpr const uint02 Constant<uint02>::Max = 65534;
285 template<> constexpr const uint02 Constant<uint02>::Min = 0;
286
287 template<> constexpr const sint04 Constant<sint04>::Invalid = 0x80000000;
288 template<> constexpr const sint04 Constant<sint04>::Max = 2147483647;
289 template<> constexpr const sint04 Constant<sint04>::Min = -2147483647;
290
291 template<> constexpr const uint04 Constant<uint04>::Invalid = 4294967295UL;
292 template<> constexpr const uint04 Constant<uint04>::Max = 4294967294UL;
293 template<> constexpr const uint04 Constant<uint04>::Min = 0;
294
295 template<> constexpr const sint08 Constant<sint08>::Invalid = 0x8000000000000000;
296 template<> constexpr const sint08 Constant<sint08>::Max = 9223372036854775807LL;
297 template<> constexpr const sint08 Constant<sint08>::Min = -9223372036854775807LL;
298
299 template<> constexpr const uint08 Constant<uint08>::Invalid = 18446744073709551615ULL;
300 template<> constexpr const uint08 Constant<uint08>::Max = 18446744073709551614ULL;
301 template<> constexpr const uint08 Constant<uint08>::Min = 0;
302
303 template<> constexpr const fltp04 Constant<fltp04>::Invalid = std::numeric_limits<fltp04>::quiet_NaN();
304 template<> constexpr const fltp04 Constant<fltp04>::Max = std::numeric_limits<fltp04>::infinity();
305 template<> constexpr const fltp04 Constant<fltp04>::Min = -std::numeric_limits<fltp04>::infinity();
306
307 template<> constexpr const fltp08 Constant<fltp08>::Invalid = std::numeric_limits<fltp08>::quiet_NaN();
308 template<> constexpr const fltp08 Constant<fltp08>::Max = std::numeric_limits<fltp08>::infinity();
309 template<> constexpr const fltp08 Constant<fltp08>::Min = -std::numeric_limits<fltp08>::infinity();
310
326 template<class t_to, class t_from>
327 constexpr t_to cast(t_from value)
328 {
329 return static_cast<t_to>(value);
330 }
331
347 template<>
348 constexpr uint04 cast(fltp04 value)
349 {
350 lib_assert(value >= 0, "Bad value");
351 return static_cast<uint04>(value);
352 }
353
368 template<>
369 constexpr uint04 cast(fltp08 value)
370 {
371 lib_assert(value >= 0, "Bad value");
372 return static_cast<uint04>(value);
373 }
374
389 template<>
390 constexpr uint04 cast(sint04 value)
391 {
392 lib_assert(value >= 0, "Bad value");
393 return static_cast<uint04>(value);
394 }
395
410 template<>
411 constexpr uint04 cast(sint08 value)
412 {
413 lib_assert(value >= 0, "Bad value");
414 return static_cast<uint04>(value);
415 }
416
430 template<class t_to, class t_from>
431 constexpr t_to& rcast(t_from& value)
432 {
433 static_assert(sizeof(t_to) <= sizeof(t_from), "Bad rcast conversion");
434 return *((t_to*)(&value));
435 }
436 template<class t_to, class t_from>
437 constexpr const t_to& rcast(const t_from& value)
438 {
439 static_assert(sizeof(t_to) <= sizeof(t_from), "Bad rcast conversion");
440 return *((const t_to*)(&value));
441 }
442 #define UNUSED(expr) do { (void)(expr); } while (0)
443
444
445 static_assert(sizeof(bool) == 1, "Bad bool size");
446 static_assert(sizeof(char) == 1, "Bad char size");
447 //static_assert(sizeof(wchar) == 4, "Bad bool size");
448 static_assert(sizeof(float) == 4, "Bad float size");
449 static_assert(sizeof(double) == 8, "Bad double size");
450
451 static_assert(sizeof(fltp04) == 4, "Bad fltp04 size");
452 static_assert(sizeof(fltp08) == 8, "Bad fltp08 size");
453
454 static_assert(sizeof(uint01) == 1, "Bad int size");
455 static_assert(sizeof(uint02) == 2, "Bad int size");
456 static_assert(sizeof(uint04) == 4, "Bad int size");
457 static_assert(sizeof(uint08) == 8, "Bad int size");
458
459 static_assert(sizeof(sint01) == 1, "Bad int size");
460 static_assert(sizeof(sint02) == 2, "Bad int size");
461 static_assert(sizeof(sint04) == 4, "Bad int size");
462 static_assert(sizeof(sint08) == 8, "Bad int size");
463};
464
465#include "BaseFunctions.hpp"
Dummy class to ensure creation of an include file around core root values.
The primary namespace for the NDEVR SDK.
DimensionValues
Values that represent dimension values.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int16_t sint02
-Defines an alias representing a 2 byte, signed integer.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
InterpolationValues
Values that represent interpolation functions.
constexpr t_to & rcast(t_from &value)
Casts the given value.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
IntersectionTypes
Used for classifying shape intersections.
GeodeticValues
Values that represent dimension values for geodic dimensions.
int8_t sint01
-Defines an alias representing a 1 byte, signed integer.
wchar_t wchar
Allias for wchar_t, a value that represents a character of two bytes in size.
LocationValues
Values that represent location values.
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Definition Angle.h:408
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...