fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / registry / reader.hxx
bloba867f3b1185a6d0c3c37ee96e168482bacfddd49
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 #ifndef INCLUDED_registry_reader_hxx
21 #define INCLUDED_registry_reader_hxx
23 #include "registry/reader.h"
24 #include "registry/refltype.hxx"
25 #include "registry/types.h"
26 #include "registry/version.h"
28 #include "rtl/ustring.hxx"
29 #include "sal/types.h"
31 #include <algorithm>
32 #include <new>
34 namespace typereg {
36 /**
37 A type reader working on a binary blob that represents a UNOIDL type.
39 <p>Instances of this class are not multi-thread&ndash;safe.</p>
41 @since UDK 3.2.0
43 class Reader {
44 public:
45 /**
46 Creates an invalid type reader.
48 Reader(): m_handle(0) {}
50 /**
51 Creates a type reader.
53 <p>If the given binary blob is malformed, or of a version larger than
54 <code>maxVersion</code>, the created type reader is flagged as
55 invalid.</p>
57 @param buffer the binary blob representing the type; must point to at
58 least <code>length</code> bytes, and need only be byte-aligned
60 @param length the size in bytes of the binary blob representing the type
62 @param copy if true, the type reader creates an internal copy of the
63 given buffer, and the given buffer is not accessed after this constructor
64 returns; if false, the type reader works directly on the given buffer,
65 which must remain available unmodified until the underlying type reader
66 is destroyed (note that the lifetime of the underlying type reader can be
67 different from the lifetime of this <code>Reader</code> instance)
69 @param maxVersion the maximum binary blob version the client is prepared
70 to handle; must not be negative
72 @exception std::bad_alloc is raised if an out-of-memory condition occurs
74 Reader(
75 void const * buffer, sal_uInt32 length, bool copy,
76 typereg_Version maxVersion)
78 if (!typereg_reader_create(buffer, length, copy, maxVersion, &m_handle))
80 throw std::bad_alloc();
84 /**
85 Shares a type reader between two <code>Reader</code> instances.
87 @param other another <code>Reader</code> instance
89 Reader(Reader const & other): m_handle(other.m_handle) {
90 typereg_reader_acquire(m_handle);
93 /**
94 Destroys this <code>Reader</code> instance.
96 <p>The underlying type reader is only destroyed if this instance was its
97 last user.</p>
99 ~Reader() {
100 typereg_reader_release(m_handle);
104 Replaces the underlying type reader.
106 @param other any <code>Reader</code> instance
108 @return this <code>Reader</code> instance
110 Reader & operator =(Reader const & other) {
111 Reader temp(other);
112 std::swap(this->m_handle, temp.m_handle);
113 return *this;
117 Returns whether this type reader is valid.
119 @return true iff this type reader is valid
121 bool isValid() const {
122 return m_handle != 0;
126 Returns the binary blob version of this type reader.
128 @return the version of the binary blob from which this type reader was
129 constructed; if this type reader is invalid,
130 <code>TYPEREG_VERSION_0</code> is returned
132 typereg_Version getVersion() const {
133 return typereg_reader_getVersion(m_handle);
137 Returns the documentation of this type reader.
139 @return the documentation 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
144 OUString getDocumentation() const {
145 rtl_uString * s = 0;
146 typereg_reader_getDocumentation(m_handle, &s);
147 if (s == 0) {
148 throw std::bad_alloc();
150 return OUString(s, SAL_NO_ACQUIRE);
154 Returns the file name of this type reader.
156 @return the file name of this type reader; if this type reader is
157 invalid, an empty string is returned
159 @exception std::bad_alloc is raised if an out-of-memory condition occurs
160 @deprecated
162 OUString getFileName() const {
163 rtl_uString * s = 0;
164 typereg_reader_getFileName(m_handle, &s);
165 if (s == 0) {
166 throw std::bad_alloc();
168 return OUString(s, SAL_NO_ACQUIRE);
172 Returns the type class of this type reader.
174 <p>This function will always return the type class without the internal
175 <code>RT_TYPE_PUBLISHED</code> flag set. Use <code>isPublished</code> to
176 determine whether this type reader is published.</p>
178 @return the type class of this type reader; if this type reader is
179 invalid, <code>RT_TYPE_INVALID</code> is returned
181 RTTypeClass getTypeClass() const {
182 return typereg_reader_getTypeClass(m_handle);
186 Returns whether this type reader is published.
188 @return whether this type reader is published; if this type reader is
189 invalid, <code>false</code> is returned
191 bool isPublished() const {
192 return typereg_reader_isPublished(m_handle);
196 Returns the type name of this type reader.
198 @return the type name of this type reader; if this type reader is
199 invalid, an empty string is returned
201 @exception std::bad_alloc is raised if an out-of-memory condition occurs
203 OUString getTypeName() const {
204 rtl_uString * s = 0;
205 typereg_reader_getTypeName(m_handle, &s);
206 if (s == 0) {
207 throw std::bad_alloc();
209 return OUString(s, SAL_NO_ACQUIRE);
213 Returns the number of super types of this type reader.
215 @return the number of super types of this type reader; if this type
216 reader is invalid, zero is returned
218 sal_uInt16 getSuperTypeCount() const {
219 return typereg_reader_getSuperTypeCount(m_handle);
223 Returns the type name of a super type of this type reader.
225 @param index a valid index into the range of super types of this type
226 reader
228 @return the type name of the given super type
230 @exception std::bad_alloc is raised if an out-of-memory condition occurs
232 OUString getSuperTypeName(sal_uInt16 index) const {
233 rtl_uString * s = 0;
234 typereg_reader_getSuperTypeName(m_handle, &s, index);
235 if (s == 0) {
236 throw std::bad_alloc();
238 return OUString(s, SAL_NO_ACQUIRE);
242 Returns the number of fields of this type reader.
244 @return the number of fields of this type reader; if this type reader is
245 invalid, zero is returned
247 sal_uInt16 getFieldCount() const {
248 return typereg_reader_getFieldCount(m_handle);
252 Returns the documentation of a field of this type reader.
254 @param index a valid index into the range of fields of this type reader
256 @return the documentation of the given field
258 @exception std::bad_alloc is raised if an out-of-memory condition occurs
260 OUString getFieldDocumentation(sal_uInt16 index) const {
261 rtl_uString * s = 0;
262 typereg_reader_getFieldDocumentation(m_handle, &s, index);
263 if (s == 0) {
264 throw std::bad_alloc();
266 return OUString(s, SAL_NO_ACQUIRE);
270 Returns the file name 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 file name of the given field
276 @exception std::bad_alloc is raised if an out-of-memory condition occurs
277 @deprecated
279 OUString getFieldFileName(sal_uInt16 index) const {
280 rtl_uString * s = 0;
281 typereg_reader_getFieldFileName(m_handle, &s, index);
282 if (s == 0) {
283 throw std::bad_alloc();
285 return OUString(s, SAL_NO_ACQUIRE);
289 Returns the flags of a field of this type reader.
291 @param index a valid index into the range of fields of this type reader
293 @return the flags of the given field
295 RTFieldAccess getFieldFlags(sal_uInt16 index) const {
296 return typereg_reader_getFieldFlags(m_handle, index);
300 Returns the name of a field of this type reader.
302 @param index a valid index into the range of fields of this type reader
304 @return the name of the given field
306 @exception std::bad_alloc is raised if an out-of-memory condition occurs
308 OUString getFieldName(sal_uInt16 index) const {
309 rtl_uString * s = 0;
310 typereg_reader_getFieldName(m_handle, &s, index);
311 if (s == 0) {
312 throw std::bad_alloc();
314 return OUString(s, SAL_NO_ACQUIRE);
318 Returns the type name of a field of this type reader.
320 @param index a valid index into the range of fields of this type reader
322 @return the type name of the given field
324 @exception std::bad_alloc is raised if an out-of-memory condition occurs
326 OUString getFieldTypeName(sal_uInt16 index) const {
327 rtl_uString * s = 0;
328 typereg_reader_getFieldTypeName(m_handle, &s, index);
329 if (s == 0) {
330 throw std::bad_alloc();
332 return OUString(s, SAL_NO_ACQUIRE);
336 Returns the value of a field of this type reader.
338 @param index a valid index into the range of fields of this type reader
340 @return the value of the given field
342 @exception std::bad_alloc is raised if an out-of-memory condition occurs
344 RTConstValue getFieldValue(sal_uInt16 index) const {
345 RTConstValue v;
346 if (!typereg_reader_getFieldValue(
347 m_handle, index, &v.m_type, &v.m_value))
349 throw std::bad_alloc();
351 return v;
355 Returns the number of methods of this type reader.
357 @return the number of methods of this type reader; if this type reader is
358 invalid, zero is returned
360 sal_uInt16 getMethodCount() const {
361 return typereg_reader_getMethodCount(m_handle);
365 Returns the documentation of a method of this type reader.
367 @param index a valid index into the range of methods of this type reader
369 @return the documentation of the given method
371 @exception std::bad_alloc is raised if an out-of-memory condition occurs
373 OUString getMethodDocumentation(sal_uInt16 index) const {
374 rtl_uString * s = 0;
375 typereg_reader_getMethodDocumentation(m_handle, &s, index);
376 if (s == 0) {
377 throw std::bad_alloc();
379 return OUString(s, SAL_NO_ACQUIRE);
383 Returns the flags of a method of this type reader.
385 @param index a valid index into the range of methods of this type reader
387 @return the flags of the given method
389 RTMethodMode getMethodFlags(sal_uInt16 index) const {
390 return typereg_reader_getMethodFlags(m_handle, index);
394 Returns the name of a method of this type reader.
396 @param index a valid index into the range of methods of this type reader
398 @return the name of the given method
400 @exception std::bad_alloc is raised if an out-of-memory condition occurs
402 OUString getMethodName(sal_uInt16 index) const {
403 rtl_uString * s = 0;
404 typereg_reader_getMethodName(m_handle, &s, index);
405 if (s == 0) {
406 throw std::bad_alloc();
408 return OUString(s, SAL_NO_ACQUIRE);
412 Returns the return type name of a method of this type reader.
414 @param index a valid index into the range of methods of this type reader
416 @return the return type name of the given method
418 @exception std::bad_alloc is raised if an out-of-memory condition occurs
420 OUString getMethodReturnTypeName(sal_uInt16 index) const {
421 rtl_uString * s = 0;
422 typereg_reader_getMethodReturnTypeName(m_handle, &s, index);
423 if (s == 0) {
424 throw std::bad_alloc();
426 return OUString(s, SAL_NO_ACQUIRE);
430 Returns the number of parameters of a method of this type reader.
432 @param index a valid index into the range of methods of this type reader
434 @return the number of parameters of the given method
436 sal_uInt16 getMethodParameterCount(sal_uInt16 index) const {
437 return typereg_reader_getMethodParameterCount(m_handle, index);
441 Returns the flags of a parameter of a method of this type reader.
443 @param methodIndex a valid index into the range of methods of this type
444 reader
446 @param parameterIndex a valid index into the range of parameters of the
447 given method
449 @return the flags of the given method parameter
451 RTParamMode getMethodParameterFlags(
452 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
454 return typereg_reader_getMethodParameterFlags(
455 m_handle, methodIndex, parameterIndex);
459 Returns the name of a parameter of a method of this type reader.
461 @param methodIndex a valid index into the range of methods of this type
462 reader
464 @param parameterIndex a valid index into the range of parameters of the
465 given method
467 @return the name of the given method parameter
469 @exception std::bad_alloc is raised if an out-of-memory condition occurs
471 OUString getMethodParameterName(
472 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
474 rtl_uString * s = 0;
475 typereg_reader_getMethodParameterName(
476 m_handle, &s, methodIndex, parameterIndex);
477 if (s == 0) {
478 throw std::bad_alloc();
480 return OUString(s, SAL_NO_ACQUIRE);
484 Returns the type name of a parameter of a method of this type reader.
486 @param methodIndex a valid index into the range of methods of this type
487 reader
489 @param parameterIndex a valid index into the range of parameters of the
490 given method
492 @return the type name of the given method parameter
494 @exception std::bad_alloc is raised if an out-of-memory condition occurs
496 OUString getMethodParameterTypeName(
497 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
499 rtl_uString * s = 0;
500 typereg_reader_getMethodParameterTypeName(
501 m_handle, &s, methodIndex, parameterIndex);
502 if (s == 0) {
503 throw std::bad_alloc();
505 return OUString(s, SAL_NO_ACQUIRE);
509 Returns the number of exceptions of a method of this type reader.
511 @param index a valid index into the range of methods of this type reader
513 @return the number of exceptions of the given method
515 sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const {
516 return typereg_reader_getMethodExceptionCount(m_handle, index);
520 Returns the type name of an exception of a method of this type reader.
522 @param methodIndex a valid index into the range of methods of this type
523 reader
525 @param exceptionIndex a valid index into the range of exceptions of the
526 given method
528 @return the type name of the given method exception
530 @exception std::bad_alloc is raised if an out-of-memory condition occurs
532 OUString getMethodExceptionTypeName(
533 sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const
535 rtl_uString * s = 0;
536 typereg_reader_getMethodExceptionTypeName(
537 m_handle, &s, methodIndex, exceptionIndex);
538 if (s == 0) {
539 throw std::bad_alloc();
541 return OUString(s, SAL_NO_ACQUIRE);
545 Returns the number of references of this type reader.
547 @return the number of references of this type reader; if this type reader
548 is invalid, zero is returned
550 sal_uInt16 getReferenceCount() const {
551 return typereg_reader_getReferenceCount(m_handle);
555 Returns the documentation 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 documentation of the given reference
562 @exception std::bad_alloc is raised if an out-of-memory condition occurs
564 OUString getReferenceDocumentation(sal_uInt16 index) const {
565 rtl_uString * s = 0;
566 typereg_reader_getReferenceDocumentation(m_handle, &s, index);
567 if (s == 0) {
568 throw std::bad_alloc();
570 return OUString(s, SAL_NO_ACQUIRE);
574 Returns the flags of a reference of this type reader.
576 @param index a valid index into the range of references of this type
577 reader
579 @return the flags of the given reference
581 RTFieldAccess getReferenceFlags(sal_uInt16 index) const {
582 return typereg_reader_getReferenceFlags(m_handle, index);
586 Returns the sort of a reference of this type reader.
588 @param index a valid index into the range of references of this type
589 reader
591 @return the sort of the given reference
593 RTReferenceType getReferenceSort(sal_uInt16 index) const {
594 return typereg_reader_getReferenceSort(m_handle, index);
598 Returns the type name of a reference of this type reader.
600 @param index a valid index into the range of references of this type
601 reader
603 @return the type name of the given reference
605 @exception std::bad_alloc is raised if an out-of-memory condition occurs
607 OUString getReferenceTypeName(sal_uInt16 index) const {
608 rtl_uString * s = 0;
609 typereg_reader_getReferenceTypeName(m_handle, &s, index);
610 if (s == 0) {
611 throw std::bad_alloc();
613 return OUString(s, SAL_NO_ACQUIRE);
616 private:
617 void * m_handle;
622 #endif
624 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */