30 #ifndef __MYGUI_ANY_H__
31 #define __MYGUI_ANY_H__
37 #ifndef MYGUI_RTTI_DISABLE_TYPE_INFO
91 template<
typename ValueType>
92 Any(
const ValueType& value) :
93 mContent(new Holder<ValueType>(value))
101 template<
typename ValueType>
102 Any& operator = (
const ValueType& rhs)
109 Any& operator = (
const Any& rhs);
113 #ifndef MYGUI_RTTI_DISABLE_TYPE_INFO
114 const std::type_info& getType()
const;
116 template<
typename ValueType>
119 if (this->getType() ==
typeid(ValueType))
120 return &
static_cast<Any::Holder<ValueType> *
>(this->mContent)->held;
121 MYGUI_ASSERT(!_throw,
"Bad cast from type '" << getType().name() <<
"' to '" <<
typeid(ValueType).name() <<
"'");
125 template<
typename ValueType>
126 ValueType* castType(
bool _throw =
true)
const
128 Any::Holder<ValueType>* data =
dynamic_cast<Any::Holder<ValueType> *
>(this->mContent);
136 void* castUnsafe()
const;
142 virtual ~Placeholder() { }
145 #ifndef MYGUI_RTTI_DISABLE_TYPE_INFO
146 virtual const std::type_info& getType()
const = 0;
148 virtual Placeholder* clone()
const = 0;
151 template<
typename ValueType>
156 Holder(
const ValueType& value) :
162 #ifndef MYGUI_RTTI_DISABLE_TYPE_INFO
163 virtual const std::type_info& getType()
const
165 return typeid(ValueType);
169 virtual Placeholder* clone()
const
171 return new Holder(held);
178 Holder& operator=(
const Holder&);
182 Placeholder* mContent;
187 #endif // __MYGUI_ANY_H__
ValueType * castType(bool _throw=true) const
#define MYGUI_ASSERT(exp, dest)
Any(const ValueType &value)