]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MIUtilVariant.cpp
Merge ^/head r275118 through r275209.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MIUtilVariant.cpp
1 //===-- MIUtilVariant.cpp----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 //++
11 // File:                MIUtilVariant.cpp
12 //
13 // Overview:    CMIUtilVariant implementation.
14 //
15 // Environment: Compilers:      Visual C++ 12.
16 //                                                      gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 //                              Libraries:      See MIReadmetxt. 
18 //
19 // Gotchas:             See CMIUtilVariant class description.
20 //
21 // Copyright:   None.
22 //--
23
24 // In-house headers:
25 #include "MIUtilVariant.h"  
26
27 //++ ------------------------------------------------------------------------------------
28 // Details:     CDataObjectBase constructor.
29 // Type:        Method.
30 // Args:        None.
31 // Return:      None.
32 // Throws:      None.
33 //--
34 CMIUtilVariant::CDataObjectBase::CDataObjectBase( void )
35 {
36 }
37
38 //++ ------------------------------------------------------------------------------------
39 // Details:     CDataObjectBase copy constructor.
40 // Type:        Method.
41 // Args:        vrOther - (R) The other object.
42 // Return:      None.
43 // Throws:      None.
44 //--
45 CMIUtilVariant::CDataObjectBase::CDataObjectBase( const CDataObjectBase & vrOther )
46 {
47         MIunused( vrOther );
48 }
49
50 //++ ------------------------------------------------------------------------------------
51 // Details:     CDataObjectBase copy constructor.
52 // Type:        Method.
53 // Args:        vrOther - (R) The other object.
54 // Return:      None.
55 // Throws:      None.
56 //--
57 CMIUtilVariant::CDataObjectBase::CDataObjectBase( CDataObjectBase & vrOther )
58 {
59         MIunused( vrOther );
60 }
61
62 //++ ------------------------------------------------------------------------------------
63 // Details:     CDataObjectBase move constructor.
64 // Type:        Method.
65 // Args:        vrwOther        - (R) The other object.
66 // Return:      None.
67 // Throws:      None.
68 //--
69 CMIUtilVariant::CDataObjectBase::CDataObjectBase( CDataObjectBase && vrwOther )
70 {
71         MIunused( vrwOther );
72 }
73
74 //++ ------------------------------------------------------------------------------------
75 // Details:     CDataObjectBase destructor.
76 // Type:        Overrideable.
77 // Args:        None.
78 // Return:      None.
79 // Throws:      None.
80 //--
81 CMIUtilVariant::CDataObjectBase::~CDataObjectBase( void )
82 {
83         Destroy();
84 }
85
86 //++ ------------------------------------------------------------------------------------
87 // Details:     CDataObjectBase copy assignment.
88 // Type:        Method.
89 // Args:        vrOther - (R) The other object.
90 // Return:      None.
91 // Throws:      None.
92 //--
93 CMIUtilVariant::CDataObjectBase & CMIUtilVariant::CDataObjectBase::operator= ( const CDataObjectBase & vrOther )
94 {
95         Copy( vrOther );
96         return *this;
97 }
98
99 //++ ------------------------------------------------------------------------------------
100 // Details:     CDataObjectBase move assignment.
101 // Type:        Method.
102 // Args:        vrwOther        - (R) The other object.
103 // Return:      None.
104 // Throws:      None.
105 //--
106 CMIUtilVariant::CDataObjectBase & CMIUtilVariant::CDataObjectBase::operator= ( CDataObjectBase && vrwOther )
107 {
108         Copy( vrwOther );
109         vrwOther.Destroy();
110         return *this;
111 }
112
113 //++ ------------------------------------------------------------------------------------
114 // Details:     Create a new copy of *this class.
115 // Type:        Overrideable.
116 // Args:        None.
117 // Return:      CDataObjectBase *       - Pointer to a new object.
118 // Throws:      None.
119 //--
120 CMIUtilVariant::CDataObjectBase * CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf( void )
121 {
122         // Override to implement copying of variant's data object
123         return new CDataObjectBase();
124 }
125
126 //++ ------------------------------------------------------------------------------------
127 // Details:     Determine if *this object is a derived from CDataObjectBase.
128 // Type:        Overrideable.
129 // Args:        None.
130 // Return:      bool    - True = *this is derived from CDataObjectBase, false = *this is instance of the this base class.
131 // Throws:      None.
132 //--
133 bool CMIUtilVariant::CDataObjectBase::GetIsDerivedClass( void ) const
134 {
135         // Override to in the derived class and return true
136         return false;
137 }
138
139 //++ ------------------------------------------------------------------------------------
140 // Details:     Perform a bitwise copy of *this object.
141 // Type:        Overrideable.
142 // Args:        vrOther - (R) The other object.
143 // Return:      None.
144 // Throws:      None.
145 //--
146 void CMIUtilVariant::CDataObjectBase::Copy( const CDataObjectBase & vrOther )
147 {
148         // Override to implement
149         MIunused( vrOther );
150 }
151
152 //++ ------------------------------------------------------------------------------------
153 // Details:     Release any resources used by *this object.
154 // Type:        Overrideable.
155 // Args:        None.
156 // Return:      None.
157 // Throws:      None.
158 //--
159 void CMIUtilVariant::CDataObjectBase::Destroy( void )
160 {
161         // Do nothing - override to implement
162 }
163
164 //---------------------------------------------------------------------------------------
165 //---------------------------------------------------------------------------------------
166 //---------------------------------------------------------------------------------------
167
168 //++ ------------------------------------------------------------------------------------
169 // Details:     CDataObject copy constructor.
170 // Type:        Method.
171 // Args:        T               - The object's type.
172 //                      vrOther - (R) The other object.
173 // Return:      None.
174 // Throws:      None.
175 //--
176 template< typename T >
177 CMIUtilVariant::CDataObject< T >::CDataObject( const CDataObject & vrOther )
178 {
179         if( this == &vrOther )
180                 return;
181         Copy( vrOther );        
182 }
183
184 //++ ------------------------------------------------------------------------------------
185 // Details:     CDataObject copy constructor.
186 // Type:        Method.
187 // Args:        T               - The object's type.
188 //                      vrOther - (R) The other object.
189 // Return:      None.
190 // Throws:      None.
191 //--
192 template< typename T >
193 CMIUtilVariant::CDataObject< T >::CDataObject( CDataObject & vrOther )
194 {
195         if( this == &vrOther )
196                 return;
197         Copy( vrOther );        
198 }
199
200 //++ ------------------------------------------------------------------------------------
201 // Details:     CDataObject move constructor.
202 // Type:        Method.
203 // Args:        T                       - The object's type.
204 //                      vrwOther        - (R) The other object.
205 // Return:      None.
206 // Throws:      None.
207 //--
208 template< typename T >
209 CMIUtilVariant::CDataObject< T >::CDataObject( CDataObject && vrwOther )
210 {
211         if( this == &vrwOther )
212                 return;
213         Copy( vrwOther );       
214         vrwOther.Destroy();
215 }
216
217 //++ ------------------------------------------------------------------------------------
218 // Details:     CDataObject copy assignment.
219 // Type:        Method.
220 // Args:        T               - The object's type.
221 //                      vrOther - (R) The other object.
222 // Return:      None.
223 // Throws:      None.
224 //--
225 template< typename T >
226 CMIUtilVariant::CDataObject< T > & CMIUtilVariant::CDataObject< T >::operator= ( const CDataObject & vrOther )
227 {
228         if( this == &vrOther )
229                 return *this;
230         Copy( vrOther );
231         return *this;
232 }
233
234 //++ ------------------------------------------------------------------------------------
235 // Details:     CDataObject move assignment.
236 // Type:        Method.
237 // Args:        T                       - The object's type.
238 //                      vrwOther        - (R) The other object.
239 // Return:      None.
240 // Throws:      None.
241 //--
242 template< typename T >
243 CMIUtilVariant::CDataObject< T > & CMIUtilVariant::CDataObject< T >::operator= ( CDataObject && vrwOther )
244 {
245         if( this == &vrwOther )
246                 return *this;
247         Copy( vrwOther );
248         vrwOther.Destroy();
249         return *this;
250 }
251
252 //---------------------------------------------------------------------------------------
253 //---------------------------------------------------------------------------------------
254 //---------------------------------------------------------------------------------------
255
256 //++ ------------------------------------------------------------------------------------
257 // Details:     CMIUtilVariant constructor.
258 // Type:        Method.
259 // Args:        None.
260 // Return:      None.
261 // Throws:      None.
262 //--
263 CMIUtilVariant::CMIUtilVariant( void )
264 :       m_pDataObject( nullptr )
265 {
266 }
267
268 //++ ------------------------------------------------------------------------------------
269 // Details:     CMIUtilVariant copy constructor.
270 // Type:        Method.
271 // Args:        vrOther - (R) The other object.
272 // Return:      None.
273 // Throws:      None.
274 //--
275 CMIUtilVariant::CMIUtilVariant( const CMIUtilVariant & vrOther )
276 :       m_pDataObject( nullptr )
277 {
278         if( this == &vrOther )
279                 return;
280
281         Copy( vrOther );
282 }
283
284 //++ ------------------------------------------------------------------------------------
285 // Details:     CMIUtilVariant copy constructor.
286 // Type:        Method.
287 // Args:        vrOther - (R) The other object.
288 // Return:      None.
289 // Throws:      None.
290 //--
291 CMIUtilVariant::CMIUtilVariant( CMIUtilVariant & vrOther )
292 :       m_pDataObject( nullptr )
293 {
294         if( this == &vrOther )
295                 return;
296
297         Copy( vrOther );
298 }
299
300 //++ ------------------------------------------------------------------------------------
301 // Details:     CMIUtilVariant move constructor.
302 // Type:        Method.
303 // Args:        vrwOther        - (R) The other object.
304 // Return:      None.
305 // Throws:      None.
306 //--
307 CMIUtilVariant::CMIUtilVariant( CMIUtilVariant && vrwOther )
308 :       m_pDataObject( nullptr )
309 {
310         if( this == &vrwOther )
311                 return;
312
313         Copy( vrwOther );
314         vrwOther.Destroy();
315 }
316
317 //++ ------------------------------------------------------------------------------------
318 // Details:     CMIUtilVariant destructor.
319 // Type:        Method.
320 // Args:        None.
321 // Return:      None.
322 // Throws:      None.
323 //--
324 CMIUtilVariant::~CMIUtilVariant( void )
325 {
326         Destroy();
327 }
328
329 //++ ------------------------------------------------------------------------------------
330 // Details:     CMIUtilVariant copy assignment.
331 // Type:        Method.
332 // Args:        vrOther - (R) The other object.
333 // Return:      None.
334 // Throws:      None.
335 //--
336 CMIUtilVariant & CMIUtilVariant::operator= ( const CMIUtilVariant & vrOther )
337 {
338         if( this == &vrOther )
339                 return *this;
340
341         Copy( vrOther );
342         return *this;
343 }
344
345 //++ ------------------------------------------------------------------------------------
346 // Details:     CMIUtilVariant move assignment.
347 // Type:        Method.
348 // Args:        vrwOther        - (R) The other object.
349 // Return:      None.
350 // Throws:      None.
351 //--
352 CMIUtilVariant & CMIUtilVariant::operator= ( CMIUtilVariant && vrwOther )
353 {
354         if( this == &vrwOther )
355                 return *this;
356
357         Copy( vrwOther );
358         vrwOther.Destroy();
359         return *this;
360 }
361
362 //++ ------------------------------------------------------------------------------------
363 // Details:     Release the resources used by *this object.
364 // Type:        Method.
365 // Args:        None.
366 // Return:      None.
367 // Throws:      None.
368 //--
369 void CMIUtilVariant::Destroy( void )
370 {
371         if( m_pDataObject != nullptr )
372                 delete m_pDataObject;
373         m_pDataObject = nullptr;
374 }
375
376 //++ ------------------------------------------------------------------------------------
377 // Details:     Bitwise copy another data object to *this variant object.
378 // Type:        Method.
379 // Args:        vrOther - (R) The other object.
380 // Return:      None.
381 // Throws:      None.
382 //--
383 void CMIUtilVariant::Copy( const CMIUtilVariant & vrOther )
384 {
385         Destroy();
386         
387         if( vrOther.m_pDataObject != nullptr )
388         {
389                 m_pDataObject = vrOther.m_pDataObject->CreateCopyOfSelf();
390         }
391 }
392