mmCEsim 0.3.0
mmWave Channel Estimation Simulation
type.h
Go to the documentation of this file.
1
12#ifndef _EXPORT_TYPE_H_
13#define _EXPORT_TYPE_H_
14
15#include <string>
16#include <tuple>
17
18class Type {
30 enum class Data {
31 COMPLEX,
32 FLOAT,
33 INTEGER,
34 UNSIGNED,
35 BOOL,
36 STRING,
37 CHAR,
38 OTHER,
39 UNKNOWN
40 };
41
47 enum class Suffix {
48 NONE,
49 CONST_,
50 REFERENCE_,
51 VOLATILE_,
52 UNKNOWN,
53 };
54
55 using Dim = int8_t;
56
57 public:
58 Type() = default;
59
60 Type(const std::string& str);
61
62 Data data() const noexcept;
63
64 Dim dim() const noexcept;
65
71 std::string string() const noexcept;
72
73 bool isUnknown() const noexcept;
74
75 bool isConst() const noexcept;
76
77 bool isReference() const noexcept;
78
79 static std::string string(const std::string&) noexcept;
80
81 private:
82 std::tuple<Data, Dim> _getData(char c) const noexcept;
83
84 Suffix _getSuffix(char c) const noexcept;
85
86 std::string _getString(const std::string& elem_type) const noexcept;
87
88 private:
89 Data _data = Data::UNKNOWN;
90 Dim _dim = -1;
92};
93
94inline Type::Data Type::data() const noexcept { return _data; }
95
96inline Type::Dim Type::dim() const noexcept { return _dim; }
97
98inline bool Type::isUnknown() const noexcept {
99 return (_data == Data::UNKNOWN || _dim == -1 || _suffix == Suffix::UNKNOWN);
100}
101
102inline bool Type::isConst() const noexcept { return _suffix == Suffix::CONST_; }
103
104inline bool Type::isReference() const noexcept { return _suffix == Suffix::REFERENCE_; }
105
106inline std::string Type::string(const std::string& str) noexcept {
107 Type t(str);
108 return t.string();
109}
110
111#endif
@ NONE
Definition: alg_opt.h:20
Definition: type.h:18
std::string string() const noexcept
Get the C++ type name.
Definition: type.cpp:57
Data data() const noexcept
Definition: type.h:94
Data _data
Definition: type.h:89
int8_t Dim
Definition: type.h:55
std::tuple< Data, Dim > _getData(char c) const noexcept
Definition: type.cpp:92
Type()=default
Data
Data type specification.
Definition: type.h:30
std::string _getString(const std::string &elem_type) const noexcept
Definition: type.cpp:123
Dim _dim
Definition: type.h:90
Suffix _suffix
Definition: type.h:91
bool isReference() const noexcept
Definition: type.h:104
bool isUnknown() const noexcept
Definition: type.h:98
bool isConst() const noexcept
Definition: type.h:102
Dim dim() const noexcept
Definition: type.h:96
Suffix
Type prefix.
Definition: type.h:47
Suffix _getSuffix(char c) const noexcept
Definition: type.cpp:112
str
Definition: version_bump.py:14