treelite
typeinfo.h
Go to the documentation of this file.
1 
8 #ifndef TREELITE_ENUM_TYPEINFO_H_
9 #define TREELITE_ENUM_TYPEINFO_H_
10 
11 #include <treelite/logging.h>
12 
13 #include <cstdint>
14 #include <string>
15 #include <type_traits>
16 #include <typeinfo>
17 
18 namespace treelite {
19 
21 enum class TypeInfo : std::uint8_t { kInvalid = 0, kUInt32 = 1, kFloat32 = 2, kFloat64 = 3 };
22 
25 
27 TypeInfo TypeInfoFromString(std::string const& str);
28 
34 template <typename T>
36  if (std::is_same_v<T, std::uint32_t>) {
37  return TypeInfo::kUInt32;
38  } else if (std::is_same_v<T, float>) {
39  return TypeInfo::kFloat32;
40  } else if (std::is_same_v<T, double>) {
41  return TypeInfo::kFloat64;
42  } else {
43  return TypeInfo::kInvalid;
44  }
45 }
46 
47 } // namespace treelite
48 
49 #endif // TREELITE_ENUM_TYPEINFO_H_
logging facility for Treelite
Definition: contiguous_array.h:14
TypeInfo TypeInfoFromType()
Convert a template type into a type info.
Definition: typeinfo.h:35
TypeInfo
Types used by thresholds and leaf outputs.
Definition: typeinfo.h:21
std::string TypeInfoToString(treelite::TypeInfo info)
Get string representation of TypeInfo.
TypeInfo TypeInfoFromString(std::string const &str)
Get TypeInfo from string.