-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.cpp
37 lines (36 loc) · 1.19 KB
/
Utils.cpp
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
#include "Utils.h"
String objectToString(const Object& any) {
if (any.type() == typeid(short)) {
return std::to_string(std::any_cast<short>(any));
}
else if (any.type() == typeid(int)) {
return std::to_string(std::any_cast<int>(any));
}
else if (any.type() == typeid(long)) {
return std::to_string(std::any_cast<long>(any));
}
else if (any.type() == typeid(long long)) {
return std::to_string(std::any_cast<long long>(any));
}
else if (any.type() == typeid(float)) {
return std::to_string(std::any_cast<float>(any));
}
else if (any.type() == typeid(double)) {
return std::to_string(std::any_cast<double>(any));
}
else if (any.type() == typeid(long double)) {
return std::to_string(std::any_cast<long double>(any));
}
else if (any.type() == typeid(const char*)) {
return std::string(std::any_cast<const char*>(any));
}
else if (any.type() == typeid(char)) {
return std::string(1, std::any_cast<char>(any));
}
else if (any.type() == typeid(bool)) {
return std::to_string(std::any_cast<bool>(any));
}
else {
return std::any_cast<String>(any);
}
}