MyGUI: MyGUI_Any.cpp Source File

MyGUI 3.2.2

MyGUI_Any.cpp
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #include "MyGUI_Precompiled.h"
8 #include "MyGUI_Any.h"
9
10 namespace MyGUI
11 {
12
13 Any::AnyEmpty Any::Null;
14
15 Any::Any() :
16 mContent(nullptr)
17 {
18 }
19
20 Any::Any(const Any::AnyEmpty& value) :
21 mContent(nullptr)
22 {
23 }
24
25 Any::Any(const Any& other) :
26 mContent(other.mContent ? other.mContent->clone() : nullptr)
27 {
28 }
29
30 Any::~Any()
31 {
32 delete mContent;
33 }
34
35 Any& Any::swap(Any& rhs)
36 {
37 std::swap(mContent, rhs.mContent);
38 return *this;
39 }
40
41 Any& Any::operator = (const Any::AnyEmpty& rhs)
42 {
43 delete mContent;
44 mContent = nullptr;
45 return *this;
46 }
47
48 Any& Any::operator = (const Any& rhs)
49 {
50 Any(rhs).swap(*this);
51 return *this;
52 }
53
54 bool Any::empty() const
55 {
56 return !mContent;
57 }
58
59 const std::type_info& Any::getType() const
60 {
61 return mContent ? mContent->getType() : typeid(void);
62 }
63
64 void* Any::castUnsafe() const
65 {
66 return mContent ? static_cast<Any::Holder<void*> *>(this->mContent)->held : nullptr;
67 }
68
69 } // namespace MyGUI
MyGUI::Any::operator=
Any & operator=(const ValueType &rhs)
Definition: MyGUI_Any.h:84
MyGUI::Any::getType
const std::type_info & getType() const
Definition: MyGUI_Any.cpp:59
MyGUI::Any::AnyEmpty
Definition: MyGUI_Any.h:66
MyGUI::Any::swap
Any & swap(Any &rhs)
Definition: MyGUI_Any.cpp:35
MyGUI::Any
Definition: MyGUI_Any.h:63
MyGUI_Precompiled.h
MyGUI::Any::empty
bool empty() const
Definition: MyGUI_Any.cpp:54
nullptr
#define nullptr
Definition: MyGUI_Prerequest.h:29
MyGUI::Any::Any
Any()
Definition: MyGUI_Any.cpp:15
MyGUI::Any::castUnsafe
void * castUnsafe() const
Definition: MyGUI_Any.cpp:64
MyGUI::Any::Null
static AnyEmpty Null
Definition: MyGUI_Any.h:67
MyGUI::Any::~Any
~Any()
Definition: MyGUI_Any.cpp:30
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI_Any.h