32#ifndef RDKIT_RDVALUE_PTRMAGIC_H
33#define RDKIT_RDVALUE_PTRMAGIC_H
45#include <boost/utility.hpp>
46#include <boost/lexical_cast.hpp>
47#include <boost/type_traits.hpp>
48#include <boost/static_assert.hpp>
53#define RDVALUE_HASBOOL
94static const boost::uint64_t
NaN = 0xfff7FFFFFFFFFFFF;
95static const boost::uint64_t
MaxDouble = 0xfff8000000000000;
96static const boost::uint64_t
DoubleTag = 0xfff8000000000000;
97static const boost::uint64_t
FloatTag = 0xfff9000000000000;
98static const boost::uint64_t
IntTag = 0xfffa000000000000;
100static const boost::uint64_t
BoolTag = 0xfffc000000000000;
103static const boost::uint64_t
PtrTag = 0xffff000000000000;
104static const boost::uint64_t
StringTag = 0xffff000000000001;
107static const boost::uint64_t
VecIntTag = 0xffff000000000004;
110static const boost::uint64_t
AnyTag = 0xffff000000000007;
169 static const boost::uint64_t
TagMask = 0xFFFF000000000000;
171 static const boost::uint64_t
ApplyMask = 0x0000FFFFFFFFFFFF;
182 if (boost::math::isnan(number)) {
219 std::any *pointer =
new std::any(
any);
228 std::any *pointer =
new std::any(v);
235 std::string *pointer =
new std::string(v);
236 assert((
reinterpret_cast<boost::uint64_t
>(pointer) &
242 inline RDValue(
const std::vector<double> &v) {
243 std::vector<double> *pointer =
new std::vector<double>(v);
244 assert((
reinterpret_cast<boost::uint64_t
>(pointer) &
251 std::vector<float> *pointer =
new std::vector<float>(v);
252 assert((
reinterpret_cast<boost::uint64_t
>(pointer) &
259 std::vector<int> *pointer =
new std::vector<int>(v);
260 assert((
reinterpret_cast<boost::uint64_t
>(pointer) &
266 inline RDValue(
const std::vector<unsigned int> &v) {
267 std::vector<unsigned int> *pointer =
new std::vector<unsigned int>(v);
268 assert((
reinterpret_cast<boost::uint64_t
>(pointer) &
270 otherBits =
reinterpret_cast<boost::uint64_t
>(pointer) |
274 inline RDValue(
const std::vector<std::string> &v) {
275 std::vector<std::string> *pointer =
new std::vector<std::string>(v);
276 assert((
reinterpret_cast<boost::uint64_t
>(pointer) &
341 switch (
src.getTag()) {
374 RDTypeTag::GetTag<typename boost::remove_reference<T>::type>();
375 if (v.getTag() ==
tag)
return true;
379 return v.value.a->type() ==
typeid(T);
423 (boost::is_pointer<T>::value &&
424 (boost::is_integral<
typename boost::remove_pointer<T>::type>::value ||
425 boost::is_floating_point<
426 typename boost::remove_pointer<T>::type>::value)) ||
427 (boost::is_reference<T>::value &&
428 (boost::is_integral<
typename boost::remove_reference<T>::type>::value ||
429 boost::is_floating_point<
430 typename boost::remove_reference<T>::type>::value))));
433 return std::any_cast<T>(*v.
ptrCast<std::any>());
435 throw std::bad_any_cast();
442 throw std::bad_any_cast();
452 throw std::bad_any_cast();
461 throw std::bad_any_cast();
467 throw std::bad_any_cast();
474 throw std::bad_any_cast();
static const boost::uint64_t NaN
boost::uint64_t GetTag< int >()
static const boost::uint64_t UnsignedIntTag
static const boost::uint64_t StringTag
boost::uint64_t GetTag< std::string >()
static const boost::uint64_t MaxDouble
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 PtrTag
static const boost::uint64_t VecFloatTag
static const boost::uint64_t VecDoubleTag
static const boost::uint64_t BoolTag
int rdvalue_cast< int >(RDValue_cast_t v)
unsigned int rdvalue_cast< unsigned int >(RDValue_cast_t v)
bool rdvalue_is(const RDValue_cast_t)
double rdvalue_cast< double >(RDValue_cast_t v)
bool rdvalue_is< const double & >(const RDValue_cast_t)
void copy_rdvalue(RDValue &dest, const RDValue &src)
T rdvalue_cast(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)
static const boost::uint64_t TagMask
RDValue(const std::vector< double > &v)
RDValue(const std::vector< unsigned int > &v)
boost::uint64_t getTag() const
RDValue(const std::any &any)
static const boost::uint64_t ApplyPtrMask
boost::uint64_t otherBits
RDValue(const std::string &v)
RDValue(unsigned int number)
RDValue(const std::vector< float > &v)
static void cleanup_rdvalue(RDValue v)
static const boost::uint64_t PointerTagMask
RDValue(std::any *pointer)
static const boost::uint64_t ApplyMask