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