My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
reader.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef INCLUDED_registry_reader_hxx
30 #define INCLUDED_registry_reader_hxx
31 
32 #include "registry/reader.h"
33 #include "registry/refltype.hxx"
34 #include "registry/types.h"
35 #include "registry/version.h"
36 
37 #include "rtl/ustring.hxx"
38 #include "sal/types.h"
39 
40 #include <algorithm>
41 #include <new>
42 
43 namespace typereg {
44 
52 class Reader {
53 public:
57  Reader(): m_handle(0) {}
58 
84  void const * buffer, sal_uInt32 length, bool copy,
85  typereg_Version maxVersion)
86  {
87  if (!typereg_reader_create(buffer, length, copy, maxVersion, &m_handle))
88  {
89  throw std::bad_alloc();
90  }
91  }
92 
98  Reader(Reader const & other): m_handle(other.m_handle) {
99  typereg_reader_acquire(m_handle);
100  }
101 
109  typereg_reader_release(m_handle);
110  }
111 
119  Reader & operator =(Reader const & other) {
120  Reader temp(other);
121  std::swap(this->m_handle, temp.m_handle);
122  return *this;
123  }
124 
130  bool isValid() const {
131  return m_handle != 0;
132  }
133 
142  return typereg_reader_getVersion(m_handle);
143  }
144 
154  rtl_uString * s = 0;
155  typereg_reader_getDocumentation(m_handle, &s);
156  if (s == 0) {
157  throw std::bad_alloc();
158  }
159  return rtl::OUString(s, SAL_NO_ACQUIRE);
160  }
161 
172  rtl_uString * s = 0;
173  typereg_reader_getFileName(m_handle, &s);
174  if (s == 0) {
175  throw std::bad_alloc();
176  }
177  return rtl::OUString(s, SAL_NO_ACQUIRE);
178  }
179 
191  return typereg_reader_getTypeClass(m_handle);
192  }
193 
200  bool isPublished() const {
201  return typereg_reader_isPublished(m_handle);
202  }
203 
213  rtl_uString * s = 0;
214  typereg_reader_getTypeName(m_handle, &s);
215  if (s == 0) {
216  throw std::bad_alloc();
217  }
218  return rtl::OUString(s, SAL_NO_ACQUIRE);
219  }
220 
227  sal_uInt16 getSuperTypeCount() const {
228  return typereg_reader_getSuperTypeCount(m_handle);
229  }
230 
241  rtl::OUString getSuperTypeName(sal_uInt16 index) const {
242  rtl_uString * s = 0;
243  typereg_reader_getSuperTypeName(m_handle, &s, index);
244  if (s == 0) {
245  throw std::bad_alloc();
246  }
247  return rtl::OUString(s, SAL_NO_ACQUIRE);
248  }
249 
256  sal_uInt16 getFieldCount() const {
257  return typereg_reader_getFieldCount(m_handle);
258  }
259 
269  rtl::OUString getFieldDocumentation(sal_uInt16 index) const {
270  rtl_uString * s = 0;
271  typereg_reader_getFieldDocumentation(m_handle, &s, index);
272  if (s == 0) {
273  throw std::bad_alloc();
274  }
275  return rtl::OUString(s, SAL_NO_ACQUIRE);
276  }
277 
288  rtl::OUString getFieldFileName(sal_uInt16 index) const {
289  rtl_uString * s = 0;
290  typereg_reader_getFieldFileName(m_handle, &s, index);
291  if (s == 0) {
292  throw std::bad_alloc();
293  }
294  return rtl::OUString(s, SAL_NO_ACQUIRE);
295  }
296 
304  RTFieldAccess getFieldFlags(sal_uInt16 index) const {
305  return typereg_reader_getFieldFlags(m_handle, index);
306  }
307 
317  rtl::OUString getFieldName(sal_uInt16 index) const {
318  rtl_uString * s = 0;
319  typereg_reader_getFieldName(m_handle, &s, index);
320  if (s == 0) {
321  throw std::bad_alloc();
322  }
323  return rtl::OUString(s, SAL_NO_ACQUIRE);
324  }
325 
335  rtl::OUString getFieldTypeName(sal_uInt16 index) const {
336  rtl_uString * s = 0;
337  typereg_reader_getFieldTypeName(m_handle, &s, index);
338  if (s == 0) {
339  throw std::bad_alloc();
340  }
341  return rtl::OUString(s, SAL_NO_ACQUIRE);
342  }
343 
353  RTConstValue getFieldValue(sal_uInt16 index) const {
354  RTConstValue v;
356  m_handle, index, &v.m_type, &v.m_value))
357  {
358  throw std::bad_alloc();
359  }
360  return v;
361  }
362 
369  sal_uInt16 getMethodCount() const {
370  return typereg_reader_getMethodCount(m_handle);
371  }
372 
382  rtl::OUString getMethodDocumentation(sal_uInt16 index) const {
383  rtl_uString * s = 0;
384  typereg_reader_getMethodDocumentation(m_handle, &s, index);
385  if (s == 0) {
386  throw std::bad_alloc();
387  }
388  return rtl::OUString(s, SAL_NO_ACQUIRE);
389  }
390 
398  RTMethodMode getMethodFlags(sal_uInt16 index) const {
399  return typereg_reader_getMethodFlags(m_handle, index);
400  }
401 
411  rtl::OUString getMethodName(sal_uInt16 index) const {
412  rtl_uString * s = 0;
413  typereg_reader_getMethodName(m_handle, &s, index);
414  if (s == 0) {
415  throw std::bad_alloc();
416  }
417  return rtl::OUString(s, SAL_NO_ACQUIRE);
418  }
419 
429  rtl::OUString getMethodReturnTypeName(sal_uInt16 index) const {
430  rtl_uString * s = 0;
431  typereg_reader_getMethodReturnTypeName(m_handle, &s, index);
432  if (s == 0) {
433  throw std::bad_alloc();
434  }
435  return rtl::OUString(s, SAL_NO_ACQUIRE);
436  }
437 
445  sal_uInt16 getMethodParameterCount(sal_uInt16 index) const {
446  return typereg_reader_getMethodParameterCount(m_handle, index);
447  }
448 
461  sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
462  {
464  m_handle, methodIndex, parameterIndex);
465  }
466 
481  sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
482  {
483  rtl_uString * s = 0;
485  m_handle, &s, methodIndex, parameterIndex);
486  if (s == 0) {
487  throw std::bad_alloc();
488  }
489  return rtl::OUString(s, SAL_NO_ACQUIRE);
490  }
491 
506  sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
507  {
508  rtl_uString * s = 0;
510  m_handle, &s, methodIndex, parameterIndex);
511  if (s == 0) {
512  throw std::bad_alloc();
513  }
514  return rtl::OUString(s, SAL_NO_ACQUIRE);
515  }
516 
524  sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const {
525  return typereg_reader_getMethodExceptionCount(m_handle, index);
526  }
527 
542  sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const
543  {
544  rtl_uString * s = 0;
546  m_handle, &s, methodIndex, exceptionIndex);
547  if (s == 0) {
548  throw std::bad_alloc();
549  }
550  return rtl::OUString(s, SAL_NO_ACQUIRE);
551  }
552 
559  sal_uInt16 getReferenceCount() const {
560  return typereg_reader_getReferenceCount(m_handle);
561  }
562 
573  rtl::OUString getReferenceDocumentation(sal_uInt16 index) const {
574  rtl_uString * s = 0;
575  typereg_reader_getReferenceDocumentation(m_handle, &s, index);
576  if (s == 0) {
577  throw std::bad_alloc();
578  }
579  return rtl::OUString(s, SAL_NO_ACQUIRE);
580  }
581 
590  RTFieldAccess getReferenceFlags(sal_uInt16 index) const {
591  return typereg_reader_getReferenceFlags(m_handle, index);
592  }
593 
602  RTReferenceType getReferenceSort(sal_uInt16 index) const {
603  return typereg_reader_getReferenceSort(m_handle, index);
604  }
605 
616  rtl::OUString getReferenceTypeName(sal_uInt16 index) const {
617  rtl_uString * s = 0;
618  typereg_reader_getReferenceTypeName(m_handle, &s, index);
619  if (s == 0) {
620  throw std::bad_alloc();
621  }
622  return rtl::OUString(s, SAL_NO_ACQUIRE);
623  }
624 
625 private:
626  void * m_handle;
627 };
628 
629 }
630 
631 #endif
632 
633 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */