Line data Source code
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 _REGISTRY_REFLREAD_HXX_
21 : #define _REGISTRY_REFLREAD_HXX_
22 :
23 : #include <registry/regdllapi.h>
24 : #include <registry/refltype.hxx>
25 : #include <registry/regtype.h>
26 : #include <rtl/ustring.hxx>
27 :
28 : /// Implememetation handle
29 : typedef void* TypeReaderImpl;
30 :
31 : /****************************************************************************
32 :
33 : C-Api
34 :
35 : *****************************************************************************/
36 :
37 : #ifdef __cplusplus
38 : extern "C" {
39 : #endif
40 :
41 : /** specifies a collection of function pointers which represents the complete registry type reader C-API.
42 :
43 : This funtions pointers are used by the C++ wrapper to call the C-API.
44 : */
45 : struct RegistryTypeReader_Api
46 : {
47 : TypeReaderImpl (TYPEREG_CALLTYPE *createEntry) (const sal_uInt8*, sal_uInt32, sal_Bool);
48 : void (TYPEREG_CALLTYPE *acquire) (TypeReaderImpl);
49 : void (TYPEREG_CALLTYPE *release) (TypeReaderImpl);
50 : sal_uInt16 (TYPEREG_CALLTYPE *getMinorVersion) (TypeReaderImpl);
51 : sal_uInt16 (TYPEREG_CALLTYPE *getMajorVersion) (TypeReaderImpl);
52 : RTTypeClass (TYPEREG_CALLTYPE *getTypeClass) (TypeReaderImpl);
53 : void (TYPEREG_CALLTYPE *getUik) (TypeReaderImpl, RTUik*);
54 : void (TYPEREG_CALLTYPE *getDoku) (TypeReaderImpl, rtl_uString**);
55 : void (TYPEREG_CALLTYPE *getFileName) (TypeReaderImpl, rtl_uString**);
56 : void (TYPEREG_CALLTYPE *getTypeName) (TypeReaderImpl, rtl_uString**);
57 : void (TYPEREG_CALLTYPE *getSuperTypeName) (TypeReaderImpl, rtl_uString**);
58 : sal_uInt32 (TYPEREG_CALLTYPE *getFieldCount) (TypeReaderImpl);
59 : void (TYPEREG_CALLTYPE *getFieldName) (TypeReaderImpl, rtl_uString**, sal_uInt16);
60 : void (TYPEREG_CALLTYPE *getFieldType) (TypeReaderImpl, rtl_uString**, sal_uInt16);
61 : RTFieldAccess (TYPEREG_CALLTYPE *getFieldAccess) (TypeReaderImpl, sal_uInt16);
62 : RTValueType (TYPEREG_CALLTYPE *getFieldConstValue) (TypeReaderImpl, sal_uInt16, RTConstValueUnion*);
63 : void (TYPEREG_CALLTYPE *getFieldDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16);
64 : void (TYPEREG_CALLTYPE *getFieldFileName) (TypeReaderImpl, rtl_uString**, sal_uInt16);
65 : sal_uInt32 (TYPEREG_CALLTYPE *getMethodCount) (TypeReaderImpl);
66 : void (TYPEREG_CALLTYPE *getMethodName) (TypeReaderImpl, rtl_uString**, sal_uInt16);
67 : sal_uInt32 (TYPEREG_CALLTYPE *getMethodParamCount) (TypeReaderImpl, sal_uInt16);
68 : void (TYPEREG_CALLTYPE *getMethodParamType) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16);
69 : void (TYPEREG_CALLTYPE *getMethodParamName) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16);
70 : RTParamMode (TYPEREG_CALLTYPE *getMethodParamMode) (TypeReaderImpl, sal_uInt16, sal_uInt16);
71 : sal_uInt32 (TYPEREG_CALLTYPE *getMethodExcCount) (TypeReaderImpl, sal_uInt16);
72 : void (TYPEREG_CALLTYPE *getMethodExcType) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16);
73 : void (TYPEREG_CALLTYPE *getMethodReturnType) (TypeReaderImpl, rtl_uString**, sal_uInt16);
74 : RTMethodMode (TYPEREG_CALLTYPE *getMethodMode) (TypeReaderImpl, sal_uInt16);
75 : void (TYPEREG_CALLTYPE *getMethodDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16);
76 :
77 : sal_uInt32 (TYPEREG_CALLTYPE *getReferenceCount) (TypeReaderImpl);
78 : void (TYPEREG_CALLTYPE *getReferenceName) (TypeReaderImpl, rtl_uString**, sal_uInt16);
79 : RTReferenceType (TYPEREG_CALLTYPE *getReferenceType) (TypeReaderImpl, sal_uInt16);
80 : void (TYPEREG_CALLTYPE *getReferenceDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16);
81 : RTFieldAccess (TYPEREG_CALLTYPE *getReferenceAccess) (TypeReaderImpl, sal_uInt16);
82 : };
83 :
84 : /** the API initialization function.
85 : */
86 : REG_DLLPUBLIC RegistryTypeReader_Api* TYPEREG_CALLTYPE initRegistryTypeReader_Api(void);
87 :
88 : #ifdef __cplusplus
89 : }
90 : #endif
91 :
92 : /** RegistryTypeReades reads a binary type blob.
93 :
94 : This class provides the necessary functions to read type information
95 : for all kinds of types of a type blob.
96 : The class is inline and use a C-Api.
97 :
98 : @deprecated
99 : use typereg::Reader instead
100 : */
101 : class RegistryTypeReader
102 : {
103 : public:
104 :
105 : /** Constructor.
106 :
107 : @param buffer points to the binary data block.
108 : @param bufferLen specifies the size of the binary data block.
109 : @param copyData specifies if the data block should be copied.
110 : The block can be copied to ensure that the data
111 : is valid for the lifetime of this instance.
112 : */
113 : inline RegistryTypeReader(const sal_uInt8* buffer,
114 : sal_uInt32 bufferLen,
115 : sal_Bool copyData);
116 :
117 : /// Copy constructcor
118 : inline RegistryTypeReader(const RegistryTypeReader& toCopy);
119 :
120 : /// Destructor. The Destructor frees the data block if the copyData flag was TRUE.
121 : inline ~RegistryTypeReader();
122 :
123 : /// Assign operator
124 : inline RegistryTypeReader& operator == (const RegistryTypeReader& toAssign);
125 :
126 : /// checks if the registry type reader points to a valid Api.
127 : inline sal_Bool isValid() const;
128 :
129 : /** @deprecated
130 : returns the minor version number.
131 :
132 : We currently don't support a versioning concept of IDL interfaces and
133 : so this function is currently not used.
134 : */
135 : inline sal_uInt16 getMinorVersion() const;
136 :
137 : /** @deprecated
138 : returns the major version number.
139 :
140 : We currently don't support a versioning concept of IDL interfaces and
141 : so this function is currently not used.
142 : */
143 : inline sal_uInt16 getMajorVersion() const;
144 :
145 : /** returns the typeclass of the type represented by this blob.
146 :
147 : This function will always return the type class without the internal
148 : RT_TYPE_PUBLISHED flag set.
149 : */
150 : inline RTTypeClass getTypeClass() const;
151 :
152 : /** returns the full qualified name of the type.
153 : */
154 : inline OUString getTypeName() const;
155 :
156 : /** returns the full qualified name of the supertype.
157 : */
158 : inline OUString getSuperTypeName() const;
159 :
160 : /** @deprecated
161 : returns the unique identifier for an interface type as an out parameter.
162 :
163 : An earlier version of UNO used an unique identifier for interfaces. In the
164 : current version of UNO this uik was eliminated and this function is
165 : not longer used.
166 : */
167 : inline void getUik(RTUik& uik) const;
168 :
169 : /** returns the documentation string of this type.
170 : */
171 : inline OUString getDoku() const;
172 :
173 : /** returns the IDL filename where the type is defined.
174 : */
175 : inline OUString getFileName() const;
176 :
177 : /** returns the number of fields (attributes/properties, enum values or number
178 : of constants in a module).
179 :
180 : */
181 : inline sal_uInt32 getFieldCount() const;
182 :
183 : /** returns the name of the field specified by index.
184 : */
185 : inline OUString getFieldName( sal_uInt16 index ) const;
186 :
187 : /** returns the full qualified name of the field specified by index.
188 : */
189 : inline OUString getFieldType( sal_uInt16 index ) const;
190 :
191 : /** returns the access mode of the field specified by index.
192 : */
193 : inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const;
194 :
195 : /** returns the value of the field specified by index.
196 :
197 : This function returns the value of an enum value or of a constant.
198 : */
199 : inline RTConstValue getFieldConstValue( sal_uInt16 index ) const;
200 :
201 : /** returns the documentation string for the field specified by index.
202 :
203 : Each field of a type can have their own documentation.
204 : */
205 : inline OUString getFieldDoku( sal_uInt16 index ) const;
206 :
207 : /** returns the IDL filename of the field specified by index.
208 :
209 : The IDL filename of a field can differ from the filename of the ype itself
210 : because modules and also constants can be defined in different IDL files.
211 : */
212 : inline OUString getFieldFileName( sal_uInt16 index ) const;
213 :
214 : /** returns the number of methods of an interface type.
215 : */
216 : inline sal_uInt32 getMethodCount() const;
217 :
218 : /** returns the name of the method specified by index.
219 : */
220 : inline OUString getMethodName( sal_uInt16 index ) const;
221 :
222 : /** returns number of parameters of the method specified by index.
223 : */
224 : inline sal_uInt32 getMethodParamCount( sal_uInt16 index ) const;
225 :
226 : /** returns the full qualified parameter typename.
227 :
228 : @param index indicates the method
229 : @param paramIndex indeciates the parameter which type will be returned.
230 : */
231 : inline OUString getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const;
232 :
233 : /** returns the name of a parameter.
234 :
235 : @param index indicates the method
236 : @param paramIndex indiciates the parameter which name will be returned.
237 : */
238 : inline OUString getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const;
239 :
240 : /** returns the parameter mode, if it is an in, out or inout parameter.
241 :
242 : @param index indicates the method
243 : @param paramIndex indeciates the parameter which mode will be returned.
244 : */
245 : inline RTParamMode getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const;
246 :
247 : /** returns the number of exceptions which are declared for the method specified by index.
248 :
249 : @param index indicates the method
250 : */
251 : inline sal_uInt32 getMethodExcCount( sal_uInt16 index ) const;
252 :
253 : /** returns the full qualified exception type of the specified exception.
254 :
255 : @param index indicates the method
256 : @param excIndex indeciates the exception which typename will be returned.
257 : */
258 : inline OUString getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const;
259 :
260 : /** returns the full qualified return type of the method specified by index.
261 : */
262 : inline OUString getMethodReturnType( sal_uInt16 index ) const;
263 :
264 : /** returns the full qualified exception type of the specified exception.
265 :
266 : @param index indicates the method
267 : */
268 : inline RTMethodMode getMethodMode( sal_uInt16 index ) const;
269 :
270 : /** returns the documentation string of the method specified by index.
271 :
272 : @param index indicates the method.
273 : */
274 : inline OUString getMethodDoku( sal_uInt16 index ) const;
275 :
276 : /** returns the number of references (supported interfaces, exported services).
277 : */
278 : inline sal_uInt32 getReferenceCount() const;
279 :
280 : /** returns the full qualified typename of the reference specified by index.
281 :
282 : @param index indicates the reference.
283 : */
284 : inline OUString getReferenceName( sal_uInt16 index ) const;
285 :
286 : /** returns the type of the reference specified by index.
287 :
288 : @param index indicates the reference.
289 : */
290 : inline RTReferenceType getReferenceType( sal_uInt16 index ) const;
291 :
292 : /** returns the documentation string of the reference specified by index.
293 :
294 : @param index indicates the reference.
295 : */
296 : inline OUString getReferenceDoku( sal_uInt16 index ) const;
297 :
298 : /** returns the access mode of the reference specified by index.
299 :
300 : The only valid value is RT_ACCESS_OPTIONAL in the context of
301 : references.
302 : @param index indicates the reference.
303 : */
304 : inline RTFieldAccess getReferenceAccess( sal_uInt16 index ) const;
305 :
306 : protected:
307 :
308 : /// stores the registry type reader Api.
309 : const RegistryTypeReader_Api* m_pApi;
310 : /// stores the handle of an implementation class
311 : TypeReaderImpl m_hImpl;
312 : };
313 :
314 :
315 :
316 41712 : inline RegistryTypeReader::RegistryTypeReader(const sal_uInt8* buffer,
317 : sal_uInt32 bufferLen,
318 : sal_Bool copyData)
319 41712 : : m_pApi(initRegistryTypeReader_Api())
320 41712 : , m_hImpl(NULL)
321 : {
322 41712 : m_hImpl = m_pApi->createEntry(buffer, bufferLen, copyData);
323 41712 : }
324 :
325 :
326 : inline RegistryTypeReader::RegistryTypeReader(const RegistryTypeReader& toCopy)
327 : : m_pApi(toCopy.m_pApi)
328 : , m_hImpl(toCopy.m_hImpl)
329 : { m_pApi->acquire(m_hImpl); }
330 :
331 :
332 41712 : inline RegistryTypeReader::~RegistryTypeReader()
333 41712 : { m_pApi->release(m_hImpl); }
334 :
335 : inline RegistryTypeReader& RegistryTypeReader::operator == (const RegistryTypeReader& toAssign)
336 : {
337 : if (m_hImpl != toAssign.m_hImpl)
338 : {
339 : m_pApi->release(m_hImpl);
340 : m_hImpl = toAssign.m_hImpl;
341 : m_pApi->acquire(m_hImpl);
342 : }
343 :
344 : return *this;
345 : }
346 :
347 : inline sal_uInt16 RegistryTypeReader::getMinorVersion() const
348 : { return m_pApi->getMinorVersion(m_hImpl); }
349 :
350 : inline sal_Bool RegistryTypeReader::isValid() const
351 : { return (m_hImpl != NULL); }
352 :
353 : inline sal_uInt16 RegistryTypeReader::getMajorVersion() const
354 : { return m_pApi->getMajorVersion(m_hImpl); }
355 :
356 104280 : inline RTTypeClass RegistryTypeReader::getTypeClass() const
357 104280 : { return m_pApi->getTypeClass(m_hImpl); }
358 :
359 0 : inline OUString RegistryTypeReader::getTypeName() const
360 : {
361 0 : OUString sRet;
362 0 : m_pApi->getTypeName(m_hImpl, &sRet.pData);
363 0 : return sRet;
364 : }
365 :
366 0 : inline OUString RegistryTypeReader::getSuperTypeName() const
367 : {
368 0 : OUString sRet;
369 0 : m_pApi->getSuperTypeName(m_hImpl, &sRet.pData);
370 0 : return sRet;
371 : }
372 :
373 : inline void RegistryTypeReader::getUik(RTUik& uik) const
374 : { m_pApi->getUik(m_hImpl, &uik); }
375 :
376 : inline OUString RegistryTypeReader::getDoku() const
377 : {
378 : OUString sRet;
379 : m_pApi->getDoku(m_hImpl, &sRet.pData);
380 : return sRet;
381 : }
382 :
383 : inline OUString RegistryTypeReader::getFileName() const
384 : {
385 : OUString sRet;
386 : m_pApi->getFileName(m_hImpl, &sRet.pData);
387 : return sRet;
388 : }
389 :
390 41712 : inline sal_uInt32 RegistryTypeReader::getFieldCount() const
391 41712 : { return m_pApi->getFieldCount(m_hImpl); }
392 :
393 0 : inline OUString RegistryTypeReader::getFieldName( sal_uInt16 index ) const
394 : {
395 0 : OUString sRet;
396 0 : m_pApi->getFieldName(m_hImpl, &sRet.pData, index);
397 0 : return sRet;
398 : }
399 :
400 0 : inline OUString RegistryTypeReader::getFieldType( sal_uInt16 index ) const
401 : {
402 0 : OUString sRet;
403 0 : m_pApi->getFieldType(m_hImpl, &sRet.pData, index);
404 0 : return sRet;
405 : }
406 :
407 0 : inline RTFieldAccess RegistryTypeReader::getFieldAccess( sal_uInt16 index ) const
408 0 : { return m_pApi->getFieldAccess(m_hImpl, index); }
409 :
410 0 : inline RTConstValue RegistryTypeReader::getFieldConstValue( sal_uInt16 index ) const
411 : {
412 0 : RTConstValue ret;
413 0 : ret.m_type = m_pApi->getFieldConstValue(m_hImpl, index, &ret.m_value);
414 0 : return ret;
415 : }
416 :
417 0 : inline OUString RegistryTypeReader::getFieldDoku( sal_uInt16 index ) const
418 : {
419 0 : OUString sRet;
420 0 : m_pApi->getFieldDoku(m_hImpl, &sRet.pData, index);
421 0 : return sRet;
422 : }
423 :
424 0 : inline OUString RegistryTypeReader::getFieldFileName( sal_uInt16 index ) const
425 : {
426 0 : OUString sRet;
427 0 : m_pApi->getFieldFileName(m_hImpl, &sRet.pData, index);
428 0 : return sRet;
429 : }
430 :
431 : inline sal_uInt32 RegistryTypeReader::getMethodCount() const
432 : { return m_pApi->getMethodCount(m_hImpl); }
433 :
434 : inline OUString RegistryTypeReader::getMethodName( sal_uInt16 index ) const
435 : {
436 : OUString sRet;
437 : m_pApi->getMethodName(m_hImpl, &sRet.pData, index);
438 : return sRet;
439 : }
440 :
441 : inline sal_uInt32 RegistryTypeReader::getMethodParamCount( sal_uInt16 index ) const
442 : { return m_pApi->getMethodParamCount(m_hImpl, index); }
443 :
444 : inline OUString RegistryTypeReader::getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const
445 : {
446 : OUString sRet;
447 : m_pApi->getMethodParamType(m_hImpl, &sRet.pData, index, paramIndex);
448 : return sRet;
449 : }
450 :
451 : inline OUString RegistryTypeReader::getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const
452 : {
453 : OUString sRet;
454 : m_pApi->getMethodParamName(m_hImpl, &sRet.pData, index, paramIndex);
455 : return sRet;
456 : }
457 :
458 : inline RTParamMode RegistryTypeReader::getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const
459 : { return m_pApi->getMethodParamMode(m_hImpl, index, paramIndex); }
460 :
461 : inline sal_uInt32 RegistryTypeReader::getMethodExcCount( sal_uInt16 index ) const
462 : { return m_pApi->getMethodExcCount(m_hImpl, index); }
463 :
464 : inline OUString RegistryTypeReader::getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const
465 : {
466 : OUString sRet;
467 : m_pApi->getMethodExcType(m_hImpl, &sRet.pData, index, excIndex);
468 : return sRet;
469 : }
470 :
471 : inline OUString RegistryTypeReader::getMethodReturnType( sal_uInt16 index ) const
472 : {
473 : OUString sRet;
474 : m_pApi->getMethodReturnType(m_hImpl, &sRet.pData, index);
475 : return sRet;
476 : }
477 :
478 : inline RTMethodMode RegistryTypeReader::getMethodMode( sal_uInt16 index ) const
479 : { return m_pApi->getMethodMode(m_hImpl, index); }
480 :
481 : inline OUString RegistryTypeReader::getMethodDoku( sal_uInt16 index ) const
482 : {
483 : OUString sRet;
484 : m_pApi->getMethodDoku(m_hImpl, &sRet.pData, index);
485 : return sRet;
486 : }
487 :
488 : inline sal_uInt32 RegistryTypeReader::getReferenceCount() const
489 : { return m_pApi->getReferenceCount(m_hImpl); }
490 :
491 : inline OUString RegistryTypeReader::getReferenceName( sal_uInt16 index ) const
492 : {
493 : OUString sRet;
494 : m_pApi->getReferenceName(m_hImpl, &sRet.pData, index);
495 : return sRet;
496 : }
497 :
498 : inline RTReferenceType RegistryTypeReader::getReferenceType( sal_uInt16 index ) const
499 : { return m_pApi->getReferenceType(m_hImpl, index); }
500 :
501 : inline OUString RegistryTypeReader::getReferenceDoku( sal_uInt16 index ) const
502 : {
503 : OUString sRet;
504 : m_pApi->getReferenceDoku(m_hImpl, &sRet.pData, index);
505 : return sRet;
506 : }
507 :
508 : inline RTFieldAccess RegistryTypeReader::getReferenceAccess( sal_uInt16 index ) const
509 : { return m_pApi->getReferenceAccess(m_hImpl, index); }
510 :
511 : #endif
512 :
513 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|