LibreOffice Module cppu (master) 1
eq.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
21#include <cmath>
22#include <string.h>
23
24#include <o3tl/intcmp.hxx>
25#include <osl/diagnose.h>
26#include <rtl/ustring.hxx>
27
28#include "prim.hxx"
29
30
31namespace cppu
32{
33
34
35//#### equality ####################################################################################
36
37
38inline bool _equalObject(
39 void * pI1, void * pI2,
40 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
41{
42 if (pI1 == pI2)
43 return true;
44 if ((nullptr == pI1) || (nullptr == pI2))
45 return false;
46 bool bRet = false;
47
48 typelib_TypeDescriptionReference * type_XInterface =
49 * typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE );
50 if (nullptr == queryInterface)
52 pI1 = (*queryInterface)( pI1, type_XInterface );
53 if (nullptr != pI1)
54 {
55 pI2 = (*queryInterface)( pI2, type_XInterface );
56 if (nullptr != pI2)
57 {
58 bRet = (pI1 == pI2);
59 _release( pI2, release );
60 }
61 _release( pI1, release );
62 }
63 return bRet;
64}
65
66
67bool equalStruct(
68 void * pDest, void *pSource,
69 typelib_CompoundTypeDescription * pTypeDescr,
70 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
71
72inline bool _equalStruct(
73 void * pDest, void *pSource,
74 typelib_CompoundTypeDescription * pTypeDescr,
75 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
76{
77 if (pTypeDescr->pBaseTypeDescription &&
78 !equalStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription, queryInterface, release ))
79 {
80 return false;
81 }
82
83 typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
84 sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
85 sal_Int32 nDescr = pTypeDescr->nMembers;
86
87 while (nDescr--)
88 {
89 sal_Int32 nOffset = pMemberOffsets[nDescr];
90 if (! ::uno_type_equalData( static_cast<char *>(pDest) + nOffset,
91 ppTypeRefs[nDescr],
92 static_cast<char *>(pSource) + nOffset,
93 ppTypeRefs[nDescr],
94 queryInterface, release ))
95 {
96 return false;
97 }
98 }
99 return true;
100}
101
102bool equalSequence(
103 uno_Sequence * pDest, uno_Sequence * pSource,
104 typelib_TypeDescriptionReference * pElementType,
105 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release );
106
107inline bool _equalSequence(
108 uno_Sequence * pDest, uno_Sequence * pSource,
109 typelib_TypeDescriptionReference * pElementType,
110 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
111{
112 if (pDest == pSource)
113 return true;
114 sal_Int32 nElements = pDest->nElements;
115 if (nElements != pSource->nElements)
116 return false;
117 if (! nElements)
118 return true;
119
120 void * pDestElements = pDest->elements;
121 void * pSourceElements = pSource->elements;
122
123 switch (pElementType->eTypeClass)
124 {
125 case typelib_TypeClass_CHAR:
126 return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Unicode) * nElements ));
127 case typelib_TypeClass_BOOLEAN:
128 {
129 for ( sal_Int32 nPos = nElements; nPos--; )
130 {
131 if (bool(static_cast<sal_Bool *>(pDestElements)[nPos]) !=
132 bool(static_cast<sal_Bool *>(pSourceElements)[nPos]))
133 {
134 return false;
135 }
136 }
137 return true;
138 }
139 case typelib_TypeClass_BYTE:
140 return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int8) * nElements ));
141 case typelib_TypeClass_SHORT:
142 case typelib_TypeClass_UNSIGNED_SHORT:
143 return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int16) * nElements ));
144 case typelib_TypeClass_LONG:
145 case typelib_TypeClass_UNSIGNED_LONG:
146 return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
147 case typelib_TypeClass_HYPER:
148 case typelib_TypeClass_UNSIGNED_HYPER:
149 return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int64) * nElements ));
150 case typelib_TypeClass_FLOAT:
151 {
152 for ( sal_Int32 nPos = nElements; nPos--; )
153 {
154 if (static_cast<float *>(pDestElements)[nPos] != static_cast<float *>(pSourceElements)[nPos])
155 return false;
156 }
157 return true;
158 }
159 case typelib_TypeClass_DOUBLE:
160 {
161 for ( sal_Int32 nPos = nElements; nPos--; )
162 {
163 if (static_cast<double *>(pDestElements)[nPos] != static_cast<double *>(pSourceElements)[nPos])
164 return false;
165 }
166 return true;
167 }
168 case typelib_TypeClass_STRING:
169 {
170 for ( sal_Int32 nPos = nElements; nPos--; )
171 {
172 if ( static_cast<OUString *>(pDestElements)[nPos] != static_cast<const OUString *>(pSourceElements)[nPos] )
173 return false;
174 }
175 return true;
176 }
177 case typelib_TypeClass_TYPE:
178 {
179 for ( sal_Int32 nPos = nElements; nPos--; )
180 {
181 if (! _type_equals( static_cast<typelib_TypeDescriptionReference **>(pDestElements)[nPos],
182 static_cast<typelib_TypeDescriptionReference **>(pSourceElements)[nPos] ))
183 {
184 return false;
185 }
186 }
187 return true;
188 }
189 case typelib_TypeClass_ANY:
190 {
191 for ( sal_Int32 nPos = nElements; nPos--; )
192 {
193 uno_Any * pDest2 = static_cast<uno_Any *>(pDestElements) + nPos;
194 uno_Any * pSource2 = static_cast<uno_Any *>(pSourceElements) + nPos;
195 if (! ::uno_type_equalData( pDest2->pData, pDest2->pType,
196 pSource2->pData, pSource2->pType,
197 queryInterface, release ))
198 {
199 return false;
200 }
201 }
202 return true;
203 }
204 case typelib_TypeClass_ENUM:
205 return (0 == memcmp( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements ));
206 case typelib_TypeClass_STRUCT:
207 case typelib_TypeClass_EXCEPTION:
208 {
209 typelib_TypeDescription * pElementTypeDescr = nullptr;
210 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
211 sal_Int32 nElementSize = pElementTypeDescr->nSize;
212 for ( sal_Int32 nPos = nElements; nPos--; )
213 {
214 if (! _equalStruct( static_cast<char *>(pDestElements) + (nPos * nElementSize),
215 static_cast<char *>(pSourceElements) + (nPos * nElementSize),
216 reinterpret_cast<typelib_CompoundTypeDescription *>(pElementTypeDescr),
217 queryInterface, release ))
218 {
219 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
220 return false;
221 }
222 }
223 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
224 return true;
225 }
226 case typelib_TypeClass_SEQUENCE: // sequence of sequence
227 {
228 typelib_TypeDescription * pElementTypeDescr = nullptr;
229 TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType );
230 typelib_TypeDescriptionReference * pSeqElementType =
231 reinterpret_cast<typelib_IndirectTypeDescription *>(pElementTypeDescr)->pType;
232 for ( sal_Int32 nPos = nElements; nPos--; )
233 {
234 if (! equalSequence( static_cast<uno_Sequence **>(pDestElements)[nPos],
235 static_cast<uno_Sequence **>(pSourceElements)[nPos],
236 pSeqElementType, queryInterface, release ))
237 {
238 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
239 return false;
240 }
241 }
242 TYPELIB_DANGER_RELEASE( pElementTypeDescr );
243 return true;
244 }
245 case typelib_TypeClass_INTERFACE:
246 {
247 for ( sal_Int32 nPos = nElements; nPos--; )
248 {
249 if (! _equalObject( static_cast<void **>(pDestElements)[nPos], static_cast<void **>(pSourceElements)[nPos],
250 queryInterface, release ))
251 {
252 return false;
253 }
254 }
255 return true;
256 }
257 default:
258 OSL_ASSERT(false);
259 return false;
260 }
261}
262
263inline bool _equalData(
264 void * pDest,
265 typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
266 void * pSource,
267 typelib_TypeDescriptionReference * pSourceType,
268 uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
269{
270 typelib_TypeClass eSourceTypeClass, eDestTypeClass;
271 while (typelib_TypeClass_ANY == (eDestTypeClass = pDestType->eTypeClass))
272 {
273 pDestTypeDescr = nullptr;
274 pDestType = static_cast<uno_Any *>(pDest)->pType;
275 pDest = static_cast<uno_Any *>(pDest)->pData;
276 }
277 while (typelib_TypeClass_ANY == (eSourceTypeClass = pSourceType->eTypeClass))
278 {
279 pSourceType = static_cast<uno_Any *>(pSource)->pType;
280 pSource = static_cast<uno_Any *>(pSource)->pData;
281 }
282
283 switch (eDestTypeClass)
284 {
285 case typelib_TypeClass_VOID:
286 return eSourceTypeClass == typelib_TypeClass_VOID;
287 case typelib_TypeClass_CHAR:
288 return eSourceTypeClass == typelib_TypeClass_CHAR
289 && *static_cast<sal_Unicode *>(pDest) == *static_cast<sal_Unicode *>(pSource);
290 case typelib_TypeClass_BOOLEAN:
291 return eSourceTypeClass == typelib_TypeClass_BOOLEAN
292 && (bool(*static_cast<sal_Bool *>(pDest))
293 == bool(*static_cast<sal_Bool *>(pSource)));
294 case typelib_TypeClass_BYTE:
295 switch (eSourceTypeClass)
296 {
297 case typelib_TypeClass_BYTE:
298 return o3tl::cmp_equal(
299 *static_cast<sal_Int8 *>(pDest), *static_cast<sal_Int8 *>(pSource));
300 case typelib_TypeClass_SHORT:
301 return o3tl::cmp_equal(
302 *static_cast<sal_Int8 *>(pDest), *static_cast<sal_Int16 *>(pSource));
303 case typelib_TypeClass_UNSIGNED_SHORT:
304 return o3tl::cmp_equal(
305 *static_cast<sal_Int8 *>(pDest), *static_cast<sal_uInt16 *>(pSource));
306 case typelib_TypeClass_LONG:
307 return o3tl::cmp_equal(
308 *static_cast<sal_Int8 *>(pDest), *static_cast<sal_Int32 *>(pSource));
309 case typelib_TypeClass_UNSIGNED_LONG:
310 return o3tl::cmp_equal(
311 *static_cast<sal_Int8 *>(pDest), *static_cast<sal_uInt32 *>(pSource));
312 case typelib_TypeClass_HYPER:
313 return o3tl::cmp_equal(
314 *static_cast<sal_Int8 *>(pDest), *static_cast<sal_Int64 *>(pSource));
315 case typelib_TypeClass_UNSIGNED_HYPER:
316 return o3tl::cmp_equal(
317 *static_cast<sal_Int8 *>(pDest), *static_cast<sal_Int64 *>(pSource));
318 case typelib_TypeClass_FLOAT:
319 return (static_cast<float>(*static_cast<sal_Int8 *>(pDest)) == *static_cast<float *>(pSource));
320 case typelib_TypeClass_DOUBLE:
321 return (static_cast<double>(*static_cast<sal_Int8 *>(pDest)) == *static_cast<double *>(pSource));
322 default:
323 return false;
324 }
325 case typelib_TypeClass_SHORT:
326 switch (eSourceTypeClass)
327 {
328 case typelib_TypeClass_BYTE:
329 return o3tl::cmp_equal(
330 *static_cast<sal_Int16 *>(pDest), *static_cast<sal_Int8 *>(pSource));
331 case typelib_TypeClass_SHORT:
332 return o3tl::cmp_equal(
333 *static_cast<sal_Int16 *>(pDest), *static_cast<sal_Int16 *>(pSource));
334 case typelib_TypeClass_UNSIGNED_SHORT:
335 return o3tl::cmp_equal(
336 *static_cast<sal_Int16 *>(pDest), *static_cast<sal_uInt16 *>(pSource));
337 case typelib_TypeClass_LONG:
338 return o3tl::cmp_equal(
339 *static_cast<sal_Int16 *>(pDest), *static_cast<sal_Int32 *>(pSource));
340 case typelib_TypeClass_UNSIGNED_LONG:
341 return o3tl::cmp_equal(
342 *static_cast<sal_Int16 *>(pDest), *static_cast<sal_uInt32 *>(pSource));
343 case typelib_TypeClass_HYPER:
344 return o3tl::cmp_equal(
345 *static_cast<sal_Int16 *>(pDest), *static_cast<sal_Int64 *>(pSource));
346 case typelib_TypeClass_UNSIGNED_HYPER:
347 return o3tl::cmp_equal(
348 *static_cast<sal_Int16 *>(pDest), *static_cast<sal_Int64 *>(pSource));
349 case typelib_TypeClass_FLOAT:
350 return (static_cast<float>(*static_cast<sal_Int16 *>(pDest)) == *static_cast<float *>(pSource));
351 case typelib_TypeClass_DOUBLE:
352 return (static_cast<double>(*static_cast<sal_Int16 *>(pDest)) == *static_cast<double *>(pSource));
353 default:
354 return false;
355 }
356 case typelib_TypeClass_UNSIGNED_SHORT:
357 switch (eSourceTypeClass)
358 {
359 case typelib_TypeClass_BYTE:
360 return o3tl::cmp_equal(
361 *static_cast<sal_uInt16 *>(pDest), *static_cast<sal_Int8 *>(pSource));
362 case typelib_TypeClass_SHORT:
363 return o3tl::cmp_equal(
364 *static_cast<sal_uInt16 *>(pDest), *static_cast<sal_Int16 *>(pSource));
365 case typelib_TypeClass_UNSIGNED_SHORT:
366 return o3tl::cmp_equal(
367 *static_cast<sal_uInt16 *>(pDest), *static_cast<sal_uInt16 *>(pSource));
368 case typelib_TypeClass_LONG:
369 return o3tl::cmp_equal(
370 *static_cast<sal_uInt16 *>(pDest), *static_cast<sal_Int32 *>(pSource));
371 case typelib_TypeClass_UNSIGNED_LONG:
372 return o3tl::cmp_equal(
373 *static_cast<sal_uInt16 *>(pDest), *static_cast<sal_uInt32 *>(pSource));
374 case typelib_TypeClass_HYPER:
375 return o3tl::cmp_equal(
376 *static_cast<sal_uInt16 *>(pDest), *static_cast<sal_Int64 *>(pSource));
377 case typelib_TypeClass_UNSIGNED_HYPER:
378 return o3tl::cmp_equal(
379 *static_cast<sal_uInt16 *>(pDest), *static_cast<sal_uInt64 *>(pSource));
380 case typelib_TypeClass_FLOAT:
381 return (static_cast<float>(*static_cast<sal_uInt16 *>(pDest)) == *static_cast<float *>(pSource));
382 case typelib_TypeClass_DOUBLE:
383 return (static_cast<double>(*static_cast<sal_uInt16 *>(pDest)) == *static_cast<double *>(pSource));
384 default:
385 return false;
386 }
387 case typelib_TypeClass_LONG:
388 switch (eSourceTypeClass)
389 {
390 case typelib_TypeClass_BYTE:
391 return o3tl::cmp_equal(
392 *static_cast<sal_Int32 *>(pDest), *static_cast<sal_Int8 *>(pSource));
393 case typelib_TypeClass_SHORT:
394 return o3tl::cmp_equal(
395 *static_cast<sal_Int32 *>(pDest), *static_cast<sal_Int16 *>(pSource));
396 case typelib_TypeClass_UNSIGNED_SHORT:
397 return o3tl::cmp_equal(
398 *static_cast<sal_Int32 *>(pDest), *static_cast<sal_uInt16 *>(pSource));
399 case typelib_TypeClass_LONG:
400 return o3tl::cmp_equal(
401 *static_cast<sal_Int32 *>(pDest), *static_cast<sal_Int32 *>(pSource));
402 case typelib_TypeClass_UNSIGNED_LONG:
403 return o3tl::cmp_equal(
404 *static_cast<sal_Int32 *>(pDest), *static_cast<sal_uInt32 *>(pSource));
405 case typelib_TypeClass_HYPER:
406 return o3tl::cmp_equal(
407 *static_cast<sal_Int32 *>(pDest), *static_cast<sal_Int64 *>(pSource));
408 case typelib_TypeClass_UNSIGNED_HYPER:
409 return o3tl::cmp_equal(
410 *static_cast<sal_Int32 *>(pDest), *static_cast<sal_Int64 *>(pSource));
411 case typelib_TypeClass_FLOAT:
412 return (static_cast<float>(*static_cast<sal_Int32 *>(pDest)) == *static_cast<float *>(pSource));
413 case typelib_TypeClass_DOUBLE:
414 return (static_cast<double>(*static_cast<sal_Int32 *>(pDest)) == *static_cast<double *>(pSource));
415 default:
416 return false;
417 }
418 case typelib_TypeClass_UNSIGNED_LONG:
419 switch (eSourceTypeClass)
420 {
421 case typelib_TypeClass_BYTE:
422 return o3tl::cmp_equal(
423 *static_cast<sal_uInt32 *>(pDest), *static_cast<sal_Int8 *>(pSource));
424 case typelib_TypeClass_SHORT:
425 return o3tl::cmp_equal(
426 *static_cast<sal_uInt32 *>(pDest), *static_cast<sal_Int16 *>(pSource));
427 case typelib_TypeClass_UNSIGNED_SHORT:
428 return o3tl::cmp_equal(
429 *static_cast<sal_uInt32 *>(pDest), *static_cast<sal_uInt16 *>(pSource));
430 case typelib_TypeClass_LONG:
431 return o3tl::cmp_equal(
432 *static_cast<sal_uInt32 *>(pDest), *static_cast<sal_Int32 *>(pSource));
433 case typelib_TypeClass_UNSIGNED_LONG:
434 return o3tl::cmp_equal(
435 *static_cast<sal_uInt32 *>(pDest), *static_cast<sal_uInt32 *>(pSource));
436 case typelib_TypeClass_HYPER:
437 return o3tl::cmp_equal(
438 *static_cast<sal_uInt32 *>(pDest), *static_cast<sal_Int64 *>(pSource));
439 case typelib_TypeClass_UNSIGNED_HYPER:
440 return o3tl::cmp_equal(
441 *static_cast<sal_uInt32 *>(pDest), *static_cast<sal_uInt64 *>(pSource));
442 case typelib_TypeClass_FLOAT:
443 return (static_cast<float>(*static_cast<sal_uInt32 *>(pDest)) == *static_cast<float *>(pSource));
444 case typelib_TypeClass_DOUBLE:
445 return (static_cast<double>(*static_cast<sal_uInt32 *>(pDest)) == *static_cast<double *>(pSource));
446 default:
447 return false;
448 }
449 case typelib_TypeClass_HYPER:
450 switch (eSourceTypeClass)
451 {
452 case typelib_TypeClass_BYTE:
453 return o3tl::cmp_equal(
454 *static_cast<sal_Int64 *>(pDest), *static_cast<sal_Int8 *>(pSource));
455 case typelib_TypeClass_SHORT:
456 return o3tl::cmp_equal(
457 *static_cast<sal_Int64 *>(pDest), *static_cast<sal_Int16 *>(pSource));
458 case typelib_TypeClass_UNSIGNED_SHORT:
459 return o3tl::cmp_equal(
460 *static_cast<sal_Int64 *>(pDest), *static_cast<sal_uInt16 *>(pSource));
461 case typelib_TypeClass_LONG:
462 return o3tl::cmp_equal(
463 *static_cast<sal_Int64 *>(pDest), *static_cast<sal_Int32 *>(pSource));
464 case typelib_TypeClass_UNSIGNED_LONG:
465 return o3tl::cmp_equal(
466 *static_cast<sal_Int64 *>(pDest), *static_cast<sal_uInt32 *>(pSource));
467 case typelib_TypeClass_HYPER:
468 return o3tl::cmp_equal(
469 *static_cast<sal_Int64 *>(pDest), *static_cast<sal_Int64 *>(pSource));
470 case typelib_TypeClass_UNSIGNED_HYPER:
471 return o3tl::cmp_equal(
472 *static_cast<sal_Int64 *>(pDest), *static_cast<sal_Int64 *>(pSource));
473 case typelib_TypeClass_FLOAT:
474 return (static_cast<float>(*static_cast<sal_Int64 *>(pDest)) == *static_cast<float *>(pSource));
475 case typelib_TypeClass_DOUBLE:
476 return (static_cast<double>(*static_cast<sal_Int64 *>(pDest)) == *static_cast<double *>(pSource));
477 default:
478 return false;
479 }
480 case typelib_TypeClass_UNSIGNED_HYPER:
481 switch (eSourceTypeClass)
482 {
483 case typelib_TypeClass_BYTE:
484 return o3tl::cmp_equal(
485 *static_cast<sal_uInt64 *>(pDest), *static_cast<sal_Int8 *>(pSource));
486 case typelib_TypeClass_SHORT:
487 return o3tl::cmp_equal(
488 *static_cast<sal_uInt64 *>(pDest), *static_cast<sal_Int16 *>(pSource));
489 case typelib_TypeClass_UNSIGNED_SHORT:
490 return o3tl::cmp_equal(
491 *static_cast<sal_uInt64 *>(pDest), *static_cast<sal_uInt16 *>(pSource));
492 case typelib_TypeClass_LONG:
493 return o3tl::cmp_equal(
494 *static_cast<sal_uInt64 *>(pDest), *static_cast<sal_Int32 *>(pSource));
495 case typelib_TypeClass_UNSIGNED_LONG:
496 return o3tl::cmp_equal(
497 *static_cast<sal_uInt64 *>(pDest), *static_cast<sal_uInt32 *>(pSource));
498 case typelib_TypeClass_HYPER:
499 return o3tl::cmp_equal(
500 *static_cast<sal_uInt64 *>(pDest), *static_cast<sal_Int64 *>(pSource));
501 case typelib_TypeClass_UNSIGNED_HYPER:
502 return o3tl::cmp_equal(
503 *static_cast<sal_uInt64 *>(pDest), *static_cast<sal_uInt64 *>(pSource));
504 case typelib_TypeClass_FLOAT:
505 if (::floor( *static_cast<float *>(pSource) ) != *static_cast<float *>(pSource) || *static_cast<float *>(pSource) < 0)
506 return false;
507 return (*static_cast<sal_uInt64 *>(pDest) == static_cast<sal_uInt64>(*static_cast<float *>(pSource)));
508 case typelib_TypeClass_DOUBLE:
509 if (::floor( *static_cast<double *>(pSource) ) != *static_cast<double *>(pSource) || *static_cast<double *>(pSource) < 0)
510 return false;
511 return (*static_cast<sal_uInt64 *>(pDest) == static_cast<sal_uInt64>(*static_cast<double *>(pSource)));
512 default:
513 return false;
514 }
515 case typelib_TypeClass_FLOAT:
516 switch (eSourceTypeClass)
517 {
518 case typelib_TypeClass_BYTE:
519 return (*static_cast<float *>(pDest) == static_cast<float>(*static_cast<sal_Int8 *>(pSource)));
520 case typelib_TypeClass_SHORT:
521 return (*static_cast<float *>(pDest) == static_cast<float>(*static_cast<sal_Int16 *>(pSource)));
522 case typelib_TypeClass_UNSIGNED_SHORT:
523 return (*static_cast<float *>(pDest) == static_cast<float>(*static_cast<sal_uInt16 *>(pSource)));
524 case typelib_TypeClass_LONG:
525 return (*static_cast<float *>(pDest) == static_cast<float>(*static_cast<sal_Int32 *>(pSource)));
526 case typelib_TypeClass_UNSIGNED_LONG:
527 return (*static_cast<float *>(pDest) == static_cast<float>(*static_cast<sal_uInt32 *>(pSource)));
528 case typelib_TypeClass_HYPER:
529 return (*static_cast<float *>(pDest) == static_cast<float>(*static_cast<sal_Int64 *>(pSource)));
530 case typelib_TypeClass_UNSIGNED_HYPER:
531 if (::floor( *static_cast<float *>(pDest) ) != *static_cast<float *>(pDest) || *static_cast<float *>(pDest) < 0)
532 return false;
533 return (static_cast<sal_uInt64>(*static_cast<float *>(pDest)) == *static_cast<sal_uInt64 *>(pSource));
534 case typelib_TypeClass_FLOAT:
535 return (*static_cast<float *>(pDest) == *static_cast<float *>(pSource));
536 case typelib_TypeClass_DOUBLE:
537 return (static_cast<double>(*static_cast<float *>(pDest)) == *static_cast<double *>(pSource));
538 default:
539 return false;
540 }
541 case typelib_TypeClass_DOUBLE:
542 switch (eSourceTypeClass)
543 {
544 case typelib_TypeClass_BYTE:
545 return (*static_cast<double *>(pDest) == static_cast<double>(*static_cast<sal_Int8 *>(pSource)));
546 case typelib_TypeClass_SHORT:
547 return (*static_cast<double *>(pDest) == static_cast<double>(*static_cast<sal_Int16 *>(pSource)));
548 case typelib_TypeClass_UNSIGNED_SHORT:
549 return (*static_cast<double *>(pDest) == static_cast<double>(*static_cast<sal_uInt16 *>(pSource)));
550 case typelib_TypeClass_LONG:
551 return (*static_cast<double *>(pDest) == static_cast<double>(*static_cast<sal_Int32 *>(pSource)));
552 case typelib_TypeClass_UNSIGNED_LONG:
553 return (*static_cast<double *>(pDest) == static_cast<double>(*static_cast<sal_uInt32 *>(pSource)));
554 case typelib_TypeClass_HYPER:
555 return (*static_cast<double *>(pDest) == static_cast<double>(*static_cast<sal_Int64 *>(pSource)));
556 case typelib_TypeClass_UNSIGNED_HYPER:
557 if (::floor( *static_cast<double *>(pDest) ) != *static_cast<double *>(pDest) || *static_cast<double *>(pDest) < 0)
558 return false;
559 return (static_cast<sal_uInt64>(*static_cast<double *>(pDest)) == *static_cast<sal_uInt64 *>(pSource));
560 case typelib_TypeClass_FLOAT:
561 return (*static_cast<double *>(pDest) == static_cast<double>(*static_cast<float *>(pSource)));
562 case typelib_TypeClass_DOUBLE:
563 return (*static_cast<double *>(pDest) == *static_cast<double *>(pSource));
564 default:
565 return false;
566 }
567 case typelib_TypeClass_STRING:
568 return eSourceTypeClass == typelib_TypeClass_STRING
569 && *static_cast<OUString *>(pDest) ==
570 *static_cast<OUString const *>(pSource);
571 case typelib_TypeClass_TYPE:
572 return eSourceTypeClass == typelib_TypeClass_TYPE
573 && _type_equals(
574 *static_cast<typelib_TypeDescriptionReference **>(pDest),
575 *static_cast<typelib_TypeDescriptionReference **>(pSource) );
576 case typelib_TypeClass_ENUM:
577 return (_type_equals( pDestType, pSourceType ) &&
578 *static_cast<sal_Int32 *>(pDest) == *static_cast<sal_Int32 *>(pSource));
579 case typelib_TypeClass_STRUCT:
580 case typelib_TypeClass_EXCEPTION:
581 if (! _type_equals( pDestType, pSourceType ))
582 return false;
583 if (pDestTypeDescr)
584 {
585 return _equalStruct(
586 pDest, pSource,
587 reinterpret_cast<typelib_CompoundTypeDescription *>(pDestTypeDescr),
588 queryInterface, release );
589 }
590 else
591 {
592 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
593 bool bRet = _equalStruct(
594 pDest, pSource,
595 reinterpret_cast<typelib_CompoundTypeDescription *>(pDestTypeDescr),
596 queryInterface, release );
597 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
598 return bRet;
599 }
600 case typelib_TypeClass_SEQUENCE:
601 if (_type_equals( pDestType, pSourceType ))
602 {
603 if (pDestTypeDescr)
604 {
605 return _equalSequence(
606 *static_cast<uno_Sequence **>(pDest), *static_cast<uno_Sequence **>(pSource),
607 reinterpret_cast<typelib_IndirectTypeDescription *>(pDestTypeDescr)->pType,
608 queryInterface, release );
609 }
610 else
611 {
612 TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
613 bool bRet = _equalSequence(
614 *static_cast<uno_Sequence **>(pDest), *static_cast<uno_Sequence **>(pSource),
615 reinterpret_cast<typelib_IndirectTypeDescription *>(pDestTypeDescr)->pType,
616 queryInterface, release );
617 TYPELIB_DANGER_RELEASE( pDestTypeDescr );
618 return bRet;
619 }
620 }
621 return false;
622 case typelib_TypeClass_INTERFACE:
623 if (typelib_TypeClass_INTERFACE == eSourceTypeClass)
624 return _equalObject( *static_cast<void **>(pDest), *static_cast<void **>(pSource), queryInterface, release );
625 break;
626 default:
627 OSL_ASSERT(false);
628 break;
629 }
630 return false;
631}
632
633}
634
635/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nElements
Definition: copy.hxx:39
sal_Bool SAL_CALL uno_type_equalData(void *pVal1, typelib_TypeDescriptionReference *pVal1Type, void *pVal2, typelib_TypeDescriptionReference *pVal2Type, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Definition: data.cxx:238
sal_uInt16 nPos
std::unique_ptr< sal_Int32[]> pData
struct _typelib_TypeDescription typelib_TypeDescription
struct _uno_Any uno_Any
void _release(void *p, uno_ReleaseFunc release)
Definition: prim.hxx:79
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool equalSequence(uno_Sequence *pDest, uno_Sequence *pSource, typelib_TypeDescriptionReference *pElementType, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release)
Definition: data.cxx:158
bool _equalObject(void *pI1, void *pI2, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release)
Definition: eq.hxx:38
bool equalStruct(void *pDest, void *pSource, typelib_CompoundTypeDescription *pTypeDescr, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release)
Definition: data.cxx:122
bool _equalSequence(uno_Sequence *pDest, uno_Sequence *pSource, typelib_TypeDescriptionReference *pElementType, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release)
Definition: eq.hxx:107
bool _equalStruct(void *pDest, void *pSource, typelib_CompoundTypeDescription *pTypeDescr, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release)
Definition: eq.hxx:72
void * binuno_queryInterface(void *pUnoI, typelib_TypeDescriptionReference *pDestType)
Definition: data.cxx:40
bool _type_equals(typelib_TypeDescriptionReference const *pType1, typelib_TypeDescriptionReference const *pType2)
Definition: prim.hxx:141
bool _equalData(void *pDest, typelib_TypeDescriptionReference *pDestType, typelib_TypeDescription *pDestTypeDescr, void *pSource, typelib_TypeDescriptionReference *pSourceType, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release)
Definition: eq.hxx:263
constexpr bool cmp_equal(T1 value1, T2 value2) noexcept
typelib_TypeDescriptionReference **SAL_CALL typelib_static_type_getByTypeClass(typelib_TypeClass eTypeClass) SAL_THROW_EXTERN_C()
unsigned char sal_Bool
sal_uInt16 sal_Unicode
signed char sal_Int8