32#ifndef RDKIT_RDVALUE_TAGGED_UNION_H
33#define RDKIT_RDVALUE_TAGGED_UNION_H
45#include <boost/utility.hpp>
46#include <boost/lexical_cast.hpp>
47#include <boost/numeric/conversion/cast.hpp>
48#include <boost/type_traits/is_floating_point.hpp>
52#define RDVALUE_HASBOOL
159 std::vector<double> *
vd;
160 std::vector<float> *
vf;
161 std::vector<int> *
vi;
162 std::vector<unsigned int> *
vu;
163 std::vector<std::string> *
vs;
173 inline Value(std::vector<double> *v) :
vd(v) {}
174 inline Value(std::vector<float> *v) :
vf(v) {}
176 inline Value(std::vector<unsigned int> *v) :
vu(v) {}
177 inline Value(std::vector<std::string> *v) :
vs(v) {}
182 return std::any_cast<T *>(*value.
a);
237 :
value(
new std::string(v)),
type(RDTypeTag::StringTag) {}
248 inline RDValue(
const std::vector<unsigned int> &v)
250 type(RDTypeTag::VecUnsignedIntTag) {}
251 inline RDValue(
const std::vector<std::string> &v)
252 :
value(
new std::vector<std::string>(v)),
type(RDTypeTag::VecStringTag) {}
259 return RDTypeTag::detail::valuePtrCast<T>(
value);
315 dest.value.s =
new std::string(*
src.value.s);
318 dest.value.a =
new std::any(*
src.value.a);
321 dest.value.vd =
new std::vector<double>(*
src.value.vd);
324 dest.value.vf =
new std::vector<float>(*
src.value.vf);
327 dest.value.vi =
new std::vector<int>(*
src.value.vi);
330 dest.value.vu =
new std::vector<unsigned int>(*
src.value.vu);
333 dest.value.vs =
new std::vector<std::string>(*
src.value.vs);
340#ifdef RDK_32BIT_BUILD
353 RDTypeTag::GetTag<typename boost::remove_reference<T>::type>();
359 return v.
value.
a->type() ==
typeid(T);
362 if (v.getTag() ==
tag) {
388 (boost::is_pointer<T>::value &&
389 (boost::is_integral<
typename boost::remove_pointer<T>::type>::value ||
390 boost::is_floating_point<
391 typename boost::remove_pointer<T>::type>::value)) ||
392 (boost::is_reference<T>::value &&
393 (boost::is_integral<
typename boost::remove_reference<T>::type>::value ||
394 boost::is_floating_point<
395 typename boost::remove_reference<T>::type>::value))));
398 return std::any_cast<T>(*v.ptrCast<std::any>());
400 throw std::bad_any_cast();
412 throw std::bad_any_cast();
421 return boost::numeric_cast<float>(v.
value.
d);
423 throw std::bad_any_cast();
432 return boost::numeric_cast<int>(v.
value.
u);
434 throw std::bad_any_cast();
440 return boost::numeric_cast<std::int8_t>(v.
value.
i);
443 return boost::numeric_cast<std::int8_t>(v.
value.
u);
445 throw std::bad_any_cast();
451 return boost::numeric_cast<std::int16_t>(v.
value.
i);
454 return boost::numeric_cast<std::int16_t>(v.
value.
u);
456 throw std::bad_any_cast();
462 return static_cast<std::int64_t
>(v.
value.
i);
465 return static_cast<std::int64_t
>(v.
value.
u);
468 return std::any_cast<std::int64_t>(*v.
ptrCast<std::any>());
470 throw std::bad_any_cast();
479 return boost::numeric_cast<unsigned int>(v.
value.
i);
481 throw std::bad_any_cast();
487 return boost::numeric_cast<std::uint8_t>(v.
value.
i);
490 return boost::numeric_cast<std::uint8_t>(v.
value.
u);
492 throw std::bad_any_cast();
498 return boost::numeric_cast<std::uint16_t>(v.
value.
i);
501 return boost::numeric_cast<std::uint16_t>(v.
value.
u);
503 throw std::bad_any_cast();
509 return static_cast<std::uint64_t
>(v.
value.
u);
512 return boost::numeric_cast<std::uint64_t>(v.
value.
i);
515 return std::any_cast<std::uint64_t>(*v.
ptrCast<std::any>());
517 throw std::bad_any_cast();
525 throw std::bad_any_cast();
std::any * valuePtrCast< std::any >(Value value)
std::string * valuePtrCast< std::string >(Value value)
T * valuePtrCast(Value value)
boost::uint64_t GetTag< int >()
static const boost::uint64_t UnsignedIntTag
static const boost::uint64_t StringTag
boost::uint64_t GetTag< std::string >()
boost::uint64_t GetTag< bool >()
boost::uint64_t GetTag< unsigned int >()
static const boost::uint64_t VecStringTag
boost::uint64_t GetTag< std::any >()
static const boost::uint64_t VecIntTag
static const boost::uint64_t FloatTag
static const boost::uint64_t VecUnsignedIntTag
static const boost::uint64_t DoubleTag
boost::uint64_t GetTag< double >()
static const boost::uint64_t IntTag
boost::uint64_t GetTag< float >()
static const boost::uint64_t AnyTag
static const boost::uint64_t VecFloatTag
static const boost::uint64_t VecDoubleTag
static const boost::uint64_t BoolTag
std::int16_t rdvalue_cast< std::int16_t >(RDValue_cast_t v)
int rdvalue_cast< int >(RDValue_cast_t v)
unsigned int rdvalue_cast< unsigned int >(RDValue_cast_t v)
std::uint8_t rdvalue_cast< std::uint8_t >(RDValue_cast_t v)
bool rdvalue_is(const RDValue_cast_t)
std::int64_t rdvalue_cast< std::int64_t >(RDValue_cast_t v)
std::uint64_t rdvalue_cast< std::uint64_t >(RDValue_cast_t v)
double rdvalue_cast< double >(RDValue_cast_t v)
void copy_rdvalue(RDValue &dest, const RDValue &src)
T rdvalue_cast(RDValue_cast_t v)
std::int8_t rdvalue_cast< std::int8_t >(RDValue_cast_t v)
std::uint16_t rdvalue_cast< std::uint16_t >(RDValue_cast_t v)
bool rdvalue_is< double >(const RDValue_cast_t)
bool rdvalue_cast< bool >(RDValue_cast_t v)
float rdvalue_cast< float >(RDValue_cast_t v)
bool rdvalue_is< std::any >(RDValue_cast_t v)
RDValue(const std::vector< int > &v)
RDValue(const std::vector< std::string > &v)
RDValue(const std::vector< double > &v)
RDValue(const std::vector< unsigned int > &v)
boost::uint64_t getTag() const
RDTypeTag::detail::Value value
RDValue(const std::string &v)
RDValue(const std::vector< float > &v)
RDValue(const std::any &v)
static void cleanup_rdvalue(RDValue &rdvalue)
Value(std::vector< std::string > *v)
std::vector< std::string > * vs
Value(std::vector< unsigned int > *v)
Value(std::vector< double > *v)
Value(std::vector< float > *v)
std::vector< unsigned int > * vu
std::vector< float > * vf
std::vector< double > * vd
Value(std::vector< int > *v)