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