PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
ConfigurationPropertySupportedTypes.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __CONFIGURATIONPROPERTYSUPPORTEDTYPES_H
13#define __CONFIGURATIONPROPERTYSUPPORTEDTYPES_H
14
15#include "Eigen/Eigen"
16#include "StringsUtilities.hpp"
17#include <set>
18#include <string>
19#include <typeinfo>
20
21namespace Gedim
22{
24{
25 public:
27 {
29 Int = 1,
30 Char = 2,
31 String = 3,
32 Double = 4,
35 Bool = 7,
37 UInt = 9,
39 Matrix = 11
40 };
41
43 template <class K> static SupportedTypes GetSupportedType()
44 {
45 const char *propertyType = typeid(K).name();
46
47 if (propertyType == typeid(int).name())
48 return Int;
49
50 if (propertyType == typeid(char).name())
51 return Char;
52
53 if (propertyType == typeid(double).name())
54 return Double;
55
56 if (propertyType == typeid(std::string).name())
57 return String;
58
59 if (propertyType == typeid(std::vector<int>).name())
60 return VectorInt;
61
62 if (propertyType == typeid(std::vector<double>).name())
63 return VectorDouble;
64
65 if (propertyType == typeid(bool).name())
66 return Bool;
67
68 if (propertyType == typeid(unsigned int).name())
69 return UInt;
70
71 if (propertyType == typeid(std::vector<unsigned int>).name())
72 return VectorUInt;
73
74 if (propertyType == typeid(std::set<unsigned int>).name())
75 return SetUInt;
76
77 if (propertyType == typeid(Eigen::MatrixXd).name())
78 return Matrix;
79
80 return Unknown;
81 }
82
83 template <class K> static std::string TypeToString()
84 {
86 }
87
89 static std::string TypeToString(const SupportedTypes &type)
90 {
91 switch (type)
92 {
93 case Int:
94 return "int";
95 case Char:
96 return "char";
97 case String:
98 return "string";
99 case Double:
100 return "double";
101 case VectorInt:
102 return "vector_int";
103 case VectorDouble:
104 return "vector_double";
105 case Bool:
106 return "bool";
107 case UInt:
108 return "uint";
109 case SetUInt:
110 return "set_uint";
111 case VectorUInt:
112 return "vector_uint";
113 case Matrix:
114 return "Matrix";
115 default:
116 return "unknown";
117 }
118 }
119
121 static SupportedTypes StringToType(const std::string &stringType)
122 {
124
125 if (stringTypeToLow == "int")
126 return Int;
127 if (stringTypeToLow == "char")
128 return Char;
129 if (stringTypeToLow == "string")
130 return String;
131 if (stringTypeToLow == "double")
132 return Double;
133 if (stringTypeToLow == "vector_int")
134 return VectorInt;
135 if (stringTypeToLow == "vector_double")
136 return VectorDouble;
137 if (stringTypeToLow == "bool")
138 return Bool;
139 if (stringTypeToLow == "set_uint")
140 return SetUInt;
141 if (stringTypeToLow == "uint")
142 return UInt;
143 if (stringTypeToLow == "vector_uint")
144 return VectorUInt;
145 if (stringTypeToLow == "Matrix")
146 return Matrix;
147
148 return Unknown;
149 }
150
151 template <class K> static bool IsSupported()
152 {
154 }
155};
156} // namespace Gedim
157
158#endif // __CONFIGURATIONPROPERTYSUPPORTEDTYPES_H
Definition ConfigurationPropertySupportedTypes.hpp:24
static bool IsSupported()
Definition ConfigurationPropertySupportedTypes.hpp:151
static std::string TypeToString(const SupportedTypes &type)
Convert the SupportedType to string.
Definition ConfigurationPropertySupportedTypes.hpp:89
SupportedTypes
Definition ConfigurationPropertySupportedTypes.hpp:27
@ VectorInt
Definition ConfigurationPropertySupportedTypes.hpp:33
@ Unknown
Definition ConfigurationPropertySupportedTypes.hpp:28
@ String
Definition ConfigurationPropertySupportedTypes.hpp:31
@ VectorUInt
Definition ConfigurationPropertySupportedTypes.hpp:38
@ VectorDouble
Definition ConfigurationPropertySupportedTypes.hpp:34
@ UInt
Definition ConfigurationPropertySupportedTypes.hpp:37
@ Double
Definition ConfigurationPropertySupportedTypes.hpp:32
@ SetUInt
Definition ConfigurationPropertySupportedTypes.hpp:36
@ Int
Definition ConfigurationPropertySupportedTypes.hpp:29
@ Bool
Definition ConfigurationPropertySupportedTypes.hpp:35
@ Matrix
Definition ConfigurationPropertySupportedTypes.hpp:39
@ Char
Definition ConfigurationPropertySupportedTypes.hpp:30
static SupportedTypes GetSupportedType()
Get Supported Type from the type.
Definition ConfigurationPropertySupportedTypes.hpp:43
static std::string TypeToString()
Definition ConfigurationPropertySupportedTypes.hpp:83
static SupportedTypes StringToType(const std::string &stringType)
Convert a string to SupportedType.
Definition ConfigurationPropertySupportedTypes.hpp:121
Eigen column vector.
Definition Eigen_Array.hpp:23
static std::string ToLower(const std::string &input)
Convert string to lower.
Definition StringsUtilities.cpp:101
Definition Eigen_Array.cpp:22