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 * CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf( void )
122 // Override to implement copying of variant's data object
123 return new CDataObjectBase();
126 //++ ------------------------------------------------------------------------------------
127 // Details: Determine if *this object is a derived from CDataObjectBase.
128 // Type: Overrideable.
130 // Return: bool - True = *this is derived from CDataObjectBase, false = *this is instance of the this base class.
133 bool CMIUtilVariant::CDataObjectBase::GetIsDerivedClass( void ) const
135 // Override to in the derived class and return true
139 //++ ------------------------------------------------------------------------------------
140 // Details: Perform a bitwise copy of *this object.
141 // Type: Overrideable.
142 // Args: vrOther - (R) The other object.
146 void CMIUtilVariant::CDataObjectBase::Copy( const CDataObjectBase & vrOther )
148 // Override to implement
152 //++ ------------------------------------------------------------------------------------
153 // Details: Release any resources used by *this object.
154 // Type: Overrideable.
159 void CMIUtilVariant::CDataObjectBase::Destroy( void )
161 // Do nothing - override to implement
164 //---------------------------------------------------------------------------------------
165 //---------------------------------------------------------------------------------------
166 //---------------------------------------------------------------------------------------
168 //++ ------------------------------------------------------------------------------------
169 // Details: CDataObject copy constructor.
171 // Args: T - The object's type.
172 // vrOther - (R) The other object.
176 template< typename T >
177 CMIUtilVariant::CDataObject< T >::CDataObject( const CDataObject & vrOther )
179 if( this == &vrOther )
184 //++ ------------------------------------------------------------------------------------
185 // Details: CDataObject copy constructor.
187 // Args: T - The object's type.
188 // vrOther - (R) The other object.
192 template< typename T >
193 CMIUtilVariant::CDataObject< T >::CDataObject( CDataObject & vrOther )
195 if( this == &vrOther )
200 //++ ------------------------------------------------------------------------------------
201 // Details: CDataObject move constructor.
203 // Args: T - The object's type.
204 // vrwOther - (R) The other object.
208 template< typename T >
209 CMIUtilVariant::CDataObject< T >::CDataObject( CDataObject && vrwOther )
211 if( this == &vrwOther )
217 //++ ------------------------------------------------------------------------------------
218 // Details: CDataObject copy assignment.
220 // Args: T - The object's type.
221 // vrOther - (R) The other object.
225 template< typename T >
226 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 >
243 CMIUtilVariant::CDataObject< T > & CMIUtilVariant::CDataObject< T >::operator= ( CDataObject && vrwOther )
245 if( this == &vrwOther )
252 //---------------------------------------------------------------------------------------
253 //---------------------------------------------------------------------------------------
254 //---------------------------------------------------------------------------------------
256 //++ ------------------------------------------------------------------------------------
257 // Details: CMIUtilVariant constructor.
263 CMIUtilVariant::CMIUtilVariant( void )
264 : m_pDataObject( nullptr )
268 //++ ------------------------------------------------------------------------------------
269 // Details: CMIUtilVariant copy constructor.
271 // Args: vrOther - (R) The other object.
275 CMIUtilVariant::CMIUtilVariant( const CMIUtilVariant & vrOther )
276 : m_pDataObject( nullptr )
278 if( this == &vrOther )
284 //++ ------------------------------------------------------------------------------------
285 // Details: CMIUtilVariant copy constructor.
287 // Args: vrOther - (R) The other object.
291 CMIUtilVariant::CMIUtilVariant( CMIUtilVariant & vrOther )
292 : m_pDataObject( nullptr )
294 if( this == &vrOther )
300 //++ ------------------------------------------------------------------------------------
301 // Details: CMIUtilVariant move constructor.
303 // Args: vrwOther - (R) The other object.
307 CMIUtilVariant::CMIUtilVariant( CMIUtilVariant && vrwOther )
308 : m_pDataObject( nullptr )
310 if( this == &vrwOther )
317 //++ ------------------------------------------------------------------------------------
318 // Details: CMIUtilVariant destructor.
324 CMIUtilVariant::~CMIUtilVariant( void )
329 //++ ------------------------------------------------------------------------------------
330 // Details: CMIUtilVariant copy assignment.
332 // Args: vrOther - (R) The other object.
336 CMIUtilVariant & CMIUtilVariant::operator= ( const CMIUtilVariant & vrOther )
338 if( this == &vrOther )
345 //++ ------------------------------------------------------------------------------------
346 // Details: CMIUtilVariant move assignment.
348 // Args: vrwOther - (R) The other object.
352 CMIUtilVariant & CMIUtilVariant::operator= ( CMIUtilVariant && vrwOther )
354 if( this == &vrwOther )
362 //++ ------------------------------------------------------------------------------------
363 // Details: Release the resources used by *this object.
369 void 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.
383 void CMIUtilVariant::Copy( const CMIUtilVariant & vrOther )
387 if( vrOther.m_pDataObject != nullptr )
389 m_pDataObject = vrOther.m_pDataObject->CreateCopyOfSelf();