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