tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / include / registry / reader.hxx
blob27b3cb50e8d74f61a64c38ca24326f9a341a4e53
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <registry/typereg_reader.hxx>
23 #include <registry/refltype.hxx>
24 #include <registry/types.hxx>
25 #include <registry/version.h>
27 #include <rtl/ustring.hxx>
28 #include <sal/types.h>
30 #include <new>
32 namespace typereg {
34 /**
35 A type reader working on a binary blob that represents a UNOIDL type.
37 <p>Instances of this class are not multi-thread&ndash;safe.</p>
39 @since UDK 3.2.0
41 class Reader {
42 public:
43 /**
44 Creates a type reader.
46 <p>If the given binary blob is malformed, or of a version larger than
47 <code>maxVersion</code>, the created type reader is flagged as
48 invalid.</p>
50 @param buffer the binary blob representing the type; must point to at
51 least <code>length</code> bytes, and need only be byte-aligned
53 @param length the size in bytes of the binary blob representing the type
55 @exception std::bad_alloc is raised if an out-of-memory condition occurs
57 Reader(void const * buffer, sal_uInt32 length)
59 if (!typereg_reader_create(buffer, length, &m_handle))
61 throw std::bad_alloc();
65 /**
66 Shares a type reader between two <code>Reader</code> instances.
68 @param other another <code>Reader</code> instance
70 Reader(Reader const & other): m_handle(other.m_handle) {
71 typereg_reader_acquire(m_handle);
74 /**
75 Destroys this <code>Reader</code> instance.
77 <p>The underlying type reader is only destroyed if this instance was its
78 last user.</p>
80 ~Reader() {
81 typereg_reader_release(m_handle);
84 /**
85 Replaces the underlying type reader.
87 @param other any <code>Reader</code> instance
89 @return this <code>Reader</code> instance
91 Reader & operator =(Reader const & other) {
92 Reader temp(other);
93 std::swap(m_handle, temp.m_handle);
94 return *this;
97 /**
98 Returns whether this type reader is valid.
100 @return true iff this type reader is valid
102 bool isValid() const {
103 return m_handle != nullptr;
107 Returns the binary blob version of this type reader.
109 @return the version of the binary blob from which this type reader was
110 constructed; if this type reader is invalid,
111 <code>TYPEREG_VERSION_0</code> is returned
113 typereg_Version getVersion() const {
114 return typereg_reader_getVersion(m_handle);
118 Returns the documentation of this type reader.
120 @return the documentation of this type reader; if this type reader is
121 invalid, an empty string is returned
123 @exception std::bad_alloc is raised if an out-of-memory condition occurs
125 OUString getDocumentation() const {
126 rtl_uString * s = nullptr;
127 typereg_reader_getDocumentation(m_handle, &s);
128 if (s == nullptr) {
129 throw std::bad_alloc();
131 return OUString(s, SAL_NO_ACQUIRE);
135 Returns the file name of this type reader.
137 @return the file name of this type reader; if this type reader is
138 invalid, an empty string is returned
140 @exception std::bad_alloc is raised if an out-of-memory condition occurs
141 @deprecated
143 OUString getFileName() const {
144 rtl_uString * s = nullptr;
145 typereg_reader_getFileName(m_handle, &s);
146 if (s == nullptr) {
147 throw std::bad_alloc();
149 return OUString(s, SAL_NO_ACQUIRE);
153 Returns the type class of this type reader.
155 <p>This function will always return the type class without the internal
156 <code>RT_TYPE_PUBLISHED</code> flag set. Use <code>isPublished</code> to
157 determine whether this type reader is published.</p>
159 @return the type class of this type reader; if this type reader is
160 invalid, <code>RT_TYPE_INVALID</code> is returned
162 RTTypeClass getTypeClass() const {
163 return typereg_reader_getTypeClass(m_handle);
167 Returns whether this type reader is published.
169 @return whether this type reader is published; if this type reader is
170 invalid, <code>false</code> is returned
172 bool isPublished() const {
173 return typereg_reader_isPublished(m_handle);
177 Returns the type name of this type reader.
179 @return the type name of this type reader; if this type reader is
180 invalid, an empty string is returned
182 @exception std::bad_alloc is raised if an out-of-memory condition occurs
184 OUString getTypeName() const {
185 rtl_uString * s = nullptr;
186 typereg_reader_getTypeName(m_handle, &s);
187 if (s == nullptr) {
188 throw std::bad_alloc();
190 return OUString(s, SAL_NO_ACQUIRE);
194 Returns the number of super types of this type reader.
196 @return the number of super types of this type reader; if this type
197 reader is invalid, zero is returned
199 sal_uInt16 getSuperTypeCount() const {
200 return typereg_reader_getSuperTypeCount(m_handle);
204 Returns the type name of a super type of this type reader.
206 @param index a valid index into the range of super types of this type
207 reader
209 @return the type name of the given super type
211 @exception std::bad_alloc is raised if an out-of-memory condition occurs
213 OUString getSuperTypeName(sal_uInt16 index) const {
214 rtl_uString * s = nullptr;
215 typereg_reader_getSuperTypeName(m_handle, &s, index);
216 if (s == nullptr) {
217 throw std::bad_alloc();
219 return OUString(s, SAL_NO_ACQUIRE);
223 Returns the number of fields of this type reader.
225 @return the number of fields of this type reader; if this type reader is
226 invalid, zero is returned
228 sal_uInt16 getFieldCount() const {
229 return typereg_reader_getFieldCount(m_handle);
233 Returns the documentation of a field of this type reader.
235 @param index a valid index into the range of fields of this type reader
237 @return the documentation of the given field
239 @exception std::bad_alloc is raised if an out-of-memory condition occurs
241 OUString getFieldDocumentation(sal_uInt16 index) const {
242 rtl_uString * s = nullptr;
243 typereg_reader_getFieldDocumentation(m_handle, &s, index);
244 if (s == nullptr) {
245 throw std::bad_alloc();
247 return OUString(s, SAL_NO_ACQUIRE);
251 Returns the file name of a field of this type reader.
253 @param index a valid index into the range of fields of this type reader
255 @return the file name of the given field
257 @exception std::bad_alloc is raised if an out-of-memory condition occurs
258 @deprecated
260 OUString getFieldFileName(sal_uInt16 index) const {
261 rtl_uString * s = nullptr;
262 typereg_reader_getFieldFileName(m_handle, &s, index);
263 if (s == nullptr) {
264 throw std::bad_alloc();
266 return OUString(s, SAL_NO_ACQUIRE);
270 Returns the flags of a field of this type reader.
272 @param index a valid index into the range of fields of this type reader
274 @return the flags of the given field
276 RTFieldAccess getFieldFlags(sal_uInt16 index) const {
277 return typereg_reader_getFieldFlags(m_handle, index);
281 Returns the name of a field of this type reader.
283 @param index a valid index into the range of fields of this type reader
285 @return the name of the given field
287 @exception std::bad_alloc is raised if an out-of-memory condition occurs
289 OUString getFieldName(sal_uInt16 index) const {
290 rtl_uString * s = nullptr;
291 typereg_reader_getFieldName(m_handle, &s, index);
292 if (s == nullptr) {
293 throw std::bad_alloc();
295 return OUString(s, SAL_NO_ACQUIRE);
299 Returns the type name of a field of this type reader.
301 @param index a valid index into the range of fields of this type reader
303 @return the type name of the given field
305 @exception std::bad_alloc is raised if an out-of-memory condition occurs
307 OUString getFieldTypeName(sal_uInt16 index) const {
308 rtl_uString * s = nullptr;
309 typereg_reader_getFieldTypeName(m_handle, &s, index);
310 if (s == nullptr) {
311 throw std::bad_alloc();
313 return OUString(s, SAL_NO_ACQUIRE);
317 Returns the value of a field of this type reader.
319 @param index a valid index into the range of fields of this type reader
321 @return the value of the given field
323 @exception std::bad_alloc is raised if an out-of-memory condition occurs
325 RTConstValue getFieldValue(sal_uInt16 index) const {
326 RTConstValue v;
327 if (!typereg_reader_getFieldValue(
328 m_handle, index, &v.m_type, &v.m_value))
330 throw std::bad_alloc();
332 return v;
336 Returns the number of methods of this type reader.
338 @return the number of methods of this type reader; if this type reader is
339 invalid, zero is returned
341 sal_uInt16 getMethodCount() const {
342 return typereg_reader_getMethodCount(m_handle);
346 Returns the documentation of a method of this type reader.
348 @param index a valid index into the range of methods of this type reader
350 @return the documentation of the given method
352 @exception std::bad_alloc is raised if an out-of-memory condition occurs
354 OUString getMethodDocumentation(sal_uInt16 index) const {
355 rtl_uString * s = nullptr;
356 typereg_reader_getMethodDocumentation(m_handle, &s, index);
357 if (s == nullptr) {
358 throw std::bad_alloc();
360 return OUString(s, SAL_NO_ACQUIRE);
364 Returns the flags of a method of this type reader.
366 @param index a valid index into the range of methods of this type reader
368 @return the flags of the given method
370 RTMethodMode getMethodFlags(sal_uInt16 index) const {
371 return typereg_reader_getMethodFlags(m_handle, index);
375 Returns the name of a method of this type reader.
377 @param index a valid index into the range of methods of this type reader
379 @return the name of the given method
381 @exception std::bad_alloc is raised if an out-of-memory condition occurs
383 OUString getMethodName(sal_uInt16 index) const {
384 rtl_uString * s = nullptr;
385 typereg_reader_getMethodName(m_handle, &s, index);
386 if (s == nullptr) {
387 throw std::bad_alloc();
389 return OUString(s, SAL_NO_ACQUIRE);
393 Returns the return type name of a method of this type reader.
395 @param index a valid index into the range of methods of this type reader
397 @return the return type name of the given method
399 @exception std::bad_alloc is raised if an out-of-memory condition occurs
401 OUString getMethodReturnTypeName(sal_uInt16 index) const {
402 rtl_uString * s = nullptr;
403 typereg_reader_getMethodReturnTypeName(m_handle, &s, index);
404 if (s == nullptr) {
405 throw std::bad_alloc();
407 return OUString(s, SAL_NO_ACQUIRE);
411 Returns the number of parameters of a method of this type reader.
413 @param index a valid index into the range of methods of this type reader
415 @return the number of parameters of the given method
417 sal_uInt16 getMethodParameterCount(sal_uInt16 index) const {
418 return typereg_reader_getMethodParameterCount(m_handle, index);
422 Returns the flags of a parameter of a method of this type reader.
424 @param methodIndex a valid index into the range of methods of this type
425 reader
427 @param parameterIndex a valid index into the range of parameters of the
428 given method
430 @return the flags of the given method parameter
432 RTParamMode getMethodParameterFlags(
433 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
435 return typereg_reader_getMethodParameterFlags(
436 m_handle, methodIndex, parameterIndex);
440 Returns the name of a parameter of a method of this type reader.
442 @param methodIndex a valid index into the range of methods of this type
443 reader
445 @param parameterIndex a valid index into the range of parameters of the
446 given method
448 @return the name of the given method parameter
450 @exception std::bad_alloc is raised if an out-of-memory condition occurs
452 OUString getMethodParameterName(
453 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
455 rtl_uString * s = nullptr;
456 typereg_reader_getMethodParameterName(
457 m_handle, &s, methodIndex, parameterIndex);
458 if (s == nullptr) {
459 throw std::bad_alloc();
461 return OUString(s, SAL_NO_ACQUIRE);
465 Returns the type name of a parameter of a method of this type reader.
467 @param methodIndex a valid index into the range of methods of this type
468 reader
470 @param parameterIndex a valid index into the range of parameters of the
471 given method
473 @return the type name of the given method parameter
475 @exception std::bad_alloc is raised if an out-of-memory condition occurs
477 OUString getMethodParameterTypeName(
478 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
480 rtl_uString * s = nullptr;
481 typereg_reader_getMethodParameterTypeName(
482 m_handle, &s, methodIndex, parameterIndex);
483 if (s == nullptr) {
484 throw std::bad_alloc();
486 return OUString(s, SAL_NO_ACQUIRE);
490 Returns the number of exceptions of a method of this type reader.
492 @param index a valid index into the range of methods of this type reader
494 @return the number of exceptions of the given method
496 sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const {
497 return typereg_reader_getMethodExceptionCount(m_handle, index);
501 Returns the type name of an exception of a method of this type reader.
503 @param methodIndex a valid index into the range of methods of this type
504 reader
506 @param exceptionIndex a valid index into the range of exceptions of the
507 given method
509 @return the type name of the given method exception
511 @exception std::bad_alloc is raised if an out-of-memory condition occurs
513 OUString getMethodExceptionTypeName(
514 sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const
516 rtl_uString * s = nullptr;
517 typereg_reader_getMethodExceptionTypeName(
518 m_handle, &s, methodIndex, exceptionIndex);
519 if (s == nullptr) {
520 throw std::bad_alloc();
522 return OUString(s, SAL_NO_ACQUIRE);
526 Returns the number of references of this type reader.
528 @return the number of references of this type reader; if this type reader
529 is invalid, zero is returned
531 sal_uInt16 getReferenceCount() const {
532 return typereg_reader_getReferenceCount(m_handle);
536 Returns the documentation of a reference of this type reader.
538 @param index a valid index into the range of references of this type
539 reader
541 @return the documentation of the given reference
543 @exception std::bad_alloc is raised if an out-of-memory condition occurs
545 OUString getReferenceDocumentation(sal_uInt16 index) const {
546 rtl_uString * s = nullptr;
547 typereg_reader_getReferenceDocumentation(m_handle, &s, index);
548 if (s == nullptr) {
549 throw std::bad_alloc();
551 return OUString(s, SAL_NO_ACQUIRE);
555 Returns the flags of a reference of this type reader.
557 @param index a valid index into the range of references of this type
558 reader
560 @return the flags of the given reference
562 RTFieldAccess getReferenceFlags(sal_uInt16 index) const {
563 return typereg_reader_getReferenceFlags(m_handle, index);
567 Returns the sort of a reference of this type reader.
569 @param index a valid index into the range of references of this type
570 reader
572 @return the sort of the given reference
574 RTReferenceType getReferenceSort(sal_uInt16 index) const {
575 return typereg_reader_getReferenceSort(m_handle, index);
579 Returns the type name of a reference of this type reader.
581 @param index a valid index into the range of references of this type
582 reader
584 @return the type name of the given reference
586 @exception std::bad_alloc is raised if an out-of-memory condition occurs
588 OUString getReferenceTypeName(sal_uInt16 index) const {
589 rtl_uString * s = nullptr;
590 typereg_reader_getReferenceTypeName(m_handle, &s, index);
591 if (s == nullptr) {
592 throw std::bad_alloc();
594 return OUString(s, SAL_NO_ACQUIRE);
597 private:
598 void * m_handle;
603 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */