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