Bump version to 6.4-15
[LibreOffice.git] / include / registry / reader.hxx
blobb804ba3ed559d859c776ee858e2d227981cee5d3
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/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>
31 #include <new>
33 namespace typereg {
35 /**
36 A type reader working on a binary blob that represents a UNOIDL type.
38 <p>Instances of this class are not multi-thread&ndash;safe.</p>
40 @since UDK 3.2.0
42 class Reader {
43 public:
44 /**
45 Creates a type reader.
47 <p>If the given binary blob is malformed, or of a version larger than
48 <code>maxVersion</code>, the created type reader is flagged as
49 invalid.</p>
51 @param buffer the binary blob representing the type; must point to at
52 least <code>length</code> bytes, and need only be byte-aligned
54 @param length the size in bytes of the binary blob representing the type
56 @exception std::bad_alloc is raised if an out-of-memory condition occurs
58 Reader(void const * buffer, sal_uInt32 length)
60 if (!typereg_reader_create(buffer, length, &m_handle))
62 throw std::bad_alloc();
66 /**
67 Shares a type reader between two <code>Reader</code> instances.
69 @param other another <code>Reader</code> instance
71 Reader(Reader const & other): m_handle(other.m_handle) {
72 typereg_reader_acquire(m_handle);
75 /**
76 Destroys this <code>Reader</code> instance.
78 <p>The underlying type reader is only destroyed if this instance was its
79 last user.</p>
81 ~Reader() {
82 typereg_reader_release(m_handle);
85 /**
86 Replaces the underlying type reader.
88 @param other any <code>Reader</code> instance
90 @return this <code>Reader</code> instance
92 Reader & operator =(Reader const & other) {
93 Reader temp(other);
94 std::swap(m_handle, temp.m_handle);
95 return *this;
98 /**
99 Returns whether this type reader is valid.
101 @return true iff this type reader is valid
103 bool isValid() const {
104 return m_handle != nullptr;
108 Returns the binary blob version of this type reader.
110 @return the version of the binary blob from which this type reader was
111 constructed; if this type reader is invalid,
112 <code>TYPEREG_VERSION_0</code> is returned
114 typereg_Version getVersion() const {
115 return typereg_reader_getVersion(m_handle);
119 Returns the documentation of this type reader.
121 @return the documentation of this type reader; if this type reader is
122 invalid, an empty string is returned
124 @exception std::bad_alloc is raised if an out-of-memory condition occurs
126 OUString getDocumentation() const {
127 rtl_uString * s = nullptr;
128 typereg_reader_getDocumentation(m_handle, &s);
129 if (s == nullptr) {
130 throw std::bad_alloc();
132 return OUString(s, SAL_NO_ACQUIRE);
136 Returns the file name of this type reader.
138 @return the file name of this type reader; if this type reader is
139 invalid, an empty string is returned
141 @exception std::bad_alloc is raised if an out-of-memory condition occurs
142 @deprecated
144 OUString getFileName() const {
145 rtl_uString * s = nullptr;
146 typereg_reader_getFileName(m_handle, &s);
147 if (s == nullptr) {
148 throw std::bad_alloc();
150 return OUString(s, SAL_NO_ACQUIRE);
154 Returns the type class of this type reader.
156 <p>This function will always return the type class without the internal
157 <code>RT_TYPE_PUBLISHED</code> flag set. Use <code>isPublished</code> to
158 determine whether this type reader is published.</p>
160 @return the type class of this type reader; if this type reader is
161 invalid, <code>RT_TYPE_INVALID</code> is returned
163 RTTypeClass getTypeClass() const {
164 return typereg_reader_getTypeClass(m_handle);
168 Returns whether this type reader is published.
170 @return whether this type reader is published; if this type reader is
171 invalid, <code>false</code> is returned
173 bool isPublished() const {
174 return typereg_reader_isPublished(m_handle);
178 Returns the type name of this type reader.
180 @return the type name of this type reader; if this type reader is
181 invalid, an empty string is returned
183 @exception std::bad_alloc is raised if an out-of-memory condition occurs
185 OUString getTypeName() const {
186 rtl_uString * s = nullptr;
187 typereg_reader_getTypeName(m_handle, &s);
188 if (s == nullptr) {
189 throw std::bad_alloc();
191 return OUString(s, SAL_NO_ACQUIRE);
195 Returns the number of super types of this type reader.
197 @return the number of super types of this type reader; if this type
198 reader is invalid, zero is returned
200 sal_uInt16 getSuperTypeCount() const {
201 return typereg_reader_getSuperTypeCount(m_handle);
205 Returns the type name of a super type of this type reader.
207 @param index a valid index into the range of super types of this type
208 reader
210 @return the type name of the given super type
212 @exception std::bad_alloc is raised if an out-of-memory condition occurs
214 OUString getSuperTypeName(sal_uInt16 index) const {
215 rtl_uString * s = nullptr;
216 typereg_reader_getSuperTypeName(m_handle, &s, index);
217 if (s == nullptr) {
218 throw std::bad_alloc();
220 return OUString(s, SAL_NO_ACQUIRE);
224 Returns the number of fields of this type reader.
226 @return the number of fields of this type reader; if this type reader is
227 invalid, zero is returned
229 sal_uInt16 getFieldCount() const {
230 return typereg_reader_getFieldCount(m_handle);
234 Returns the documentation of a field of this type reader.
236 @param index a valid index into the range of fields of this type reader
238 @return the documentation of the given field
240 @exception std::bad_alloc is raised if an out-of-memory condition occurs
242 OUString getFieldDocumentation(sal_uInt16 index) const {
243 rtl_uString * s = nullptr;
244 typereg_reader_getFieldDocumentation(m_handle, &s, index);
245 if (s == nullptr) {
246 throw std::bad_alloc();
248 return OUString(s, SAL_NO_ACQUIRE);
252 Returns the file name 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 file name of the given field
258 @exception std::bad_alloc is raised if an out-of-memory condition occurs
259 @deprecated
261 OUString getFieldFileName(sal_uInt16 index) const {
262 rtl_uString * s = nullptr;
263 typereg_reader_getFieldFileName(m_handle, &s, index);
264 if (s == nullptr) {
265 throw std::bad_alloc();
267 return OUString(s, SAL_NO_ACQUIRE);
271 Returns the flags of a field of this type reader.
273 @param index a valid index into the range of fields of this type reader
275 @return the flags of the given field
277 RTFieldAccess getFieldFlags(sal_uInt16 index) const {
278 return typereg_reader_getFieldFlags(m_handle, index);
282 Returns the name of a field of this type reader.
284 @param index a valid index into the range of fields of this type reader
286 @return the name of the given field
288 @exception std::bad_alloc is raised if an out-of-memory condition occurs
290 OUString getFieldName(sal_uInt16 index) const {
291 rtl_uString * s = nullptr;
292 typereg_reader_getFieldName(m_handle, &s, index);
293 if (s == nullptr) {
294 throw std::bad_alloc();
296 return OUString(s, SAL_NO_ACQUIRE);
300 Returns the type 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 type name of the given field
306 @exception std::bad_alloc is raised if an out-of-memory condition occurs
308 OUString getFieldTypeName(sal_uInt16 index) const {
309 rtl_uString * s = nullptr;
310 typereg_reader_getFieldTypeName(m_handle, &s, index);
311 if (s == nullptr) {
312 throw std::bad_alloc();
314 return OUString(s, SAL_NO_ACQUIRE);
318 Returns the value 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 value of the given field
324 @exception std::bad_alloc is raised if an out-of-memory condition occurs
326 RTConstValue getFieldValue(sal_uInt16 index) const {
327 RTConstValue v;
328 if (!typereg_reader_getFieldValue(
329 m_handle, index, &v.m_type, &v.m_value))
331 throw std::bad_alloc();
333 return v;
337 Returns the number of methods of this type reader.
339 @return the number of methods of this type reader; if this type reader is
340 invalid, zero is returned
342 sal_uInt16 getMethodCount() const {
343 return typereg_reader_getMethodCount(m_handle);
347 Returns the documentation of a method of this type reader.
349 @param index a valid index into the range of methods of this type reader
351 @return the documentation of the given method
353 @exception std::bad_alloc is raised if an out-of-memory condition occurs
355 OUString getMethodDocumentation(sal_uInt16 index) const {
356 rtl_uString * s = nullptr;
357 typereg_reader_getMethodDocumentation(m_handle, &s, index);
358 if (s == nullptr) {
359 throw std::bad_alloc();
361 return OUString(s, SAL_NO_ACQUIRE);
365 Returns the flags 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 flags of the given method
371 RTMethodMode getMethodFlags(sal_uInt16 index) const {
372 return typereg_reader_getMethodFlags(m_handle, index);
376 Returns the name of a method of this type reader.
378 @param index a valid index into the range of methods of this type reader
380 @return the name of the given method
382 @exception std::bad_alloc is raised if an out-of-memory condition occurs
384 OUString getMethodName(sal_uInt16 index) const {
385 rtl_uString * s = nullptr;
386 typereg_reader_getMethodName(m_handle, &s, index);
387 if (s == nullptr) {
388 throw std::bad_alloc();
390 return OUString(s, SAL_NO_ACQUIRE);
394 Returns the return type 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 return type name of the given method
400 @exception std::bad_alloc is raised if an out-of-memory condition occurs
402 OUString getMethodReturnTypeName(sal_uInt16 index) const {
403 rtl_uString * s = nullptr;
404 typereg_reader_getMethodReturnTypeName(m_handle, &s, index);
405 if (s == nullptr) {
406 throw std::bad_alloc();
408 return OUString(s, SAL_NO_ACQUIRE);
412 Returns the number of parameters 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 number of parameters of the given method
418 sal_uInt16 getMethodParameterCount(sal_uInt16 index) const {
419 return typereg_reader_getMethodParameterCount(m_handle, index);
423 Returns the flags of a parameter of a method of this type reader.
425 @param methodIndex a valid index into the range of methods of this type
426 reader
428 @param parameterIndex a valid index into the range of parameters of the
429 given method
431 @return the flags of the given method parameter
433 RTParamMode getMethodParameterFlags(
434 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
436 return typereg_reader_getMethodParameterFlags(
437 m_handle, methodIndex, parameterIndex);
441 Returns the name 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 name of the given method parameter
451 @exception std::bad_alloc is raised if an out-of-memory condition occurs
453 OUString getMethodParameterName(
454 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
456 rtl_uString * s = nullptr;
457 typereg_reader_getMethodParameterName(
458 m_handle, &s, methodIndex, parameterIndex);
459 if (s == nullptr) {
460 throw std::bad_alloc();
462 return OUString(s, SAL_NO_ACQUIRE);
466 Returns the type name of a parameter of a method of this type reader.
468 @param methodIndex a valid index into the range of methods of this type
469 reader
471 @param parameterIndex a valid index into the range of parameters of the
472 given method
474 @return the type name of the given method parameter
476 @exception std::bad_alloc is raised if an out-of-memory condition occurs
478 OUString getMethodParameterTypeName(
479 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
481 rtl_uString * s = nullptr;
482 typereg_reader_getMethodParameterTypeName(
483 m_handle, &s, methodIndex, parameterIndex);
484 if (s == nullptr) {
485 throw std::bad_alloc();
487 return OUString(s, SAL_NO_ACQUIRE);
491 Returns the number of exceptions of a method of this type reader.
493 @param index a valid index into the range of methods of this type reader
495 @return the number of exceptions of the given method
497 sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const {
498 return typereg_reader_getMethodExceptionCount(m_handle, index);
502 Returns the type name of an exception of a method of this type reader.
504 @param methodIndex a valid index into the range of methods of this type
505 reader
507 @param exceptionIndex a valid index into the range of exceptions of the
508 given method
510 @return the type name of the given method exception
512 @exception std::bad_alloc is raised if an out-of-memory condition occurs
514 OUString getMethodExceptionTypeName(
515 sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const
517 rtl_uString * s = nullptr;
518 typereg_reader_getMethodExceptionTypeName(
519 m_handle, &s, methodIndex, exceptionIndex);
520 if (s == nullptr) {
521 throw std::bad_alloc();
523 return OUString(s, SAL_NO_ACQUIRE);
527 Returns the number of references of this type reader.
529 @return the number of references of this type reader; if this type reader
530 is invalid, zero is returned
532 sal_uInt16 getReferenceCount() const {
533 return typereg_reader_getReferenceCount(m_handle);
537 Returns the documentation of a reference of this type reader.
539 @param index a valid index into the range of references of this type
540 reader
542 @return the documentation of the given reference
544 @exception std::bad_alloc is raised if an out-of-memory condition occurs
546 OUString getReferenceDocumentation(sal_uInt16 index) const {
547 rtl_uString * s = nullptr;
548 typereg_reader_getReferenceDocumentation(m_handle, &s, index);
549 if (s == nullptr) {
550 throw std::bad_alloc();
552 return OUString(s, SAL_NO_ACQUIRE);
556 Returns the flags of a reference of this type reader.
558 @param index a valid index into the range of references of this type
559 reader
561 @return the flags of the given reference
563 RTFieldAccess getReferenceFlags(sal_uInt16 index) const {
564 return typereg_reader_getReferenceFlags(m_handle, index);
568 Returns the sort of a reference of this type reader.
570 @param index a valid index into the range of references of this type
571 reader
573 @return the sort of the given reference
575 RTReferenceType getReferenceSort(sal_uInt16 index) const {
576 return typereg_reader_getReferenceSort(m_handle, index);
580 Returns the type name of a reference of this type reader.
582 @param index a valid index into the range of references of this type
583 reader
585 @return the type name of the given reference
587 @exception std::bad_alloc is raised if an out-of-memory condition occurs
589 OUString getReferenceTypeName(sal_uInt16 index) const {
590 rtl_uString * s = nullptr;
591 typereg_reader_getReferenceTypeName(m_handle, &s, index);
592 if (s == nullptr) {
593 throw std::bad_alloc();
595 return OUString(s, SAL_NO_ACQUIRE);
598 private:
599 void * m_handle;
604 #endif
606 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */