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