-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoostAnyUtilities.hpp
65 lines (53 loc) · 1.05 KB
/
BoostAnyUtilities.hpp
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
#ifndef BOOSTANYUTILITIES_H_
#define BOOSTANYUTILITIES_H_
#include <boost/any.hpp>
namespace utilities
{
bool isEmpty(const boost::any& operand)
{
return operand.empty();
}
bool isInt(const boost::any& operand)
{
return operand.type() == typeid(int);
}
bool isUint(const boost::any& operand)
{
return operand.type() == typeid(unsigned int);
}
bool isFloat(const boost::any& operand)
{
return operand.type() == typeid(float);
}
bool isDouble(const boost::any& operand)
{
return operand.type() == typeid(double);
}
bool isBool(const boost::any& operand)
{
return operand.type() == typeid(bool);
}
/*
bool is_char_ptr(const boost::any & operand)
{
try
{
boost::any_cast<const char *>(operand);
return true;
}
catch(const boost::bad_any_cast &)
{
return false;
}
}
*/
bool isString(const boost::any& operand)
{
return boost::any_cast<std::string>(&operand);
}
bool isWstring(const boost::any& operand)
{
return boost::any_cast<std::wstring>(&operand);
}
}
#endif /* BOOSTANYUTILITIES_H_ */