|
UDK 3.2.7 C/C++ API Reference
|
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 _REGISTRY_REGISTRY_HXX_ 00021 #define _REGISTRY_REGISTRY_HXX_ 00022 00023 #include <registry/regdllapi.h> 00024 #include <registry/regtype.h> 00025 #include <rtl/ustring.hxx> 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00035 struct Registry_Api 00036 { 00037 void (REGISTRY_CALLTYPE *acquire) (RegHandle); 00038 void (REGISTRY_CALLTYPE *release) (RegHandle); 00039 sal_Bool (REGISTRY_CALLTYPE *isReadOnly) (RegHandle); 00040 RegError (REGISTRY_CALLTYPE *openRootKey) (RegHandle, RegKeyHandle*); 00041 RegError (REGISTRY_CALLTYPE *getName) (RegHandle, rtl_uString**); 00042 RegError (REGISTRY_CALLTYPE *createRegistry) (rtl_uString*, RegHandle*); 00043 RegError (REGISTRY_CALLTYPE *openRegistry) (rtl_uString*, RegHandle*, RegAccessMode); 00044 RegError (REGISTRY_CALLTYPE *closeRegistry) (RegHandle); 00045 RegError (REGISTRY_CALLTYPE *destroyRegistry) (RegHandle, rtl_uString*); 00046 RegError (REGISTRY_CALLTYPE *loadKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*); 00047 RegError (REGISTRY_CALLTYPE *saveKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*); 00048 RegError (REGISTRY_CALLTYPE *mergeKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*, sal_Bool, sal_Bool); 00049 RegError (REGISTRY_CALLTYPE *dumpRegistry) (RegHandle, RegKeyHandle); 00050 void (REGISTRY_CALLTYPE *acquireKey) (RegKeyHandle); 00051 void (REGISTRY_CALLTYPE *releaseKey) (RegKeyHandle); 00052 sal_Bool (REGISTRY_CALLTYPE *isKeyReadOnly) (RegKeyHandle); 00053 RegError (REGISTRY_CALLTYPE *getKeyName) (RegKeyHandle, rtl_uString**); 00054 RegError (REGISTRY_CALLTYPE *createKey) (RegKeyHandle, rtl_uString*, RegKeyHandle*); 00055 RegError (REGISTRY_CALLTYPE *openKey) (RegKeyHandle, rtl_uString*, RegKeyHandle*); 00056 RegError (REGISTRY_CALLTYPE *openSubKeys) (RegKeyHandle, rtl_uString*, RegKeyHandle**, sal_uInt32*); 00057 RegError (REGISTRY_CALLTYPE *closeSubKeys) (RegKeyHandle*, sal_uInt32); 00058 RegError (REGISTRY_CALLTYPE *deleteKey) (RegKeyHandle, rtl_uString*); 00059 RegError (REGISTRY_CALLTYPE *closeKey) (RegKeyHandle); 00060 RegError (REGISTRY_CALLTYPE *setValue) (RegKeyHandle, rtl_uString*, RegValueType, RegValue, sal_uInt32); 00061 RegError (REGISTRY_CALLTYPE *setLongListValue) (RegKeyHandle, rtl_uString*, sal_Int32*, sal_uInt32); 00062 RegError (REGISTRY_CALLTYPE *setStringListValue) (RegKeyHandle, rtl_uString*, sal_Char**, sal_uInt32); 00063 RegError (REGISTRY_CALLTYPE *setUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode**, sal_uInt32); 00064 RegError (REGISTRY_CALLTYPE *getValueInfo) (RegKeyHandle, rtl_uString*, RegValueType*, sal_uInt32*); 00065 RegError (REGISTRY_CALLTYPE *getValue) (RegKeyHandle, rtl_uString*, RegValue); 00066 RegError (REGISTRY_CALLTYPE *getLongListValue) (RegKeyHandle, rtl_uString*, sal_Int32**, sal_uInt32*); 00067 RegError (REGISTRY_CALLTYPE *getStringListValue) (RegKeyHandle, rtl_uString*, sal_Char***, sal_uInt32*); 00068 RegError (REGISTRY_CALLTYPE *getUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode***, sal_uInt32*); 00069 RegError (REGISTRY_CALLTYPE *freeValueList) (RegValueType, RegValue, sal_uInt32); 00070 RegError (REGISTRY_CALLTYPE *createLink) (RegKeyHandle, rtl_uString*, rtl_uString*); 00071 RegError (REGISTRY_CALLTYPE *deleteLink) (RegKeyHandle, rtl_uString*); 00072 RegError (REGISTRY_CALLTYPE *getKeyType) (RegKeyHandle, rtl_uString*, RegKeyType*); 00073 RegError (REGISTRY_CALLTYPE *getLinkTarget) (RegKeyHandle, rtl_uString*, rtl_uString**); 00074 RegError (REGISTRY_CALLTYPE *getResolvedKeyName) (RegKeyHandle, rtl_uString*, sal_Bool, rtl_uString**); 00075 RegError (REGISTRY_CALLTYPE *getKeyNames) (RegKeyHandle, rtl_uString*, rtl_uString***, sal_uInt32*); 00076 RegError (REGISTRY_CALLTYPE *freeKeyNames) (rtl_uString**, sal_uInt32); 00077 }; 00078 00081 REG_DLLPUBLIC Registry_Api* REGISTRY_CALLTYPE initRegistry_Api(void); 00082 00083 #ifdef __cplusplus 00084 } 00085 #endif 00086 00087 00088 class RegistryKey; 00089 00090 //----------------------------------------------------------------------------- 00091 00096 class Registry 00097 { 00098 public: 00101 inline Registry(); 00102 00104 inline Registry(const Registry& toCopy); 00105 00107 inline ~Registry(); 00108 00110 inline Registry& operator = (const Registry& toAssign); 00111 00113 inline sal_Bool isValid() const; 00114 00119 inline sal_Bool isReadOnly() const; 00120 00126 inline RegError openRootKey(RegistryKey& rRootKey); 00127 00129 inline ::rtl::OUString getName(); 00130 00136 inline RegError create(const ::rtl::OUString& registryName); 00137 00145 inline RegError open(const ::rtl::OUString& registryName, 00146 RegAccessMode accessMode); 00147 00149 inline RegError close(); 00150 00157 inline RegError destroy(const ::rtl::OUString& registryName); 00158 00170 inline RegError loadKey(RegistryKey& rKey, 00171 const ::rtl::OUString& keyName, 00172 const ::rtl::OUString& regFileName); 00173 00185 inline RegError saveKey(RegistryKey& rKey, 00186 const ::rtl::OUString& keyName, 00187 const ::rtl::OUString& regFileName); 00188 00204 inline RegError mergeKey(RegistryKey& rKey, 00205 const ::rtl::OUString& keyName, 00206 const ::rtl::OUString& regFileName, 00207 sal_Bool bWarnings = sal_False, 00208 sal_Bool bReport = sal_False); 00209 00217 inline RegError dumpRegistry(RegistryKey& rKey); 00218 00219 friend class RegistryKey; 00220 friend class RegistryKeyArray; 00221 friend class RegistryKeyNames; 00222 00224 const Registry_Api* getApi() { return m_pApi; } 00225 protected: 00226 00228 const Registry_Api* m_pApi; 00230 RegHandle m_hImpl; 00231 }; 00232 00233 00234 //----------------------------------------------------------------------------- 00235 00240 class RegistryKeyArray 00241 { 00242 public: 00244 inline RegistryKeyArray(); 00245 00247 inline ~RegistryKeyArray(); 00248 00250 inline RegistryKey getElement(sal_uInt32 index); 00251 00253 inline sal_uInt32 getLength(); 00254 00255 friend class RegistryKey; 00256 protected: 00263 inline void setKeyHandles(Registry& registry, RegKeyHandle* phKeys, sal_uInt32 length); 00265 inline RegError closeKeyHandles(); 00266 00268 sal_uInt32 m_length; 00270 RegKeyHandle* m_phKeys; 00272 Registry m_registry; 00273 }; 00274 00275 00280 class RegistryKeyNames 00281 { 00282 public: 00284 inline RegistryKeyNames(); 00285 00287 inline ~RegistryKeyNames(); 00288 00290 inline ::rtl::OUString getElement(sal_uInt32 index); 00291 00293 inline sal_uInt32 getLength(); 00294 00295 friend class RegistryKey; 00296 protected: 00303 inline void setKeyNames(Registry& registry, rtl_uString** pKeyNames, sal_uInt32 length); 00305 inline RegError freeKeyNames(); 00306 00308 sal_uInt32 m_length; 00310 rtl_uString** m_pKeyNames; 00312 Registry m_registry; 00313 }; 00314 00315 //----------------------------------------------------------------------------- 00316 00321 template<class ValueType> 00322 class RegistryValueList 00323 { 00324 public: 00326 RegistryValueList() 00327 : m_length(0) 00328 , m_pValueList(NULL) 00329 , m_valueType(RG_VALUETYPE_NOT_DEFINED) 00330 {} 00331 00333 ~RegistryValueList() 00334 { 00335 if (m_pValueList) 00336 { 00337 m_registry.getApi()->freeValueList(m_valueType, m_pValueList, m_length); 00338 } 00339 } 00340 00342 ValueType getElement(sal_uInt32 index) 00343 { 00344 if (m_registry.isValid() && index < m_length) 00345 { 00346 return m_pValueList[index]; 00347 } else 00348 { 00349 return 0; 00350 } 00351 } 00352 00354 sal_uInt32 getLength() 00355 { 00356 return m_length; 00357 } 00358 00359 friend class RegistryKey; 00360 protected: 00368 void setValueList(Registry& registry, RegValueType valueType, 00369 ValueType* pValueList, sal_uInt32 length) 00370 { 00371 m_length = length; 00372 m_pValueList = pValueList; 00373 m_valueType = valueType; 00374 m_registry = registry; 00375 } 00376 00378 sal_uInt32 m_length; 00380 ValueType* m_pValueList; 00382 RegValueType m_valueType; 00386 Registry m_registry; 00387 }; 00388 00389 //----------------------------------------------------------------------------- 00390 00395 class RegistryKey 00396 { 00397 public: 00399 inline RegistryKey(); 00400 00402 inline RegistryKey(const RegistryKey& toCopy); 00403 00405 inline ~RegistryKey(); 00406 00408 inline RegistryKey& operator = (const RegistryKey& toAssign); 00409 00411 inline sal_Bool isValid() const; 00412 00417 inline sal_Bool isReadOnly() const; 00418 00420 inline ::rtl::OUString getName(); 00421 00429 inline RegError createKey(const ::rtl::OUString& keyName, 00430 RegistryKey& rNewKey); 00431 00439 inline RegError openKey(const ::rtl::OUString& keyName, 00440 RegistryKey& rOpenKey); 00441 00449 inline RegError openSubKeys(const ::rtl::OUString& keyName, 00450 RegistryKeyArray& rSubKeys); 00451 00459 inline RegError getKeyNames(const ::rtl::OUString& keyName, 00460 RegistryKeyNames& rSubKeyNames); 00461 00467 inline RegError closeSubKeys(RegistryKeyArray& rSubKeys); 00468 00474 inline RegError deleteKey(const ::rtl::OUString& keyName); 00475 00477 inline RegError closeKey(); 00478 00480 inline void releaseKey(); 00481 00492 inline RegError setValue(const ::rtl::OUString& keyName, 00493 RegValueType valueType, 00494 RegValue pValue, 00495 sal_uInt32 valueSize); 00496 00506 inline RegError setLongListValue(const ::rtl::OUString& keyName, 00507 sal_Int32* pValueList, 00508 sal_uInt32 len); 00509 00519 inline RegError setStringListValue(const ::rtl::OUString& keyName, 00520 sal_Char** pValueList, 00521 sal_uInt32 len); 00522 00532 inline RegError setUnicodeListValue(const ::rtl::OUString& keyName, 00533 sal_Unicode** pValueList, 00534 sal_uInt32 len); 00535 00545 inline RegError getValueInfo(const ::rtl::OUString& keyName, 00546 RegValueType* pValueType, 00547 sal_uInt32* pValueSize); 00548 00557 inline RegError getValue(const ::rtl::OUString& keyName, 00558 RegValue pValue); 00559 00568 inline RegError getLongListValue(const ::rtl::OUString& keyName, 00569 RegistryValueList<sal_Int32>& rValueList); 00570 00579 inline RegError getStringListValue(const ::rtl::OUString& keyName, 00580 RegistryValueList<sal_Char*>& rValueList); 00581 00590 inline RegError getUnicodeListValue(const ::rtl::OUString& keyName, 00591 RegistryValueList<sal_Unicode*>& rValueList); 00592 00599 inline RegError createLink(const ::rtl::OUString& linkName, 00600 const ::rtl::OUString& linkTarget); 00601 00608 inline RegError deleteLink(const ::rtl::OUString& linkName); 00609 00616 inline RegError getKeyType(const ::rtl::OUString& name, 00617 RegKeyType* pKeyType) const; 00618 00625 inline RegError getLinkTarget(const ::rtl::OUString& linkName, 00626 ::rtl::OUString& rLinkTarget) const; 00627 00635 inline RegError getResolvedKeyName(const ::rtl::OUString& keyName, 00636 sal_Bool firstLinkOnly, 00637 ::rtl::OUString& rResolvedName) const; 00638 00640 inline ::rtl::OUString getRegistryName(); 00641 00643 Registry getRegistry() const { return m_registry; } 00644 00645 friend class Registry; 00646 public: 00648 00653 inline RegistryKey(Registry& registry, 00654 RegKeyHandle hKey); 00655 00658 RegKeyHandle getKeyHandle() const { return m_hImpl; } 00659 00660 protected: 00663 inline void setRegistry(Registry& registry); 00664 00666 00668 Registry m_registry; 00670 RegKeyHandle m_hImpl; 00671 }; 00672 00673 00674 //----------------------------------------------------------------------------- 00675 00676 inline RegistryKeyArray::RegistryKeyArray() 00677 : m_length(0) 00678 , m_phKeys(NULL) 00679 { 00680 } 00681 00682 inline RegistryKeyArray::~RegistryKeyArray() 00683 { 00684 if (m_phKeys) 00685 m_registry.m_pApi->closeSubKeys(m_phKeys, m_length); 00686 } 00687 00688 inline RegistryKey RegistryKeyArray::getElement(sal_uInt32 index) 00689 { 00690 if (m_registry.isValid() && index < m_length) 00691 return RegistryKey(m_registry, m_phKeys[index]); 00692 else 00693 return RegistryKey(); 00694 } 00695 00696 inline sal_uInt32 RegistryKeyArray::getLength() 00697 { 00698 return m_length; 00699 } 00700 00701 inline void RegistryKeyArray::setKeyHandles(Registry& registry, 00702 RegKeyHandle* phKeys, 00703 sal_uInt32 length) 00704 { 00705 m_phKeys = phKeys; 00706 m_length = length; 00707 m_registry = registry; 00708 } 00709 00710 inline RegError RegistryKeyArray::closeKeyHandles() 00711 { 00712 if (m_registry.isValid() && m_phKeys) 00713 { 00714 RegError ret; 00715 ret = m_registry.m_pApi->closeSubKeys(m_phKeys, m_length); 00716 m_registry = Registry(); 00717 m_length = 0; 00718 m_phKeys = NULL; 00719 return ret; 00720 } else 00721 return(REG_INVALID_KEY); 00722 } 00723 00724 //----------------------------------------------------------------------------- 00725 00726 inline RegistryKeyNames::RegistryKeyNames() 00727 : m_length(0) 00728 , m_pKeyNames(NULL) 00729 { 00730 } 00731 00732 inline RegistryKeyNames::~RegistryKeyNames() 00733 { 00734 if (m_pKeyNames) 00735 m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length); 00736 } 00737 00738 inline ::rtl::OUString RegistryKeyNames::getElement(sal_uInt32 index) 00739 { 00740 00741 if (m_pKeyNames && index < m_length) 00742 return m_pKeyNames[index]; 00743 else 00744 return ::rtl::OUString(); 00745 } 00746 00747 inline sal_uInt32 RegistryKeyNames::getLength() 00748 { 00749 return m_length; 00750 } 00751 00752 inline void RegistryKeyNames::setKeyNames(Registry& registry, 00753 rtl_uString** pKeyNames, 00754 sal_uInt32 length) 00755 { 00756 m_pKeyNames = pKeyNames; 00757 m_length = length; 00758 m_registry = registry; 00759 } 00760 00761 inline RegError RegistryKeyNames::freeKeyNames() 00762 { 00763 if (m_registry.isValid() && m_pKeyNames) 00764 { 00765 RegError ret = REG_NO_ERROR; 00766 ret = m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length); 00767 m_registry = Registry(); 00768 m_length = 0; 00769 m_pKeyNames = NULL; 00770 return ret; 00771 } else 00772 return REG_INVALID_KEY; 00773 } 00774 00775 //----------------------------------------------------------------------------- 00776 00777 inline RegistryKey::RegistryKey() 00778 : m_hImpl(NULL) 00779 { } 00780 00782 inline RegistryKey::RegistryKey(Registry& registry, RegKeyHandle hKey) 00783 : m_registry(registry) 00784 , m_hImpl(hKey) 00785 { 00786 if (m_hImpl) 00787 m_registry.m_pApi->acquireKey(m_hImpl); 00788 } 00790 00791 inline RegistryKey::RegistryKey(const RegistryKey& toCopy) 00792 : m_registry(toCopy.m_registry) 00793 , m_hImpl(toCopy.m_hImpl) 00794 { 00795 if (m_hImpl) 00796 m_registry.m_pApi->acquireKey(m_hImpl); 00797 } 00798 00800 inline void RegistryKey::setRegistry(Registry& registry) 00801 { 00802 m_registry = registry; 00803 } 00805 00806 inline RegistryKey::~RegistryKey() 00807 { 00808 if (m_hImpl) 00809 m_registry.m_pApi->releaseKey(m_hImpl); 00810 } 00811 00812 inline RegistryKey& RegistryKey::operator = (const RegistryKey& toAssign) 00813 { 00814 m_registry = toAssign.m_registry; 00815 00816 if (toAssign.m_hImpl) 00817 m_registry.m_pApi->acquireKey(toAssign.m_hImpl); 00818 if (m_hImpl) 00819 m_registry.m_pApi->releaseKey(m_hImpl); 00820 m_hImpl = toAssign.m_hImpl; 00821 00822 return *this; 00823 } 00824 00825 inline sal_Bool RegistryKey::isValid() const 00826 { return (m_hImpl != NULL); } 00827 00828 inline sal_Bool RegistryKey::isReadOnly() const 00829 { 00830 if (m_registry.isValid()) 00831 return (m_registry.m_pApi)->isKeyReadOnly(m_hImpl); 00832 else 00833 return sal_False; 00834 } 00835 00836 inline ::rtl::OUString RegistryKey::getName() 00837 { 00838 ::rtl::OUString sRet; 00839 if (m_registry.isValid()) 00840 m_registry.m_pApi->getKeyName(m_hImpl, &sRet.pData); 00841 return sRet; 00842 } 00843 00844 inline RegError RegistryKey::createKey(const ::rtl::OUString& keyName, 00845 RegistryKey& rNewKey) 00846 { 00847 if (rNewKey.isValid()) rNewKey.closeKey(); 00848 if (m_registry.isValid()) 00849 { 00850 RegError ret = m_registry.m_pApi->createKey(m_hImpl, keyName.pData, &rNewKey.m_hImpl); 00851 if (!ret) rNewKey.setRegistry(m_registry); 00852 return ret; 00853 } else 00854 return REG_INVALID_KEY; 00855 } 00856 00857 inline RegError RegistryKey::openKey(const ::rtl::OUString& keyName, 00858 RegistryKey& rOpenKey) 00859 { 00860 if (rOpenKey.isValid()) rOpenKey.closeKey(); 00861 if (m_registry.isValid()) 00862 { 00863 RegError ret = m_registry.m_pApi->openKey(m_hImpl, keyName.pData, 00864 &rOpenKey.m_hImpl); 00865 if (!ret) rOpenKey.setRegistry(m_registry); 00866 return ret; 00867 } else 00868 return REG_INVALID_KEY; 00869 } 00870 00871 inline RegError RegistryKey::openSubKeys(const ::rtl::OUString& keyName, 00872 RegistryKeyArray& rSubKeys) 00873 { 00874 if (m_registry.isValid()) 00875 { 00876 RegError ret = REG_NO_ERROR; 00877 RegKeyHandle* pSubKeys; 00878 sal_uInt32 nSubKeys; 00879 ret = m_registry.m_pApi->openSubKeys(m_hImpl, keyName.pData, 00880 &pSubKeys, &nSubKeys); 00881 if ( ret ) 00882 { 00883 return ret; 00884 } else 00885 { 00886 rSubKeys.setKeyHandles(m_registry, pSubKeys, nSubKeys); 00887 return ret; 00888 } 00889 } else 00890 return REG_INVALID_KEY; 00891 } 00892 00893 inline RegError RegistryKey::getKeyNames(const ::rtl::OUString& keyName, 00894 RegistryKeyNames& rSubKeyNames) 00895 { 00896 if (m_registry.isValid()) 00897 { 00898 RegError ret = REG_NO_ERROR; 00899 rtl_uString** pSubKeyNames; 00900 sal_uInt32 nSubKeys; 00901 ret = m_registry.m_pApi->getKeyNames(m_hImpl, keyName.pData, 00902 &pSubKeyNames, &nSubKeys); 00903 if ( ret ) 00904 { 00905 return ret; 00906 } else 00907 { 00908 rSubKeyNames.setKeyNames(m_registry, pSubKeyNames, nSubKeys); 00909 return ret; 00910 } 00911 } else 00912 return REG_INVALID_KEY; 00913 } 00914 00915 inline RegError RegistryKey::closeSubKeys(RegistryKeyArray& rSubKeys) 00916 { 00917 if (m_registry.isValid()) 00918 return rSubKeys.closeKeyHandles(); 00919 else 00920 return REG_INVALID_KEY; 00921 } 00922 00923 inline RegError RegistryKey::deleteKey(const ::rtl::OUString& keyName) 00924 { 00925 if (m_registry.isValid()) 00926 return m_registry.m_pApi->deleteKey(m_hImpl, keyName.pData); 00927 else 00928 return REG_INVALID_KEY; 00929 } 00930 00931 inline RegError RegistryKey::closeKey() 00932 { 00933 if (m_registry.isValid()) 00934 { 00935 RegError ret = m_registry.m_pApi->closeKey(m_hImpl); 00936 if (!ret) 00937 { 00938 m_hImpl = NULL; 00939 m_registry = Registry(); 00940 } 00941 return ret; 00942 } else 00943 return REG_INVALID_KEY; 00944 } 00945 00946 inline void RegistryKey::releaseKey() 00947 { 00948 if (m_registry.isValid() && (m_hImpl != 0)) 00949 { 00950 m_registry.m_pApi->releaseKey(m_hImpl), m_hImpl = 0; 00951 } 00952 } 00953 00954 inline RegError RegistryKey::setValue(const ::rtl::OUString& keyName, 00955 RegValueType valueType, 00956 RegValue pValue, 00957 sal_uInt32 valueSize) 00958 { 00959 if (m_registry.isValid()) 00960 return m_registry.m_pApi->setValue(m_hImpl, keyName.pData, valueType, 00961 pValue, valueSize); 00962 else 00963 return REG_INVALID_KEY; 00964 } 00965 00966 inline RegError RegistryKey::setLongListValue(const ::rtl::OUString& keyName, 00967 sal_Int32* pValueList, 00968 sal_uInt32 len) 00969 { 00970 if (m_registry.isValid()) 00971 return m_registry.m_pApi->setLongListValue(m_hImpl, keyName.pData, 00972 pValueList, len); 00973 else 00974 return REG_INVALID_KEY; 00975 } 00976 00977 inline RegError RegistryKey::setStringListValue(const ::rtl::OUString& keyName, 00978 sal_Char** pValueList, 00979 sal_uInt32 len) 00980 { 00981 if (m_registry.isValid()) 00982 return m_registry.m_pApi->setStringListValue(m_hImpl, keyName.pData, 00983 pValueList, len); 00984 else 00985 return REG_INVALID_KEY; 00986 } 00987 00988 inline RegError RegistryKey::setUnicodeListValue(const ::rtl::OUString& keyName, 00989 sal_Unicode** pValueList, 00990 sal_uInt32 len) 00991 { 00992 if (m_registry.isValid()) 00993 return m_registry.m_pApi->setUnicodeListValue(m_hImpl, keyName.pData, 00994 pValueList, len); 00995 else 00996 return REG_INVALID_KEY; 00997 } 00998 00999 inline RegError RegistryKey::getValueInfo(const ::rtl::OUString& keyName, 01000 RegValueType* pValueType, 01001 sal_uInt32* pValueSize) 01002 { 01003 if (m_registry.isValid()) 01004 return m_registry.m_pApi->getValueInfo(m_hImpl, keyName.pData, pValueType, pValueSize); 01005 else 01006 return REG_INVALID_KEY; 01007 } 01008 01009 inline RegError RegistryKey::getValue(const ::rtl::OUString& keyName, 01010 RegValue pValue) 01011 { 01012 if (m_registry.isValid()) 01013 return m_registry.m_pApi->getValue(m_hImpl, keyName.pData, pValue); 01014 else 01015 return REG_INVALID_KEY; 01016 } 01017 01018 inline RegError RegistryKey::getLongListValue(const ::rtl::OUString& keyName, 01019 RegistryValueList<sal_Int32>& rValueList) 01020 { 01021 if (m_registry.isValid()) 01022 { 01023 RegError ret = REG_NO_ERROR; 01024 sal_Int32* pValueList; 01025 sal_uInt32 length; 01026 ret = m_registry.m_pApi->getLongListValue(m_hImpl, keyName.pData, 01027 &pValueList, &length); 01028 if ( ret ) 01029 { 01030 return ret; 01031 } else 01032 { 01033 rValueList.setValueList(m_registry, RG_VALUETYPE_LONGLIST, 01034 pValueList, length); 01035 return ret; 01036 } 01037 } else 01038 return REG_INVALID_KEY; 01039 } 01040 01041 inline RegError RegistryKey::getStringListValue(const ::rtl::OUString& keyName, 01042 RegistryValueList<sal_Char*>& rValueList) 01043 { 01044 if (m_registry.isValid()) 01045 { 01046 RegError ret = REG_NO_ERROR; 01047 sal_Char** pValueList; 01048 sal_uInt32 length; 01049 ret = m_registry.m_pApi->getStringListValue(m_hImpl, keyName.pData, 01050 &pValueList, &length); 01051 if ( ret ) 01052 { 01053 return ret; 01054 } else 01055 { 01056 rValueList.setValueList(m_registry, RG_VALUETYPE_STRINGLIST, 01057 pValueList, length); 01058 return ret; 01059 } 01060 } else 01061 return REG_INVALID_KEY; 01062 } 01063 01064 inline RegError RegistryKey::getUnicodeListValue(const ::rtl::OUString& keyName, 01065 RegistryValueList<sal_Unicode*>& rValueList) 01066 { 01067 if (m_registry.isValid()) 01068 { 01069 RegError ret = REG_NO_ERROR; 01070 sal_Unicode** pValueList; 01071 sal_uInt32 length; 01072 ret = m_registry.m_pApi->getUnicodeListValue(m_hImpl, keyName.pData, 01073 &pValueList, &length); 01074 if ( ret ) 01075 { 01076 return ret; 01077 } else 01078 { 01079 rValueList.setValueList(m_registry, RG_VALUETYPE_UNICODELIST, 01080 pValueList, length); 01081 return ret; 01082 } 01083 } else 01084 return REG_INVALID_KEY; 01085 } 01086 01087 inline RegError RegistryKey::createLink(const ::rtl::OUString& linkName, 01088 const ::rtl::OUString& linkTarget) 01089 { 01090 if (m_registry.isValid()) 01091 return m_registry.m_pApi->createLink(m_hImpl, linkName.pData, linkTarget.pData); 01092 else 01093 return REG_INVALID_KEY; 01094 } 01095 01096 inline RegError RegistryKey::deleteLink(const ::rtl::OUString& linkName) 01097 { 01098 if (m_registry.isValid()) 01099 return m_registry.m_pApi->deleteLink(m_hImpl, linkName.pData); 01100 else 01101 return REG_INVALID_KEY; 01102 } 01103 01104 inline RegError RegistryKey::getKeyType(const ::rtl::OUString& keyName, 01105 RegKeyType* pKeyType) const 01106 { 01107 if (m_registry.isValid()) 01108 return m_registry.m_pApi->getKeyType(m_hImpl, keyName.pData, pKeyType); 01109 else 01110 return REG_INVALID_KEY; 01111 } 01112 01113 inline RegError RegistryKey::getLinkTarget(const ::rtl::OUString& linkName, 01114 ::rtl::OUString& rLinkTarget) const 01115 { 01116 if (m_registry.isValid()) 01117 { 01118 return m_registry.m_pApi->getLinkTarget(m_hImpl, 01119 linkName.pData, 01120 &rLinkTarget.pData); 01121 } else 01122 return REG_INVALID_KEY; 01123 } 01124 01125 01126 inline RegError RegistryKey::getResolvedKeyName(const ::rtl::OUString& keyName, 01127 sal_Bool firstLinkOnly, 01128 ::rtl::OUString& rResolvedName) const 01129 { 01130 if (m_registry.isValid()) 01131 return m_registry.m_pApi->getResolvedKeyName(m_hImpl, 01132 keyName.pData, 01133 firstLinkOnly, 01134 &rResolvedName.pData); 01135 else 01136 return REG_INVALID_KEY; 01137 } 01138 01139 inline ::rtl::OUString RegistryKey::getRegistryName() 01140 { 01141 if (m_registry.isValid()) 01142 { 01143 return m_registry.getName(); 01144 } else 01145 return ::rtl::OUString(); 01146 } 01147 01148 //----------------------------------------------------------------------------- 01149 01150 inline Registry::Registry() 01151 : m_pApi(initRegistry_Api()) 01152 , m_hImpl(NULL) 01153 { } 01154 01155 inline Registry::Registry(const Registry& toCopy) 01156 : m_pApi(toCopy.m_pApi) 01157 , m_hImpl(toCopy.m_hImpl) 01158 { 01159 if (m_hImpl) 01160 m_pApi->acquire(m_hImpl); 01161 } 01162 01163 01164 inline Registry::~Registry() 01165 { 01166 if (m_hImpl) 01167 m_pApi->release(m_hImpl); 01168 } 01169 01170 inline Registry& Registry::operator = (const Registry& toAssign) 01171 { 01172 if (toAssign.m_hImpl) 01173 toAssign.m_pApi->acquire(toAssign.m_hImpl); 01174 if (m_hImpl) 01175 m_pApi->release(m_hImpl); 01176 01177 m_pApi = toAssign.m_pApi; 01178 m_hImpl = toAssign.m_hImpl; 01179 01180 return *this; 01181 } 01182 01183 inline sal_Bool Registry::isValid() const 01184 { return ( m_hImpl != NULL ); } 01185 01186 inline sal_Bool Registry::isReadOnly() const 01187 { return m_pApi->isReadOnly(m_hImpl); } 01188 01189 inline RegError Registry::openRootKey(RegistryKey& rRootKey) 01190 { 01191 rRootKey.setRegistry(*this); 01192 return m_pApi->openRootKey(m_hImpl, &rRootKey.m_hImpl); 01193 } 01194 01195 inline ::rtl::OUString Registry::getName() 01196 { 01197 ::rtl::OUString sRet; 01198 m_pApi->getName(m_hImpl, &sRet.pData); 01199 return sRet; 01200 } 01201 01202 inline RegError Registry::create(const ::rtl::OUString& registryName) 01203 { 01204 if (m_hImpl) 01205 m_pApi->release(m_hImpl); 01206 return m_pApi->createRegistry(registryName.pData, &m_hImpl); 01207 } 01208 01209 inline RegError Registry::open(const ::rtl::OUString& registryName, 01210 RegAccessMode accessMode) 01211 { 01212 if (m_hImpl) 01213 m_pApi->release(m_hImpl); 01214 return m_pApi->openRegistry(registryName.pData, &m_hImpl, accessMode); 01215 } 01216 01217 inline RegError Registry::close() 01218 { 01219 RegError ret = m_pApi->closeRegistry(m_hImpl); 01220 if (!ret) 01221 m_hImpl = NULL; 01222 return ret; 01223 } 01224 01225 inline RegError Registry::destroy(const ::rtl::OUString& registryName) 01226 { 01227 RegError ret = m_pApi->destroyRegistry(m_hImpl, registryName.pData); 01228 if ( !ret && registryName.isEmpty() ) 01229 m_hImpl = NULL; 01230 return ret; 01231 } 01232 01233 inline RegError Registry::loadKey(RegistryKey& rKey, 01234 const ::rtl::OUString& keyName, 01235 const ::rtl::OUString& regFileName) 01236 { return m_pApi->loadKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); } 01237 01238 inline RegError Registry::saveKey(RegistryKey& rKey, 01239 const ::rtl::OUString& keyName, 01240 const ::rtl::OUString& regFileName) 01241 { return m_pApi->saveKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); } 01242 01243 inline RegError Registry::mergeKey(RegistryKey& rKey, 01244 const ::rtl::OUString& keyName, 01245 const ::rtl::OUString& regFileName, 01246 sal_Bool bWarnings, 01247 sal_Bool bReport) 01248 { return m_pApi->mergeKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData, bWarnings, bReport); } 01249 01250 inline RegError Registry::dumpRegistry(RegistryKey& rKey) 01251 { return m_pApi->dumpRegistry(m_hImpl, rKey.m_hImpl); } 01252 01253 01254 #endif 01255 01256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1.7.3