1 #ifndef CommonTools_Utils_AnyMethodArgument_h 2 #define CommonTools_Utils_AnyMethodArgument_h 12 #include <boost/variant.hpp> 13 #include <boost/type_traits/is_same.hpp> 14 #include <boost/mpl/if.hpp> 15 #include <type_traits> 34 typedef boost::mpl::if_<
37 variant<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, double, float, std::string>,
38 boost::variant<int8_t,
54 template <
typename From,
typename To>
55 std::pair<AnyMethodArgument, int>
retOk_(
const From &
f,
int cast)
const {
56 return std::pair<AnyMethodArgument, int>(
AnyMethodArgument(static_cast<To>(f)), cast);
60 std::pair<AnyMethodArgument, int>
doInt(
int t)
const {
61 if (dataType_ ==
typeid(int8_t)) {
62 return retOk_<int, int8_t>(
t, 0);
64 if (dataType_ ==
typeid(uint8_t)) {
65 return retOk_<int, uint8_t>(
t, 0);
67 if (dataType_ ==
typeid(int16_t)) {
68 return retOk_<int, int16_t>(
t, 0);
70 if (dataType_ ==
typeid(uint16_t)) {
71 return retOk_<int, uint16_t>(
t, 0);
73 if (dataType_ ==
typeid(int32_t)) {
74 return retOk_<int, int32_t>(
t, 0);
76 if (dataType_ ==
typeid(uint32_t)) {
77 return retOk_<int, uint32_t>(
t, 0);
79 if (dataType_ ==
typeid(int64_t)) {
80 return retOk_<int, int64_t>(
t, 0);
82 if (dataType_ ==
typeid(uint64_t)) {
83 return retOk_<int, uint64_t>(
t, 0);
85 if (dataType_ ==
typeid(
unsigned long)) {
86 return retOk_<int, unsigned long>(
t, 0);
88 if (dataType_ ==
typeid(
double)) {
89 return retOk_<int, double>(
t, 1);
91 if (dataType_ ==
typeid(
float)) {
92 return retOk_<int, float>(
t, 1);
94 return std::pair<AnyMethodArgument, int>(
t, -1);
101 template <
typename I>
107 template <
typename F>
110 if (dataType_ ==
typeid(
double)) {
111 return retOk_<F, double>(
t, 0);
113 if (dataType_ ==
typeid(
float)) {
114 return retOk_<F, float>(
t, 0);
116 return std::pair<AnyMethodArgument, int>(
t, -1);
123 <<
"Enumerator '" << dataType_.
name() <<
"' has no keys.\nPerhaps the dictionary is missing?\n";
127 return std::pair<AnyMethodArgument, int>(ival, 1);
130 return std::pair<AnyMethodArgument, int>(
t, 0);
132 return std::pair<AnyMethodArgument, int>(
t, -1);
138 template <
typename T>
140 return const_cast<void *
>(
static_cast<const void *
>(&
t));
void * operator()(const T &t) const
edm::TypeWithDict dataType_
boost::mpl::if_< matches_another_integral_type< unsigned long >, boost::variant< int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, double, float, std::string >, boost::variant< int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, unsigned long, double, float, std::string > >::type AnyMethodArgument
size_t dataMemberSize() const
std::pair< AnyMethodArgument, int > retOk_(const From &f, int cast) const
const std::complex< double > I
AnyMethodArgumentFixup(const edm::TypeWithDict &type)
int stringToEnumValue(std::string const &) const
unsigned long long uint64_t
std::pair< AnyMethodArgument, int > operator()(const std::string &t) const
std::pair< AnyMethodArgument, int > doInt(int t) const
std::enable_if< std::is_integral< I >::value, std::pair< AnyMethodArgument, int > >::type operator()(const I &t) const
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
std::enable_if< std::is_floating_point< F >::value, std::pair< AnyMethodArgument, int > >::type operator()(const F &t) const