/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/// checks if the registry points to a valid registry data file. inlinebool isValid() const;
/** returns the access mode of the registry.
@return TRUE if the access mode is readonly else FALSE.
*/ inlinebool isReadOnly() const;
/** opens the root key of the registry.
@param rRootKey reference to a RegistryKey which is filled with the rootkey. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError openRootKey(RegistryKey& rRootKey);
/// returns the name of the current registry data file. inline OUString getName();
/** creates a new registry with the specified name and creates a root key.
@param registryName specifies the name of the new registry. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError create(const OUString& registryName);
/** opens a registry with the specified name.
If the registry already points to a valid registry, the old registry will be closed. @param registryName specifies a registry name. @param accessMode specifies the access mode for the registry, RegAccessMode::READONLY or RegAccessMode::READWRITE. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError open(const OUString& registryName,
RegAccessMode accessMode);
/// closes explicitly the current registry data file. inline RegError close();
/** destroys a registry.
@param registryName specifies a registry name, if the name is an empty string the registry itself will be destroyed. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError destroy(const OUString& registryName);
/// returns the used registry Api. const Registry_Api* getApi() const { return m_pApi; }
private: /// stores the used and initialized registry Api. const Registry_Api* m_pApi; /// stores the handle of the underlying registry file on which most of the functions work.
RegHandle m_hImpl;
};
/** RegistryKeyArray represents an array of open keys.
RegistryKeyArray is a helper class to work with an array of keys.
*/ class RegistryKeyArray
{ public: /// Default constructor inline RegistryKeyArray();
/// Destructor, all subkeys will be closed. inline ~RegistryKeyArray();
/// returns the open key specified by index. inline RegistryKey getElement(sal_uInt32 index);
/// returns the length of the array. inline sal_uInt32 getLength() const;
friendclass RegistryKey;
private: /** sets the data of the key array.
@param registry specifies the registry files where the keys are located. @param phKeys points to an array of open keys. @param length specifies the length of the array specified by phKeys.
*/ inlinevoid setKeyHandles(Registry const & registry, RegKeyHandle* phKeys, sal_uInt32 length);
/// stores the number of open subkeys, the number of elements.
sal_uInt32 m_length; /// stores an array of open subkeys.
RegKeyHandle* m_phKeys; /// stores the handle to the registry file where the appropriate keys are located.
Registry m_registry;
};
/** RegistryKeyNames represents an array of key names.
RegistryKeyNames is a helper class to work with an array of key names.
*/ class RegistryKeyNames
{ public: /// Default constructor inline RegistryKeyNames();
/// Destructor, the internal array with key names will be deleted. inline ~RegistryKeyNames();
/// returns the name of the key specified by index. inline OUString getElement(sal_uInt32 index);
/// returns the length of the array. inline sal_uInt32 getLength() const;
friendclass RegistryKey;
private: /** sets the data of the array.
@param registry specifies the registry files where the keys are located. @param pKeyNames points to an array of key names. @param length specifies the length of the array specified by pKeyNames.
*/ inlinevoid setKeyNames(Registry const & registry, rtl_uString** pKeyNames, sal_uInt32 length);
/// stores the number of key names, the number of elements.
sal_uInt32 m_length; /// stores an array of key names.
rtl_uString** m_pKeyNames; /// stores the handle to the registry file where the appropriate keys are located.
Registry m_registry;
};
/** RegistryValueList represents a value list of the specified type.
RegistryValueList is a helper class to work with a list value.
*/ template<class ValueType> class RegistryValueList final
{ public: /// Default constructor
RegistryValueList()
: m_length(0)
, m_pValueList(nullptr)
, m_valueType(RegValueType::NOT_DEFINED)
{}
/// Destructor, the internal value list will be freed.
~RegistryValueList()
{ if (m_pValueList)
{
m_registry.getApi()->freeValueList(m_valueType, m_pValueList, m_length);
}
}
/// returns the value of the list specified by index.
ValueType getElement(sal_uInt32 index)
{ if (m_registry.isValid() && index < m_length)
{ return m_pValueList[index];
} else
{ return {};
}
}
/// returns the length of the list.
sal_uInt32 getLength()
{ return m_length;
}
friendclass RegistryKey;
private: /** sets the data of the value list.
@param registry specifies the registry files where the appropriate key is located. @param valueType specifies the type of the list values. @param pValueList points to a value list. @param length specifies the length of the list.
*/ void setValueList(const Registry& registry, RegValueType valueType,
ValueType* pValueList, sal_uInt32 length)
{
m_length = length;
m_pValueList = pValueList;
m_valueType = valueType;
m_registry = registry;
}
/// stores the length of the list, the number of elements.
sal_uInt32 m_length; /// stores the value list.
ValueType* m_pValueList; /// stores the type of the list elements
RegValueType m_valueType; /** stores the handle to the registry file where the appropriate key to this value is located.
*/
Registry m_registry;
};
/** RegistryKey reads or writes information of the underlying key in a registry.
Class is inline and use a load on call C-Api.
*/ class RegistryKey
{ public: /// Default constructor inline RegistryKey();
/// checks if the key points to a valid registry key. inlinebool isValid() const;
/** returns the access mode of the key.
@return TRUE if access mode is read only else FALSE.
*/ inlinebool isReadOnly() const;
/// returns the full qualified name of the key beginning with the rootkey. inline OUString getName();
/** creates a new key or opens a key if the specified key already exists.
The specified keyname is relative to this key. @param keyName specifies the name of the key which will be opened or created. @param rNewKey references a RegistryKey which will be filled with the new or open key. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError createKey(const OUString& keyName,
RegistryKey& rNewKey);
/** opens the specified key.
The specified keyname is relative to this key. @param keyName specifies the name of the key which will be opened. @param rOpenKey references a RegistryKey which will be filled with the open key. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError openKey(const OUString& keyName,
RegistryKey& rOpenKey);
/** opens all subkeys of the specified key.
The specified keyname is relative to this key. @param keyName specifies the name of the key which subkeys will be opened. @param rSubKeys reference a RegistryKeyArray which will be filled with the open subkeys. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError openSubKeys(const OUString& keyName,
RegistryKeyArray& rSubKeys);
/** returns an array with the names of all subkeys of the specified key.
The specified keyname is relative to this key. @param keyName specifies the name of the key which subkey names will be returned. @param rSubKeyNames reference a RegistryKeyNames array which will be filled with the subkey names. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError getKeyNames(const OUString& keyName,
RegistryKeyNames& rSubKeyNames);
/** deletes the specified key.
@param keyName specifies the name of the key which will be deleted. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError deleteKey(const OUString& keyName);
/// closes explicitly the current key inline RegError closeKey();
/** sets a value of a key.
@param keyName specifies the name of the key which value will be set. If keyName is an empty string, the value will be set for the key specified by hKey. @param valueType specifies the type of the value. @param pValue points to a memory block containing the data for the value. @param valueSize specifies the size of pData in bytes @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError setValue(const OUString& keyName,
RegValueType valueType,
RegValue pValue,
sal_uInt32 valueSize);
/** sets a long list value of a key.
@param keyName specifies the name of the key which value will be set. If keyName is an empty string, the value will be set for the key specified by hKey. @param pValueList points to an array of longs containing the data for the value. @param len specifies the length of the list (the array referenced by pValueList). @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError setLongListValue(const OUString& keyName,
sal_Int32 const * pValueList,
sal_uInt32 len);
/** sets an ascii list value of a key.
@param keyName specifies the name of the key which value will be set. If keyName is an empty string, the value will be set for the key specified by hKey. @param pValueList points to an array of char* containing the data for the value. @param len specifies the length of the list (the array referenced by pValueList). @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError setStringListValue(const OUString& keyName, char** pValueList,
sal_uInt32 len);
/** sets a unicode string list value of a key.
@param keyName specifies the name of the key which value will be set. If keyName is an empty string, the value will be set for the key specified by hKey. @param pValueList points to an array of sal_Unicode* containing the data for the value. @param len specifies the length of the list (the array referenced by pValueList). @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError setUnicodeListValue(const OUString& keyName,
sal_Unicode** pValueList,
sal_uInt32 len);
/** gets info about type and size of a value.
@param keyName specifies the name of the key which value info will be returned. If keyName is an empty string, the value info of the key specified by hKey will be returned. @param pValueType returns the type of the value. @param pValueSize returns the size of the value in bytes or the length of a list value. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError getValueInfo(const OUString& keyName,
RegValueType* pValueType,
sal_uInt32* pValueSize);
/** gets the value of a key.
@param keyName specifies the name of the key which value will be returned. If keyName is an empty string, the value is get from the key specified by hKey. @param pValue points to an allocated memory block receiving the data of the value. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError getValue(const OUString& keyName,
RegValue pValue);
/** gets a long list value of a key.
@param keyName specifies the name of the key which value will be returned. If keyName is an empty string, the value is get from the key specified by hKey. @param rValueList references a RegistryValueList which will be filled with the long values. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError getLongListValue(const OUString& keyName,
RegistryValueList<sal_Int32>& rValueList);
/** gets an ascii list value of a key.
@param keyName specifies the name of the key which value will be returned. If keyName is an empty string, the value is get from the key specified by hKey. @param rValueList references a RegistryValueList which will be filled with the ascii values. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError getStringListValue(const OUString& keyName,
RegistryValueList<char*>& rValueList);
/** gets a unicode value of a key.
@param keyName specifies the name of the key which value will be returned. If keyName is an empty string, the value is get from the key specified by hKey. @param rValueList reference a RegistryValueList which will be filled with the unicode values. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError getUnicodeListValue(const OUString& keyName,
RegistryValueList<sal_Unicode*>& rValueList);
/** resolves a keyname.
@param[in] keyName specifies the name of the key which will be resolved relative to this key. The resolved name will be prefixed with the name of this key. @param[out] rResolvedName the resolved name. @return RegError::NO_ERROR if succeeds else an error code.
*/ inline RegError getResolvedKeyName(const OUString& keyName,
OUString& rResolvedName) const;
/// returns the name of the registry in which the key is defined. inline OUString getRegistryName();
friendclass Registry; public: /// @cond INTERNAL
/** Constructor, which initialize a RegistryKey with registry and a valid key handle.
This constructor is internal only.
*/ inline RegistryKey(Registry const & registry,
RegKeyHandle hKey);
private: /** sets the internal registry on which this key should work.
*/ inlinevoid setRegistry(Registry const & registry);
/// @endcond
/// stores the registry on which this key works
Registry m_registry; /// stores the current key handle of this key
RegKeyHandle m_hImpl;
};
if (toAssign.m_hImpl)
m_registry.m_pApi->acquireKey(toAssign.m_hImpl); if (m_hImpl)
m_registry.m_pApi->releaseKey(m_hImpl);
m_hImpl = toAssign.m_hImpl;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.