AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
unotype.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 
4 #ifndef INCLUDED_CPPU_UNOTYPE_HXX
5 #define INCLUDED_CPPU_UNOTYPE_HXX
6 
7 #include "sal/config.h"
8 
9 #include <cstddef>
10 
11 #if defined LIBO_INTERNAL_ONLY
12 #include <type_traits>
13 #endif
14 
15 #include "sal/types.h"
16 #include "typelib/typeclass.h"
18 
19 namespace com { namespace sun { namespace star { namespace uno {
20  class Type;
21  class Any;
22  class Exception;
23  template< typename > class Reference;
24  template< typename > class Sequence;
25  class XInterface;
26 } } } }
27 namespace rtl { class OUString; }
28 
29 namespace cppu {
30 
31 template< typename > class UnoType;
32 
41 struct UnoVoidType;
42 
54 struct UnoUnsignedShortType;
55 
67 struct UnoCharType;
68 
81 template< typename > struct UnoSequenceType;
82 
83 namespace detail {
84 
85 inline css::uno::Type const & getTypeFromTypeDescriptionReference(
86  ::typelib_TypeDescriptionReference * const * tdr)
87 {
88  return *reinterpret_cast< css::uno::Type const * >(tdr);
89 }
90 
91 inline css::uno::Type const &
95 }
96 
97 }
98 
99 }
100 
101 namespace cppu { namespace detail {
102 
103 inline css::uno::Type const &
104 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
106 }
107 
108 inline css::uno::Type const &
111 }
112 
113 inline css::uno::Type const &
116 }
117 
118 inline css::uno::Type const &
121 }
122 
123 inline css::uno::Type const &
124 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
126 }
127 
128 inline css::uno::Type const &
130  SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
131 {
134 }
135 
136 #if defined LIBO_INTERNAL_ONLY
137  // cf. sal/types.h sal_Unicode
138 inline css::uno::Type const &
139 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER sal_uInt16 const *) {
141 }
142 #endif
143 
144 inline css::uno::Type const &
145 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
147 }
148 
149 inline css::uno::Type const &
150 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
153 }
154 
155 inline css::uno::Type const &
156 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
158 }
159 
160 inline css::uno::Type const &
161 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
164 }
165 
166 inline css::uno::Type const &
169 }
170 
171 inline css::uno::Type const &
174 }
175 
176 inline css::uno::Type const &
177 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
179 }
180 
181 #if defined LIBO_INTERNAL_ONLY
182  // cf. sal/types.h sal_Unicode
183 inline css::uno::Type const &
186 }
187 #endif
188 
189 inline css::uno::Type const &
190 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
192 }
193 
194 inline css::uno::Type const &
196 {
198 }
199 
200 inline css::uno::Type const &
202 {
204 }
205 
206 template< typename T > inline css::uno::Type const &
208  SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
209 {
210  //TODO: depending on memory model, the following might not work reliably
211  static typelib_TypeDescriptionReference * p = NULL;
212  if (p == NULL) {
214  &p, ::cppu::UnoType< T >::get().getTypeLibType());
215  }
217 }
218 
219 template< typename T > inline css::uno::Type const &
221  SAL_UNUSED_PARAMETER css::uno::Sequence< T > const *)
222 {
223  return cppu_detail_getUnoType(
224  static_cast< ::cppu::UnoSequenceType< T > * >(NULL));
225 }
226 
227 inline css::uno::Type const & cppu_detail_getUnoType(
228  SAL_UNUSED_PARAMETER css::uno::Exception const *)
229 {
231 }
232 
233 inline css::uno::Type const & cppu_detail_getUnoType(
234  SAL_UNUSED_PARAMETER css::uno::XInterface const *)
235 {
237 }
238 
239 template< typename T > inline css::uno::Type const &
241  SAL_UNUSED_PARAMETER css::uno::Reference< T > const *)
242 {
243  return ::cppu::UnoType< T >::get();
244 }
245 
246 } }
247 
248 namespace cppu {
249 
270 template< typename T > class UnoType {
271 public:
272  static css::uno::Type const & get() {
273  using namespace ::cppu::detail;
274 #if defined LIBO_INTERNAL_ONLY
275  typedef typename std::remove_reference<T>::type T1;
276  // for certain uses of UnoType<decltype(x)>
277 #else
278  typedef T T1;
279 #endif
280  return cppu_detail_getUnoType(static_cast< T1 * >(NULL));
281  }
282 
283 private:
285  ~UnoType() SAL_DELETED_FUNCTION;
286  void operator =(UnoType &) SAL_DELETED_FUNCTION;
287 };
288 
289 template<> css::uno::Type inline const & UnoType<void>::get() {
291 }
292 
303 template< typename T > inline css::uno::Type const &
305  return ::cppu::UnoType< T >::get();
306 }
307 
318 inline css::uno::Type const &
319 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
320  return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
321 }
322 
333 template< typename T > inline css::uno::Type const &
334 getTypeFavourUnsigned(css::uno::Sequence< T > const *);
335  // defined in com/sun/star/uno/Sequence.hxx
336 
338 
350 template< typename T > inline css::uno::Type const &
352  return ::cppu::UnoType< T >::get();
353 }
354 
366 inline css::uno::Type const &
368  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
369 }
370 
382 template< typename T > inline css::uno::Type const &
383 getTypeFavourChar(css::uno::Sequence< T > const *);
384  // defined in com/sun/star/uno/Sequence.hxx
385 
387 
388 }
389 
390 #endif
391 
392 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CPPU_DLLPUBLIC typelib_TypeDescriptionReference ** typelib_static_type_getByTypeClass(typelib_TypeClass eTypeClass) SAL_THROW_EXTERN_C()
Gets static type reference of standard types by type class.
static css::uno::Type const & get()
Definition: unotype.hxx:272
unsigned char sal_Bool
Definition: types.h:18
type class of void
Definition: typeclass.h:12
type class of long
Definition: typeclass.h:24
type class of string
Definition: typeclass.h:36
type class of exception
Definition: typeclass.h:53
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:24
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
type class of double
Definition: typeclass.h:34
type class of char
Definition: typeclass.h:14
type class of unsigned long
Definition: typeclass.h:26
type class of short
Definition: typeclass.h:20
css::uno::Type const & getTypeFromTypeDescriptionReference(::typelib_TypeDescriptionReference *const *tdr)
Definition: unotype.hxx:85
sal_uInt16 sal_Unicode
Definition: types.h:103
type class of any
Definition: typeclass.h:40
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:548
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:31
type class of interface
Definition: typeclass.h:62
css::uno::Type const & getTypeFromTypeClass(::typelib_TypeClass tc)
Definition: unotype.hxx:92
type class of boolean
Definition: typeclass.h:16
type class of hyper
Definition: typeclass.h:28
type class of float
Definition: typeclass.h:32
type class of type
Definition: typeclass.h:38
CPPU_DLLPUBLIC void typelib_static_sequence_type_init(typelib_TypeDescriptionReference **ppRef, typelib_TypeDescriptionReference *pElementType) SAL_THROW_EXTERN_C()
Inits static sequence type reference.
A unique C++ type template representing the UNO sequence types in cppu::UnoType.
Definition: unotype.hxx:81
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:23
css::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER::cppu::UnoVoidType const *)
Definition: unotype.hxx:104
type class of byte
Definition: typeclass.h:18
signed char sal_Int8
Definition: types.h:23
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:304
type class of unsigned hyper
Definition: typeclass.h:30
::com::sun::star::uno::Type const & getTypeFavourChar(SAL_UNUSED_PARAMETER::com::sun::star::uno::Sequence< T > const *)
Definition: Sequence.hxx:323
type class of unsigned short
Definition: typeclass.h:22
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:358