UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 00029 #ifndef INCLUDED_registry_reader_hxx 00030 #define INCLUDED_registry_reader_hxx 00031 00032 #include "registry/reader.h" 00033 #include "registry/refltype.hxx" 00034 #include "registry/types.h" 00035 #include "registry/version.h" 00036 00037 #include "rtl/ustring.hxx" 00038 #include "sal/types.h" 00039 00040 #include <algorithm> 00041 #include <new> 00042 00043 namespace typereg { 00044 00052 class Reader { 00053 public: 00057 Reader(): m_handle(0) {} 00058 00083 Reader( 00084 void const * buffer, sal_uInt32 length, bool copy, 00085 typereg_Version maxVersion) 00086 { 00087 if (!typereg_reader_create(buffer, length, copy, maxVersion, &m_handle)) 00088 { 00089 throw std::bad_alloc(); 00090 } 00091 } 00092 00098 Reader(Reader const & other): m_handle(other.m_handle) { 00099 typereg_reader_acquire(m_handle); 00100 } 00101 00108 ~Reader() { 00109 typereg_reader_release(m_handle); 00110 } 00111 00119 Reader & operator =(Reader const & other) { 00120 Reader temp(other); 00121 std::swap(this->m_handle, temp.m_handle); 00122 return *this; 00123 } 00124 00130 bool isValid() const { 00131 return m_handle != 0; 00132 } 00133 00141 typereg_Version getVersion() const { 00142 return typereg_reader_getVersion(m_handle); 00143 } 00144 00153 rtl::OUString getDocumentation() const { 00154 rtl_uString * s = 0; 00155 typereg_reader_getDocumentation(m_handle, &s); 00156 if (s == 0) { 00157 throw std::bad_alloc(); 00158 } 00159 return rtl::OUString(s, SAL_NO_ACQUIRE); 00160 } 00161 00171 rtl::OUString getFileName() const { 00172 rtl_uString * s = 0; 00173 typereg_reader_getFileName(m_handle, &s); 00174 if (s == 0) { 00175 throw std::bad_alloc(); 00176 } 00177 return rtl::OUString(s, SAL_NO_ACQUIRE); 00178 } 00179 00190 RTTypeClass getTypeClass() const { 00191 return typereg_reader_getTypeClass(m_handle); 00192 } 00193 00200 bool isPublished() const { 00201 return typereg_reader_isPublished(m_handle); 00202 } 00203 00212 rtl::OUString getTypeName() const { 00213 rtl_uString * s = 0; 00214 typereg_reader_getTypeName(m_handle, &s); 00215 if (s == 0) { 00216 throw std::bad_alloc(); 00217 } 00218 return rtl::OUString(s, SAL_NO_ACQUIRE); 00219 } 00220 00227 sal_uInt16 getSuperTypeCount() const { 00228 return typereg_reader_getSuperTypeCount(m_handle); 00229 } 00230 00241 rtl::OUString getSuperTypeName(sal_uInt16 index) const { 00242 rtl_uString * s = 0; 00243 typereg_reader_getSuperTypeName(m_handle, &s, index); 00244 if (s == 0) { 00245 throw std::bad_alloc(); 00246 } 00247 return rtl::OUString(s, SAL_NO_ACQUIRE); 00248 } 00249 00256 sal_uInt16 getFieldCount() const { 00257 return typereg_reader_getFieldCount(m_handle); 00258 } 00259 00269 rtl::OUString getFieldDocumentation(sal_uInt16 index) const { 00270 rtl_uString * s = 0; 00271 typereg_reader_getFieldDocumentation(m_handle, &s, index); 00272 if (s == 0) { 00273 throw std::bad_alloc(); 00274 } 00275 return rtl::OUString(s, SAL_NO_ACQUIRE); 00276 } 00277 00288 rtl::OUString getFieldFileName(sal_uInt16 index) const { 00289 rtl_uString * s = 0; 00290 typereg_reader_getFieldFileName(m_handle, &s, index); 00291 if (s == 0) { 00292 throw std::bad_alloc(); 00293 } 00294 return rtl::OUString(s, SAL_NO_ACQUIRE); 00295 } 00296 00304 RTFieldAccess getFieldFlags(sal_uInt16 index) const { 00305 return typereg_reader_getFieldFlags(m_handle, index); 00306 } 00307 00317 rtl::OUString getFieldName(sal_uInt16 index) const { 00318 rtl_uString * s = 0; 00319 typereg_reader_getFieldName(m_handle, &s, index); 00320 if (s == 0) { 00321 throw std::bad_alloc(); 00322 } 00323 return rtl::OUString(s, SAL_NO_ACQUIRE); 00324 } 00325 00335 rtl::OUString getFieldTypeName(sal_uInt16 index) const { 00336 rtl_uString * s = 0; 00337 typereg_reader_getFieldTypeName(m_handle, &s, index); 00338 if (s == 0) { 00339 throw std::bad_alloc(); 00340 } 00341 return rtl::OUString(s, SAL_NO_ACQUIRE); 00342 } 00343 00353 RTConstValue getFieldValue(sal_uInt16 index) const { 00354 RTConstValue v; 00355 if (!typereg_reader_getFieldValue( 00356 m_handle, index, &v.m_type, &v.m_value)) 00357 { 00358 throw std::bad_alloc(); 00359 } 00360 return v; 00361 } 00362 00369 sal_uInt16 getMethodCount() const { 00370 return typereg_reader_getMethodCount(m_handle); 00371 } 00372 00382 rtl::OUString getMethodDocumentation(sal_uInt16 index) const { 00383 rtl_uString * s = 0; 00384 typereg_reader_getMethodDocumentation(m_handle, &s, index); 00385 if (s == 0) { 00386 throw std::bad_alloc(); 00387 } 00388 return rtl::OUString(s, SAL_NO_ACQUIRE); 00389 } 00390 00398 RTMethodMode getMethodFlags(sal_uInt16 index) const { 00399 return typereg_reader_getMethodFlags(m_handle, index); 00400 } 00401 00411 rtl::OUString getMethodName(sal_uInt16 index) const { 00412 rtl_uString * s = 0; 00413 typereg_reader_getMethodName(m_handle, &s, index); 00414 if (s == 0) { 00415 throw std::bad_alloc(); 00416 } 00417 return rtl::OUString(s, SAL_NO_ACQUIRE); 00418 } 00419 00429 rtl::OUString getMethodReturnTypeName(sal_uInt16 index) const { 00430 rtl_uString * s = 0; 00431 typereg_reader_getMethodReturnTypeName(m_handle, &s, index); 00432 if (s == 0) { 00433 throw std::bad_alloc(); 00434 } 00435 return rtl::OUString(s, SAL_NO_ACQUIRE); 00436 } 00437 00445 sal_uInt16 getMethodParameterCount(sal_uInt16 index) const { 00446 return typereg_reader_getMethodParameterCount(m_handle, index); 00447 } 00448 00460 RTParamMode getMethodParameterFlags( 00461 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const 00462 { 00463 return typereg_reader_getMethodParameterFlags( 00464 m_handle, methodIndex, parameterIndex); 00465 } 00466 00480 rtl::OUString getMethodParameterName( 00481 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const 00482 { 00483 rtl_uString * s = 0; 00484 typereg_reader_getMethodParameterName( 00485 m_handle, &s, methodIndex, parameterIndex); 00486 if (s == 0) { 00487 throw std::bad_alloc(); 00488 } 00489 return rtl::OUString(s, SAL_NO_ACQUIRE); 00490 } 00491 00505 rtl::OUString getMethodParameterTypeName( 00506 sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const 00507 { 00508 rtl_uString * s = 0; 00509 typereg_reader_getMethodParameterTypeName( 00510 m_handle, &s, methodIndex, parameterIndex); 00511 if (s == 0) { 00512 throw std::bad_alloc(); 00513 } 00514 return rtl::OUString(s, SAL_NO_ACQUIRE); 00515 } 00516 00524 sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const { 00525 return typereg_reader_getMethodExceptionCount(m_handle, index); 00526 } 00527 00541 rtl::OUString getMethodExceptionTypeName( 00542 sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const 00543 { 00544 rtl_uString * s = 0; 00545 typereg_reader_getMethodExceptionTypeName( 00546 m_handle, &s, methodIndex, exceptionIndex); 00547 if (s == 0) { 00548 throw std::bad_alloc(); 00549 } 00550 return rtl::OUString(s, SAL_NO_ACQUIRE); 00551 } 00552 00559 sal_uInt16 getReferenceCount() const { 00560 return typereg_reader_getReferenceCount(m_handle); 00561 } 00562 00573 rtl::OUString getReferenceDocumentation(sal_uInt16 index) const { 00574 rtl_uString * s = 0; 00575 typereg_reader_getReferenceDocumentation(m_handle, &s, index); 00576 if (s == 0) { 00577 throw std::bad_alloc(); 00578 } 00579 return rtl::OUString(s, SAL_NO_ACQUIRE); 00580 } 00581 00590 RTFieldAccess getReferenceFlags(sal_uInt16 index) const { 00591 return typereg_reader_getReferenceFlags(m_handle, index); 00592 } 00593 00602 RTReferenceType getReferenceSort(sal_uInt16 index) const { 00603 return typereg_reader_getReferenceSort(m_handle, index); 00604 } 00605 00616 rtl::OUString getReferenceTypeName(sal_uInt16 index) const { 00617 rtl_uString * s = 0; 00618 typereg_reader_getReferenceTypeName(m_handle, &s, index); 00619 if (s == 0) { 00620 throw std::bad_alloc(); 00621 } 00622 return rtl::OUString(s, SAL_NO_ACQUIRE); 00623 } 00624 00625 private: 00626 void * m_handle; 00627 }; 00628 00629 } 00630 00631 #endif 00632 00633 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */