diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/registry | |
parent | move global headers script (diff) | |
download | core-b9337e22ce1dbf2eba0e8c8db294ae99f4111f91.tar.gz core-b9337e22ce1dbf2eba0e8c8db294ae99f4111f91.zip |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/registry')
-rw-r--r-- | include/registry/reader.h | 603 | ||||
-rw-r--r-- | include/registry/reader.hxx | 624 | ||||
-rw-r--r-- | include/registry/reflread.hxx | 513 | ||||
-rw-r--r-- | include/registry/refltype.hxx | 80 | ||||
-rw-r--r-- | include/registry/reflwrit.hxx | 350 | ||||
-rw-r--r-- | include/registry/regdllapi.h | 33 | ||||
-rw-r--r-- | include/registry/registry.h | 456 | ||||
-rw-r--r-- | include/registry/registry.hxx | 1257 | ||||
-rw-r--r-- | include/registry/regtype.h | 168 | ||||
-rw-r--r-- | include/registry/types.h | 334 | ||||
-rw-r--r-- | include/registry/version.h | 69 | ||||
-rw-r--r-- | include/registry/writer.h | 262 | ||||
-rw-r--r-- | include/registry/writer.hxx | 291 |
13 files changed, 5040 insertions, 0 deletions
diff --git a/include/registry/reader.h b/include/registry/reader.h new file mode 100644 index 000000000000..263215a92722 --- /dev/null +++ b/include/registry/reader.h @@ -0,0 +1,603 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_registry_reader_h +#define INCLUDED_registry_reader_h + +#include "registry/regdllapi.h" +#include "registry/types.h" +#include "registry/version.h" + +#include "rtl/ustring.h" +#include "sal/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + Creates a type reader working on a binary blob that represents a UNOIDL type. + + <p>If a non-null handle is returned through <code>result</code>, its + reference count will be one. Operations on a non-null handle are not + multi-thread–safe.</p> + + @param buffer the binary blob representing the type; must point to at least + <code>length</code> bytes, and need only be byte-aligned + + @param length the size in bytes of the binary blob representing the type + + @param copy if true, the type reader creates an internal copy of the given + buffer, and the given buffer is not accessed after this function returns; if + false, the type reader works directly on the given buffer, which must remain + available unmodified until the type reader is destroyed + + @param maxVersion the maximum binary blob version the client is prepared to + handle; must not be negative + + @param result an out-parameter obtaining a handle on the type reader; must + not be null; if the given binary blob is malformed, or of a version larger + than <code>maxVersion</code>, null is returned + + @return false iff an out-of-memory condition occurred, in which case + <code>result</code> is left unchanged, and no type reader is created + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_reader_create( + void const * buffer, sal_uInt32 length, sal_Bool copy, + enum typereg_Version maxVersion, void ** result) + SAL_THROW_EXTERN_C(); + +/** + Increments the reference count of a type reader. + + @param handle a handle on a type reader; may be null + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_acquire(void * handle) SAL_THROW_EXTERN_C(); + +/** + Decrements the reference count of a type reader. + + <p>If the reference count drops to zero, the type reader is destroyed.</p> + + @param handle a handle on a type reader; may be null + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_release(void * handle) SAL_THROW_EXTERN_C(); + +/** + Returns the binary blob version of a type reader. + + @param handle a handle on a type reader; may be null + + @return the version of the binary blob from which the type reader was + constructed; if <code>handle</code> is null, <code>TYPEREG_VERSION_0</code> + is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC enum typereg_Version SAL_CALL typereg_reader_getVersion(void * handle) + SAL_THROW_EXTERN_C(); + +/** + Returns the documentation of a type reader. + + @param handle a handle on a type reader; may be null + + @param result an out-parameter obtaining the documentation string; must not + be null; if <code>handle</code> is null, an empty string is returned; if an + out-of-memory condition occurs, a pointer to a null pointer is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getDocumentation( + void * handle, rtl_uString ** result) SAL_THROW_EXTERN_C(); + +/** + Returns the file name of a type reader. + + @param handle a handle on a type reader; may be null + + @param result an out-parameter obtaining the file name string; must not be + null; if <code>handle</code> is null, an empty string is returned; if an + out-of-memory condition occurs, a pointer to a null pointer is returned + + @since UDK 3.2.0 + @deprecated + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getFileName(void * handle, rtl_uString ** result) + SAL_THROW_EXTERN_C(); + +/** + Returns the type class of a type reader. + + <p>This function will always return the type class without the internal + <code>RT_TYPE_PUBLISHED</code> flag set. Use + <code>typereg_reader_isPublished</code> to determine whether a type reader is + published.</p> + + @param handle a handle on a type reader; may be null + + @return the type class of the type reader; if <code>handle</code> is null, + <code>RT_TYPE_INVALID</code> is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC enum RTTypeClass SAL_CALL typereg_reader_getTypeClass(void * handle) + SAL_THROW_EXTERN_C(); + +/** + Returns whether a type reader is published. + + @param handle a handle on a type reader; may be null + + @return whether the type reader is published; if <code>handle</code> is null, + <code>sal_False</code> is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_reader_isPublished(void * handle) + SAL_THROW_EXTERN_C(); + +/** + Returns the type name of a type reader. + + @param handle a handle on a type reader; may be null + + @param result an out-parameter obtaining the type name string; must not be + null; if <code>handle</code> is null, an empty string is returned; if an + out-of-memory condition occurs, a pointer to a null pointer is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getTypeName(void * handle, rtl_uString ** result) + SAL_THROW_EXTERN_C(); + +/** + Returns the number of super types of a type reader. + + @param handle a handle on a type reader; may be null + + @return the number of super types of the type reader; if <code>handle</code> + is null, zero is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_uInt16 SAL_CALL typereg_reader_getSuperTypeCount(void * handle) + SAL_THROW_EXTERN_C(); + +/** + Returns the type name of a super type of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the super type's type name string; + must not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param index a valid index into the range of super types of the given type + reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getSuperTypeName( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the number of fields of a type reader. + + @param handle a handle on a type reader; may be null + + @return the number of fields of the type reader; if <code>handle</code> is + null, zero is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_uInt16 SAL_CALL typereg_reader_getFieldCount(void * handle) + SAL_THROW_EXTERN_C(); + +/** + Returns the documentation of a field of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the field's documentation string; + must not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param index a valid index into the range of fields of the given type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getFieldDocumentation( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the file name of a field of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the field's file name string; must + not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param index a valid index into the range of fields of the given type reader + + @since UDK 3.2.0 + @deprecated + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getFieldFileName( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the flags of a field of a type reader. + + @param handle a handle on a type reader; must not be null + + @param index a valid index into the range of fields of the given type reader + + @return the flags of the given field of the type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC RTFieldAccess SAL_CALL typereg_reader_getFieldFlags( + void * handle, sal_uInt16 index) SAL_THROW_EXTERN_C(); + +/** + Returns the name of a field of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the field's name string; must not be + null; if an out-of-memory condition occurs, a pointer to a null pointer is + returned + + @param index a valid index into the range of fields of the given type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getFieldName( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the type name of a field of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the field's type name string; must + not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param index a valid index into the range of fields of the given type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getFieldTypeName( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the value of a field of a type reader. + + @param handle a handle on a type reader; must not be null + + @param index a valid index into the range of fields of the given type reader + + @param type an out-parameter obtaining the field value's type; must not be + null + + @param value an out-parameter obtaining the field value's value; must not be + null + + @return false iff an out-of-memory condition occurred, in which case + <code>type</code> and <code>value</code> are left unchanged + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_reader_getFieldValue( + void * handle, sal_uInt16 index, enum RTValueType * type, + union RTConstValueUnion * value) + SAL_THROW_EXTERN_C(); + +/** + Returns the number of methods of a type reader. + + @param handle a handle on a type reader; may be null + + @return the number of methods of the type reader; if <code>handle</code> is + null, zero is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_uInt16 SAL_CALL typereg_reader_getMethodCount(void * handle) + SAL_THROW_EXTERN_C(); + +/** + Returns the documentation of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the methods's documentation string; + must not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param index a valid index into the range of methods of the given type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getMethodDocumentation( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the flags of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param index a valid index into the range of methods of the given type reader + + @return the flags of the given method of the type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC enum RTMethodMode SAL_CALL typereg_reader_getMethodFlags( + void * handle, sal_uInt16 index) SAL_THROW_EXTERN_C(); + +/** + Returns the name of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the methods's name string; must not + be null; if an out-of-memory condition occurs, a pointer to a null pointer is + returned + + @param index a valid index into the range of methods of the given type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getMethodName( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the return type name of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the methods's return type name + string; must not be null; if an out-of-memory condition occurs, a pointer to + a null pointer is returned + + @param index a valid index into the range of methods of the given type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getMethodReturnTypeName( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the number of parameters of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param index a valid index into the range of methods of the given type reader + + @return the number of parameters of the given method of the type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_uInt16 SAL_CALL typereg_reader_getMethodParameterCount( + void * handle, sal_uInt16 index) SAL_THROW_EXTERN_C(); + +/** + Returns the flags of a parameter of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param methodIndex a valid index into the range of methods of the given type + reader + + @param parameterIndex a valid index into the range of parameters of the given + method + + @return the flags of the given parameter of the given method of the type + reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC enum RTParamMode SAL_CALL typereg_reader_getMethodParameterFlags( + void * handle, sal_uInt16 methodIndex, sal_uInt16 parameterIndex) + SAL_THROW_EXTERN_C(); + +/** + Returns the name of a parameter of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the parameter's name string; must + not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param methodIndex a valid index into the range of methods of the given type + reader + + @param parameterIndex a valid index into the range of parameters of the given + method + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getMethodParameterName( + void * handle, rtl_uString ** result, sal_uInt16 methodIndex, + sal_uInt16 parameterIndex) + SAL_THROW_EXTERN_C(); + +/** + Returns the type name of a parameter of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the parameter's type name string; + must not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param methodIndex a valid index into the range of methods of the given type + reader + + @param parameterIndex a valid index into the range of parameters of the given + method + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getMethodParameterTypeName( + void * handle, rtl_uString ** result, sal_uInt16 methodIndex, + sal_uInt16 parameterIndex) + SAL_THROW_EXTERN_C(); + +/** + Returns the number of exceptions of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param index a valid index into the range of methods of the given type reader + + @return the number of exceptions of the given method of the type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_uInt16 SAL_CALL typereg_reader_getMethodExceptionCount( + void * handle, sal_uInt16 index) SAL_THROW_EXTERN_C(); + +/** + Returns the type name of an exception of a method of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the exception's type name string; + must not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param methodIndex a valid index into the range of methods of the given type + reader + + @param exceptionIndex a valid index into the range of exceptions of the given + method + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getMethodExceptionTypeName( + void * handle, rtl_uString ** result, sal_uInt16 methodIndex, + sal_uInt16 exceptionIndex) + SAL_THROW_EXTERN_C(); + +/** + Returns the number of references of a type reader. + + @param handle a handle on a type reader; may be null + + @return the number of references of the type reader; if <code>handle</code> + is null, zero is returned + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_uInt16 SAL_CALL typereg_reader_getReferenceCount(void * handle) + SAL_THROW_EXTERN_C(); + +/** + Returns the documentation of a reference of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the reference's documentation + string; must not be null; if an out-of-memory condition occurs, a pointer to + a null pointer is returned + + @param index a valid index into the range of references of the given type + reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getReferenceDocumentation( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +/** + Returns the flags of a reference of a type reader. + + @param handle a handle on a type reader; must not be null + + @param index a valid index into the range of references of the given type + reader + + @return the flags of the given reference of the type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC RTFieldAccess SAL_CALL typereg_reader_getReferenceFlags( + void * handle, sal_uInt16 index) SAL_THROW_EXTERN_C(); + +/** + Returns the sort of a reference of a type reader. + + @param handle a handle on a type reader; must not be null + + @param index a valid index into the range of references of the given type + reader + + @return the sort of the given reference of the type reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC enum RTReferenceType SAL_CALL typereg_reader_getReferenceSort( + void * handle, sal_uInt16 index) SAL_THROW_EXTERN_C(); + +/** + Returns the type name of a reference of a type reader. + + @param handle a handle on a type reader; must not be null + + @param result an out-parameter obtaining the reference's type name string; + must not be null; if an out-of-memory condition occurs, a pointer to a null + pointer is returned + + @param index a valid index into the range of references of the given type + reader + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_reader_getReferenceTypeName( + void * handle, rtl_uString ** result, sal_uInt16 index) + SAL_THROW_EXTERN_C(); + +#ifdef __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/reader.hxx b/include/registry/reader.hxx new file mode 100644 index 000000000000..a867f3b1185a --- /dev/null +++ b/include/registry/reader.hxx @@ -0,0 +1,624 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_registry_reader_hxx +#define INCLUDED_registry_reader_hxx + +#include "registry/reader.h" +#include "registry/refltype.hxx" +#include "registry/types.h" +#include "registry/version.h" + +#include "rtl/ustring.hxx" +#include "sal/types.h" + +#include <algorithm> +#include <new> + +namespace typereg { + +/** + A type reader working on a binary blob that represents a UNOIDL type. + + <p>Instances of this class are not multi-thread–safe.</p> + + @since UDK 3.2.0 + */ +class Reader { +public: + /** + Creates an invalid type reader. + */ + Reader(): m_handle(0) {} + + /** + Creates a type reader. + + <p>If the given binary blob is malformed, or of a version larger than + <code>maxVersion</code>, the created type reader is flagged as + invalid.</p> + + @param buffer the binary blob representing the type; must point to at + least <code>length</code> bytes, and need only be byte-aligned + + @param length the size in bytes of the binary blob representing the type + + @param copy if true, the type reader creates an internal copy of the + given buffer, and the given buffer is not accessed after this constructor + returns; if false, the type reader works directly on the given buffer, + which must remain available unmodified until the underlying type reader + is destroyed (note that the lifetime of the underlying type reader can be + different from the lifetime of this <code>Reader</code> instance) + + @param maxVersion the maximum binary blob version the client is prepared + to handle; must not be negative + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + Reader( + void const * buffer, sal_uInt32 length, bool copy, + typereg_Version maxVersion) + { + if (!typereg_reader_create(buffer, length, copy, maxVersion, &m_handle)) + { + throw std::bad_alloc(); + } + } + + /** + Shares a type reader between two <code>Reader</code> instances. + + @param other another <code>Reader</code> instance + */ + Reader(Reader const & other): m_handle(other.m_handle) { + typereg_reader_acquire(m_handle); + } + + /** + Destroys this <code>Reader</code> instance. + + <p>The underlying type reader is only destroyed if this instance was its + last user.</p> + */ + ~Reader() { + typereg_reader_release(m_handle); + } + + /** + Replaces the underlying type reader. + + @param other any <code>Reader</code> instance + + @return this <code>Reader</code> instance + */ + Reader & operator =(Reader const & other) { + Reader temp(other); + std::swap(this->m_handle, temp.m_handle); + return *this; + } + + /** + Returns whether this type reader is valid. + + @return true iff this type reader is valid + */ + bool isValid() const { + return m_handle != 0; + } + + /** + Returns the binary blob version of this type reader. + + @return the version of the binary blob from which this type reader was + constructed; if this type reader is invalid, + <code>TYPEREG_VERSION_0</code> is returned + */ + typereg_Version getVersion() const { + return typereg_reader_getVersion(m_handle); + } + + /** + Returns the documentation of this type reader. + + @return the documentation of this type reader; if this type reader is + invalid, an empty string is returned + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getDocumentation() const { + rtl_uString * s = 0; + typereg_reader_getDocumentation(m_handle, &s); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the file name of this type reader. + + @return the file name of this type reader; if this type reader is + invalid, an empty string is returned + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + @deprecated + */ + OUString getFileName() const { + rtl_uString * s = 0; + typereg_reader_getFileName(m_handle, &s); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the type class of this type reader. + + <p>This function will always return the type class without the internal + <code>RT_TYPE_PUBLISHED</code> flag set. Use <code>isPublished</code> to + determine whether this type reader is published.</p> + + @return the type class of this type reader; if this type reader is + invalid, <code>RT_TYPE_INVALID</code> is returned + */ + RTTypeClass getTypeClass() const { + return typereg_reader_getTypeClass(m_handle); + } + + /** + Returns whether this type reader is published. + + @return whether this type reader is published; if this type reader is + invalid, <code>false</code> is returned + */ + bool isPublished() const { + return typereg_reader_isPublished(m_handle); + } + + /** + Returns the type name of this type reader. + + @return the type name of this type reader; if this type reader is + invalid, an empty string is returned + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getTypeName() const { + rtl_uString * s = 0; + typereg_reader_getTypeName(m_handle, &s); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the number of super types of this type reader. + + @return the number of super types of this type reader; if this type + reader is invalid, zero is returned + */ + sal_uInt16 getSuperTypeCount() const { + return typereg_reader_getSuperTypeCount(m_handle); + } + + /** + Returns the type name of a super type of this type reader. + + @param index a valid index into the range of super types of this type + reader + + @return the type name of the given super type + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getSuperTypeName(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getSuperTypeName(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the number of fields of this type reader. + + @return the number of fields of this type reader; if this type reader is + invalid, zero is returned + */ + sal_uInt16 getFieldCount() const { + return typereg_reader_getFieldCount(m_handle); + } + + /** + Returns the documentation of a field of this type reader. + + @param index a valid index into the range of fields of this type reader + + @return the documentation of the given field + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getFieldDocumentation(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getFieldDocumentation(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the file name of a field of this type reader. + + @param index a valid index into the range of fields of this type reader + + @return the file name of the given field + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + @deprecated + */ + OUString getFieldFileName(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getFieldFileName(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the flags of a field of this type reader. + + @param index a valid index into the range of fields of this type reader + + @return the flags of the given field + */ + RTFieldAccess getFieldFlags(sal_uInt16 index) const { + return typereg_reader_getFieldFlags(m_handle, index); + } + + /** + Returns the name of a field of this type reader. + + @param index a valid index into the range of fields of this type reader + + @return the name of the given field + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getFieldName(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getFieldName(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the type name of a field of this type reader. + + @param index a valid index into the range of fields of this type reader + + @return the type name of the given field + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getFieldTypeName(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getFieldTypeName(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the value of a field of this type reader. + + @param index a valid index into the range of fields of this type reader + + @return the value of the given field + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + RTConstValue getFieldValue(sal_uInt16 index) const { + RTConstValue v; + if (!typereg_reader_getFieldValue( + m_handle, index, &v.m_type, &v.m_value)) + { + throw std::bad_alloc(); + } + return v; + } + + /** + Returns the number of methods of this type reader. + + @return the number of methods of this type reader; if this type reader is + invalid, zero is returned + */ + sal_uInt16 getMethodCount() const { + return typereg_reader_getMethodCount(m_handle); + } + + /** + Returns the documentation of a method of this type reader. + + @param index a valid index into the range of methods of this type reader + + @return the documentation of the given method + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getMethodDocumentation(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getMethodDocumentation(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the flags of a method of this type reader. + + @param index a valid index into the range of methods of this type reader + + @return the flags of the given method + */ + RTMethodMode getMethodFlags(sal_uInt16 index) const { + return typereg_reader_getMethodFlags(m_handle, index); + } + + /** + Returns the name of a method of this type reader. + + @param index a valid index into the range of methods of this type reader + + @return the name of the given method + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getMethodName(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getMethodName(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the return type name of a method of this type reader. + + @param index a valid index into the range of methods of this type reader + + @return the return type name of the given method + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getMethodReturnTypeName(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getMethodReturnTypeName(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the number of parameters of a method of this type reader. + + @param index a valid index into the range of methods of this type reader + + @return the number of parameters of the given method + */ + sal_uInt16 getMethodParameterCount(sal_uInt16 index) const { + return typereg_reader_getMethodParameterCount(m_handle, index); + } + + /** + Returns the flags of a parameter of a method of this type reader. + + @param methodIndex a valid index into the range of methods of this type + reader + + @param parameterIndex a valid index into the range of parameters of the + given method + + @return the flags of the given method parameter + */ + RTParamMode getMethodParameterFlags( + sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const + { + return typereg_reader_getMethodParameterFlags( + m_handle, methodIndex, parameterIndex); + } + + /** + Returns the name of a parameter of a method of this type reader. + + @param methodIndex a valid index into the range of methods of this type + reader + + @param parameterIndex a valid index into the range of parameters of the + given method + + @return the name of the given method parameter + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getMethodParameterName( + sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const + { + rtl_uString * s = 0; + typereg_reader_getMethodParameterName( + m_handle, &s, methodIndex, parameterIndex); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the type name of a parameter of a method of this type reader. + + @param methodIndex a valid index into the range of methods of this type + reader + + @param parameterIndex a valid index into the range of parameters of the + given method + + @return the type name of the given method parameter + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getMethodParameterTypeName( + sal_uInt16 methodIndex, sal_uInt16 parameterIndex) const + { + rtl_uString * s = 0; + typereg_reader_getMethodParameterTypeName( + m_handle, &s, methodIndex, parameterIndex); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the number of exceptions of a method of this type reader. + + @param index a valid index into the range of methods of this type reader + + @return the number of exceptions of the given method + */ + sal_uInt16 getMethodExceptionCount(sal_uInt16 index) const { + return typereg_reader_getMethodExceptionCount(m_handle, index); + } + + /** + Returns the type name of an exception of a method of this type reader. + + @param methodIndex a valid index into the range of methods of this type + reader + + @param exceptionIndex a valid index into the range of exceptions of the + given method + + @return the type name of the given method exception + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getMethodExceptionTypeName( + sal_uInt16 methodIndex, sal_uInt16 exceptionIndex) const + { + rtl_uString * s = 0; + typereg_reader_getMethodExceptionTypeName( + m_handle, &s, methodIndex, exceptionIndex); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the number of references of this type reader. + + @return the number of references of this type reader; if this type reader + is invalid, zero is returned + */ + sal_uInt16 getReferenceCount() const { + return typereg_reader_getReferenceCount(m_handle); + } + + /** + Returns the documentation of a reference of this type reader. + + @param index a valid index into the range of references of this type + reader + + @return the documentation of the given reference + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getReferenceDocumentation(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getReferenceDocumentation(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + + /** + Returns the flags of a reference of this type reader. + + @param index a valid index into the range of references of this type + reader + + @return the flags of the given reference + */ + RTFieldAccess getReferenceFlags(sal_uInt16 index) const { + return typereg_reader_getReferenceFlags(m_handle, index); + } + + /** + Returns the sort of a reference of this type reader. + + @param index a valid index into the range of references of this type + reader + + @return the sort of the given reference + */ + RTReferenceType getReferenceSort(sal_uInt16 index) const { + return typereg_reader_getReferenceSort(m_handle, index); + } + + /** + Returns the type name of a reference of this type reader. + + @param index a valid index into the range of references of this type + reader + + @return the type name of the given reference + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + OUString getReferenceTypeName(sal_uInt16 index) const { + rtl_uString * s = 0; + typereg_reader_getReferenceTypeName(m_handle, &s, index); + if (s == 0) { + throw std::bad_alloc(); + } + return OUString(s, SAL_NO_ACQUIRE); + } + +private: + void * m_handle; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/reflread.hxx b/include/registry/reflread.hxx new file mode 100644 index 000000000000..541692443127 --- /dev/null +++ b/include/registry/reflread.hxx @@ -0,0 +1,513 @@ +/* -*- 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 . + */ + +#ifndef _REGISTRY_REFLREAD_HXX_ +#define _REGISTRY_REFLREAD_HXX_ + +#include <registry/regdllapi.h> +#include <registry/refltype.hxx> +#include <registry/regtype.h> +#include <rtl/ustring.hxx> + +/// Implememetation handle +typedef void* TypeReaderImpl; + +/**************************************************************************** + + C-Api + +*****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** specifies a collection of function pointers which represents the complete registry type reader C-API. + + This funtions pointers are used by the C++ wrapper to call the C-API. +*/ +struct RegistryTypeReader_Api +{ + TypeReaderImpl (TYPEREG_CALLTYPE *createEntry) (const sal_uInt8*, sal_uInt32, sal_Bool); + void (TYPEREG_CALLTYPE *acquire) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *release) (TypeReaderImpl); + sal_uInt16 (TYPEREG_CALLTYPE *getMinorVersion) (TypeReaderImpl); + sal_uInt16 (TYPEREG_CALLTYPE *getMajorVersion) (TypeReaderImpl); + RTTypeClass (TYPEREG_CALLTYPE *getTypeClass) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getUik) (TypeReaderImpl, RTUik*); + void (TYPEREG_CALLTYPE *getDoku) (TypeReaderImpl, rtl_uString**); + void (TYPEREG_CALLTYPE *getFileName) (TypeReaderImpl, rtl_uString**); + void (TYPEREG_CALLTYPE *getTypeName) (TypeReaderImpl, rtl_uString**); + void (TYPEREG_CALLTYPE *getSuperTypeName) (TypeReaderImpl, rtl_uString**); + sal_uInt32 (TYPEREG_CALLTYPE *getFieldCount) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getFieldName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + void (TYPEREG_CALLTYPE *getFieldType) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTFieldAccess (TYPEREG_CALLTYPE *getFieldAccess) (TypeReaderImpl, sal_uInt16); + RTValueType (TYPEREG_CALLTYPE *getFieldConstValue) (TypeReaderImpl, sal_uInt16, RTConstValueUnion*); + void (TYPEREG_CALLTYPE *getFieldDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16); + void (TYPEREG_CALLTYPE *getFieldFileName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + sal_uInt32 (TYPEREG_CALLTYPE *getMethodCount) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getMethodName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + sal_uInt32 (TYPEREG_CALLTYPE *getMethodParamCount) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodParamType) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodParamName) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16); + RTParamMode (TYPEREG_CALLTYPE *getMethodParamMode) (TypeReaderImpl, sal_uInt16, sal_uInt16); + sal_uInt32 (TYPEREG_CALLTYPE *getMethodExcCount) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodExcType) (TypeReaderImpl, rtl_uString**, sal_uInt16, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodReturnType) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTMethodMode (TYPEREG_CALLTYPE *getMethodMode) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getMethodDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16); + + sal_uInt32 (TYPEREG_CALLTYPE *getReferenceCount) (TypeReaderImpl); + void (TYPEREG_CALLTYPE *getReferenceName) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTReferenceType (TYPEREG_CALLTYPE *getReferenceType) (TypeReaderImpl, sal_uInt16); + void (TYPEREG_CALLTYPE *getReferenceDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16); + RTFieldAccess (TYPEREG_CALLTYPE *getReferenceAccess) (TypeReaderImpl, sal_uInt16); +}; + +/** the API initialization function. +*/ +REG_DLLPUBLIC RegistryTypeReader_Api* TYPEREG_CALLTYPE initRegistryTypeReader_Api(void); + +#ifdef __cplusplus +} +#endif + +/** RegistryTypeReades reads a binary type blob. + + This class provides the necessary functions to read type information + for all kinds of types of a type blob. + The class is inline and use a C-Api. + + @deprecated + use typereg::Reader instead +*/ +class RegistryTypeReader +{ +public: + + /** Constructor. + + @param buffer points to the binary data block. + @param bufferLen specifies the size of the binary data block. + @param copyData specifies if the data block should be copied. + The block can be copied to ensure that the data + is valid for the lifetime of this instance. + */ + inline RegistryTypeReader(const sal_uInt8* buffer, + sal_uInt32 bufferLen, + sal_Bool copyData); + + /// Copy constructcor + inline RegistryTypeReader(const RegistryTypeReader& toCopy); + + /// Destructor. The Destructor frees the data block if the copyData flag was TRUE. + inline ~RegistryTypeReader(); + + /// Assign operator + inline RegistryTypeReader& operator == (const RegistryTypeReader& toAssign); + + /// checks if the registry type reader points to a valid Api. + inline sal_Bool isValid() const; + + /** @deprecated + returns the minor version number. + + We currently don't support a versioning concept of IDL interfaces and + so this function is currently not used. + */ + inline sal_uInt16 getMinorVersion() const; + + /** @deprecated + returns the major version number. + + We currently don't support a versioning concept of IDL interfaces and + so this function is currently not used. + */ + inline sal_uInt16 getMajorVersion() const; + + /** returns the typeclass of the type represented by this blob. + + This function will always return the type class without the internal + RT_TYPE_PUBLISHED flag set. + */ + inline RTTypeClass getTypeClass() const; + + /** returns the full qualified name of the type. + */ + inline OUString getTypeName() const; + + /** returns the full qualified name of the supertype. + */ + inline OUString getSuperTypeName() const; + + /** @deprecated + returns the unique identifier for an interface type as an out parameter. + + An earlier version of UNO used an unique identifier for interfaces. In the + current version of UNO this uik was eliminated and this function is + not longer used. + */ + inline void getUik(RTUik& uik) const; + + /** returns the documentation string of this type. + */ + inline OUString getDoku() const; + + /** returns the IDL filename where the type is defined. + */ + inline OUString getFileName() const; + + /** returns the number of fields (attributes/properties, enum values or number + of constants in a module). + + */ + inline sal_uInt32 getFieldCount() const; + + /** returns the name of the field specified by index. + */ + inline OUString getFieldName( sal_uInt16 index ) const; + + /** returns the full qualified name of the field specified by index. + */ + inline OUString getFieldType( sal_uInt16 index ) const; + + /** returns the access mode of the field specified by index. + */ + inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const; + + /** returns the value of the field specified by index. + + This function returns the value of an enum value or of a constant. + */ + inline RTConstValue getFieldConstValue( sal_uInt16 index ) const; + + /** returns the documentation string for the field specified by index. + + Each field of a type can have their own documentation. + */ + inline OUString getFieldDoku( sal_uInt16 index ) const; + + /** returns the IDL filename of the field specified by index. + + The IDL filename of a field can differ from the filename of the ype itself + because modules and also constants can be defined in different IDL files. + */ + inline OUString getFieldFileName( sal_uInt16 index ) const; + + /** returns the number of methods of an interface type. + */ + inline sal_uInt32 getMethodCount() const; + + /** returns the name of the method specified by index. + */ + inline OUString getMethodName( sal_uInt16 index ) const; + + /** returns number of parameters of the method specified by index. + */ + inline sal_uInt32 getMethodParamCount( sal_uInt16 index ) const; + + /** returns the full qualified parameter typename. + + @param index indicates the method + @param paramIndex indeciates the parameter which type will be returned. + */ + inline OUString getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const; + + /** returns the name of a parameter. + + @param index indicates the method + @param paramIndex indiciates the parameter which name will be returned. + */ + inline OUString getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const; + + /** returns the parameter mode, if it is an in, out or inout parameter. + + @param index indicates the method + @param paramIndex indeciates the parameter which mode will be returned. + */ + inline RTParamMode getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const; + + /** returns the number of exceptions which are declared for the method specified by index. + + @param index indicates the method + */ + inline sal_uInt32 getMethodExcCount( sal_uInt16 index ) const; + + /** returns the full qualified exception type of the specified exception. + + @param index indicates the method + @param excIndex indeciates the exception which typename will be returned. + */ + inline OUString getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const; + + /** returns the full qualified return type of the method specified by index. + */ + inline OUString getMethodReturnType( sal_uInt16 index ) const; + + /** returns the full qualified exception type of the specified exception. + + @param index indicates the method + */ + inline RTMethodMode getMethodMode( sal_uInt16 index ) const; + + /** returns the documentation string of the method specified by index. + + @param index indicates the method. + */ + inline OUString getMethodDoku( sal_uInt16 index ) const; + + /** returns the number of references (supported interfaces, exported services). + */ + inline sal_uInt32 getReferenceCount() const; + + /** returns the full qualified typename of the reference specified by index. + + @param index indicates the reference. + */ + inline OUString getReferenceName( sal_uInt16 index ) const; + + /** returns the type of the reference specified by index. + + @param index indicates the reference. + */ + inline RTReferenceType getReferenceType( sal_uInt16 index ) const; + + /** returns the documentation string of the reference specified by index. + + @param index indicates the reference. + */ + inline OUString getReferenceDoku( sal_uInt16 index ) const; + + /** returns the access mode of the reference specified by index. + + The only valid value is RT_ACCESS_OPTIONAL in the context of + references. + @param index indicates the reference. + */ + inline RTFieldAccess getReferenceAccess( sal_uInt16 index ) const; + +protected: + + /// stores the registry type reader Api. + const RegistryTypeReader_Api* m_pApi; + /// stores the handle of an implementation class + TypeReaderImpl m_hImpl; +}; + + + +inline RegistryTypeReader::RegistryTypeReader(const sal_uInt8* buffer, + sal_uInt32 bufferLen, + sal_Bool copyData) + : m_pApi(initRegistryTypeReader_Api()) + , m_hImpl(NULL) + { + m_hImpl = m_pApi->createEntry(buffer, bufferLen, copyData); + } + + +inline RegistryTypeReader::RegistryTypeReader(const RegistryTypeReader& toCopy) + : m_pApi(toCopy.m_pApi) + , m_hImpl(toCopy.m_hImpl) + { m_pApi->acquire(m_hImpl); } + + +inline RegistryTypeReader::~RegistryTypeReader() + { m_pApi->release(m_hImpl); } + +inline RegistryTypeReader& RegistryTypeReader::operator == (const RegistryTypeReader& toAssign) +{ + if (m_hImpl != toAssign.m_hImpl) + { + m_pApi->release(m_hImpl); + m_hImpl = toAssign.m_hImpl; + m_pApi->acquire(m_hImpl); + } + + return *this; +} + +inline sal_uInt16 RegistryTypeReader::getMinorVersion() const + { return m_pApi->getMinorVersion(m_hImpl); } + +inline sal_Bool RegistryTypeReader::isValid() const + { return (m_hImpl != NULL); } + +inline sal_uInt16 RegistryTypeReader::getMajorVersion() const + { return m_pApi->getMajorVersion(m_hImpl); } + +inline RTTypeClass RegistryTypeReader::getTypeClass() const + { return m_pApi->getTypeClass(m_hImpl); } + +inline OUString RegistryTypeReader::getTypeName() const + { + OUString sRet; + m_pApi->getTypeName(m_hImpl, &sRet.pData); + return sRet; + } + +inline OUString RegistryTypeReader::getSuperTypeName() const + { + OUString sRet; + m_pApi->getSuperTypeName(m_hImpl, &sRet.pData); + return sRet; + } + +inline void RegistryTypeReader::getUik(RTUik& uik) const + { m_pApi->getUik(m_hImpl, &uik); } + +inline OUString RegistryTypeReader::getDoku() const + { + OUString sRet; + m_pApi->getDoku(m_hImpl, &sRet.pData); + return sRet; + } + +inline OUString RegistryTypeReader::getFileName() const + { + OUString sRet; + m_pApi->getFileName(m_hImpl, &sRet.pData); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getFieldCount() const + { return m_pApi->getFieldCount(m_hImpl); } + +inline OUString RegistryTypeReader::getFieldName( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getFieldName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline OUString RegistryTypeReader::getFieldType( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getFieldType(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTFieldAccess RegistryTypeReader::getFieldAccess( sal_uInt16 index ) const + { return m_pApi->getFieldAccess(m_hImpl, index); } + +inline RTConstValue RegistryTypeReader::getFieldConstValue( sal_uInt16 index ) const + { + RTConstValue ret; + ret.m_type = m_pApi->getFieldConstValue(m_hImpl, index, &ret.m_value); + return ret; + } + +inline OUString RegistryTypeReader::getFieldDoku( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getFieldDoku(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline OUString RegistryTypeReader::getFieldFileName( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getFieldFileName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getMethodCount() const + { return m_pApi->getMethodCount(m_hImpl); } + +inline OUString RegistryTypeReader::getMethodName( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getMethodName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getMethodParamCount( sal_uInt16 index ) const + { return m_pApi->getMethodParamCount(m_hImpl, index); } + +inline OUString RegistryTypeReader::getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const + { + OUString sRet; + m_pApi->getMethodParamType(m_hImpl, &sRet.pData, index, paramIndex); + return sRet; + } + +inline OUString RegistryTypeReader::getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const + { + OUString sRet; + m_pApi->getMethodParamName(m_hImpl, &sRet.pData, index, paramIndex); + return sRet; + } + +inline RTParamMode RegistryTypeReader::getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const + { return m_pApi->getMethodParamMode(m_hImpl, index, paramIndex); } + +inline sal_uInt32 RegistryTypeReader::getMethodExcCount( sal_uInt16 index ) const + { return m_pApi->getMethodExcCount(m_hImpl, index); } + +inline OUString RegistryTypeReader::getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const + { + OUString sRet; + m_pApi->getMethodExcType(m_hImpl, &sRet.pData, index, excIndex); + return sRet; + } + +inline OUString RegistryTypeReader::getMethodReturnType( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getMethodReturnType(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTMethodMode RegistryTypeReader::getMethodMode( sal_uInt16 index ) const + { return m_pApi->getMethodMode(m_hImpl, index); } + +inline OUString RegistryTypeReader::getMethodDoku( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getMethodDoku(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline sal_uInt32 RegistryTypeReader::getReferenceCount() const + { return m_pApi->getReferenceCount(m_hImpl); } + +inline OUString RegistryTypeReader::getReferenceName( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getReferenceName(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTReferenceType RegistryTypeReader::getReferenceType( sal_uInt16 index ) const + { return m_pApi->getReferenceType(m_hImpl, index); } + +inline OUString RegistryTypeReader::getReferenceDoku( sal_uInt16 index ) const + { + OUString sRet; + m_pApi->getReferenceDoku(m_hImpl, &sRet.pData, index); + return sRet; + } + +inline RTFieldAccess RegistryTypeReader::getReferenceAccess( sal_uInt16 index ) const + { return m_pApi->getReferenceAccess(m_hImpl, index); } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/refltype.hxx b/include/registry/refltype.hxx new file mode 100644 index 000000000000..0de7716a9ed3 --- /dev/null +++ b/include/registry/refltype.hxx @@ -0,0 +1,80 @@ +/* -*- 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 . + */ + +#ifndef _REGISTRY_REFLTYPE_HXX_ +#define _REGISTRY_REFLTYPE_HXX_ + +#include "registry/types.h" +#include <sal/types.h> + +/** specifies the type source of a binary type blob. + + Currently only RT_UNO_IDL type is used. + */ +enum RTTypeSource +{ + RT_UNO_IDL, + RT_CORBA_IDL, + RT_JAVA +}; + +/** specifies a helper class for const values. + + This class is used for easy handling of constants or enum values + as fields in binary type blob. + */ +class RTConstValue +{ +public: + /// stores the type of the constant value. + RTValueType m_type; + /// stores the value of the constant. + RTConstValueUnion m_value; + + /// Default constructor. + RTConstValue() + : m_type(RT_TYPE_NONE) + { + m_value.aDouble = 0.0; + } + + /// Destructor + ~RTConstValue() {} +}; + +/** deprecated. + + An earlier version of UNO used an unique identifier for interfaces. In the + current version of UNO this uik was eliminated and this type is not longer used. + */ +struct RTUik +{ + sal_uInt32 m_Data1; + sal_uInt16 m_Data2; + sal_uInt16 m_Data3; + sal_uInt32 m_Data4; + sal_uInt32 m_Data5; +}; + +/// specifies the calling convention for type reader/writer api +#define TYPEREG_CALLTYPE SAL_CALL + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/reflwrit.hxx b/include/registry/reflwrit.hxx new file mode 100644 index 000000000000..8e84aa9b1483 --- /dev/null +++ b/include/registry/reflwrit.hxx @@ -0,0 +1,350 @@ +/* -*- 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 . + */ + +#ifndef _REGISTRY_REFLWRIT_HXX_ +#define _REGISTRY_REFLWRIT_HXX_ + +#include <registry/regdllapi.h> +#include <registry/refltype.hxx> +#include <registry/regtype.h> +#include <rtl/ustring.hxx> + +/// Implememetation handle +typedef void* TypeWriterImpl; + +/**************************************************************************** + + C-Api + +*****************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** specifies a collection of function pointers which represents the complete registry type writer C-API. + + This funtions pointers are used by the C++ wrapper to call the C-API. +*/ +struct RegistryTypeWriter_Api +{ + TypeWriterImpl (TYPEREG_CALLTYPE *createEntry) (RTTypeClass, rtl_uString*, rtl_uString*, sal_uInt16, sal_uInt16, sal_uInt16); + void (TYPEREG_CALLTYPE *acquire) (TypeWriterImpl); + void (TYPEREG_CALLTYPE *release) (TypeWriterImpl); + void (TYPEREG_CALLTYPE *setUik) (TypeWriterImpl, const RTUik*); + void (TYPEREG_CALLTYPE *setDoku) (TypeWriterImpl, rtl_uString*); + void (TYPEREG_CALLTYPE *setFileName) (TypeWriterImpl, rtl_uString*); + void (TYPEREG_CALLTYPE *setFieldData) (TypeWriterImpl, sal_uInt16, rtl_uString*, rtl_uString*, rtl_uString*, rtl_uString*, RTFieldAccess, RTValueType, RTConstValueUnion); + void (TYPEREG_CALLTYPE *setMethodData) (TypeWriterImpl, sal_uInt16, rtl_uString*, rtl_uString*, RTMethodMode, sal_uInt16, sal_uInt16, rtl_uString*); + void (TYPEREG_CALLTYPE *setParamData) (TypeWriterImpl, sal_uInt16, sal_uInt16, rtl_uString*, rtl_uString*, RTParamMode); + void (TYPEREG_CALLTYPE *setExcData) (TypeWriterImpl, sal_uInt16, sal_uInt16, rtl_uString*); + const sal_uInt8* (TYPEREG_CALLTYPE *getBlop) (TypeWriterImpl); + sal_uInt32 (TYPEREG_CALLTYPE *getBlopSize) (TypeWriterImpl); + + void (TYPEREG_CALLTYPE *setReferenceData) (TypeWriterImpl, sal_uInt16, rtl_uString*, RTReferenceType, rtl_uString*, RTFieldAccess); +}; + +/** the API initialization function. +*/ +REG_DLLPUBLIC RegistryTypeWriter_Api* TYPEREG_CALLTYPE initRegistryTypeWriter_Api(void); + +#ifdef __cplusplus +} +#endif + +/** RegistryTypeWriter writes/creates a binary type blob. + + This class provides the necessary functions to write type information + for all kinds of types into a blob. + The class is inline and use a C-Api. + + @deprecated + use typereg::Writer instead +*/ +class RegistryTypeWriter +{ +public: + + /** Constructor. + + @param RTTypeClass specifies the type of the new blob. + @param typeName specifies the full qualified type name with '/' as separator. + @param superTypeName specifies the full qualified type name of the base type + with '/' as separator. + @param fieldCount specifies the number of fields (eg. number of attrbutes/properties, + enum values or constants). + @param methodCount specifies the number of methods. + @param referenceCount specifies the number of references (eg. number of supported interfaces, + exported services ...) + */ + inline RegistryTypeWriter(RTTypeClass RTTypeClass, + const OUString& typeName, + const OUString& superTypeName, + sal_uInt16 fieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount); + + /// Copy constructcor + inline RegistryTypeWriter(const RegistryTypeWriter& toCopy); + + /** Destructor. The Destructor frees the internal data block. + + The pointer (returned by getBlop) will be set to NULL. + */ + inline ~RegistryTypeWriter(); + + /// Assign operator + inline RegistryTypeWriter& operator == (const RegistryTypeWriter& toAssign); + + /** @deprecated + sets the unique identifier for an interface type. + + An earlier version of UNO used an unique identifier for interfaces. In the + current version of UNO this uik was eliminated and this function is + not longer used. + */ + inline void setUik(const RTUik& uik); + + /** sets a documentation string for the type. + + This documentation should be the same as the documentation which is provided + for this type in IDL. + */ + inline void setDoku(const OUString& doku); + + /** sets the IDL filename where this type is defined. + */ + inline void setFileName(const OUString& fileName); + + /** sets the data for a field member of a type blob. + + @param index indicates the index of the field. + @param name specifies the name. + @param typeName specifies the full qualified typename. + @param doku specifies the documentation string of the field. + @param fileName specifies the name of the IDL file where the field is defined. + @param access specifies the access mode of the field. + @param constValue specifies the value of the field. The value is only interesting + for enum values or constants. + */ + inline void setFieldData( sal_uInt16 index, + const OUString& name, + const OUString& typeName, + const OUString& doku, + const OUString& fileName, + RTFieldAccess access, + RTConstValue constValue = RTConstValue()); + + /** sets the data for a method. + + @param index indicates the index of the method. + @param name specifies the name. + @param returnTypeName specifies the full qualified return typename. + @param mode specifies the method mode. + @param paramCount specifies the number of parameters. + @param excCount specifies the number of exceptions. + @param doku specifies the documentation string of the field. + */ + inline void setMethodData(sal_uInt16 index, + const OUString& name, + const OUString& returnTypeName, + RTMethodMode mode, + sal_uInt16 paramCount, + sal_uInt16 excCount, + const OUString& doku); + + /** sets the data for the specified parameter of a method. + + @param index indicates the index of the method. + @param paramIndex specifies the index of the parameter. + @param type specifies the full qualified typename. + @param name specifies the name. + @param mode specifies the parameter mode. + */ + inline void setParamData(sal_uInt16 index, + sal_uInt16 paramIndex, + const OUString& type, + const OUString& name, + RTParamMode mode); + + /** sets the data for the specified exception of a mehtod. + + @param index indicates the index of the method. + @param excIndex specifies the index of the exception. + @param type specifies the full qualified typename of the exception. + */ + inline void setExcData(sal_uInt16 index, + sal_uInt16 excIndex, + const OUString& type); + + /** returns a pointer to the new type blob. + + The pointer will be invalid (NULL) if the instance of + the RegistryTypeWriter will be destroyed. + */ + inline const sal_uInt8* getBlop(); + + /** returns the size of the new type blob in bytes. + */ + inline sal_uInt32 getBlopSize(); + + /** sets the data for a reference member. + + @param index indicates the index of the reference. + @param name specifies the name. + @param refType specifies the full qualified typename of the reference. + @param doku specifies the documentation string of the reference. + @param access specifies the access mode of the reference. + */ + inline void setReferenceData( sal_uInt16 index, + const OUString& name, + RTReferenceType refType, + const OUString& doku, + RTFieldAccess access = RT_ACCESS_INVALID); + +protected: + + /// stores the registry type writer Api. + const RegistryTypeWriter_Api* m_pApi; + /// stores the handle of an implementation class + TypeWriterImpl m_hImpl; +}; + + + +inline RegistryTypeWriter::RegistryTypeWriter(RTTypeClass RTTypeClass, + const OUString& typeName, + const OUString& superTypeName, + sal_uInt16 fieldCount, + sal_uInt16 methodCount, + sal_uInt16 referenceCount) + : m_pApi(initRegistryTypeWriter_Api()) + , m_hImpl(NULL) +{ + m_hImpl = m_pApi->createEntry(RTTypeClass, + typeName.pData, + superTypeName.pData, + fieldCount, + methodCount, + referenceCount); +} + + +inline RegistryTypeWriter::RegistryTypeWriter(const RegistryTypeWriter& toCopy) + : m_pApi(toCopy.m_pApi) + , m_hImpl(toCopy.m_hImpl) +{ + m_pApi->acquire(m_hImpl); +} + +inline RegistryTypeWriter::~RegistryTypeWriter() +{ + m_pApi->release(m_hImpl); +} + +inline RegistryTypeWriter& RegistryTypeWriter::operator == (const RegistryTypeWriter& toAssign) +{ + if (m_hImpl != toAssign.m_hImpl) + { + m_pApi->release(m_hImpl); + m_hImpl = toAssign.m_hImpl; + m_pApi->acquire(m_hImpl); + } + + return *this; +} + +inline void RegistryTypeWriter::setFieldData( sal_uInt16 index, + const OUString& name, + const OUString& typeName, + const OUString& doku, + const OUString& fileName, + RTFieldAccess access, + RTConstValue constValue) +{ + m_pApi->setFieldData(m_hImpl, index, name.pData, typeName.pData, doku.pData, fileName.pData, access, constValue.m_type, constValue.m_value); +} + + +inline void RegistryTypeWriter::setMethodData(sal_uInt16 index, + const OUString& name, + const OUString& returnTypeName, + RTMethodMode mode, + sal_uInt16 paramCount, + sal_uInt16 excCount, + const OUString& doku) +{ + m_pApi->setMethodData(m_hImpl, index, name.pData, returnTypeName.pData, mode, paramCount, excCount, doku.pData); +} + + +inline void RegistryTypeWriter::setUik(const RTUik& uik) +{ + m_pApi->setUik(m_hImpl, &uik); +} + +inline void RegistryTypeWriter::setDoku(const OUString& doku) +{ + m_pApi->setDoku(m_hImpl, doku.pData); +} + +inline void RegistryTypeWriter::setFileName(const OUString& doku) +{ + m_pApi->setFileName(m_hImpl, doku.pData); +} + +inline void RegistryTypeWriter::setParamData(sal_uInt16 index, + sal_uInt16 paramIndex, + const OUString& type, + const OUString& name, + RTParamMode mode) +{ + m_pApi->setParamData(m_hImpl, index, paramIndex, type.pData, name.pData, mode); +} + +inline void RegistryTypeWriter::setExcData(sal_uInt16 index, + sal_uInt16 excIndex, + const OUString& type) +{ + m_pApi->setExcData(m_hImpl, index, excIndex, type.pData); +} + +inline const sal_uInt8* RegistryTypeWriter::getBlop() +{ + return m_pApi->getBlop(m_hImpl); +} + +inline sal_uInt32 RegistryTypeWriter::getBlopSize() +{ + return m_pApi->getBlopSize(m_hImpl); +} + + +inline void RegistryTypeWriter::setReferenceData( sal_uInt16 index, + const OUString& name, + RTReferenceType refType, + const OUString& doku, + RTFieldAccess access) +{ + m_pApi->setReferenceData(m_hImpl, index, name.pData, refType, doku.pData, access); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/regdllapi.h b/include/registry/regdllapi.h new file mode 100644 index 000000000000..5116a7062d24 --- /dev/null +++ b/include/registry/regdllapi.h @@ -0,0 +1,33 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_REGDLLAPI_H +#define INCLUDED_REGDLLAPI_H + +#include "sal/types.h" + +#if defined(REG_DLLIMPLEMENTATION) +#define REG_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define REG_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +#endif /* INCLUDED_REGDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/registry.h b/include/registry/registry.h new file mode 100644 index 000000000000..030e1a12a5de --- /dev/null +++ b/include/registry/registry.h @@ -0,0 +1,456 @@ +/* -*- 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 . + */ + +#ifndef _REGISTRY_REGISTRY_H_ +#define _REGISTRY_REGISTRY_H_ + +#include <stddef.h> +#include <rtl/ustring.h> +#include <registry/regtype.h> +#include <registry/regdllapi.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** This function creates the specified key. + + If the key already exists in the registry, the function opens the key only. + @param hKey identifies a currently open key. The key which will be opened or created by this + function is a subkey of the key identified by hKey. + @param keyName points to a null terminated string specifying the name of a key. + @param phNewKey points to a variable that receives the handle of the opened or created key. + The memory to store this variable will be allocated and will be freed by the function + reg_closeKey. If the function fails, phNewKey is NULL. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_createKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phNewKey); + + +/** This function opens the specified key. + + @param hKey identifies a currently open key. The key which will be opened by this function + is a subkey of the key identified by hKey + @param keyName points to a null terminated string specifying the name of a key. + @param phOpenKey points to a variable that receives the handle of the opened key. + The memory to store this variable will be allocated and will be freed by the function + reg_closeKey. If the function fails, phNewKey is NULL. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openKey(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle* phOpenKey); + + + +/** This function opens all subkeys of the specified key. + + @param hKey identifies a currently open key. The key that subkeys will be opened by this + function is a subkey of the key identified by hKey + @param keyName points to a null terminated string specifying the name of a key whose subkeys + will be opened. + @param pphSubKeys points to a variable that receives an array of all opened subkeys. + The memory to store this variable will be allocated and will be freed by the function + reg_closeSubKeys. If the function fails, pphSubKeys is NULL. + @param pnSubKeys specifies the length of the array (the number of open subkeys). + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openSubKeys(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyHandle** pphSubKeys, + sal_uInt32* pnSubKeys); + + +/** This function closes all subkeys specified in the array. + + @param phSubKeys points to a variable that containss an array of all opened subkeys. + The allocated memory of pphSubKeys and all open subkeys will be freed. + @param nSubKeys specifies the length of the array (the number of subkeys to closed). + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_closeSubKeys(RegKeyHandle* phSubKeys, + sal_uInt32 nSubKeys); + + +/** This function deletes the specified key. + + @param hKey identifies a currently open key. The key deleted by this function + is a subkey of the key identified by hKey + @param keyName points to a null terminated string specifying the name of a key which will + be deleted. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_deleteKey(RegKeyHandle hKey, + rtl_uString* keyName); + + +/** This function closes the specified key. + + @param hKey identifies a currently open key which will be closed by this function. + The memory of the variable specifying the key will be freed. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_closeKey(RegKeyHandle hKey); + + +/** This function returns the name of a key. + + @param hKey identifies a currently open key which name will be returned. + @param pKeyName contains the keyname if succeeds else an empty string. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getKeyName(RegKeyHandle hKey, rtl_uString** pKeyName); + + +/** This function sets a value of a key. + + @param hKey identifies a currently open key. The key which value will be set by this + function is a subkey of the key identified by hKey. + @param keyName points to a null terminated string specifying the name of a key which value + will be set. If keyName is NULL, then the value of the key specified by + hKey will be set. + @param valueType specifies the type of the value. + @param pData points to a memory block containing the data of the value. + @param valueSize specifies the size of pData in bytes + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_setValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType valueType, + RegValue pData, + sal_uInt32 valueSize); + + +/** This function sets an long list value of a key. + + @param[in] hKey identifies a currently open key. The key which value will be set by this + function is a subkey of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the name of a key which value + will be set. If keyName is NULL, then the value of the key specified by + hKey will be set. + @param[out] pValueList points to an array of longs containing the data of the value. + @param[out] len specifies the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_setLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32* pValueList, + sal_uInt32 len); + + +/** This function sets an ascii list value of a key. + + @param[in] hKey identifies a currently open key. The key which value will be set by this + function is a subkey of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the name of a key which value + will be set. If keyName is NULL, then the value of the key specified by + hKey will be set. + @param[in] pValueList points to an array of sal_Char* containing the data of the value. + @param[in] len specifies the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_setStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char** pValueList, + sal_uInt32 len); + + +/** This function sets an unicode string list value of a key. + + @param[in] hKey identifies a currently open key. The key which value will be set by this + function is a subkey of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the name of a key which value + will be set. If keyName is NULL, then the value of the key specified by + hKey will be set. + @param[in] pValueList points to an array of sal_Unicode* containing the data of the value. + @param[in] len specifies the len of pValueList. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_setUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode** pValueList, + sal_uInt32 len); + + +/** This function gets info about type and size of a key value. + + @param hKey identifies a currently open key. The key which value info will be got by this + function is a subkey of the key identified by hKey. + @param keyName points to a null terminated string specifying the name of a key which value + will be got. If keyName is NULL, then the value info of the key specified by + hKey will be got. + @param pValueType returns the type of the value. + @param pValueSize returns the size of the value in bytes + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getValueInfo(RegKeyHandle hKey, + rtl_uString* keyName, + RegValueType* pValueType, + sal_uInt32* pValueSize); + + +/** This function gets the value of a key. + + @param hKey identifies a currently open key. The key which value will be got by this + function is a subkey of the key identified by hKey. + @param keyName points to a null terminated string specifying the name of a key which value + will be got. If keyName is NULL, then the value of the key specified by + hKey will be got. + @param pData points to an allocated memory block receiving the data of the value. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getValue(RegKeyHandle hKey, + rtl_uString* keyName, + RegValue pData); + + +/** This function gets the long list value of a key. + + @param[in] hKey identifies a currently open key. The key which value will be got by this + function is a subkey of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the name of a key which value + will be got. If keyName is NULL, then the value of the key specified by + hKey will be got. + @param[out] pValueList a Pointer to a long value list which returns the data of the value. + @param[out] pLen returns the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getLongListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Int32** pValueList, + sal_uInt32* pLen); + + +/** This function gets the string list value of a key. + + @param[in] hKey identifies a currently open key. The key whose value will be retrived by this + function is a subkey of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the name of a key whose value + will be retrived. If keyName is NULL, then the value of the key specified by + hKey will be retrived. + @param[out] pValueList a Pointer to an ascii value list which returns the data of the value. + @param[out] pLen returns the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getStringListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Char*** pValueList, + sal_uInt32* pLen); + + +/** This function gets the unicode list value of a key. + + @param[in] hKey identifies a currently open key. The key whose value will be retrived by this + function is a subkey of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the name of a key whose value + will be retrived. If keyName is NULL, then the value of the key specified by + hKey will be retrived. + @param[out] pValueList a Pointer to an unicode value list which returns the data of the value. + @param[out] pLen returns the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getUnicodeListValue(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Unicode*** pValueList, + sal_uInt32* pLen); + + +/** This function frees the memory of a value list. + + @param valueType specifies the type of the list values. + @param pValueList a Pointer to the value list. + @param len specifies the length of the value list. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_freeValueList(RegValueType valueType, + RegValue pValueList, + sal_uInt32 len); + +/** This function returns the type of a key. + + The registry differentiates two possible types: + - RG_KEYTYPE represents a real key + - RG_LINKTYPE used to represent a link (no longer used) + @param[in] hKey identifies a currently open key. The key specified by keyName is a subkey + of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the name of the key which keytype + will be returned. + @param[out] pKeyType returns the type of the key. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getKeyType(RegKeyHandle hKey, + rtl_uString* keyName, + RegKeyType* pKeyType); + +/** This function resolves a keyname. + + @param[in] hKey identifies a currently open key. The key specified by keyName is a subkey + of the key identified by hKey. + @param[in] keyName points to a null terminated string specifying the relativ name of a key. + The name of hKey together with keyName will be generated. + @param[in] firstLinkOnly ignored + @param[out] pResolvedName returns the resolved keyName. + @return REG_NO_ERROR if succeeds else an error code. + */ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getResolvedKeyName(RegKeyHandle hKey, + rtl_uString* keyName, + sal_Bool firstLinkOnly, + rtl_uString** pResolvedName); + +/** This function loads registry information from a file and save it under the + specified keyName. + + @param hKey identifies a currently open key. The key which should store the registry information + is a subkey of this key. + @param keyName points to a null terminated string specifying the name of the key which stores the + registry information. If keyName is NULL the registry information will be saved under + the key specified by hKey. + @param regFileName points to a null terminated string specifying the file which conains the + registry information. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_loadKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName); + + +/** This function saves the registry information under a specified key and all of its subkeys and save + it in a registry file. + + @param hKey identifies a currently open key. The key which information is saved by this + function is a subkey of the key identified by hKey. + @param keyName points to a null terminated string specifying the name of the subkey. + If keyName is NULL the registry information under the key specified by hKey + will be saved in the specified file. + @param regFileName points to a null terminated string specifying the file which will contain the + registry information. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_saveKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName); + + +/** This function merges the registry information from a specified source with the information of the + currently open registry. + + All existing keys will be extended and existing key values will be overwritten. + @param hKey identifies a currently open key. The key which information is merged by this + function is a subkey of the key identified by hKey. + @param keyName points to a null terminated string specifying the name of the key which will be merged. + If keyName is NULL the registry information under the key specified by hKey + is merged with the complete information from the specified file. + @param regFileName points to a null terminated string specifying the file containing the + registry information. + @param bWarnings if TRUE the function returns an error if a key already exists. + @param bReport if TRUE the function reports warnings on stdout if a key already exists. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_mergeKey(RegKeyHandle hKey, + rtl_uString* keyName, + rtl_uString* regFileName, + sal_Bool bWarnings, + sal_Bool bReport); + + +/** This function creates a new registry with the specified name and creates a root key. + + @param registryName points to a null terminated string specifying the name of the new registry. + @param phRegistry points to a handle of the new registry if the function succeeds otherwise NULL. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_createRegistry(rtl_uString* registryName, + RegHandle* phRegistry); + + +/** This function opens the root key of a registry. + + @param hRegistry identifies a currently open registry whose rootKey will be returned. + @param phRootKey points to a handle of the open root key if the function succeeds otherwise NULL. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openRootKey(RegHandle hRegistry, + RegKeyHandle* phRootKey); + + +/** This function returns the name of a registry. + + @param hRegistry identifies a currently open registry whose name will be returned. + @param pName returns the name of the registry if the function succeeds otherwise an empty string. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_getName(RegHandle hRegistry, rtl_uString** pName); + + +/** This function returns the access mode of the registry. + + @param hReg identifies a currently open registry. + @return TRUE if accessmode is read only else FALSE. +*/ +REG_DLLPUBLIC sal_Bool REGISTRY_CALLTYPE reg_isReadOnly(RegHandle hReg); + + +/** This function opens a registry with the specified name. + + @param registryName points to a null terminated string specifying the name of the registry. + @param phRegistry points to a hanle of the opened registry if the function succeeds otherwise NULL. + @param accessMode specifies the accessmode of the registry, REG_READONLY or REG_READWRITE. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_openRegistry(rtl_uString* registryName, + RegHandle* phRegistry, + RegAccessMode accessMode); + + +/** This function closes a registry. + + @param hRegistry identifies a currently open registry which should be closed. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_closeRegistry(RegHandle hRegistry); + + +/** This function destroys a registry. + + @param hRegistry identifies a currently open registry. + @param registryName specifies a registry name of a registry which should be destroyed. If the + name is NULL the registry itselfs will be destroyed. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_destroyRegistry(RegHandle hRegistry, + rtl_uString* registryName); + + +/** This function reports the complete registry information of a key and all of its subkeys. + + All information which are available (keynames, value types, values, ...) + will be printed to stdout for report issues only. + @param hKey identifies a currently open key which content will be reported. + @return REG_NO_ERROR if succeeds else an error code. +*/ +REG_DLLPUBLIC RegError REGISTRY_CALLTYPE reg_dumpRegistry(RegKeyHandle hKey); + +#ifdef __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/registry.hxx b/include/registry/registry.hxx new file mode 100644 index 000000000000..d165c594adff --- /dev/null +++ b/include/registry/registry.hxx @@ -0,0 +1,1257 @@ +/* -*- 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 . + */ + +#ifndef _REGISTRY_REGISTRY_HXX_ +#define _REGISTRY_REGISTRY_HXX_ + +#include <registry/regdllapi.h> +#include <registry/regtype.h> +#include <rtl/ustring.hxx> + +#ifdef __cplusplus +extern "C" { +#endif + +/** specifies a collection of function pointers which represents the complete registry C-API. + + This funtions pointers are used by the C++ wrapper to call the C-API. +*/ +struct Registry_Api +{ + void (REGISTRY_CALLTYPE *acquire) (RegHandle); + void (REGISTRY_CALLTYPE *release) (RegHandle); + sal_Bool (REGISTRY_CALLTYPE *isReadOnly) (RegHandle); + RegError (REGISTRY_CALLTYPE *openRootKey) (RegHandle, RegKeyHandle*); + RegError (REGISTRY_CALLTYPE *getName) (RegHandle, rtl_uString**); + RegError (REGISTRY_CALLTYPE *createRegistry) (rtl_uString*, RegHandle*); + RegError (REGISTRY_CALLTYPE *openRegistry) (rtl_uString*, RegHandle*, RegAccessMode); + RegError (REGISTRY_CALLTYPE *closeRegistry) (RegHandle); + RegError (REGISTRY_CALLTYPE *destroyRegistry) (RegHandle, rtl_uString*); + RegError (REGISTRY_CALLTYPE *loadKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*); + RegError (REGISTRY_CALLTYPE *saveKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*); + RegError (REGISTRY_CALLTYPE *mergeKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*, sal_Bool, sal_Bool); + RegError (REGISTRY_CALLTYPE *dumpRegistry) (RegHandle, RegKeyHandle); + void (REGISTRY_CALLTYPE *acquireKey) (RegKeyHandle); + void (REGISTRY_CALLTYPE *releaseKey) (RegKeyHandle); + sal_Bool (REGISTRY_CALLTYPE *isKeyReadOnly) (RegKeyHandle); + RegError (REGISTRY_CALLTYPE *getKeyName) (RegKeyHandle, rtl_uString**); + RegError (REGISTRY_CALLTYPE *createKey) (RegKeyHandle, rtl_uString*, RegKeyHandle*); + RegError (REGISTRY_CALLTYPE *openKey) (RegKeyHandle, rtl_uString*, RegKeyHandle*); + RegError (REGISTRY_CALLTYPE *openSubKeys) (RegKeyHandle, rtl_uString*, RegKeyHandle**, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *closeSubKeys) (RegKeyHandle*, sal_uInt32); + RegError (REGISTRY_CALLTYPE *deleteKey) (RegKeyHandle, rtl_uString*); + RegError (REGISTRY_CALLTYPE *closeKey) (RegKeyHandle); + RegError (REGISTRY_CALLTYPE *setValue) (RegKeyHandle, rtl_uString*, RegValueType, RegValue, sal_uInt32); + RegError (REGISTRY_CALLTYPE *setLongListValue) (RegKeyHandle, rtl_uString*, sal_Int32*, sal_uInt32); + RegError (REGISTRY_CALLTYPE *setStringListValue) (RegKeyHandle, rtl_uString*, sal_Char**, sal_uInt32); + RegError (REGISTRY_CALLTYPE *setUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode**, sal_uInt32); + RegError (REGISTRY_CALLTYPE *getValueInfo) (RegKeyHandle, rtl_uString*, RegValueType*, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *getValue) (RegKeyHandle, rtl_uString*, RegValue); + RegError (REGISTRY_CALLTYPE *getLongListValue) (RegKeyHandle, rtl_uString*, sal_Int32**, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *getStringListValue) (RegKeyHandle, rtl_uString*, sal_Char***, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *getUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode***, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *freeValueList) (RegValueType, RegValue, sal_uInt32); + RegError (REGISTRY_CALLTYPE *createLink) (RegKeyHandle, rtl_uString*, rtl_uString*); + RegError (REGISTRY_CALLTYPE *deleteLink) (RegKeyHandle, rtl_uString*); + RegError (REGISTRY_CALLTYPE *getKeyType) (RegKeyHandle, rtl_uString*, RegKeyType*); + RegError (REGISTRY_CALLTYPE *getLinkTarget) (RegKeyHandle, rtl_uString*, rtl_uString**); + RegError (REGISTRY_CALLTYPE *getResolvedKeyName) (RegKeyHandle, rtl_uString*, sal_Bool, rtl_uString**); + RegError (REGISTRY_CALLTYPE *getKeyNames) (RegKeyHandle, rtl_uString*, rtl_uString***, sal_uInt32*); + RegError (REGISTRY_CALLTYPE *freeKeyNames) (rtl_uString**, sal_uInt32); +}; + +/** the API initialization function. +*/ +REG_DLLPUBLIC Registry_Api* REGISTRY_CALLTYPE initRegistry_Api(void); + +#ifdef __cplusplus +} +#endif + + +class RegistryKey; + +//----------------------------------------------------------------------------- + +/** The Registry provides the functionality to read and write information in a registry file. + + The class is implemented inline and use a C-Api. +*/ +class Registry +{ +public: + /** Default constructor. + */ + inline Registry(); + + /// Copy constructcor + inline Registry(const Registry& toCopy); + + /// Destructor. The Destructor close the registry if it is open. + inline ~Registry(); + + /// Assign operator + inline Registry& operator = (const Registry& toAssign); + + /// checks if the registry points to a valid registry data file. + inline sal_Bool isValid() const; + + /** returns the access mode of the registry. + + @return TRUE if the access mode is readonly else FALSE. + */ + inline sal_Bool isReadOnly() const; + + /** opens the root key of the registry. + + @param rRootKey reference to a RegistryKey which is filled with the rootkey. + @return REG_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 REG_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, REG_READONLY or REG_READWRITE. + @return REG_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 + itselfs will be destroyed. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError destroy(const OUString& registryName); + + /** loads registry information from a specified file and save it under the + specified keyName. + + @param rKey references a currently open key. The key which should store the registry information + is a subkey of this key. + @param keyName specifies the name of the key which stores the registry information. If keyName is + is an empty string the registry information will be saved under the key specified + by rKey. + @param regFileName specifies the file containing the registry information. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError loadKey(RegistryKey& rKey, + const OUString& keyName, + const OUString& regFileName); + + /** saves the registry information of the specified key and all subkeys and save + it in the specified file. + + @param rKey references a currently open key. The key which information is saved by this + function is a subkey of this key. + @param keyName specifies the name of the key which information should be stored. + If keyName is an empty string the registry information under the key specified + by rKey is saved in the specified file. + @param regFileName specifies the file containing the registry information. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError saveKey(RegistryKey& rKey, + const OUString& keyName, + const OUString& regFileName); + + /** merges the registry information of the specified key with the registry + information of the specified file. + + All existing keys will be extended and existing key values will be overwritten. + @param rKey references a currently open key. The key which information is merged by this + function is a subkey of this key + @param keyName specifies the name of the key which will be merged. + If keyName is an empty string the registry information under the key specified + by rKey is merged with the information from the specified file. + @param regFileName specifies the file containing the registry information. + @param bWarnings if TRUE the function returns an error if a key already exists. + @param bReport if TRUE the function reports warnings on stdout if a key already exists. + @return REG_NO_ERROR if succeeds else an error code. If it returns an error the registry will + restore the state before merging. + */ + inline RegError mergeKey(RegistryKey& rKey, + const OUString& keyName, + const OUString& regFileName, + sal_Bool bWarnings = sal_False, + sal_Bool bReport = sal_False); + + /** This function reports the complete registry information of a key and all of its subkeys. + + All information which are available (keynames, value types, values, ...) + will be printed to stdout for report issues only. + @param rKey references a currently open key which content will be reported. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError dumpRegistry(RegistryKey& rKey); + + friend class RegistryKey; + friend class RegistryKeyArray; + friend class RegistryKeyNames; + + /// returns the used registry Api. + const Registry_Api* getApi() { return m_pApi; } +protected: + + /// 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(); + + friend class RegistryKey; +protected: + /** 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. + */ + inline void setKeyHandles(Registry& registry, RegKeyHandle* phKeys, sal_uInt32 length); + /// close all subkeys + inline RegError closeKeyHandles(); + + /// 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 sepecified by index. + inline OUString getElement(sal_uInt32 index); + + /// returns the length of the array. + inline sal_uInt32 getLength(); + + friend class RegistryKey; +protected: + /** 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. + */ + inline void setKeyNames(Registry& registry, rtl_uString** pKeyNames, sal_uInt32 length); + /// delete the array of key names. + inline RegError freeKeyNames(); + + /// 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 +{ +public: + /// Default constructor + RegistryValueList() + : m_length(0) + , m_pValueList(NULL) + , m_valueType(RG_VALUETYPE_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 0; + } + } + + /// returns the length of the list. + sal_uInt32 getLength() + { + return m_length; + } + + friend class RegistryKey; +protected: + /** 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(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(); + + /// Copy constructor + inline RegistryKey(const RegistryKey& toCopy); + + /// Destructor, close the key if it references an open one. + inline ~RegistryKey(); + + /// Assign operator + inline RegistryKey& operator = (const RegistryKey& toAssign); + + /// checks if the key points to a valid registry key. + inline sal_Bool isValid() const; + + /** returns the access mode of the key. + + @return TRUE if access mode is read only else FALSE. + */ + inline sal_Bool 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 relativ 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 REG_NO_ERROR if succeeds else an error code. + */ + inline RegError createKey(const OUString& keyName, + RegistryKey& rNewKey); + + /** opens the specified key. + + The specified keyname is relativ 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 REG_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 relativ 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 REG_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 relativ 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 REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getKeyNames(const OUString& keyName, + RegistryKeyNames& rSubKeyNames); + + /** closes all keys specified in the array. + + @param rSubKeys reference a RegistryKeyArray which contains the open keys. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError closeSubKeys(RegistryKeyArray& rSubKeys); + + /** deletes the specified key. + + @param keyName specifies the name of the key which will be deleted. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError deleteKey(const OUString& keyName); + + /// closes explicitly the current key + inline RegError closeKey(); + + /// releases the current key + inline void releaseKey(); + + /** 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 REG_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 REG_NO_ERROR if succeeds else an error code. + */ + inline RegError setLongListValue(const OUString& keyName, + sal_Int32* 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 sal_Char* containing the data for the value. + @param len specifies the length of the list (the array referenced by pValueList). + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError setStringListValue(const OUString& keyName, + sal_Char** pValueList, + sal_uInt32 len); + + /** sets an 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 REG_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 REG_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 REG_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 REG_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 REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getStringListValue(const OUString& keyName, + RegistryValueList<sal_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 REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getUnicodeListValue(const OUString& keyName, + RegistryValueList<sal_Unicode*>& rValueList); + + /** used to create a link. + + @deprecated Links are no longer supported. + + @return REG_INVALID_LINK + */ + inline RegError createLink(const OUString& linkName, + const OUString& linkTarget); + + /** used to delete a link. + + @deprecated Links are no longer supported. + + @return REG_INVALID_LINK + */ + inline RegError deleteLink(const OUString& linkName); + + /** returns the type of the specified key. + + @param name specifies the name of the key or link. + @param pKeyType returns the type of the key (always RG_KEYTYPE). + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getKeyType(const OUString& name, + RegKeyType* pKeyType) const; + + /** used to return the target of a link. + + @deprecated Links are no longer supported. + + @return REG_INVALID_LINK + */ + inline RegError getLinkTarget(const OUString& linkName, + OUString& rLinkTarget) const; + + /** 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[in] firstLinkOnly ignored + @param[out] rResolvedName the resolved name. + @return REG_NO_ERROR if succeeds else an error code. + */ + inline RegError getResolvedKeyName(const OUString& keyName, + sal_Bool firstLinkOnly, + OUString& rResolvedName) const; + + /// returns the name of the registry in which the key is defined. + inline OUString getRegistryName(); + + /// returns the registry in which the key is defined. + Registry getRegistry() const { return m_registry; } + + friend class Registry; +public: + /// @cond INTERNAL + + /** Constructor, which initialize a RegistryKey with registry and an valid key handle. + + This constructor is internal only. + */ + inline RegistryKey(Registry& registry, + RegKeyHandle hKey); + + /** returns the internal key handle. + */ + RegKeyHandle getKeyHandle() const { return m_hImpl; } + +protected: + /** sets the internal registry on which this key should work. + */ + inline void setRegistry(Registry& registry); + + /// @endcond + + /// stores the registry on which this key works + Registry m_registry; + /// stores the current key handle of this key + RegKeyHandle m_hImpl; +}; + + +//----------------------------------------------------------------------------- + +inline RegistryKeyArray::RegistryKeyArray() + : m_length(0) + , m_phKeys(NULL) +{ +} + +inline RegistryKeyArray::~RegistryKeyArray() +{ + if (m_phKeys) + m_registry.m_pApi->closeSubKeys(m_phKeys, m_length); +} + +inline RegistryKey RegistryKeyArray::getElement(sal_uInt32 index) +{ + if (m_registry.isValid() && index < m_length) + return RegistryKey(m_registry, m_phKeys[index]); + else + return RegistryKey(); +} + +inline sal_uInt32 RegistryKeyArray::getLength() +{ + return m_length; +} + +inline void RegistryKeyArray::setKeyHandles(Registry& registry, + RegKeyHandle* phKeys, + sal_uInt32 length) +{ + m_phKeys = phKeys; + m_length = length; + m_registry = registry; +} + +inline RegError RegistryKeyArray::closeKeyHandles() +{ + if (m_registry.isValid() && m_phKeys) + { + RegError ret; + ret = m_registry.m_pApi->closeSubKeys(m_phKeys, m_length); + m_registry = Registry(); + m_length = 0; + m_phKeys = NULL; + return ret; + } else + return(REG_INVALID_KEY); +} + +//----------------------------------------------------------------------------- + +inline RegistryKeyNames::RegistryKeyNames() + : m_length(0) + , m_pKeyNames(NULL) +{ +} + +inline RegistryKeyNames::~RegistryKeyNames() +{ + if (m_pKeyNames) + m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length); +} + +inline OUString RegistryKeyNames::getElement(sal_uInt32 index) +{ + + if (m_pKeyNames && index < m_length) + return m_pKeyNames[index]; + else + return OUString(); +} + +inline sal_uInt32 RegistryKeyNames::getLength() +{ + return m_length; +} + +inline void RegistryKeyNames::setKeyNames(Registry& registry, + rtl_uString** pKeyNames, + sal_uInt32 length) +{ + m_pKeyNames = pKeyNames; + m_length = length; + m_registry = registry; +} + +inline RegError RegistryKeyNames::freeKeyNames() +{ + if (m_registry.isValid() && m_pKeyNames) + { + RegError ret = REG_NO_ERROR; + ret = m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length); + m_registry = Registry(); + m_length = 0; + m_pKeyNames = NULL; + return ret; + } else + return REG_INVALID_KEY; +} + +//----------------------------------------------------------------------------- + +inline RegistryKey::RegistryKey() + : m_hImpl(NULL) + { } + +/// @cond INTERNAL +inline RegistryKey::RegistryKey(Registry& registry, RegKeyHandle hKey) + : m_registry(registry) + , m_hImpl(hKey) + { + if (m_hImpl) + m_registry.m_pApi->acquireKey(m_hImpl); + } +/// @endcond + +inline RegistryKey::RegistryKey(const RegistryKey& toCopy) + : m_registry(toCopy.m_registry) + , m_hImpl(toCopy.m_hImpl) + { + if (m_hImpl) + m_registry.m_pApi->acquireKey(m_hImpl); + } + +/// @cond INTERNAL +inline void RegistryKey::setRegistry(Registry& registry) + { + m_registry = registry; + } +/// @endcond + +inline RegistryKey::~RegistryKey() + { + if (m_hImpl) + m_registry.m_pApi->releaseKey(m_hImpl); + } + +inline RegistryKey& RegistryKey::operator = (const RegistryKey& toAssign) +{ + m_registry = toAssign.m_registry; + + 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; + + return *this; +} + +inline sal_Bool RegistryKey::isValid() const + { return (m_hImpl != NULL); } + +inline sal_Bool RegistryKey::isReadOnly() const + { + if (m_registry.isValid()) + return (m_registry.m_pApi)->isKeyReadOnly(m_hImpl); + else + return sal_False; + } + +inline OUString RegistryKey::getName() + { + OUString sRet; + if (m_registry.isValid()) + m_registry.m_pApi->getKeyName(m_hImpl, &sRet.pData); + return sRet; + } + +inline RegError RegistryKey::createKey(const OUString& keyName, + RegistryKey& rNewKey) + { + if (rNewKey.isValid()) rNewKey.closeKey(); + if (m_registry.isValid()) + { + RegError ret = m_registry.m_pApi->createKey(m_hImpl, keyName.pData, &rNewKey.m_hImpl); + if (!ret) rNewKey.setRegistry(m_registry); + return ret; + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::openKey(const OUString& keyName, + RegistryKey& rOpenKey) + { + if (rOpenKey.isValid()) rOpenKey.closeKey(); + if (m_registry.isValid()) + { + RegError ret = m_registry.m_pApi->openKey(m_hImpl, keyName.pData, + &rOpenKey.m_hImpl); + if (!ret) rOpenKey.setRegistry(m_registry); + return ret; + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::openSubKeys(const OUString& keyName, + RegistryKeyArray& rSubKeys) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + RegKeyHandle* pSubKeys; + sal_uInt32 nSubKeys; + ret = m_registry.m_pApi->openSubKeys(m_hImpl, keyName.pData, + &pSubKeys, &nSubKeys); + if ( ret ) + { + return ret; + } else + { + rSubKeys.setKeyHandles(m_registry, pSubKeys, nSubKeys); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getKeyNames(const OUString& keyName, + RegistryKeyNames& rSubKeyNames) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + rtl_uString** pSubKeyNames; + sal_uInt32 nSubKeys; + ret = m_registry.m_pApi->getKeyNames(m_hImpl, keyName.pData, + &pSubKeyNames, &nSubKeys); + if ( ret ) + { + return ret; + } else + { + rSubKeyNames.setKeyNames(m_registry, pSubKeyNames, nSubKeys); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::closeSubKeys(RegistryKeyArray& rSubKeys) + { + if (m_registry.isValid()) + return rSubKeys.closeKeyHandles(); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::deleteKey(const OUString& keyName) + { + if (m_registry.isValid()) + return m_registry.m_pApi->deleteKey(m_hImpl, keyName.pData); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::closeKey() + { + if (m_registry.isValid()) + { + RegError ret = m_registry.m_pApi->closeKey(m_hImpl); + if (!ret) + { + m_hImpl = NULL; + m_registry = Registry(); + } + return ret; + } else + return REG_INVALID_KEY; + } + +inline void RegistryKey::releaseKey() +{ + if (m_registry.isValid() && (m_hImpl != 0)) + { + m_registry.m_pApi->releaseKey(m_hImpl), m_hImpl = 0; + } +} + +inline RegError RegistryKey::setValue(const OUString& keyName, + RegValueType valueType, + RegValue pValue, + sal_uInt32 valueSize) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setValue(m_hImpl, keyName.pData, valueType, + pValue, valueSize); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::setLongListValue(const OUString& keyName, + sal_Int32* pValueList, + sal_uInt32 len) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setLongListValue(m_hImpl, keyName.pData, + pValueList, len); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::setStringListValue(const OUString& keyName, + sal_Char** pValueList, + sal_uInt32 len) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setStringListValue(m_hImpl, keyName.pData, + pValueList, len); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::setUnicodeListValue(const OUString& keyName, + sal_Unicode** pValueList, + sal_uInt32 len) + { + if (m_registry.isValid()) + return m_registry.m_pApi->setUnicodeListValue(m_hImpl, keyName.pData, + pValueList, len); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getValueInfo(const OUString& keyName, + RegValueType* pValueType, + sal_uInt32* pValueSize) + { + if (m_registry.isValid()) + return m_registry.m_pApi->getValueInfo(m_hImpl, keyName.pData, pValueType, pValueSize); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getValue(const OUString& keyName, + RegValue pValue) + { + if (m_registry.isValid()) + return m_registry.m_pApi->getValue(m_hImpl, keyName.pData, pValue); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getLongListValue(const OUString& keyName, + RegistryValueList<sal_Int32>& rValueList) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + sal_Int32* pValueList; + sal_uInt32 length; + ret = m_registry.m_pApi->getLongListValue(m_hImpl, keyName.pData, + &pValueList, &length); + if ( ret ) + { + return ret; + } else + { + rValueList.setValueList(m_registry, RG_VALUETYPE_LONGLIST, + pValueList, length); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getStringListValue(const OUString& keyName, + RegistryValueList<sal_Char*>& rValueList) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + sal_Char** pValueList; + sal_uInt32 length; + ret = m_registry.m_pApi->getStringListValue(m_hImpl, keyName.pData, + &pValueList, &length); + if ( ret ) + { + return ret; + } else + { + rValueList.setValueList(m_registry, RG_VALUETYPE_STRINGLIST, + pValueList, length); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getUnicodeListValue(const OUString& keyName, + RegistryValueList<sal_Unicode*>& rValueList) + { + if (m_registry.isValid()) + { + RegError ret = REG_NO_ERROR; + sal_Unicode** pValueList; + sal_uInt32 length; + ret = m_registry.m_pApi->getUnicodeListValue(m_hImpl, keyName.pData, + &pValueList, &length); + if ( ret ) + { + return ret; + } else + { + rValueList.setValueList(m_registry, RG_VALUETYPE_UNICODELIST, + pValueList, length); + return ret; + } + } else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::createLink(const OUString& linkName, + const OUString& linkTarget) + { + if (m_registry.isValid()) + return m_registry.m_pApi->createLink(m_hImpl, linkName.pData, linkTarget.pData); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::deleteLink(const OUString& linkName) + { + if (m_registry.isValid()) + return m_registry.m_pApi->deleteLink(m_hImpl, linkName.pData); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getKeyType(const OUString& keyName, + RegKeyType* pKeyType) const + { + if (m_registry.isValid()) + return m_registry.m_pApi->getKeyType(m_hImpl, keyName.pData, pKeyType); + else + return REG_INVALID_KEY; + } + +inline RegError RegistryKey::getLinkTarget(const OUString& linkName, + OUString& rLinkTarget) const + { + if (m_registry.isValid()) + { + return m_registry.m_pApi->getLinkTarget(m_hImpl, + linkName.pData, + &rLinkTarget.pData); + } else + return REG_INVALID_KEY; + } + + +inline RegError RegistryKey::getResolvedKeyName(const OUString& keyName, + sal_Bool firstLinkOnly, + OUString& rResolvedName) const + { + if (m_registry.isValid()) + return m_registry.m_pApi->getResolvedKeyName(m_hImpl, + keyName.pData, + firstLinkOnly, + &rResolvedName.pData); + else + return REG_INVALID_KEY; + } + +inline OUString RegistryKey::getRegistryName() + { + if (m_registry.isValid()) + { + return m_registry.getName(); + } else + return OUString(); + } + +//----------------------------------------------------------------------------- + +inline Registry::Registry() + : m_pApi(initRegistry_Api()) + , m_hImpl(NULL) + { } + +inline Registry::Registry(const Registry& toCopy) + : m_pApi(toCopy.m_pApi) + , m_hImpl(toCopy.m_hImpl) + { + if (m_hImpl) + m_pApi->acquire(m_hImpl); + } + + +inline Registry::~Registry() + { + if (m_hImpl) + m_pApi->release(m_hImpl); + } + +inline Registry& Registry::operator = (const Registry& toAssign) +{ + if (toAssign.m_hImpl) + toAssign.m_pApi->acquire(toAssign.m_hImpl); + if (m_hImpl) + m_pApi->release(m_hImpl); + + m_pApi = toAssign.m_pApi; + m_hImpl = toAssign.m_hImpl; + + return *this; +} + +inline sal_Bool Registry::isValid() const + { return ( m_hImpl != NULL ); } + +inline sal_Bool Registry::isReadOnly() const + { return m_pApi->isReadOnly(m_hImpl); } + +inline RegError Registry::openRootKey(RegistryKey& rRootKey) + { + rRootKey.setRegistry(*this); + return m_pApi->openRootKey(m_hImpl, &rRootKey.m_hImpl); + } + +inline OUString Registry::getName() + { + OUString sRet; + m_pApi->getName(m_hImpl, &sRet.pData); + return sRet; + } + +inline RegError Registry::create(const OUString& registryName) + { + if (m_hImpl) + m_pApi->release(m_hImpl); + return m_pApi->createRegistry(registryName.pData, &m_hImpl); + } + +inline RegError Registry::open(const OUString& registryName, + RegAccessMode accessMode) + { + if (m_hImpl) + m_pApi->release(m_hImpl); + return m_pApi->openRegistry(registryName.pData, &m_hImpl, accessMode); + } + +inline RegError Registry::close() + { + RegError ret = m_pApi->closeRegistry(m_hImpl); + if (!ret) + m_hImpl = NULL; + return ret; + } + +inline RegError Registry::destroy(const OUString& registryName) + { + RegError ret = m_pApi->destroyRegistry(m_hImpl, registryName.pData); + if ( !ret && registryName.isEmpty() ) + m_hImpl = NULL; + return ret; + } + +inline RegError Registry::loadKey(RegistryKey& rKey, + const OUString& keyName, + const OUString& regFileName) + { return m_pApi->loadKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); } + +inline RegError Registry::saveKey(RegistryKey& rKey, + const OUString& keyName, + const OUString& regFileName) + { return m_pApi->saveKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); } + +inline RegError Registry::mergeKey(RegistryKey& rKey, + const OUString& keyName, + const OUString& regFileName, + sal_Bool bWarnings, + sal_Bool bReport) + { return m_pApi->mergeKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData, bWarnings, bReport); } + +inline RegError Registry::dumpRegistry(RegistryKey& rKey) + { return m_pApi->dumpRegistry(m_hImpl, rKey.m_hImpl); } + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/regtype.h b/include/registry/regtype.h new file mode 100644 index 000000000000..86ddb299fb37 --- /dev/null +++ b/include/registry/regtype.h @@ -0,0 +1,168 @@ +/* -*- 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 . + */ + +#ifndef _REGISTRY_REGTYPE_H_ +#define _REGISTRY_REGTYPE_H_ + +#include <sal/types.h> + +/// defines the type of a registry handle used in the C API. +typedef void* RegHandle; + +/// defines the type of a registry key handle used in the C API. +typedef void* RegKeyHandle; + +/// defines the type of a registry key value handle used in the C API. +typedef void* RegValue; + +/** defines the open/access mode of the registry. + + Two modes are valid: + -REG_READONLY allows readonly access + -REG_READWRITE allows read and write access + */ +typedef sal_uInt16 RegAccessMode; + +/// Flag to specify the open mode of a registry. This mode allows readonly access. +#define REG_READONLY 0x0001 +/// Flag to specify the open mode of a registry. This mode allows read and write access. +#define REG_READWRITE 0x0002 + +/** defines the type of a registry key. + + The registry differs between normal keys which can contain subkeys or + a value and link keys which navigate over the linktarget to an existing + other key (which are no longer supported). +*/ +enum RegKeyType +{ + /// represents a real key + RG_KEYTYPE, + /// represents a link (which is no longer supported) + RG_LINKTYPE +}; + +/** defines the type of a key value. + + A registry key can contain a value which has one of seven different types. + Three simple types (long, ascii and unicode string) and a list type of + these simple types. Furthermore a binary type which provides the possibilty + to define own data structures and store these types in the registry. The UNO + core reflection data is stored as a binary blob in the type registry. + */ +enum RegValueType +{ + /// The key has no value or the value type is unknown. + RG_VALUETYPE_NOT_DEFINED, + /// The key has a value of type long + RG_VALUETYPE_LONG, + /// The key has a value of type ascii string + RG_VALUETYPE_STRING, + /// The key has a value of type unicode string + RG_VALUETYPE_UNICODE, + /// The key has a value of type binary + RG_VALUETYPE_BINARY, + /// The key has a value of type long list + RG_VALUETYPE_LONGLIST, + /// The key has a value of type ascii string list + RG_VALUETYPE_STRINGLIST, + /// The key has a value of type unicode string list + RG_VALUETYPE_UNICODELIST +}; + +/// specifies the possible error codes which can occur using the registry API. +enum RegError +{ + /// no error. + REG_NO_ERROR, + /// internal registry error. + REG_INTERNAL_ERROR, + + /// registry is not open. + REG_REGISTRY_NOT_OPEN, + /// registry does not exists. + REG_REGISTRY_NOT_EXISTS, + /// registry is open with readonly access rights. + REG_REGISTRY_READONLY, + /// destroy a registry failed. There are may be any open keys. + REG_DESTROY_REGISTRY_FAILED, + /** registry cannot be opened with readwrite access because the registry is already + open with readwrite access anywhere. + */ + REG_CANNOT_OPEN_FOR_READWRITE, + /** registry is in an invalid state or the registry does not point to + a valid registry data file. + */ + REG_INVALID_REGISTRY, + + /// the key or key handle points to an invalid key or closed key. + REG_KEY_NOT_OPEN, + /// the specified keyname points to a nonexisting key. + REG_KEY_NOT_EXISTS, + /// the key with the specified keyname cannot be created. + REG_CREATE_KEY_FAILED, + /// the specified key cannot be deleted. Maybe an open key handle exists to this key. + REG_DELETE_KEY_FAILED, + /** the keyname is invalid. This error will return if the keyname + is NULL but should not be NULL in the context of a called function. + */ + REG_INVALID_KEYNAME, + /// the key is not in a valid state. + REG_INVALID_KEY, + + /// the key has no value + REG_VALUE_NOT_EXISTS, + /// setting the specified value of a key failed. + REG_SET_VALUE_FAILED, + /// deleting of the key value failed. + REG_DELETE_VALUE_FAILED, + /// the key has a invalid value or the value type is unknown. + REG_INVALID_VALUE, + + /// merging a key, the value and all subkeys failed. + REG_MERGE_ERROR, + /** conflicts exists during the merge process of a key. This could happen if + the value of a key already exists and the merge process will replace it. + */ + REG_MERGE_CONFLICT, + + /** a recursion was detected resolving different link targets (no longer + used). + */ + REG_DETECT_RECURSION, + /** the link is invalid and can not be resolved (now used by all + link-related operations, as links are no longer supported). + */ + REG_INVALID_LINK, + /// the specified linkname is not valid (no longer used). + REG_INVALID_LINKNAME, + /// the linknane is not valid (no longer used). + REG_INVALID_LINKTARGET, + /// the link target points to a nonexisting key (no longer used). + REG_LINKTARGET_NOT_EXIST, + /// the reserved buffer for the resolved keyname is to small. + REG_BUFFERSIZE_TOSMALL +}; + +/// specify the calling convention for the registry API +#define REGISTRY_CALLTYPE SAL_CALL + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/types.h b/include/registry/types.h new file mode 100644 index 000000000000..0ad7977486f4 --- /dev/null +++ b/include/registry/types.h @@ -0,0 +1,334 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_registry_types_h +#define INCLUDED_registry_types_h + +#include "sal/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** specifies the typeclass of a binary type blob. + + The general structure of a binary type blob is always the same. It depends + on the typeclass which parts of the blob are filled with data or not. + */ +enum RTTypeClass { + /** specifies that the structure of the given blob is unknown and can't be + read. + */ + RT_TYPE_INVALID, + + /** specifies that the blob represents an interface type. An interface blob + can contain a base interface, attributes and methods. + */ + RT_TYPE_INTERFACE, + + /** specifies that the blob represents a module type. A module blob can + contain a base module and constant members (fields). + */ + RT_TYPE_MODULE, + + /** specifies that the blob represents a struct type. A struct blob can + contain a base struct and members (fields). + */ + RT_TYPE_STRUCT, + + /** specifies that the blob represents an enum type. An enum blob can + contain enum values which are accessible as fields. + */ + RT_TYPE_ENUM, + + /** specifies that the blob represents an exception type. An exception blob + can contain a base exception and members (fields). + */ + RT_TYPE_EXCEPTION, + + /** specifies that the blob represents a typedef type. A typedef blob can + contain a base type. + */ + RT_TYPE_TYPEDEF, + + /** specifies that the blob represents a service type. A service blob can + contain a base service, properties (fields), references to services or + interfaces. + */ + RT_TYPE_SERVICE, + + /** specifies that the blob represents a singleton type (a named object) + which refers exactly one existing service. + */ + RT_TYPE_SINGLETON, + + /// deprecated, not used. + RT_TYPE_OBJECT, + + /** specifies that the blob represents a constants type. A constants blob + can contain constant types as fields. + */ + RT_TYPE_CONSTANTS, + + /** @deprecated + a union type was evaluated but currently not supported. + */ + RT_TYPE_UNION, + + /// @cond INTERNAL + /** + Flag for published entities. + + Used in combination with RT_TYPE_INTERFACE, RT_TYPE_STRUCT, RT_TYPE_ENUM, + RT_TYPE_EXCEPTION, RT_TYPE_TYPEDEF, RT_TYPE_SERVICE, RT_TYPE_SINGLETON, + or RT_TYPE_CONSTANTS to mark an entity as published. + + (The value of this enumerator is chosen so that it is unlikely that its + addition changes the underlying type of this enumeration for any C/C++ + compiler.) + + @since UDK 3.2.0 + */ + RT_TYPE_PUBLISHED = 0x4000 + /// @endcond +}; + +/** specifies the type for the field access. + + Fields in a type blob are used for different types. Among others they were + used for properties of services and these poperties can have several flags. + + @see RT_ACCESS_INVALID + @see RT_ACCESS_READONLY + @see RT_ACCESS_OPTIONAL + @see RT_ACCESS_MAYBEVOID + @see RT_ACCESS_BOUND + @see RT_ACCESS_CONSTRAINED + @see RT_ACCESS_TRANSIENT + @see RT_ACCESS_MAYBEAMBIGUOUS + @see RT_ACCESS_MAYBEDEFAULT + @see RT_ACCESS_REMOVEABLE + @see RT_ACCESS_ATTRIBUTE + @see RT_ACCESS_PROPERTY + @see RT_ACCESS_CONST + @see RT_ACCESS_READWRITE + @see RT_ACCESS_DEFAULT + @see RT_ACCESS_PARAMETERIZED_TYPE + @see RT_ACCESS_PUBLISHED + */ +typedef sal_uInt16 RTFieldAccess; + +/// specifies a unknown flag +#define RT_ACCESS_INVALID 0x0000 +/// specifies a readonly property/attribute +#define RT_ACCESS_READONLY 0x0001 +/// specifies a property as optional that means that it must not be implemented. +#define RT_ACCESS_OPTIONAL 0x0002 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_MAYBEVOID 0x0004 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_BOUND 0x0008 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_CONSTRAINED 0x0010 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_TRANSIENT 0x0020 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_MAYBEAMBIGUOUS 0x0040 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_MAYBEDEFAULT 0x0080 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_REMOVEABLE 0x0100 +/// @see com::sun::star::beans::PropertyAttribute +#define RT_ACCESS_ATTRIBUTE 0x0200 +/// specifies that the field is a property +#define RT_ACCESS_PROPERTY 0x0400 +/// specifies that the field is a constant or enum value +#define RT_ACCESS_CONST 0x0800 +/// specifies that the property/attribute has read/write access +#define RT_ACCESS_READWRITE 0x1000 +/// only to describe a union default label +#define RT_ACCESS_DEFAULT 0x2000 + +/** + Indicates that a member of a polymorphic struct type template is of a + parameterized type. + + Only valid for fields that represent members of polymorphic struct type + templates. + + @since UDK 3.2.0 + */ +#define RT_ACCESS_PARAMETERIZED_TYPE 0x4000 + +/** + Flag for published individual constants. + + Used in combination with RT_ACCESS_CONST for individual constants (which are + not members of constant groups). + + @since UDK 3.2.0 + */ +#define RT_ACCESS_PUBLISHED 0x8000 + +/** specifies the type of a field value. + + A field can have a value if it repsresents a constant or an enum value. + */ +enum RTValueType { + RT_TYPE_NONE, + RT_TYPE_BOOL, + RT_TYPE_BYTE, + RT_TYPE_INT16, + RT_TYPE_UINT16, + RT_TYPE_INT32, + RT_TYPE_UINT32, + RT_TYPE_INT64, + RT_TYPE_UINT64, + RT_TYPE_FLOAT, + RT_TYPE_DOUBLE, + RT_TYPE_STRING +}; + +/** specifies a variable container for field values. + */ +union RTConstValueUnion { + sal_Bool aBool; + sal_Int8 aByte; + sal_Int16 aShort; + sal_uInt16 aUShort; + sal_Int32 aLong; + sal_uInt32 aULong; + sal_Int64 aHyper; + sal_uInt64 aUHyper; + float aFloat; + double aDouble; + sal_Unicode const * aString; +}; + +/** specifies the mode of a method. + + A method can be synchron or asynchron (oneway). The const attribute for + methods was removed so that the const values are deprecated. + */ +enum RTMethodMode { + /// indicates an invalid mode + RT_MODE_INVALID, + + /// indicates the asynchronous mode of a method + RT_MODE_ONEWAY, + + /// @deprecated + RT_MODE_ONEWAY_CONST, + + /// indicated the synchronous mode of a method + RT_MODE_TWOWAY, + + /// @deprecated + RT_MODE_TWOWAY_CONST, + + /** + Indicates an extended attribute getter (that has a 'raises' clause) of an + interface type. + + @since UDK 3.2.0 + */ + RT_MODE_ATTRIBUTE_GET, + + /** + Indicates an extended attribute setter (that has a 'raises' clause) of an + interface type. + + @since UDK 3.2.0 + */ + RT_MODE_ATTRIBUTE_SET +}; + +/** specifies the mode of a parameter. + + There are three paramter modes which have impact of the handling of the + paramter in the UNO bridges and the UNO code generation. + */ +enum RTParamMode { + /// indicates an invalid parameter mode + RT_PARAM_INVALID = 0, + + /// indicates a pure in parameter which is used by value + RT_PARAM_IN = 1, + + /// indicates a pure out parameter which is used by reference + RT_PARAM_OUT = 2, + + /// indicates a in and out parameter which is used also by reference + RT_PARAM_INOUT = 3, + + /** + Indicates a rest parameter (currently only valid for service + constructors). + + This value can be combined with any of RT_PARAM_IN, RT_PARAM_OUT, and + RT_PARAM_INOUT (however, service constructors currently only allow + RT_PARAM_IN, anyway). + + @since UDK 3.2.0 + */ + RT_PARAM_REST = 4 +}; + +/** specifies the type of a reference used in a service description. + */ +enum RTReferenceType { + /// the reference type is unknown + RT_REF_INVALID, + + /** the service support the interface that means a implementation of this + service must implement this interface. + */ + RT_REF_SUPPORTS, + + /** @deprecated + the service observes the interface. + */ + RT_REF_OBSERVES, + + /** the service exports the specified service that means this service + provides also the specified service. + */ + RT_REF_EXPORTS, + + /** @deprecated + the service needs the specified service that means in the context of + this service the specified service will be used or must be available. + */ + RT_REF_NEEDS, + + /** + Indicates a type parameter of a polymorphic struct type template. + + @since UDK 3.2.0 + */ + RT_REF_TYPE_PARAMETER +}; + +#ifdef __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/version.h b/include/registry/version.h new file mode 100644 index 000000000000..01f0f8033323 --- /dev/null +++ b/include/registry/version.h @@ -0,0 +1,69 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_registry_version_h +#define INCLUDED_registry_version_h + +#include "sal/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + The version of a binary blob that represents a UNOIDL type. + + <p>All values between <code>TYPEREG_VERSION_0</code> and + <code>TYPEREG_MAX_VERSION</code> are valid, where currently unallocated + values represent future versions. Negative values are not valid.</p> + + @see typereg::Reader + @see typereg::Writer + + @since UDK 3.2.0 + */ +enum typereg_Version { + /** + Denotes the original version of UNOIDL type blobs. + */ + TYPEREG_VERSION_0, + + /** + Denotes the updated version of UNOIDL type blobs. + + <p>This version added support for multiple-inheritance interface types, + extended interface type attributes, single-interface–based + services, interface-based singletons, polymorphic struct types, and + published entities.</p> + */ + TYPEREG_VERSION_1, + + /** + Denotes the maximum future version of UNOIDL type blobs. + */ + TYPEREG_MAX_VERSION = SAL_MAX_INT32 +}; + +#ifdef __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/writer.h b/include/registry/writer.h new file mode 100644 index 000000000000..f1b39a583e22 --- /dev/null +++ b/include/registry/writer.h @@ -0,0 +1,262 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_registry_writer_h +#define INCLUDED_registry_writer_h + +#include "registry/regdllapi.h" +#include "registry/types.h" +#include "registry/version.h" + +#include "rtl/ustring.h" +#include "sal/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + Creates a type writer working on a binary blob that represents a UNOIDL type. + + <p>Operations on a returned handle are not multi-thread–safe.</p> + + @param version the version of the created type writer; must not be negative + + @param documentation the documentation; must not be null + + @param fileName the file name; must not be null (deprecated, use an empty string) + + @param typeClass the type class of the created type writer + + @param published whether the created type writer is published; for a type + class that cannot be published, this should be false + + @param typeName the type name of the created type writer; must not be null + + @param superTypeCount the number of super types of the created type writer + + @param fieldCount the number of fields of the created type writer + + @param methodCount the number of methods of the created type writer + + @param referenceCount the number of references of the created type writer + + @return a handle on the type writer; if an out-of-memory condition occurs, + null is returned, and no type writer is created + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void * SAL_CALL typereg_writer_create( + typereg_Version version, rtl_uString const * documentation, + rtl_uString const * fileName, RTTypeClass typeClass, sal_Bool published, + rtl_uString const * typeName, sal_uInt16 superTypeCount, + sal_uInt16 fieldCount, sal_uInt16 methodCount, sal_uInt16 referenceCount) + SAL_THROW_EXTERN_C(); + +/** + Destroys a type writer. + + @param handle a handle on a type writer obtained from a call to + <code>typereg_writer_create</code>; must not be null + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC void SAL_CALL typereg_writer_destroy(void * handle) SAL_THROW_EXTERN_C(); + +/** + Sets the type name of a super type of a type writer. + + @param handle a handle on a type writer; must not be null + + @param index a valid index into the range of super types of the given type + writer + + @param typeName the super type name; must not be null + + @return false iff an out-of-memory condition ocurred, in which case the type + writer is not modified + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_writer_setSuperTypeName( + void * handle, sal_uInt16 index, rtl_uString const * typeName) + SAL_THROW_EXTERN_C(); + +/** + Sets the data of a field of a type writer. + + @param handle a handle on a type writer; must not be null + + @param index a valid index into the range of fields of the given type writer + + @param documentation the documentation of the field; must not be null + + @param fileName the file name of the field; must not be null (deprecated, use an empty string) + + @param flags the flags of the field + + @param name the name of the field; must not be null + + @param typeName the type name of the field; must not be null + + @param valueType the type of the value of the field + + @param valueValue the value of the value of the field + + @return false iff an out-of-memory condition ocurred, in which case the type + writer is not modified + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_writer_setFieldData( + void * handle, sal_uInt16 index, rtl_uString const * documentation, + rtl_uString const * fileName, RTFieldAccess flags, rtl_uString const * name, + rtl_uString const * typeName, RTValueType valueType, + RTConstValueUnion valueValue) + SAL_THROW_EXTERN_C(); + +/** + Sets the data of a method of a type writer. + + @param handle a handle on a type writer; must not be null + + @param index a valid index into the range of methods of the given type writer + + @param documentation the documentation of the method; must not be null + + @param flags the flags of the method + + @param name the name of the method; must not be null + + @param returnTypeName the return type name of the method; must not be null + + @param parameterCount the number of parameters of the method + + @param exceptionCount the number of exceptions of the method + + @return false iff an out-of-memory condition ocurred, in which case the type + writer is not modified + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_writer_setMethodData( + void * handle, sal_uInt16 index, rtl_uString const * documentation, + RTMethodMode flags, rtl_uString const * name, + rtl_uString const * returnTypeName, sal_uInt16 parameterCount, + sal_uInt16 exceptionCount) + SAL_THROW_EXTERN_C(); + +/** + Sets the data of a parameter of a method of a type writer. + + @param handle a handle on a type writer; must not be null + + @param methodIndex a valid index into the range of methods of the given type + writer + + @param parameterIndex a valid index into the range of parameters of the given + method + + @param flags the flags of the parameter + + @param name the name of the parameter; must not be null + + @param typeName the type name of the parameter; must not be null + + @return false iff an out-of-memory condition ocurred, in which case the type + writer is not modified + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_writer_setMethodParameterData( + void * handle, sal_uInt16 methodIndex, sal_uInt16 parameterIndex, + RTParamMode flags, rtl_uString const * name, rtl_uString const * typeName) + SAL_THROW_EXTERN_C(); + +/** + Sets an exception type name of a method of a type writer. + + @param handle a handle on a type writer; must not be null + + @param methodIndex a valid index into the range of methods of the given type + writer + + @param exceptionIndex a valid index into the range of exceptions of the given + method + + @param typeName the exception type name; must not be null + + @return false iff an out-of-memory condition ocurred, in which case the type + writer is not modified + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_writer_setMethodExceptionTypeName( + void * handle, sal_uInt16 methodIndex, sal_uInt16 exceptionIndex, + rtl_uString const * typeName) + SAL_THROW_EXTERN_C(); + +/** + Sets the data of a reference of a type writer. + + @param handle a handle on a type writer; must not be null + + @param index a valid index into the range of references of the given type + writer + + @param documentation the documentation of the reference; must not be null + + @param sort the sort of the reference + + @param flags the flags of the reference + + @param typeName the type name of the reference; must not be null + + @return false iff an out-of-memory condition ocurred, in which case the type + writer is not modified + + @since UDK 3.2.0 + */ +REG_DLLPUBLIC sal_Bool SAL_CALL typereg_writer_setReferenceData( + void * handle, sal_uInt16 index, rtl_uString const * documentation, + RTReferenceType sort, RTFieldAccess flags, rtl_uString const * typeName) + SAL_THROW_EXTERN_C(); + +/** + Returns the blob of a type writer. + + @param handle a handle on a type writer; must not be null + + @param size an out-parameter obtaining the size of the blob; must not be null + + @return a (byte-aligned) pointer to the blob; the returned pointer and the + returned <code>size</code> remain valid until the next function is called on + the given type writer; if an out-of-memory condition occurs, null is returned + and <code>size</code> is not modified + */ +REG_DLLPUBLIC void const * SAL_CALL typereg_writer_getBlob(void * handle, sal_uInt32 * size) + SAL_THROW_EXTERN_C(); + +#ifdef __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/registry/writer.hxx b/include/registry/writer.hxx new file mode 100644 index 000000000000..cfdf479853df --- /dev/null +++ b/include/registry/writer.hxx @@ -0,0 +1,291 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_registry_writer_hxx +#define INCLUDED_registry_writer_hxx + +#include "registry/writer.h" +#include "registry/refltype.hxx" +#include "registry/types.h" +#include "registry/version.h" + +#include "rtl/ustring.hxx" +#include "sal/types.h" + +#include <new> + +namespace typereg { + +/** + A type writer working on a binary blob that represents a UNOIDL type. + + <p>Instances of this class are not multi-thread–safe.</p> + + @since UDK 3.2.0 + */ +class Writer { +public: + /** + Creates a type writer. + + @param version the version of the created type writer; must not be + negative + + @param documentation the documentation + + @param fileName the file name (deprecated, use an empty string) + + @param typeClass the type class of the created type writer + + @param published whether the created type writer is published; for a type + class that cannot be published, this should be false + + @param typeName the type name of the created type writer + + @param superTypeCount the number of super types of the created type + writer + + @param fieldCount the number of fields of the created type writer + + @param methodCount the number of methods of the created type writer + + @param referenceCount the number of references of the created type writer + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + Writer( + typereg_Version version, OUString const & documentation, + OUString const & fileName, RTTypeClass typeClass, bool published, + OUString const & typeName, sal_uInt16 superTypeCount, + sal_uInt16 fieldCount, sal_uInt16 methodCount, + sal_uInt16 referenceCount): + m_handle( + typereg_writer_create( + version, documentation.pData, fileName.pData, typeClass, + published, typeName.pData, superTypeCount, fieldCount, + methodCount, referenceCount)) + { + if (m_handle == 0) { + throw std::bad_alloc(); + } + } + + /** + Destroys this <code>Writer</code> instance. + */ + ~Writer() { + typereg_writer_destroy(m_handle); + } + + /** + Sets the type name of a super type of this type writer. + + @param index a valid index into the range of super types of this type + writer + + @param typeName the super type name + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + void setSuperTypeName(sal_uInt16 index, OUString const & typeName) { + if (!typereg_writer_setSuperTypeName(m_handle, index, typeName.pData)) { + throw std::bad_alloc(); + } + } + + /** + Sets the data of a field of this type writer. + + @param index a valid index into the range of fields of this type writer + + @param documentation the documentation of the field + + @param fileName the file name of the field (deprecated, use an empty string) + + @param flags the flags of the field + + @param name the name of the field + + @param typeName the type name of the field + + @param value the value of the field + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + void setFieldData( + sal_uInt16 index, OUString const & documentation, + OUString const & fileName, RTFieldAccess flags, OUString const & name, + OUString const & typeName, RTConstValue const & value) + { + if (!typereg_writer_setFieldData( + m_handle, index, documentation.pData, fileName.pData, flags, + name.pData, typeName.pData, value.m_type, value.m_value)) + { + throw std::bad_alloc(); + } + } + + /** + Sets the data of a method of this type writer. + + @param index a valid index into the range of methods of this type writer + + @param documentation the documentation of the method + + @param flags the flags of the method + + @param name the name of the method + + @param returnTypeName the return type name of the method + + @param parameterCount the number of parameters of the method + + @param exceptionCount the number of exceptions of the method + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + void setMethodData( + sal_uInt16 index, OUString const & documentation, + RTMethodMode flags, OUString const & name, + OUString const & returnTypeName, sal_uInt16 parameterCount, + sal_uInt16 exceptionCount) + { + if (!typereg_writer_setMethodData( + m_handle, index, documentation.pData, flags, name.pData, + returnTypeName.pData, parameterCount, exceptionCount)) + { + throw std::bad_alloc(); + } + } + + /** + Sets the data of a parameter of a method of this type writer. + + @param methodIndex a valid index into the range of methods of this type + writer + + @param parameterIndex a valid index into the range of parameters of the + given method + + @param flags the flags of the parameter + + @param name the name of the parameter + + @param typeName the type name of the parameter + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + void setMethodParameterData( + sal_uInt16 methodIndex, sal_uInt16 parameterIndex, + RTParamMode flags, OUString const & name, + OUString const & typeName) + { + if (!typereg_writer_setMethodParameterData( + m_handle, methodIndex, parameterIndex, flags, name.pData, + typeName.pData)) + { + throw std::bad_alloc(); + } + } + + /** + Sets an exception type name of a method of this type writer. + + @param methodIndex a valid index into the range of methods of this type + writer + + @param exceptionIndex a valid index into the range of exceptions of the + given method + + @param typeName the exception type name + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + void setMethodExceptionTypeName( + sal_uInt16 methodIndex, sal_uInt16 exceptionIndex, + OUString const & typeName) + { + if (!typereg_writer_setMethodExceptionTypeName( + m_handle, methodIndex, exceptionIndex, typeName.pData)) + { + throw std::bad_alloc(); + } + } + + /** + Sets the data of a reference of this type writer. + + @param index a valid index into the range of references of this type + writer + + @param documentation the documentation of the reference + + @param sort the sort of the reference + + @param flags the flags of the reference + + @param typeName the type name of the reference + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + */ + void setReferenceData( + sal_uInt16 index, OUString const & documentation, + RTReferenceType sort, RTFieldAccess flags, + OUString const & typeName) + { + if (!typereg_writer_setReferenceData( + m_handle, index, documentation.pData, sort, flags, + typeName.pData)) + { + throw std::bad_alloc(); + } + } + + /** + Returns the blob of this type writer. + + @param size an out-parameter obtaining the size of the blob + + @return a (byte-aligned) pointer to the blob; the returned pointer and + the returned <code>size</code> remain valid until the next function is + called on this type writer + + @exception std::bad_alloc is raised if an out-of-memory condition occurs + (in which case <code>siez</code> is not modified + */ + void const * getBlob(sal_uInt32 * size) { + void const * p = typereg_writer_getBlob(m_handle, size); + if (p == 0) { + throw std::bad_alloc(); + } + return p; + } + +private: + Writer(Writer &); // not implemented + void operator =(Writer); // not implemented + + void * m_handle; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |