MyGUI: MyGUI_Any.cpp Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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
10namespace 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#if defined(__clang__)
65 // That's the point of unsafe cast
66 __attribute__((no_sanitize("vptr")))
67#endif
68 void* Any::castUnsafe() const
69 {
70 return mContent ? static_cast<Any::Holder<void*> *>(this->mContent)->held : nullptr;
71 }
72
73 bool Any::compare(const Any& other) const
74 {
75 if (mContent == nullptr && other.mContent == nullptr)
76 return true;
77 return mContent != nullptr && other.mContent != nullptr && mContent->compare(other.mContent);
78 }
79
80} // namespace MyGUI
MyGUI_Any.h
MyGUI_Precompiled.h
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::Any::operator=
Any & operator=(const ValueType &rhs)
Definition MyGUI_Any.h:76
MyGUI::Any::~Any
~Any()
Definition MyGUI_Any.cpp:30
MyGUI::Any::swap
Any & swap(Any &rhs)
Definition MyGUI_Any.cpp:35
MyGUI::Any::castUnsafe
void * castUnsafe() const
Definition MyGUI_Any.cpp:68
MyGUI::Any::getType
const std::type_info & getType() const
Definition MyGUI_Any.cpp:59
MyGUI::Any::Null
static AnyEmpty Null
Definition MyGUI_Any.h:59
MyGUI::Any::empty
bool empty() const
Definition MyGUI_Any.cpp:54
MyGUI::Any::compare
bool compare(const Any &other) const
Definition MyGUI_Any.cpp:73
MyGUI::Any::Any
Any()
Definition MyGUI_Any.cpp:15
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::Any::AnyEmpty
Definition MyGUI_Any.h:58