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/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"
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 an invalid type reader.
48 Reader(): m_handle(0) {}
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
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
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();
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
);
94 Destroys this <code>Reader</code> instance.
96 <p>The underlying type reader is only destroyed if this instance was its
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
) {
112 std::swap(this->m_handle
, temp
.m_handle
);
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 {
146 typereg_reader_getDocumentation(m_handle
, &s
);
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
162 OUString
getFileName() const {
164 typereg_reader_getFileName(m_handle
, &s
);
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 {
205 typereg_reader_getTypeName(m_handle
, &s
);
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
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 {
234 typereg_reader_getSuperTypeName(m_handle
, &s
, index
);
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 {
262 typereg_reader_getFieldDocumentation(m_handle
, &s
, index
);
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
279 OUString
getFieldFileName(sal_uInt16 index
) const {
281 typereg_reader_getFieldFileName(m_handle
, &s
, index
);
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 {
310 typereg_reader_getFieldName(m_handle
, &s
, index
);
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 {
328 typereg_reader_getFieldTypeName(m_handle
, &s
, index
);
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 {
346 if (!typereg_reader_getFieldValue(
347 m_handle
, index
, &v
.m_type
, &v
.m_value
))
349 throw std::bad_alloc();
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 {
375 typereg_reader_getMethodDocumentation(m_handle
, &s
, index
);
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 {
404 typereg_reader_getMethodName(m_handle
, &s
, index
);
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 {
422 typereg_reader_getMethodReturnTypeName(m_handle
, &s
, index
);
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
446 @param parameterIndex a valid index into the range of parameters of the
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
464 @param parameterIndex a valid index into the range of parameters of the
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
475 typereg_reader_getMethodParameterName(
476 m_handle
, &s
, methodIndex
, parameterIndex
);
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
489 @param parameterIndex a valid index into the range of parameters of the
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
500 typereg_reader_getMethodParameterTypeName(
501 m_handle
, &s
, methodIndex
, parameterIndex
);
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
525 @param exceptionIndex a valid index into the range of exceptions of the
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
536 typereg_reader_getMethodExceptionTypeName(
537 m_handle
, &s
, methodIndex
, exceptionIndex
);
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
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 {
566 typereg_reader_getReferenceDocumentation(m_handle
, &s
, index
);
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
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
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
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 {
609 typereg_reader_getReferenceTypeName(m_handle
, &s
, index
);
611 throw std::bad_alloc();
613 return OUString(s
, SAL_NO_ACQUIRE
);
624 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */