MyGUI
3.2.1
|
00001 /* 00002 * This source file is part of MyGUI. For the latest info, see http://mygui.info/ 00003 * Distributed under the MIT License 00004 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 00005 */ 00006 00007 #include "MyGUI_Precompiled.h" 00008 #include "MyGUI_Any.h" 00009 00010 namespace MyGUI 00011 { 00012 00013 Any::AnyEmpty Any::Null; 00014 00015 Any::Any() : 00016 mContent(nullptr) 00017 { 00018 } 00019 00020 Any::Any(const Any::AnyEmpty& value) : 00021 mContent(nullptr) 00022 { 00023 } 00024 00025 Any::Any(const Any& other) : 00026 mContent(other.mContent ? other.mContent->clone() : nullptr) 00027 { 00028 } 00029 00030 Any::~Any() 00031 { 00032 delete mContent; 00033 } 00034 00035 Any& Any::swap(Any& rhs) 00036 { 00037 std::swap(mContent, rhs.mContent); 00038 return *this; 00039 } 00040 00041 Any& Any::operator = (const Any::AnyEmpty& rhs) 00042 { 00043 delete mContent; 00044 mContent = nullptr; 00045 return *this; 00046 } 00047 00048 Any& Any::operator = (const Any& rhs) 00049 { 00050 Any(rhs).swap(*this); 00051 return *this; 00052 } 00053 00054 bool Any::empty() const 00055 { 00056 return !mContent; 00057 } 00058 00059 const std::type_info& Any::getType() const 00060 { 00061 return mContent ? mContent->getType() : typeid(void); 00062 } 00063 00064 void* Any::castUnsafe() const 00065 { 00066 return mContent ? static_cast<Any::Holder<void*> *>(this->mContent)->held : nullptr; 00067 } 00068 00069 } // namespace MyGUI