MyGUI  3.2.0
MyGUI_Any.cpp
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "MyGUI_Precompiled.h"
24 #include "MyGUI_Any.h"
25 
26 namespace MyGUI
27 {
28 
29  Any::AnyEmpty Any::Null;
30 
32  mContent(nullptr)
33  {
34  }
35 
36  Any::Any(const Any::AnyEmpty& value) :
37  mContent(nullptr)
38  {
39  }
40 
41  Any::Any(const Any& other) :
42  mContent(other.mContent ? other.mContent->clone() : nullptr)
43  {
44  }
45 
47  {
48  delete mContent;
49  }
50 
51  Any& Any::swap(Any& rhs)
52  {
53  std::swap(mContent, rhs.mContent);
54  return *this;
55  }
56 
58  {
59  delete mContent;
60  mContent = nullptr;
61  return *this;
62  }
63 
64  Any& Any::operator = (const Any& rhs)
65  {
66  Any(rhs).swap(*this);
67  return *this;
68  }
69 
70  bool Any::empty() const
71  {
72  return !mContent;
73  }
74 
75 #ifndef MYGUI_RTTI_DISABLE_TYPE_INFO
76  const std::type_info& Any::getType() const
77  {
78  return mContent ? mContent->getType() : typeid(void);
79  }
80 #endif
81 
82  void* Any::castUnsafe() const
83  {
84  return mContent ? static_cast<Any::Holder<void*> *>(this->mContent)->held : nullptr;
85  }
86 
87 } // namespace MyGUI
void * castUnsafe() const
Definition: MyGUI_Any.cpp:82
Any & swap(Any &rhs)
Definition: MyGUI_Any.cpp:51
Any & operator=(const ValueType &rhs)
Definition: MyGUI_Any.h:102
#define nullptr
const std::type_info & getType() const
Definition: MyGUI_Any.cpp:76
bool empty() const
Definition: MyGUI_Any.cpp:70
static AnyEmpty Null
Definition: MyGUI_Any.h:85