-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTypeConstant.h
88 lines (70 loc) · 1.77 KB
/
TypeConstant.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
This file is part of the Util library.
Copyright (C) 2014 Claudius Jähn <[email protected]>
Copyright (C) 2020 Sascha Brandt <[email protected]>
This library is subject to the terms of the Mozilla Public License, v. 2.0.
You should have received a copy of the MPL along with this library; see the
file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef TYPE_CONSTANT_H
#define TYPE_CONSTANT_H
#include <cstddef>
#include <cstdint>
#include <string>
namespace Util {
//! @addtogroup util_helper
//! @{
//! This constants should not change and may be used for serialization.
enum class TypeConstant : uint8_t{
UINT8 = 0,
UINT16 = 1,
UINT32 = 2,
UINT64 = 3,
INT8 = 4,
INT16 = 5,
INT32 = 6,
INT64 = 7,
FLOAT = 8,
DOUBLE = 9,
HALF = 10,
BOOL = 11
};
//---------------------
UTILAPI uint8_t getNumBytes(TypeConstant t);
//---------------------
UTILAPI std::string getTypeString(TypeConstant t);
//---------------------
inline bool isFloatType(Util::TypeConstant type) {
switch(type) {
case Util::TypeConstant::FLOAT:
case Util::TypeConstant::DOUBLE:
case Util::TypeConstant::HALF:
return true;
default: return false;
}
}
//---------------------
inline bool isSignedIntegerType(Util::TypeConstant type) {
switch(type) {
case Util::TypeConstant::INT8:
case Util::TypeConstant::INT16:
case Util::TypeConstant::INT32:
case Util::TypeConstant::INT64:
return true;
default: return false;
}
}
//---------------------
inline bool isUnsignedIntegerType(Util::TypeConstant type) {
switch(type) {
case Util::TypeConstant::UINT8:
case Util::TypeConstant::UINT16:
case Util::TypeConstant::UINT32:
case Util::TypeConstant::UINT64:
return true;
default: return false;
}
}
//! @}
}
#endif // TYPE_CONSTANT_H