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  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_registry_reader_hxx
21 #define INCLUDED_registry_reader_hxx
22 
23 #include "registry/reader.h"
24 #include "registry/refltype.hxx"
25 #include "registry/types.h"
26 #include "registry/version.h"
27 
28 #include "rtl/ustring.hxx"
29 #include "sal/types.h"
30 
31 #include <algorithm>
32 #include <new>
33 
34 namespace typereg {
35 
43 class Reader {
44 public:
48  Reader(): m_handle(0) {}
49 
75  void const * buffer, sal_uInt32 length, bool copy,
76  typereg_Version maxVersion)
77  {
78  if (!typereg_reader_create(buffer, length, copy, maxVersion, &m_handle))
79  {
80  throw std::bad_alloc();
81  }
82  }
83 
89  Reader(Reader const & other): m_handle(other.m_handle) {
90  typereg_reader_acquire(m_handle);
91  }
92 
99  ~Reader() {
100  typereg_reader_release(m_handle);
101  }
102 
110  Reader & operator =(Reader const & other) {
111  Reader temp(other);
112  std::swap(this->m_handle, temp.m_handle);
113  return *this;
114  }
115 
121  bool isValid() const {
122  return m_handle != 0;
123  }
124 
133  return typereg_reader_getVersion(m_handle);
134  }
135 
145  rtl_uString * s = 0;
146  typereg_reader_getDocumentation(m_handle, &s);
147  if (s == 0) {
148  throw std::bad_alloc();
149  }
150  return rtl::OUString(s, SAL_NO_ACQUIRE);
151  }
152 
163  rtl_uString * s = 0;
164  typereg_reader_getFileName(m_handle, &s);
165  if (s == 0) {
166  throw std::bad_alloc();
167  }
168  return rtl::OUString(s, SAL_NO_ACQUIRE);
169  }
170 
182  return typereg_reader_getTypeClass(m_handle);
183  }
184 
191  bool isPublished() const {
192  return typereg_reader_isPublished(m_handle);
193  }
194 
204  rtl_uString * s = 0;
205  typereg_reader_getTypeName(m_handle, &s);
206  if (s == 0) {
207  throw std::bad_alloc();
208  }
209  return rtl::OUString(s, SAL_NO_ACQUIRE);
210  }
211 
218  sal_uInt16 getSuperTypeCount() const {
219  return typereg_reader_getSuperTypeCount(m_handle);
220  }
221 
232  rtl::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();
237  }
238  return rtl::OUString(s, SAL_NO_ACQUIRE);
239  }
240 
247  sal_uInt16 getFieldCount() const {
248  return typereg_reader_getFieldCount(m_handle);
249  }
250 
260  rtl::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();
265  }
266  return rtl::OUString(s, SAL_NO_ACQUIRE);
267  }
268 
279  rtl::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();
284  }
285  return rtl::OUString(s, SAL_NO_ACQUIRE);
286  }
287 
295  RTFieldAccess getFieldFlags(sal_uInt16 index) const {
296  return typereg_reader_getFieldFlags(m_handle, index);
297  }
298 
308  rtl::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();
313  }
314  return rtl::OUString(s, SAL_NO_ACQUIRE);
315  }
316 
326  rtl::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();
331  }
332  return rtl::OUString(s, SAL_NO_ACQUIRE);
333  }
334 
344  RTConstValue getFieldValue(sal_uInt16 index) const {
345  RTConstValue v;
347  m_handle, index, &v.m_type, &v.m_value))
348  {
349  throw std::bad_alloc();
350  }
351  return v;
352  }
353 
360  sal_uInt16 getMethodCount() const {
361  return typereg_reader_getMethodCount(m_handle);
362  }
363 
373  rtl::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();
378  }
379  return rtl::OUString(s, SAL_NO_ACQUIRE);
380  }
381 
389  RTMethodMode getMethodFlags(sal_uInt16 index) const {
390  return typereg_reader_getMethodFlags(m_handle, index);
391  }
392 
402  rtl::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();
407  }
408  return rtl::OUString(s, SAL_NO_ACQUIRE);
409  }
410 
420  rtl::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();
425  }
426  return rtl::OUString(s, SAL_NO_ACQUIRE);
427  }
428 
436  sal_uInt16 getMethodParameterCount(sal_uInt16 index) const {
437  return typereg_reader_getMethodParameterCount(m_handle, index);
438  }
439 
452  sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
453  {
455  m_handle, methodIndex, parameterIndex);
456  }
457 
472  sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
473  {
474  rtl_uString * s = 0;
476  m_handle, &s, methodIndex, parameterIndex);
477  if (s == 0) {
478  throw std::bad_alloc();
479  }
480  return rtl::OUString(s, SAL_NO_ACQUIRE);
481  }
482 
497  sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
498  {
499  rtl_uString * s = 0;
501  m_handle, &s, methodIndex, parameterIndex);
502  if (s == 0) {
503  throw std::bad_alloc();
504  }
505  return rtl::OUString(s, SAL_NO_ACQUIRE);
506  }
507 
515  sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const {
516  return typereg_reader_getMethodExceptionCount(m_handle, index);
517  }
518 
533  sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const
534  {
535  rtl_uString * s = 0;
537  m_handle, &s, methodIndex, exceptionIndex);
538  if (s == 0) {
539  throw std::bad_alloc();
540  }
541  return rtl::OUString(s, SAL_NO_ACQUIRE);
542  }
543 
550  sal_uInt16 getReferenceCount() const {
551  return typereg_reader_getReferenceCount(m_handle);
552  }
553 
564  rtl::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();
569  }
570  return rtl::OUString(s, SAL_NO_ACQUIRE);
571  }
572 
581  RTFieldAccess getReferenceFlags(sal_uInt16 index) const {
582  return typereg_reader_getReferenceFlags(m_handle, index);
583  }
584 
593  RTReferenceType getReferenceSort(sal_uInt16 index) const {
594  return typereg_reader_getReferenceSort(m_handle, index);
595  }
596 
607  rtl::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();
612  }
613  return rtl::OUString(s, SAL_NO_ACQUIRE);
614  }
615 
616 private:
617  void * m_handle;
618 };
619 
620 }
621 
622 #endif
623 
624 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */