1 //===-- MIUtilVariant.cpp----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // File: MIUtilVariant.cpp
13 // Overview: CMIUtilVariant implementation.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
19 // Gotchas: See CMIUtilVariant class description.
25 #include "MIUtilVariant.h"
27 //++ ------------------------------------------------------------------------------------
28 // Details: CDataObjectBase constructor.
34 CMIUtilVariant::CDataObjectBase::CDataObjectBase(void)
38 //++ ------------------------------------------------------------------------------------
39 // Details: CDataObjectBase copy constructor.
41 // Args: vrOther - (R) The other object.
45 CMIUtilVariant::CDataObjectBase::CDataObjectBase(const CDataObjectBase &vrOther)
50 //++ ------------------------------------------------------------------------------------
51 // Details: CDataObjectBase copy constructor.
53 // Args: vrOther - (R) The other object.
57 CMIUtilVariant::CDataObjectBase::CDataObjectBase(CDataObjectBase &vrOther)
62 //++ ------------------------------------------------------------------------------------
63 // Details: CDataObjectBase move constructor.
65 // Args: vrwOther - (R) The other object.
69 CMIUtilVariant::CDataObjectBase::CDataObjectBase(CDataObjectBase &&vrwOther)
74 //++ ------------------------------------------------------------------------------------
75 // Details: CDataObjectBase destructor.
76 // Type: Overrideable.
81 CMIUtilVariant::CDataObjectBase::~CDataObjectBase(void)
86 //++ ------------------------------------------------------------------------------------
87 // Details: CDataObjectBase copy assignment.
89 // Args: vrOther - (R) The other object.
93 CMIUtilVariant::CDataObjectBase &CMIUtilVariant::CDataObjectBase::operator=(const CDataObjectBase &vrOther)
99 //++ ------------------------------------------------------------------------------------
100 // Details: CDataObjectBase move assignment.
102 // Args: vrwOther - (R) The other object.
106 CMIUtilVariant::CDataObjectBase &CMIUtilVariant::CDataObjectBase::operator=(CDataObjectBase &&vrwOther)
113 //++ ------------------------------------------------------------------------------------
114 // Details: Create a new copy of *this class.
115 // Type: Overrideable.
117 // Return: CDataObjectBase * - Pointer to a new object.
120 CMIUtilVariant::CDataObjectBase *
121 CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf(void)
123 // Override to implement copying of variant's data object
124 return new CDataObjectBase();
127 //++ ------------------------------------------------------------------------------------
128 // Details: Determine if *this object is a derived from CDataObjectBase.
129 // Type: Overrideable.
131 // Return: bool - True = *this is derived from CDataObjectBase, false = *this is instance of the this base class.
135 CMIUtilVariant::CDataObjectBase::GetIsDerivedClass(void) const
137 // Override to in the derived class and return true
141 //++ ------------------------------------------------------------------------------------
142 // Details: Perform a bitwise copy of *this object.
143 // Type: Overrideable.
144 // Args: vrOther - (R) The other object.
149 CMIUtilVariant::CDataObjectBase::Copy(const CDataObjectBase &vrOther)
151 // Override to implement
155 //++ ------------------------------------------------------------------------------------
156 // Details: Release any resources used by *this object.
157 // Type: Overrideable.
163 CMIUtilVariant::CDataObjectBase::Destroy(void)
165 // Do nothing - override to implement
168 //---------------------------------------------------------------------------------------
169 //---------------------------------------------------------------------------------------
170 //---------------------------------------------------------------------------------------
172 //++ ------------------------------------------------------------------------------------
173 // Details: CDataObject copy constructor.
175 // Args: T - The object's type.
176 // vrOther - (R) The other object.
180 template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(const CDataObject &vrOther)
182 if (this == &vrOther)
187 //++ ------------------------------------------------------------------------------------
188 // Details: CDataObject copy constructor.
190 // Args: T - The object's type.
191 // vrOther - (R) The other object.
195 template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(CDataObject &vrOther)
197 if (this == &vrOther)
202 //++ ------------------------------------------------------------------------------------
203 // Details: CDataObject move constructor.
205 // Args: T - The object's type.
206 // vrwOther - (R) The other object.
210 template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(CDataObject &&vrwOther)
212 if (this == &vrwOther)
218 //++ ------------------------------------------------------------------------------------
219 // Details: CDataObject copy assignment.
221 // Args: T - The object's type.
222 // vrOther - (R) The other object.
226 template <typename T> CMIUtilVariant::CDataObject<T> &CMIUtilVariant::CDataObject<T>::operator=(const CDataObject &vrOther)
228 if (this == &vrOther)
234 //++ ------------------------------------------------------------------------------------
235 // Details: CDataObject move assignment.
237 // Args: T - The object's type.
238 // vrwOther - (R) The other object.
242 template <typename T> CMIUtilVariant::CDataObject<T> &CMIUtilVariant::CDataObject<T>::operator=(CDataObject &&vrwOther)
244 if (this == &vrwOther)
251 //---------------------------------------------------------------------------------------
252 //---------------------------------------------------------------------------------------
253 //---------------------------------------------------------------------------------------
255 //++ ------------------------------------------------------------------------------------
256 // Details: CMIUtilVariant constructor.
262 CMIUtilVariant::CMIUtilVariant(void)
263 : m_pDataObject(nullptr)
267 //++ ------------------------------------------------------------------------------------
268 // Details: CMIUtilVariant copy constructor.
270 // Args: vrOther - (R) The other object.
274 CMIUtilVariant::CMIUtilVariant(const CMIUtilVariant &vrOther)
275 : m_pDataObject(nullptr)
277 if (this == &vrOther)
283 //++ ------------------------------------------------------------------------------------
284 // Details: CMIUtilVariant copy constructor.
286 // Args: vrOther - (R) The other object.
290 CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &vrOther)
291 : m_pDataObject(nullptr)
293 if (this == &vrOther)
299 //++ ------------------------------------------------------------------------------------
300 // Details: CMIUtilVariant move constructor.
302 // Args: vrwOther - (R) The other object.
306 CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &&vrwOther)
307 : m_pDataObject(nullptr)
309 if (this == &vrwOther)
316 //++ ------------------------------------------------------------------------------------
317 // Details: CMIUtilVariant destructor.
323 CMIUtilVariant::~CMIUtilVariant(void)
328 //++ ------------------------------------------------------------------------------------
329 // Details: CMIUtilVariant copy assignment.
331 // Args: vrOther - (R) The other object.
335 CMIUtilVariant &CMIUtilVariant::operator=(const CMIUtilVariant &vrOther)
337 if (this == &vrOther)
344 //++ ------------------------------------------------------------------------------------
345 // Details: CMIUtilVariant move assignment.
347 // Args: vrwOther - (R) The other object.
351 CMIUtilVariant &CMIUtilVariant::operator=(CMIUtilVariant &&vrwOther)
353 if (this == &vrwOther)
361 //++ ------------------------------------------------------------------------------------
362 // Details: Release the resources used by *this object.
369 CMIUtilVariant::Destroy(void)
371 if (m_pDataObject != nullptr)
372 delete m_pDataObject;
373 m_pDataObject = nullptr;
376 //++ ------------------------------------------------------------------------------------
377 // Details: Bitwise copy another data object to *this variant object.
379 // Args: vrOther - (R) The other object.
384 CMIUtilVariant::Copy(const CMIUtilVariant &vrOther)
388 if (vrOther.m_pDataObject != nullptr)
390 m_pDataObject = vrOther.m_pDataObject->CreateCopyOfSelf();