]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MIUtilVariant.cpp
Update LLDB snapshot to upstream r225923 (git 2b588ecd)
[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 *
121 CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf(void)
122 {
123     // Override to implement copying of variant's data object
124     return new CDataObjectBase();
125 }
126
127 //++ ------------------------------------------------------------------------------------
128 // Details: Determine if *this object is a derived from CDataObjectBase.
129 // Type:    Overrideable.
130 // Args:    None.
131 // Return:  bool    - True = *this is derived from CDataObjectBase, false = *this is instance of the this base class.
132 // Throws:  None.
133 //--
134 bool
135 CMIUtilVariant::CDataObjectBase::GetIsDerivedClass(void) const
136 {
137     // Override to in the derived class and return true
138     return false;
139 }
140
141 //++ ------------------------------------------------------------------------------------
142 // Details: Perform a bitwise copy of *this object.
143 // Type:    Overrideable.
144 // Args:    vrOther - (R) The other object.
145 // Return:  None.
146 // Throws:  None.
147 //--
148 void
149 CMIUtilVariant::CDataObjectBase::Copy(const CDataObjectBase &vrOther)
150 {
151     // Override to implement
152     MIunused(vrOther);
153 }
154
155 //++ ------------------------------------------------------------------------------------
156 // Details: Release any resources used by *this object.
157 // Type:    Overrideable.
158 // Args:    None.
159 // Return:  None.
160 // Throws:  None.
161 //--
162 void
163 CMIUtilVariant::CDataObjectBase::Destroy(void)
164 {
165     // Do nothing - override to implement
166 }
167
168 //---------------------------------------------------------------------------------------
169 //---------------------------------------------------------------------------------------
170 //---------------------------------------------------------------------------------------
171
172 //++ ------------------------------------------------------------------------------------
173 // Details: CDataObject copy constructor.
174 // Type:    Method.
175 // Args:    T       - The object's type.
176 //          vrOther - (R) The other object.
177 // Return:  None.
178 // Throws:  None.
179 //--
180 template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(const CDataObject &vrOther)
181 {
182     if (this == &vrOther)
183         return;
184     Copy(vrOther);
185 }
186
187 //++ ------------------------------------------------------------------------------------
188 // Details: CDataObject copy constructor.
189 // Type:    Method.
190 // Args:    T       - The object's type.
191 //          vrOther - (R) The other object.
192 // Return:  None.
193 // Throws:  None.
194 //--
195 template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(CDataObject &vrOther)
196 {
197     if (this == &vrOther)
198         return;
199     Copy(vrOther);
200 }
201
202 //++ ------------------------------------------------------------------------------------
203 // Details: CDataObject move constructor.
204 // Type:    Method.
205 // Args:    T           - The object's type.
206 //          vrwOther    - (R) The other object.
207 // Return:  None.
208 // Throws:  None.
209 //--
210 template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject(CDataObject &&vrwOther)
211 {
212     if (this == &vrwOther)
213         return;
214     Copy(vrwOther);
215     vrwOther.Destroy();
216 }
217
218 //++ ------------------------------------------------------------------------------------
219 // Details: CDataObject copy assignment.
220 // Type:    Method.
221 // Args:    T       - The object's type.
222 //          vrOther - (R) The other object.
223 // Return:  None.
224 // Throws:  None.
225 //--
226 template <typename T> 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> CMIUtilVariant::CDataObject<T> &CMIUtilVariant::CDataObject<T>::operator=(CDataObject &&vrwOther)
243 {
244     if (this == &vrwOther)
245         return *this;
246     Copy(vrwOther);
247     vrwOther.Destroy();
248     return *this;
249 }
250
251 //---------------------------------------------------------------------------------------
252 //---------------------------------------------------------------------------------------
253 //---------------------------------------------------------------------------------------
254
255 //++ ------------------------------------------------------------------------------------
256 // Details: CMIUtilVariant constructor.
257 // Type:    Method.
258 // Args:    None.
259 // Return:  None.
260 // Throws:  None.
261 //--
262 CMIUtilVariant::CMIUtilVariant(void)
263     : m_pDataObject(nullptr)
264 {
265 }
266
267 //++ ------------------------------------------------------------------------------------
268 // Details: CMIUtilVariant copy constructor.
269 // Type:    Method.
270 // Args:    vrOther - (R) The other object.
271 // Return:  None.
272 // Throws:  None.
273 //--
274 CMIUtilVariant::CMIUtilVariant(const CMIUtilVariant &vrOther)
275     : m_pDataObject(nullptr)
276 {
277     if (this == &vrOther)
278         return;
279
280     Copy(vrOther);
281 }
282
283 //++ ------------------------------------------------------------------------------------
284 // Details: CMIUtilVariant copy constructor.
285 // Type:    Method.
286 // Args:    vrOther - (R) The other object.
287 // Return:  None.
288 // Throws:  None.
289 //--
290 CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &vrOther)
291     : m_pDataObject(nullptr)
292 {
293     if (this == &vrOther)
294         return;
295
296     Copy(vrOther);
297 }
298
299 //++ ------------------------------------------------------------------------------------
300 // Details: CMIUtilVariant move constructor.
301 // Type:    Method.
302 // Args:    vrwOther    - (R) The other object.
303 // Return:  None.
304 // Throws:  None.
305 //--
306 CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &&vrwOther)
307     : m_pDataObject(nullptr)
308 {
309     if (this == &vrwOther)
310         return;
311
312     Copy(vrwOther);
313     vrwOther.Destroy();
314 }
315
316 //++ ------------------------------------------------------------------------------------
317 // Details: CMIUtilVariant destructor.
318 // Type:    Method.
319 // Args:    None.
320 // Return:  None.
321 // Throws:  None.
322 //--
323 CMIUtilVariant::~CMIUtilVariant(void)
324 {
325     Destroy();
326 }
327
328 //++ ------------------------------------------------------------------------------------
329 // Details: CMIUtilVariant copy assignment.
330 // Type:    Method.
331 // Args:    vrOther - (R) The other object.
332 // Return:  None.
333 // Throws:  None.
334 //--
335 CMIUtilVariant &CMIUtilVariant::operator=(const CMIUtilVariant &vrOther)
336 {
337     if (this == &vrOther)
338         return *this;
339
340     Copy(vrOther);
341     return *this;
342 }
343
344 //++ ------------------------------------------------------------------------------------
345 // Details: CMIUtilVariant move assignment.
346 // Type:    Method.
347 // Args:    vrwOther    - (R) The other object.
348 // Return:  None.
349 // Throws:  None.
350 //--
351 CMIUtilVariant &CMIUtilVariant::operator=(CMIUtilVariant &&vrwOther)
352 {
353     if (this == &vrwOther)
354         return *this;
355
356     Copy(vrwOther);
357     vrwOther.Destroy();
358     return *this;
359 }
360
361 //++ ------------------------------------------------------------------------------------
362 // Details: Release the resources used by *this object.
363 // Type:    Method.
364 // Args:    None.
365 // Return:  None.
366 // Throws:  None.
367 //--
368 void
369 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
384 CMIUtilVariant::Copy(const CMIUtilVariant &vrOther)
385 {
386     Destroy();
387
388     if (vrOther.m_pDataObject != nullptr)
389     {
390         m_pDataObject = vrOther.m_pDataObject->CreateCopyOfSelf();
391     }
392 }