LibreOffice: cppuhelper/queryinterface.hxx Source File

LibreOffice LibreOffice 6.2 SDK C/C++ API Reference

queryinterface.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
20 #ifndef INCLUDED_CPPUHELPER_QUERYINTERFACE_HXX
21 #define INCLUDED_CPPUHELPER_QUERYINTERFACE_HXX
22
23 #include "sal/config.h"
24 #include "com/sun/star/uno/Any.hxx"
25 #include "com/sun/star/uno/Type.h"
26 #include "sal/types.h"
27
28 namespace cppu
29 {
30
38 template< class Interface1 >
39 inline css::uno::Any SAL_CALL queryInterface(
40 const css::uno::Type & rType,
41 Interface1 * p1 )
42 {
43 if (rType == Interface1::static_type())
44 return css::uno::Any( &p1, rType );
45 else
46 return css::uno::Any();
47 }
57 template< class Interface1, class Interface2 >
58 inline css::uno::Any SAL_CALL queryInterface(
59 const css::uno::Type & rType,
60 Interface1 * p1, Interface2 * p2 )
61 {
62 if (rType == Interface1::static_type())
63 return css::uno::Any( &p1, rType );
64 else if (rType == Interface2::static_type())
65 return css::uno::Any( &p2, rType );
66 else
67 return css::uno::Any();
68 }
80 template< class Interface1, class Interface2, class Interface3 >
81 inline css::uno::Any SAL_CALL queryInterface(
82 const css::uno::Type & rType,
83 Interface1 * p1, Interface2 * p2, Interface3 * p3 )
84 {
85 if (rType == Interface1::static_type())
86 return css::uno::Any( &p1, rType );
87 else if (rType == Interface2::static_type())
88 return css::uno::Any( &p2, rType );
89 else if (rType == Interface3::static_type())
90 return css::uno::Any( &p3, rType );
91 else
92 return css::uno::Any();
93 }
107 template< class Interface1, class Interface2, class Interface3, class Interface4 >
108 inline css::uno::Any SAL_CALL queryInterface(
109 const css::uno::Type & rType,
110 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 )
111 {
112 if (rType == Interface1::static_type())
113 return css::uno::Any( &p1, rType );
114 else if (rType == Interface2::static_type())
115 return css::uno::Any( &p2, rType );
116 else if (rType == Interface3::static_type())
117 return css::uno::Any( &p3, rType );
118 else if (rType == Interface4::static_type())
119 return css::uno::Any( &p4, rType );
120 else
121 return css::uno::Any();
122 }
138 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 >
139 inline css::uno::Any SAL_CALL queryInterface(
140 const css::uno::Type & rType,
141 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 )
142 {
143 if (rType == Interface1::static_type())
144 return css::uno::Any( &p1, rType );
145 else if (rType == Interface2::static_type())
146 return css::uno::Any( &p2, rType );
147 else if (rType == Interface3::static_type())
148 return css::uno::Any( &p3, rType );
149 else if (rType == Interface4::static_type())
150 return css::uno::Any( &p4, rType );
151 else if (rType == Interface5::static_type())
152 return css::uno::Any( &p5, rType );
153 else
154 return css::uno::Any();
155 }
173 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
174 class Interface6 >
175 inline css::uno::Any SAL_CALL queryInterface(
176 const css::uno::Type & rType,
177 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
178 Interface6 * p6 )
179 {
180 if (rType == Interface1::static_type())
181 return css::uno::Any( &p1, rType );
182 else if (rType == Interface2::static_type())
183 return css::uno::Any( &p2, rType );
184 else if (rType == Interface3::static_type())
185 return css::uno::Any( &p3, rType );
186 else if (rType == Interface4::static_type())
187 return css::uno::Any( &p4, rType );
188 else if (rType == Interface5::static_type())
189 return css::uno::Any( &p5, rType );
190 else if (rType == Interface6::static_type())
191 return css::uno::Any( &p6, rType );
192 else
193 return css::uno::Any();
194 }
214 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
215 class Interface6, class Interface7 >
216 inline css::uno::Any SAL_CALL queryInterface(
217 const css::uno::Type & rType,
218 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
219 Interface6 * p6, Interface7 * p7 )
220 {
221 if (rType == Interface1::static_type())
222 return css::uno::Any( &p1, rType );
223 else if (rType == Interface2::static_type())
224 return css::uno::Any( &p2, rType );
225 else if (rType == Interface3::static_type())
226 return css::uno::Any( &p3, rType );
227 else if (rType == Interface4::static_type())
228 return css::uno::Any( &p4, rType );
229 else if (rType == Interface5::static_type())
230 return css::uno::Any( &p5, rType );
231 else if (rType == Interface6::static_type())
232 return css::uno::Any( &p6, rType );
233 else if (rType == Interface7::static_type())
234 return css::uno::Any( &p7, rType );
235 else
236 return css::uno::Any();
237 }
259 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
260 class Interface6, class Interface7, class Interface8 >
261 inline css::uno::Any SAL_CALL queryInterface(
262 const css::uno::Type & rType,
263 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
264 Interface6 * p6, Interface7 * p7, Interface8 * p8 )
265 {
266 if (rType == Interface1::static_type())
267 return css::uno::Any( &p1, rType );
268 else if (rType == Interface2::static_type())
269 return css::uno::Any( &p2, rType );
270 else if (rType == Interface3::static_type())
271 return css::uno::Any( &p3, rType );
272 else if (rType == Interface4::static_type())
273 return css::uno::Any( &p4, rType );
274 else if (rType == Interface5::static_type())
275 return css::uno::Any( &p5, rType );
276 else if (rType == Interface6::static_type())
277 return css::uno::Any( &p6, rType );
278 else if (rType == Interface7::static_type())
279 return css::uno::Any( &p7, rType );
280 else if (rType == Interface8::static_type())
281 return css::uno::Any( &p8, rType );
282 else
283 return css::uno::Any();
284 }
308 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
309 class Interface6, class Interface7, class Interface8, class Interface9 >
310 inline css::uno::Any SAL_CALL queryInterface(
311 const css::uno::Type & rType,
312 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
313 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 )
314 {
315 if (rType == Interface1::static_type())
316 return css::uno::Any( &p1, rType );
317 else if (rType == Interface2::static_type())
318 return css::uno::Any( &p2, rType );
319 else if (rType == Interface3::static_type())
320 return css::uno::Any( &p3, rType );
321 else if (rType == Interface4::static_type())
322 return css::uno::Any( &p4, rType );
323 else if (rType == Interface5::static_type())
324 return css::uno::Any( &p5, rType );
325 else if (rType == Interface6::static_type())
326 return css::uno::Any( &p6, rType );
327 else if (rType == Interface7::static_type())
328 return css::uno::Any( &p7, rType );
329 else if (rType == Interface8::static_type())
330 return css::uno::Any( &p8, rType );
331 else if (rType == Interface9::static_type())
332 return css::uno::Any( &p9, rType );
333 else
334 return css::uno::Any();
335 }
361 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
362 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 >
363 inline css::uno::Any SAL_CALL queryInterface(
364 const css::uno::Type & rType,
365 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
366 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 )
367 {
368 if (rType == Interface1::static_type())
369 return css::uno::Any( &p1, rType );
370 else if (rType == Interface2::static_type())
371 return css::uno::Any( &p2, rType );
372 else if (rType == Interface3::static_type())
373 return css::uno::Any( &p3, rType );
374 else if (rType == Interface4::static_type())
375 return css::uno::Any( &p4, rType );
376 else if (rType == Interface5::static_type())
377 return css::uno::Any( &p5, rType );
378 else if (rType == Interface6::static_type())
379 return css::uno::Any( &p6, rType );
380 else if (rType == Interface7::static_type())
381 return css::uno::Any( &p7, rType );
382 else if (rType == Interface8::static_type())
383 return css::uno::Any( &p8, rType );
384 else if (rType == Interface9::static_type())
385 return css::uno::Any( &p9, rType );
386 else if (rType == Interface10::static_type())
387 return css::uno::Any( &p10, rType );
388 else
389 return css::uno::Any();
390 }
418 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
419 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
420 class Interface11 >
421 inline css::uno::Any SAL_CALL queryInterface(
422 const css::uno::Type & rType,
423 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
424 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
425 Interface11 * p11 )
426 {
427 if (rType == Interface1::static_type())
428 return css::uno::Any( &p1, rType );
429 else if (rType == Interface2::static_type())
430 return css::uno::Any( &p2, rType );
431 else if (rType == Interface3::static_type())
432 return css::uno::Any( &p3, rType );
433 else if (rType == Interface4::static_type())
434 return css::uno::Any( &p4, rType );
435 else if (rType == Interface5::static_type())
436 return css::uno::Any( &p5, rType );
437 else if (rType == Interface6::static_type())
438 return css::uno::Any( &p6, rType );
439 else if (rType == Interface7::static_type())
440 return css::uno::Any( &p7, rType );
441 else if (rType == Interface8::static_type())
442 return css::uno::Any( &p8, rType );
443 else if (rType == Interface9::static_type())
444 return css::uno::Any( &p9, rType );
445 else if (rType == Interface10::static_type())
446 return css::uno::Any( &p10, rType );
447 else if (rType == Interface11::static_type())
448 return css::uno::Any( &p11, rType );
449 else
450 return css::uno::Any();
451 }
481 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
482 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
483 class Interface11, class Interface12 >
484 inline css::uno::Any SAL_CALL queryInterface(
485 const css::uno::Type & rType,
486 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
487 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
488 Interface11 * p11, Interface12 * p12 )
489 {
490 if (rType == Interface1::static_type())
491 return css::uno::Any( &p1, rType );
492 else if (rType == Interface2::static_type())
493 return css::uno::Any( &p2, rType );
494 else if (rType == Interface3::static_type())
495 return css::uno::Any( &p3, rType );
496 else if (rType == Interface4::static_type())
497 return css::uno::Any( &p4, rType );
498 else if (rType == Interface5::static_type())
499 return css::uno::Any( &p5, rType );
500 else if (rType == Interface6::static_type())
501 return css::uno::Any( &p6, rType );
502 else if (rType == Interface7::static_type())
503 return css::uno::Any( &p7, rType );
504 else if (rType == Interface8::static_type())
505 return css::uno::Any( &p8, rType );
506 else if (rType == Interface9::static_type())
507 return css::uno::Any( &p9, rType );
508 else if (rType == Interface10::static_type())
509 return css::uno::Any( &p10, rType );
510 else if (rType == Interface11::static_type())
511 return css::uno::Any( &p11, rType );
512 else if (rType == Interface12::static_type())
513 return css::uno::Any( &p12, rType );
514 else
515 return css::uno::Any();
516 }
517
518 }
519
520 #endif
521
522 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type.h
cppu::queryInterface
css::uno::Any queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:39
types.h
config.h
cppu
Definition: Enterable.hxx:26
Any.hxx