UDK 3.2.7 C/C++ API Reference

registry/reader.hxx

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 
00020 #ifndef INCLUDED_registry_reader_hxx
00021 #define INCLUDED_registry_reader_hxx
00022 
00023 #include "registry/reader.h"
00024 #include "registry/refltype.hxx"
00025 #include "registry/types.h"
00026 #include "registry/version.h"
00027 
00028 #include "rtl/ustring.hxx"
00029 #include "sal/types.h"
00030 
00031 #include <algorithm>
00032 #include <new>
00033 
00034 namespace typereg {
00035 
00043 class Reader {
00044 public:
00048     Reader(): m_handle(0) {}
00049 
00074     Reader(
00075         void const * buffer, sal_uInt32 length, bool copy,
00076         typereg_Version maxVersion)
00077     {
00078         if (!typereg_reader_create(buffer, length, copy, maxVersion, &m_handle))
00079         {
00080             throw std::bad_alloc();
00081         }
00082     }
00083 
00089     Reader(Reader const & other): m_handle(other.m_handle) {
00090         typereg_reader_acquire(m_handle);
00091     }
00092 
00099     ~Reader() {
00100         typereg_reader_release(m_handle);
00101     }
00102 
00110     Reader & operator =(Reader const & other) {
00111         Reader temp(other);
00112         std::swap(this->m_handle, temp.m_handle);
00113         return *this;
00114     }
00115 
00121     bool isValid() const {
00122         return m_handle != 0;
00123     }
00124 
00132     typereg_Version getVersion() const {
00133         return typereg_reader_getVersion(m_handle);
00134     }
00135 
00144     rtl::OUString getDocumentation() const {
00145         rtl_uString * s = 0;
00146         typereg_reader_getDocumentation(m_handle, &s);
00147         if (s == 0) {
00148             throw std::bad_alloc();
00149         }
00150         return rtl::OUString(s, SAL_NO_ACQUIRE);
00151     }
00152 
00162     rtl::OUString getFileName() const {
00163         rtl_uString * s = 0;
00164         typereg_reader_getFileName(m_handle, &s);
00165         if (s == 0) {
00166             throw std::bad_alloc();
00167         }
00168         return rtl::OUString(s, SAL_NO_ACQUIRE);
00169     }
00170 
00181     RTTypeClass getTypeClass() const {
00182         return typereg_reader_getTypeClass(m_handle);
00183     }
00184 
00191     bool isPublished() const {
00192         return typereg_reader_isPublished(m_handle);
00193     }
00194 
00203     rtl::OUString getTypeName() const {
00204         rtl_uString * s = 0;
00205         typereg_reader_getTypeName(m_handle, &s);
00206         if (s == 0) {
00207             throw std::bad_alloc();
00208         }
00209         return rtl::OUString(s, SAL_NO_ACQUIRE);
00210     }
00211 
00218     sal_uInt16 getSuperTypeCount() const {
00219         return typereg_reader_getSuperTypeCount(m_handle);
00220     }
00221 
00232     rtl::OUString getSuperTypeName(sal_uInt16 index) const {
00233         rtl_uString * s = 0;
00234         typereg_reader_getSuperTypeName(m_handle, &s, index);
00235         if (s == 0) {
00236             throw std::bad_alloc();
00237         }
00238         return rtl::OUString(s, SAL_NO_ACQUIRE);
00239     }
00240 
00247     sal_uInt16 getFieldCount() const {
00248         return typereg_reader_getFieldCount(m_handle);
00249     }
00250 
00260     rtl::OUString getFieldDocumentation(sal_uInt16 index) const {
00261         rtl_uString * s = 0;
00262         typereg_reader_getFieldDocumentation(m_handle, &s, index);
00263         if (s == 0) {
00264             throw std::bad_alloc();
00265         }
00266         return rtl::OUString(s, SAL_NO_ACQUIRE);
00267     }
00268 
00279     rtl::OUString getFieldFileName(sal_uInt16 index) const {
00280         rtl_uString * s = 0;
00281         typereg_reader_getFieldFileName(m_handle, &s, index);
00282         if (s == 0) {
00283             throw std::bad_alloc();
00284         }
00285         return rtl::OUString(s, SAL_NO_ACQUIRE);
00286     }
00287 
00295     RTFieldAccess getFieldFlags(sal_uInt16 index) const {
00296         return typereg_reader_getFieldFlags(m_handle, index);
00297     }
00298 
00308     rtl::OUString getFieldName(sal_uInt16 index) const {
00309         rtl_uString * s = 0;
00310         typereg_reader_getFieldName(m_handle, &s, index);
00311         if (s == 0) {
00312             throw std::bad_alloc();
00313         }
00314         return rtl::OUString(s, SAL_NO_ACQUIRE);
00315     }
00316 
00326     rtl::OUString getFieldTypeName(sal_uInt16 index) const {
00327         rtl_uString * s = 0;
00328         typereg_reader_getFieldTypeName(m_handle, &s, index);
00329         if (s == 0) {
00330             throw std::bad_alloc();
00331         }
00332         return rtl::OUString(s, SAL_NO_ACQUIRE);
00333     }
00334 
00344     RTConstValue getFieldValue(sal_uInt16 index) const {
00345         RTConstValue v;
00346         if (!typereg_reader_getFieldValue(
00347                 m_handle, index, &v.m_type, &v.m_value))
00348         {
00349             throw std::bad_alloc();
00350         }
00351         return v;
00352     }
00353 
00360     sal_uInt16 getMethodCount() const {
00361         return typereg_reader_getMethodCount(m_handle);
00362     }
00363 
00373     rtl::OUString getMethodDocumentation(sal_uInt16 index) const {
00374         rtl_uString * s = 0;
00375         typereg_reader_getMethodDocumentation(m_handle, &s, index);
00376         if (s == 0) {
00377             throw std::bad_alloc();
00378         }
00379         return rtl::OUString(s, SAL_NO_ACQUIRE);
00380     }
00381 
00389     RTMethodMode getMethodFlags(sal_uInt16 index) const {
00390         return typereg_reader_getMethodFlags(m_handle, index);
00391     }
00392 
00402     rtl::OUString getMethodName(sal_uInt16 index) const {
00403         rtl_uString * s = 0;
00404         typereg_reader_getMethodName(m_handle, &s, index);
00405         if (s == 0) {
00406             throw std::bad_alloc();
00407         }
00408         return rtl::OUString(s, SAL_NO_ACQUIRE);
00409     }
00410 
00420     rtl::OUString getMethodReturnTypeName(sal_uInt16 index) const {
00421         rtl_uString * s = 0;
00422         typereg_reader_getMethodReturnTypeName(m_handle, &s, index);
00423         if (s == 0) {
00424             throw std::bad_alloc();
00425         }
00426         return rtl::OUString(s, SAL_NO_ACQUIRE);
00427     }
00428 
00436     sal_uInt16 getMethodParameterCount(sal_uInt16 index) const {
00437         return typereg_reader_getMethodParameterCount(m_handle, index);
00438     }
00439 
00451     RTParamMode getMethodParameterFlags(
00452         sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
00453     {
00454         return typereg_reader_getMethodParameterFlags(
00455             m_handle, methodIndex, parameterIndex);
00456     }
00457 
00471     rtl::OUString getMethodParameterName(
00472         sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
00473     {
00474         rtl_uString * s = 0;
00475         typereg_reader_getMethodParameterName(
00476             m_handle, &s, methodIndex, parameterIndex);
00477         if (s == 0) {
00478             throw std::bad_alloc();
00479         }
00480         return rtl::OUString(s, SAL_NO_ACQUIRE);
00481     }
00482 
00496     rtl::OUString getMethodParameterTypeName(
00497         sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const
00498     {
00499         rtl_uString * s = 0;
00500         typereg_reader_getMethodParameterTypeName(
00501             m_handle, &s, methodIndex, parameterIndex);
00502         if (s == 0) {
00503             throw std::bad_alloc();
00504         }
00505         return rtl::OUString(s, SAL_NO_ACQUIRE);
00506     }
00507 
00515     sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const {
00516         return typereg_reader_getMethodExceptionCount(m_handle, index);
00517     }
00518 
00532     rtl::OUString getMethodExceptionTypeName(
00533         sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const
00534     {
00535         rtl_uString * s = 0;
00536         typereg_reader_getMethodExceptionTypeName(
00537             m_handle, &s, methodIndex, exceptionIndex);
00538         if (s == 0) {
00539             throw std::bad_alloc();
00540         }
00541         return rtl::OUString(s, SAL_NO_ACQUIRE);
00542     }
00543 
00550     sal_uInt16 getReferenceCount() const {
00551         return typereg_reader_getReferenceCount(m_handle);
00552     }
00553 
00564     rtl::OUString getReferenceDocumentation(sal_uInt16 index) const {
00565         rtl_uString * s = 0;
00566         typereg_reader_getReferenceDocumentation(m_handle, &s, index);
00567         if (s == 0) {
00568             throw std::bad_alloc();
00569         }
00570         return rtl::OUString(s, SAL_NO_ACQUIRE);
00571     }
00572 
00581     RTFieldAccess getReferenceFlags(sal_uInt16 index) const {
00582         return typereg_reader_getReferenceFlags(m_handle, index);
00583     }
00584 
00593     RTReferenceType getReferenceSort(sal_uInt16 index) const {
00594         return typereg_reader_getReferenceSort(m_handle, index);
00595     }
00596 
00607     rtl::OUString getReferenceTypeName(sal_uInt16 index) const {
00608         rtl_uString * s = 0;
00609         typereg_reader_getReferenceTypeName(m_handle, &s, index);
00610         if (s == 0) {
00611             throw std::bad_alloc();
00612         }
00613         return rtl::OUString(s, SAL_NO_ACQUIRE);
00614     }
00615 
00616 private:
00617     void * m_handle;
00618 };
00619 
00620 }
00621 
00622 #endif
00623 
00624 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines