14 #ifndef __MYGUI_ANY_H__
15 #define __MYGUI_ANY_H__
73 template<
typename ValueType>
74 Any(
const ValueType& value) :
75 mContent(new Holder<ValueType>(value))
83 template<
typename ValueType>
84 Any& operator = (
const ValueType& rhs)
91 Any& operator = (
const Any& rhs);
95 const std::type_info& getType()
const;
97 template<
typename ValueType>
98 ValueType* castType(
bool _throw =
true)
const
100 if (this->getType() ==
typeid(ValueType))
101 return &
static_cast<Any::Holder<ValueType> *
>(this->mContent)->held;
102 MYGUI_ASSERT(!_throw,
"Bad cast from type '" << getType().name() <<
"' to '" <<
typeid(ValueType).name() <<
"'");
106 void* castUnsafe()
const;
112 virtual ~Placeholder() { }
115 virtual const std::type_info& getType()
const = 0;
116 virtual Placeholder* clone()
const = 0;
119 template<
typename ValueType>
124 Holder(
const ValueType& value) :
130 virtual const std::type_info& getType()
const
132 return typeid(ValueType);
135 virtual Placeholder* clone()
const
137 return new Holder(held);
144 Holder& operator=(
const Holder&);
148 Placeholder* mContent;
153 #endif // __MYGUI_ANY_H__