1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_REGISTRY_READER_HXX
21 #define INCLUDED_REGISTRY_READER_HXX
23 #include <registry/typereg_reader.hxx>
24 #include <registry/refltype.hxx>
25 #include <registry/types.hxx>
26 #include <registry/version.h>
28 #include <rtl/ustring.hxx>
29 #include <sal/types.h>
37 A type reader working on a binary blob that represents a UNOIDL type.
39 <p>Instances of this class are not multi-thread–safe.</p>
46 Creates a type reader.
48 <p>If the given binary blob is malformed, or of a version larger than
49 <code>maxVersion</code>, the created type reader is flagged as
52 @param buffer the binary blob representing the type; must point to at
53 least <code>length</code> bytes, and need only be byte-aligned
55 @param length the size in bytes of the binary blob representing the type
57 @exception std::bad_alloc is raised if an out-of-memory condition occurs
59 Reader(void const * buffer
, sal_uInt32 length
)
61 if (!typereg_reader_create(buffer
, length
, false/*copy*/, TYPEREG_VERSION_1
, &m_handle
))
63 throw std::bad_alloc();
68 Shares a type reader between two <code>Reader</code> instances.
70 @param other another <code>Reader</code> instance
72 Reader(Reader
const & other
): m_handle(other
.m_handle
) {
73 typereg_reader_acquire(m_handle
);
77 Destroys this <code>Reader</code> instance.
79 <p>The underlying type reader is only destroyed if this instance was its
83 typereg_reader_release(m_handle
);
87 Replaces the underlying type reader.
89 @param other any <code>Reader</code> instance
91 @return this <code>Reader</code> instance
93 Reader
& operator =(Reader
const & other
) {
95 std::swap(this->m_handle
, temp
.m_handle
);
100 Returns whether this type reader is valid.
102 @return true iff this type reader is valid
104 bool isValid() const {
105 return m_handle
!= nullptr;
109 Returns the binary blob version of this type reader.
111 @return the version of the binary blob from which this type reader was
112 constructed; if this type reader is invalid,
113 <code>TYPEREG_VERSION_0</code> is returned
115 typereg_Version
getVersion() const {
116 return typereg_reader_getVersion(m_handle
);
120 Returns the documentation of this type reader.
122 @return the documentation of this type reader; if this type reader is
123 invalid, an empty string is returned
125 @exception std::bad_alloc is raised if an out-of-memory condition occurs
127 rtl::OUString
getDocumentation() const {
128 rtl_uString
* s
= nullptr;
129 typereg_reader_getDocumentation(m_handle
, &s
);
131 throw std::bad_alloc();
133 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
137 Returns the file name of this type reader.
139 @return the file name of this type reader; if this type reader is
140 invalid, an empty string is returned
142 @exception std::bad_alloc is raised if an out-of-memory condition occurs
145 rtl::OUString
getFileName() const {
146 rtl_uString
* s
= nullptr;
147 typereg_reader_getFileName(m_handle
, &s
);
149 throw std::bad_alloc();
151 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
155 Returns the type class of this type reader.
157 <p>This function will always return the type class without the internal
158 <code>RT_TYPE_PUBLISHED</code> flag set. Use <code>isPublished</code> to
159 determine whether this type reader is published.</p>
161 @return the type class of this type reader; if this type reader is
162 invalid, <code>RT_TYPE_INVALID</code> is returned
164 RTTypeClass
getTypeClass() const {
165 return typereg_reader_getTypeClass(m_handle
);
169 Returns whether this type reader is published.
171 @return whether this type reader is published; if this type reader is
172 invalid, <code>false</code> is returned
174 bool isPublished() const {
175 return typereg_reader_isPublished(m_handle
);
179 Returns the type name of this type reader.
181 @return the type name of this type reader; if this type reader is
182 invalid, an empty string is returned
184 @exception std::bad_alloc is raised if an out-of-memory condition occurs
186 rtl::OUString
getTypeName() const {
187 rtl_uString
* s
= nullptr;
188 typereg_reader_getTypeName(m_handle
, &s
);
190 throw std::bad_alloc();
192 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
196 Returns the number of super types of this type reader.
198 @return the number of super types of this type reader; if this type
199 reader is invalid, zero is returned
201 sal_uInt16
getSuperTypeCount() const {
202 return typereg_reader_getSuperTypeCount(m_handle
);
206 Returns the type name of a super type of this type reader.
208 @param index a valid index into the range of super types of this type
211 @return the type name of the given super type
213 @exception std::bad_alloc is raised if an out-of-memory condition occurs
215 rtl::OUString
getSuperTypeName(sal_uInt16 index
) const {
216 rtl_uString
* s
= nullptr;
217 typereg_reader_getSuperTypeName(m_handle
, &s
, index
);
219 throw std::bad_alloc();
221 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
225 Returns the number of fields of this type reader.
227 @return the number of fields of this type reader; if this type reader is
228 invalid, zero is returned
230 sal_uInt16
getFieldCount() const {
231 return typereg_reader_getFieldCount(m_handle
);
235 Returns the documentation of a field of this type reader.
237 @param index a valid index into the range of fields of this type reader
239 @return the documentation of the given field
241 @exception std::bad_alloc is raised if an out-of-memory condition occurs
243 rtl::OUString
getFieldDocumentation(sal_uInt16 index
) const {
244 rtl_uString
* s
= nullptr;
245 typereg_reader_getFieldDocumentation(m_handle
, &s
, index
);
247 throw std::bad_alloc();
249 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
253 Returns the file name of a field of this type reader.
255 @param index a valid index into the range of fields of this type reader
257 @return the file name of the given field
259 @exception std::bad_alloc is raised if an out-of-memory condition occurs
262 rtl::OUString
getFieldFileName(sal_uInt16 index
) const {
263 rtl_uString
* s
= nullptr;
264 typereg_reader_getFieldFileName(m_handle
, &s
, index
);
266 throw std::bad_alloc();
268 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
272 Returns the flags of a field of this type reader.
274 @param index a valid index into the range of fields of this type reader
276 @return the flags of the given field
278 RTFieldAccess
getFieldFlags(sal_uInt16 index
) const {
279 return typereg_reader_getFieldFlags(m_handle
, index
);
283 Returns the name of a field of this type reader.
285 @param index a valid index into the range of fields of this type reader
287 @return the name of the given field
289 @exception std::bad_alloc is raised if an out-of-memory condition occurs
291 rtl::OUString
getFieldName(sal_uInt16 index
) const {
292 rtl_uString
* s
= nullptr;
293 typereg_reader_getFieldName(m_handle
, &s
, index
);
295 throw std::bad_alloc();
297 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
301 Returns the type name of a field of this type reader.
303 @param index a valid index into the range of fields of this type reader
305 @return the type name of the given field
307 @exception std::bad_alloc is raised if an out-of-memory condition occurs
309 rtl::OUString
getFieldTypeName(sal_uInt16 index
) const {
310 rtl_uString
* s
= nullptr;
311 typereg_reader_getFieldTypeName(m_handle
, &s
, index
);
313 throw std::bad_alloc();
315 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
319 Returns the value of a field of this type reader.
321 @param index a valid index into the range of fields of this type reader
323 @return the value of the given field
325 @exception std::bad_alloc is raised if an out-of-memory condition occurs
327 RTConstValue
getFieldValue(sal_uInt16 index
) const {
329 if (!typereg_reader_getFieldValue(
330 m_handle
, index
, &v
.m_type
, &v
.m_value
))
332 throw std::bad_alloc();
338 Returns the number of methods of this type reader.
340 @return the number of methods of this type reader; if this type reader is
341 invalid, zero is returned
343 sal_uInt16
getMethodCount() const {
344 return typereg_reader_getMethodCount(m_handle
);
348 Returns the documentation of a method of this type reader.
350 @param index a valid index into the range of methods of this type reader
352 @return the documentation of the given method
354 @exception std::bad_alloc is raised if an out-of-memory condition occurs
356 rtl::OUString
getMethodDocumentation(sal_uInt16 index
) const {
357 rtl_uString
* s
= nullptr;
358 typereg_reader_getMethodDocumentation(m_handle
, &s
, index
);
360 throw std::bad_alloc();
362 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
366 Returns the flags of a method of this type reader.
368 @param index a valid index into the range of methods of this type reader
370 @return the flags of the given method
372 RTMethodMode
getMethodFlags(sal_uInt16 index
) const {
373 return typereg_reader_getMethodFlags(m_handle
, index
);
377 Returns the name of a method of this type reader.
379 @param index a valid index into the range of methods of this type reader
381 @return the name of the given method
383 @exception std::bad_alloc is raised if an out-of-memory condition occurs
385 rtl::OUString
getMethodName(sal_uInt16 index
) const {
386 rtl_uString
* s
= nullptr;
387 typereg_reader_getMethodName(m_handle
, &s
, index
);
389 throw std::bad_alloc();
391 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
395 Returns the return type name of a method of this type reader.
397 @param index a valid index into the range of methods of this type reader
399 @return the return type name of the given method
401 @exception std::bad_alloc is raised if an out-of-memory condition occurs
403 rtl::OUString
getMethodReturnTypeName(sal_uInt16 index
) const {
404 rtl_uString
* s
= nullptr;
405 typereg_reader_getMethodReturnTypeName(m_handle
, &s
, index
);
407 throw std::bad_alloc();
409 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
413 Returns the number of parameters of a method of this type reader.
415 @param index a valid index into the range of methods of this type reader
417 @return the number of parameters of the given method
419 sal_uInt16
getMethodParameterCount(sal_uInt16 index
) const {
420 return typereg_reader_getMethodParameterCount(m_handle
, index
);
424 Returns the flags of a parameter of a method of this type reader.
426 @param methodIndex a valid index into the range of methods of this type
429 @param parameterIndex a valid index into the range of parameters of the
432 @return the flags of the given method parameter
434 RTParamMode
getMethodParameterFlags(
435 sal_uInt16 methodIndex
, sal_uInt16 parameterIndex
) const
437 return typereg_reader_getMethodParameterFlags(
438 m_handle
, methodIndex
, parameterIndex
);
442 Returns the name of a parameter of a method of this type reader.
444 @param methodIndex a valid index into the range of methods of this type
447 @param parameterIndex a valid index into the range of parameters of the
450 @return the name of the given method parameter
452 @exception std::bad_alloc is raised if an out-of-memory condition occurs
454 rtl::OUString
getMethodParameterName(
455 sal_uInt16 methodIndex
, sal_uInt16 parameterIndex
) const
457 rtl_uString
* s
= nullptr;
458 typereg_reader_getMethodParameterName(
459 m_handle
, &s
, methodIndex
, parameterIndex
);
461 throw std::bad_alloc();
463 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
467 Returns the type name of a parameter of a method of this type reader.
469 @param methodIndex a valid index into the range of methods of this type
472 @param parameterIndex a valid index into the range of parameters of the
475 @return the type name of the given method parameter
477 @exception std::bad_alloc is raised if an out-of-memory condition occurs
479 rtl::OUString
getMethodParameterTypeName(
480 sal_uInt16 methodIndex
, sal_uInt16 parameterIndex
) const
482 rtl_uString
* s
= nullptr;
483 typereg_reader_getMethodParameterTypeName(
484 m_handle
, &s
, methodIndex
, parameterIndex
);
486 throw std::bad_alloc();
488 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
492 Returns the number of exceptions of a method of this type reader.
494 @param index a valid index into the range of methods of this type reader
496 @return the number of exceptions of the given method
498 sal_uInt16
getMethodExceptionCount(sal_uInt16 index
) const {
499 return typereg_reader_getMethodExceptionCount(m_handle
, index
);
503 Returns the type name of an exception of a method of this type reader.
505 @param methodIndex a valid index into the range of methods of this type
508 @param exceptionIndex a valid index into the range of exceptions of the
511 @return the type name of the given method exception
513 @exception std::bad_alloc is raised if an out-of-memory condition occurs
515 rtl::OUString
getMethodExceptionTypeName(
516 sal_uInt16 methodIndex
, sal_uInt16 exceptionIndex
) const
518 rtl_uString
* s
= nullptr;
519 typereg_reader_getMethodExceptionTypeName(
520 m_handle
, &s
, methodIndex
, exceptionIndex
);
522 throw std::bad_alloc();
524 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
528 Returns the number of references of this type reader.
530 @return the number of references of this type reader; if this type reader
531 is invalid, zero is returned
533 sal_uInt16
getReferenceCount() const {
534 return typereg_reader_getReferenceCount(m_handle
);
538 Returns the documentation of a reference of this type reader.
540 @param index a valid index into the range of references of this type
543 @return the documentation of the given reference
545 @exception std::bad_alloc is raised if an out-of-memory condition occurs
547 rtl::OUString
getReferenceDocumentation(sal_uInt16 index
) const {
548 rtl_uString
* s
= nullptr;
549 typereg_reader_getReferenceDocumentation(m_handle
, &s
, index
);
551 throw std::bad_alloc();
553 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
557 Returns the flags of a reference of this type reader.
559 @param index a valid index into the range of references of this type
562 @return the flags of the given reference
564 RTFieldAccess
getReferenceFlags(sal_uInt16 index
) const {
565 return typereg_reader_getReferenceFlags(m_handle
, index
);
569 Returns the sort of a reference of this type reader.
571 @param index a valid index into the range of references of this type
574 @return the sort of the given reference
576 RTReferenceType
getReferenceSort(sal_uInt16 index
) const {
577 return typereg_reader_getReferenceSort(m_handle
, index
);
581 Returns the type name of a reference of this type reader.
583 @param index a valid index into the range of references of this type
586 @return the type name of the given reference
588 @exception std::bad_alloc is raised if an out-of-memory condition occurs
590 rtl::OUString
getReferenceTypeName(sal_uInt16 index
) const {
591 rtl_uString
* s
= nullptr;
592 typereg_reader_getReferenceTypeName(m_handle
, &s
, index
);
594 throw std::bad_alloc();
596 return rtl::OUString(s
, SAL_NO_ACQUIRE
);
607 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */