summaryrefslogtreecommitdiffstats
path: root/include/registry
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /include/registry
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/registry')
-rw-r--r--include/registry/reader.hxx606
-rw-r--r--include/registry/refltype.hxx77
-rw-r--r--include/registry/regdllapi.h33
-rw-r--r--include/registry/registry.hxx1059
-rw-r--r--include/registry/regtype.h141
-rw-r--r--include/registry/typereg_reader.hxx565
-rw-r--r--include/registry/types.hxx339
-rw-r--r--include/registry/version.h69
-rw-r--r--include/registry/writer.h262
-rw-r--r--include/registry/writer.hxx291
10 files changed, 3442 insertions, 0 deletions
diff --git a/include/registry/reader.hxx b/include/registry/reader.hxx
new file mode 100644
index 000000000..b804ba3ed
--- /dev/null
+++ b/include/registry/reader.hxx
@@ -0,0 +1,606 @@
+/* -*- 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/typereg_reader.hxx>
+#include <registry/refltype.hxx>
+#include <registry/types.hxx>
+#include <registry/version.h>
+
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+#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&ndash;safe.</p>
+
+ @since UDK 3.2.0
+ */
+class Reader {
+public:
+ /**
+ 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
+
+ @exception std::bad_alloc is raised if an out-of-memory condition occurs
+ */
+ Reader(void const * buffer, sal_uInt32 length)
+ {
+ if (!typereg_reader_create(buffer, length, &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(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 != nullptr;
+ }
+
+ /**
+ 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 = nullptr;
+ typereg_reader_getDocumentation(m_handle, &s);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getFileName(m_handle, &s);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getTypeName(m_handle, &s);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getSuperTypeName(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getFieldDocumentation(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getFieldFileName(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getFieldName(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getFieldTypeName(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getMethodDocumentation(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getMethodName(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getMethodReturnTypeName(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getMethodParameterName(
+ m_handle, &s, methodIndex, parameterIndex);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getMethodParameterTypeName(
+ m_handle, &s, methodIndex, parameterIndex);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getMethodExceptionTypeName(
+ m_handle, &s, methodIndex, exceptionIndex);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getReferenceDocumentation(m_handle, &s, index);
+ if (s == nullptr) {
+ 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 = nullptr;
+ typereg_reader_getReferenceTypeName(m_handle, &s, index);
+ if (s == nullptr) {
+ 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/refltype.hxx b/include/registry/refltype.hxx
new file mode 100644
index 000000000..0ca5803cd
--- /dev/null
+++ b/include/registry/refltype.hxx
@@ -0,0 +1,77 @@
+/* -*- 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_REFLTYPE_HXX
+#define INCLUDED_REGISTRY_REFLTYPE_HXX
+
+#include <registry/types.hxx>
+#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;
+ }
+};
+
+/** deprecated.
+
+ An earlier version of UNO used a unique identifier for interfaces. In the
+ current version of UNO this uik was eliminated and this type is no 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/regdllapi.h b/include/registry/regdllapi.h
new file mode 100644
index 000000000..603eea11d
--- /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_REGISTRY_REGDLLAPI_H
+#define INCLUDED_REGISTRY_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_REGISTRY_REGDLLAPI_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/registry/registry.hxx b/include/registry/registry.hxx
new file mode 100644
index 000000000..b98b1e936
--- /dev/null
+++ b/include/registry/registry.hxx
@@ -0,0 +1,1059 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <registry/regdllapi.h>
+#include <registry/regtype.h>
+#include <rtl/ustring.hxx>
+
+extern "C" {
+
+/** specifies a collection of function pointers which represents the complete registry C-API.
+
+ These function 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 *mergeKey) (RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*, sal_Bool, sal_Bool);
+ 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 const *, sal_uInt32);
+ RegError (REGISTRY_CALLTYPE *setStringListValue) (RegKeyHandle, rtl_uString*, 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*, 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 *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();
+
+}
+
+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 final
+{
+public:
+ /** Default constructor.
+ */
+ inline Registry();
+
+ /// Copy constructor
+ inline Registry(const Registry& toCopy);
+
+ Registry(Registry && other) noexcept : m_pApi(other.m_pApi), m_hImpl(other.m_hImpl)
+ { other.m_hImpl = nullptr; }
+
+ /// Destructor. The Destructor close the registry if it is open.
+ inline ~Registry();
+
+ /// Assign operator
+ inline Registry& operator = (const Registry& toAssign);
+
+ Registry & operator =(Registry && other) {
+ if (m_hImpl != nullptr) {
+ m_pApi->release(m_hImpl);
+ }
+ m_hImpl = other.m_hImpl;
+ other.m_hImpl = nullptr;
+ return *this;
+ }
+
+ /// checks if the registry points to a valid registry data file.
+ inline bool isValid() const;
+
+ /** returns the access mode of the registry.
+
+ @return TRUE if the access mode is readonly else FALSE.
+ */
+ inline bool isReadOnly() const;
+
+ /** opens the root key of the registry.
+
+ @param rRootKey reference to a RegistryKey which is filled with the rootkey.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError openRootKey(RegistryKey& rRootKey);
+
+ /// returns the name of the current registry data file.
+ inline OUString getName();
+
+ /** creates a new registry with the specified name and creates a root key.
+
+ @param registryName specifies the name of the new registry.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError create(const OUString& registryName);
+
+ /** opens a registry with the specified name.
+
+ If the registry already points to a valid registry, the old registry will be closed.
+ @param registryName specifies a registry name.
+ @param accessMode specifies the access mode for the registry, RegAccessMode::READONLY or RegAccessMode::READWRITE.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError open(const OUString& registryName,
+ RegAccessMode accessMode);
+
+ /// closes explicitly the current registry data file.
+ inline RegError close();
+
+ /** destroys a registry.
+
+ @param registryName specifies a registry name, if the name is an empty string the registry
+ itself will be destroyed.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError destroy(const OUString& registryName);
+
+ /** 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 bReport if TRUE the function reports warnings on stdout if a key already exists.
+ @return RegError::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,
+ bool bReport);
+
+ friend class RegistryKey;
+ friend class RegistryKeyArray;
+ friend class RegistryKeyNames;
+
+ /// returns the used registry Api.
+ const Registry_Api* getApi() const { return m_pApi; }
+
+private:
+ /// stores the used and initialized registry Api.
+ const Registry_Api* m_pApi;
+ /// stores the handle of the underlying registry file on which most of the functions work.
+ RegHandle m_hImpl;
+};
+
+
+/** RegistryKeyArray represents an array of open keys.
+
+ RegistryKeyArray is a helper class to work with an array of keys.
+*/
+class RegistryKeyArray
+{
+public:
+ /// Default constructor
+ inline RegistryKeyArray();
+
+ /// Destructor, all subkeys will be closed.
+ inline ~RegistryKeyArray();
+
+ /// returns the open key specified by index.
+ inline RegistryKey getElement(sal_uInt32 index);
+
+ /// returns the length of the array.
+ inline sal_uInt32 getLength() const;
+
+ friend class RegistryKey;
+
+private:
+ /** sets the data of the key array.
+
+ @param registry specifies the registry files where the keys are located.
+ @param phKeys points to an array of open keys.
+ @param length specifies the length of the array specified by phKeys.
+ */
+ inline void setKeyHandles(Registry const & registry, RegKeyHandle* phKeys, sal_uInt32 length);
+
+ /// stores the number of open subkeys, the number of elements.
+ sal_uInt32 m_length;
+ /// stores an array of open subkeys.
+ RegKeyHandle* m_phKeys;
+ /// stores the handle to the registry file where the appropriate keys are located.
+ Registry m_registry;
+};
+
+
+/** RegistryKeyNames represents an array of key names.
+
+ RegistryKeyNames is a helper class to work with an array of key names.
+*/
+class RegistryKeyNames
+{
+public:
+ /// Default constructor
+ inline RegistryKeyNames();
+
+ /// Destructor, the internal array with key names will be deleted.
+ inline ~RegistryKeyNames();
+
+ /// returns the name of the key specified by index.
+ inline OUString getElement(sal_uInt32 index);
+
+ /// returns the length of the array.
+ inline sal_uInt32 getLength() const;
+
+ friend class RegistryKey;
+
+private:
+ /** sets the data of the array.
+
+ @param registry specifies the registry files where the keys are located.
+ @param pKeyNames points to an array of key names.
+ @param length specifies the length of the array specified by pKeyNames.
+ */
+ inline void setKeyNames(Registry const & registry, rtl_uString** pKeyNames, sal_uInt32 length);
+
+ /// stores the number of key names, the number of elements.
+ sal_uInt32 m_length;
+ /// stores an array of key names.
+ rtl_uString** m_pKeyNames;
+ /// stores the handle to the registry file where the appropriate keys are located.
+ Registry m_registry;
+};
+
+
+/** RegistryValueList represents a value list of the specified type.
+
+ RegistryValueList is a helper class to work with a list value.
+*/
+template<class ValueType>
+class RegistryValueList final
+{
+public:
+ /// Default constructor
+ RegistryValueList()
+ : m_length(0)
+ , m_pValueList(nullptr)
+ , m_valueType(RegValueType::NOT_DEFINED)
+ {}
+
+ /// Destructor, the internal value list will be freed.
+ ~RegistryValueList()
+ {
+ if (m_pValueList)
+ {
+ m_registry.getApi()->freeValueList(m_valueType, m_pValueList, m_length);
+ }
+ }
+
+ /// returns the value of the list specified by index.
+ ValueType getElement(sal_uInt32 index)
+ {
+ if (m_registry.isValid() && index < m_length)
+ {
+ return m_pValueList[index];
+ } else
+ {
+ return {};
+ }
+ }
+
+ /// returns the length of the list.
+ sal_uInt32 getLength()
+ {
+ return m_length;
+ }
+
+ friend class RegistryKey;
+
+private:
+ /** sets the data of the value list.
+
+ @param registry specifies the registry files where the appropriate key is located.
+ @param valueType specifies the type of the list values.
+ @param pValueList points to a value list.
+ @param length specifies the length of the list.
+ */
+ void setValueList(const Registry& registry, RegValueType valueType,
+ ValueType* pValueList, sal_uInt32 length)
+ {
+ m_length = length;
+ m_pValueList = pValueList;
+ m_valueType = valueType;
+ m_registry = registry;
+ }
+
+ /// stores the length of the list, the number of elements.
+ sal_uInt32 m_length;
+ /// stores the value list.
+ ValueType* m_pValueList;
+ /// stores the type of the list elements
+ RegValueType m_valueType;
+ /** stores the handle to the registry file where the appropriate key to this
+ value is located.
+ */
+ Registry m_registry;
+};
+
+
+/** RegistryKey reads or writes information of the underlying key in a registry.
+
+ Class is inline and use a load on call C-Api.
+*/
+class RegistryKey
+{
+public:
+ /// Default constructor
+ inline RegistryKey();
+
+ /// 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 bool isValid() const;
+
+ /** returns the access mode of the key.
+
+ @return TRUE if access mode is read only else FALSE.
+ */
+ inline 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 relative to this key.
+ @param keyName specifies the name of the key which will be opened or created.
+ @param rNewKey references a RegistryKey which will be filled with the new or open key.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError createKey(const OUString& keyName,
+ RegistryKey& rNewKey);
+
+ /** opens the specified key.
+
+ The specified keyname is relative to this key.
+ @param keyName specifies the name of the key which will be opened.
+ @param rOpenKey references a RegistryKey which will be filled with the open key.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError openKey(const OUString& keyName,
+ RegistryKey& rOpenKey);
+
+ /** opens all subkeys of the specified key.
+
+ The specified keyname is relative to this key.
+ @param keyName specifies the name of the key which subkeys will be opened.
+ @param rSubKeys reference a RegistryKeyArray which will be filled with the open subkeys.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError openSubKeys(const OUString& keyName,
+ RegistryKeyArray& rSubKeys);
+
+ /** returns an array with the names of all subkeys of the specified key.
+
+ The specified keyname is relative to this key.
+ @param keyName specifies the name of the key which subkey names will be returned.
+ @param rSubKeyNames reference a RegistryKeyNames array which will be filled with the subkey names.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError getKeyNames(const OUString& keyName,
+ RegistryKeyNames& rSubKeyNames);
+
+ /** deletes the specified key.
+
+ @param keyName specifies the name of the key which will be deleted.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError deleteKey(const OUString& keyName);
+
+ /// closes explicitly the current key
+ inline RegError closeKey();
+
+ /// 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 RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError setValue(const OUString& keyName,
+ RegValueType valueType,
+ RegValue pValue,
+ sal_uInt32 valueSize);
+
+ /** sets a long list value of a key.
+
+ @param keyName specifies the name of the key which value will be set.
+ If keyName is an empty string, the value will be set for the key
+ specified by hKey.
+ @param pValueList points to an array of longs containing the data for the value.
+ @param len specifies the length of the list (the array referenced by pValueList).
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError setLongListValue(const OUString& keyName,
+ sal_Int32 const * pValueList,
+ sal_uInt32 len);
+
+ /** sets an ascii list value of a key.
+
+ @param keyName specifies the name of the key which value will be set.
+ If keyName is an empty string, the value will be set for the key
+ specified by hKey.
+ @param pValueList points to an array of char* containing the data for the value.
+ @param len specifies the length of the list (the array referenced by pValueList).
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError setStringListValue(const OUString& keyName,
+ char** pValueList,
+ sal_uInt32 len);
+
+ /** sets a unicode string list value of a key.
+
+ @param keyName specifies the name of the key which value will be set.
+ If keyName is an empty string, the value will be set for the key
+ specified by hKey.
+ @param pValueList points to an array of sal_Unicode* containing the data for the value.
+ @param len specifies the length of the list (the array referenced by pValueList).
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError setUnicodeListValue(const OUString& keyName,
+ sal_Unicode** pValueList,
+ sal_uInt32 len);
+
+ /** gets info about type and size of a value.
+
+ @param keyName specifies the name of the key which value info will be returned.
+ If keyName is an empty string, the value info of the key
+ specified by hKey will be returned.
+ @param pValueType returns the type of the value.
+ @param pValueSize returns the size of the value in bytes or the length of a list value.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError getValueInfo(const OUString& keyName,
+ RegValueType* pValueType,
+ sal_uInt32* pValueSize);
+
+ /** gets the value of a key.
+
+ @param keyName specifies the name of the key which value will be returned.
+ If keyName is an empty string, the value is get from the key
+ specified by hKey.
+ @param pValue points to an allocated memory block receiving the data of the value.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError getValue(const OUString& keyName,
+ RegValue pValue);
+
+ /** gets a long list value of a key.
+
+ @param keyName specifies the name of the key which value will be returned.
+ If keyName is an empty string, the value is get from the key
+ specified by hKey.
+ @param rValueList references a RegistryValueList which will be filled with the long values.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError getLongListValue(const OUString& keyName,
+ RegistryValueList<sal_Int32>& rValueList);
+
+ /** gets an ascii list value of a key.
+
+ @param keyName specifies the name of the key which value will be returned.
+ If keyName is an empty string, the value is get from the key
+ specified by hKey.
+ @param rValueList references a RegistryValueList which will be filled with the ascii values.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError getStringListValue(const OUString& keyName,
+ RegistryValueList<char*>& rValueList);
+
+ /** gets a unicode value of a key.
+
+ @param keyName specifies the name of the key which value will be returned.
+ If keyName is an empty string, the value is get from the key
+ specified by hKey.
+ @param rValueList reference a RegistryValueList which will be filled with the unicode values.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError getUnicodeListValue(const OUString& keyName,
+ RegistryValueList<sal_Unicode*>& rValueList);
+
+ /** resolves a keyname.
+
+ @param[in] keyName specifies the name of the key which will be resolved relative to this key.
+ The resolved name will be prefixed with the name of this key.
+ @param[out] rResolvedName the resolved name.
+ @return RegError::NO_ERROR if succeeds else an error code.
+ */
+ inline RegError getResolvedKeyName(const OUString& keyName,
+ OUString& rResolvedName) const;
+
+ /// returns the name of the registry in which the key is defined.
+ inline OUString getRegistryName();
+
+ friend class Registry;
+public:
+ /// @cond INTERNAL
+
+ /** Constructor, which initialize a RegistryKey with registry and a valid key handle.
+
+ This constructor is internal only.
+ */
+ inline RegistryKey(Registry const & registry,
+ RegKeyHandle hKey);
+
+private:
+ /** sets the internal registry on which this key should work.
+ */
+ inline void setRegistry(Registry const & registry);
+
+ /// @endcond
+
+ /// stores the registry on which this key works
+ Registry m_registry;
+ /// stores the current key handle of this key
+ RegKeyHandle m_hImpl;
+};
+
+
+inline RegistryKeyArray::RegistryKeyArray()
+ : m_length(0)
+ , m_phKeys(nullptr)
+{
+}
+
+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() const
+{
+ return m_length;
+}
+
+inline void RegistryKeyArray::setKeyHandles(Registry const & registry,
+ RegKeyHandle* phKeys,
+ sal_uInt32 length)
+{
+ m_phKeys = phKeys;
+ m_length = length;
+ m_registry = registry;
+}
+
+inline RegistryKeyNames::RegistryKeyNames()
+ : m_length(0)
+ , m_pKeyNames(nullptr)
+{
+}
+
+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() const
+{
+ return m_length;
+}
+
+inline void RegistryKeyNames::setKeyNames(Registry const & registry,
+ rtl_uString** pKeyNames,
+ sal_uInt32 length)
+{
+ m_pKeyNames = pKeyNames;
+ m_length = length;
+ m_registry = registry;
+}
+
+inline RegistryKey::RegistryKey()
+ : m_hImpl(nullptr)
+ { }
+
+/// @cond INTERNAL
+inline RegistryKey::RegistryKey(Registry const & 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 const & 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 bool RegistryKey::isValid() const
+ { return (m_hImpl != nullptr); }
+
+inline bool RegistryKey::isReadOnly() const
+ {
+ if (m_registry.isValid())
+ return m_registry.m_pApi->isKeyReadOnly(m_hImpl);
+ else
+ return 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 == RegError::NO_ERROR) rNewKey.setRegistry(m_registry);
+ return ret;
+ } else
+ return RegError::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 == RegError::NO_ERROR) rOpenKey.setRegistry(m_registry);
+ return ret;
+ } else
+ return RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::openSubKeys(const OUString& keyName,
+ RegistryKeyArray& rSubKeys)
+ {
+ if (m_registry.isValid())
+ {
+ RegError ret = RegError::NO_ERROR;
+ RegKeyHandle* pSubKeys;
+ sal_uInt32 nSubKeys;
+ ret = m_registry.m_pApi->openSubKeys(m_hImpl, keyName.pData,
+ &pSubKeys, &nSubKeys);
+ if ( ret != RegError::NO_ERROR)
+ {
+ return ret;
+ } else
+ {
+ rSubKeys.setKeyHandles(m_registry, pSubKeys, nSubKeys);
+ return ret;
+ }
+ } else
+ return RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::getKeyNames(const OUString& keyName,
+ RegistryKeyNames& rSubKeyNames)
+ {
+ if (m_registry.isValid())
+ {
+ RegError ret = RegError::NO_ERROR;
+ rtl_uString** pSubKeyNames;
+ sal_uInt32 nSubKeys;
+ ret = m_registry.m_pApi->getKeyNames(m_hImpl, keyName.pData,
+ &pSubKeyNames, &nSubKeys);
+ if ( ret != RegError::NO_ERROR)
+ {
+ return ret;
+ } else
+ {
+ rSubKeyNames.setKeyNames(m_registry, pSubKeyNames, nSubKeys);
+ return ret;
+ }
+ } else
+ return RegError::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 RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::closeKey()
+ {
+ if (m_registry.isValid())
+ {
+ RegError ret = m_registry.m_pApi->closeKey(m_hImpl);
+ if (ret == RegError::NO_ERROR)
+ {
+ m_hImpl = nullptr;
+ m_registry = Registry();
+ }
+ return ret;
+ } else
+ return RegError::INVALID_KEY;
+ }
+
+inline void RegistryKey::releaseKey()
+{
+ if (m_registry.isValid() && (m_hImpl != nullptr))
+ {
+ m_registry.m_pApi->releaseKey(m_hImpl);
+ m_hImpl = nullptr;
+ }
+}
+
+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 RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::setLongListValue(const OUString& keyName,
+ sal_Int32 const * pValueList,
+ sal_uInt32 len)
+ {
+ if (m_registry.isValid())
+ return m_registry.m_pApi->setLongListValue(m_hImpl, keyName.pData,
+ pValueList, len);
+ else
+ return RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::setStringListValue(const OUString& keyName,
+ char** pValueList,
+ sal_uInt32 len)
+ {
+ if (m_registry.isValid())
+ return m_registry.m_pApi->setStringListValue(m_hImpl, keyName.pData,
+ pValueList, len);
+ else
+ return RegError::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 RegError::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 RegError::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 RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::getLongListValue(const OUString& keyName,
+ RegistryValueList<sal_Int32>& rValueList)
+ {
+ if (m_registry.isValid())
+ {
+ RegError ret = RegError::NO_ERROR;
+ sal_Int32* pValueList;
+ sal_uInt32 length;
+ ret = m_registry.m_pApi->getLongListValue(m_hImpl, keyName.pData,
+ &pValueList, &length);
+ if ( ret != RegError::NO_ERROR)
+ {
+ return ret;
+ } else
+ {
+ rValueList.setValueList(m_registry, RegValueType::LONGLIST,
+ pValueList, length);
+ return ret;
+ }
+ } else
+ return RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::getStringListValue(const OUString& keyName,
+ RegistryValueList<char*>& rValueList)
+ {
+ if (m_registry.isValid())
+ {
+ RegError ret = RegError::NO_ERROR;
+ char** pValueList;
+ sal_uInt32 length;
+ ret = m_registry.m_pApi->getStringListValue(m_hImpl, keyName.pData,
+ &pValueList, &length);
+ if ( ret != RegError::NO_ERROR )
+ {
+ return ret;
+ } else
+ {
+ rValueList.setValueList(m_registry, RegValueType::STRINGLIST,
+ pValueList, length);
+ return ret;
+ }
+ } else
+ return RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::getUnicodeListValue(const OUString& keyName,
+ RegistryValueList<sal_Unicode*>& rValueList)
+ {
+ if (m_registry.isValid())
+ {
+ RegError ret = RegError::NO_ERROR;
+ sal_Unicode** pValueList;
+ sal_uInt32 length;
+ ret = m_registry.m_pApi->getUnicodeListValue(m_hImpl, keyName.pData,
+ &pValueList, &length);
+ if ( ret != RegError::NO_ERROR )
+ {
+ return ret;
+ } else
+ {
+ rValueList.setValueList(m_registry, RegValueType::UNICODELIST,
+ pValueList, length);
+ return ret;
+ }
+ } else
+ return RegError::INVALID_KEY;
+ }
+
+inline RegError RegistryKey::getResolvedKeyName(const OUString& keyName,
+ OUString& rResolvedName) const
+ {
+ if (m_registry.isValid())
+ return m_registry.m_pApi->getResolvedKeyName(m_hImpl,
+ keyName.pData,
+ true,
+ &rResolvedName.pData);
+ else
+ return RegError::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(nullptr)
+ { }
+
+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 bool Registry::isValid() const
+ { return ( m_hImpl != nullptr ); }
+
+inline 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 == RegError::NO_ERROR)
+ m_hImpl = nullptr;
+ return ret;
+ }
+
+inline RegError Registry::destroy(const OUString& registryName)
+ {
+ RegError ret = m_pApi->destroyRegistry(m_hImpl, registryName.pData);
+ if ( ret == RegError::NO_ERROR && registryName.isEmpty() )
+ m_hImpl = nullptr;
+ return ret;
+ }
+
+inline RegError Registry::mergeKey(RegistryKey& rKey,
+ const OUString& keyName,
+ const OUString& regFileName,
+ bool bReport)
+ { return m_pApi->mergeKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData, false/*bWarnings*/, bReport); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/registry/regtype.h b/include/registry/regtype.h
new file mode 100644
index 000000000..89fdcc940
--- /dev/null
+++ b/include/registry/regtype.h
@@ -0,0 +1,141 @@
+/* -*- 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_REGTYPE_H
+#define INCLUDED_REGISTRY_REGTYPE_H
+
+#include <sal/types.h>
+#include <o3tl/typed_flags_set.hxx>
+
+/// 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:
+ -READONLY allows readonly access
+ -READWRITE allows read and write access
+ */
+enum class RegAccessMode
+{
+ READONLY = 0x0001, /// This mode allows readonly access.
+ READWRITE = 0x0002 /// This mode allows read and write access.
+};
+namespace o3tl
+{
+template <> struct typed_flags<RegAccessMode> : is_typed_flags<RegAccessMode, 0x03>
+{
+};
+}
+
+/** 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 possibility
+ 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 class SAL_DLLPUBLIC_RTTI RegValueType
+{
+ /// The key has no value or the value type is unknown.
+ NOT_DEFINED,
+ /// The key has a value of type long
+ LONG,
+ /// The key has a value of type ascii string
+ STRING,
+ /// The key has a value of type unicode string
+ UNICODE,
+ /// The key has a value of type binary
+ BINARY,
+ /// The key has a value of type long list
+ LONGLIST,
+ /// The key has a value of type ascii string list
+ STRINGLIST,
+ /// The key has a value of type unicode string list
+ UNICODELIST
+};
+
+/// specifies the possible error codes which can occur using the registry API.
+enum class SAL_DLLPUBLIC_RTTI RegError
+{
+ /// no error.
+ NO_ERROR,
+
+ /// registry is not open.
+ REGISTRY_NOT_OPEN,
+ /// registry does not exists.
+ REGISTRY_NOT_EXISTS,
+ /// registry is open with readonly access rights.
+ REGISTRY_READONLY,
+ /// destroy a registry failed. There are may be any open keys.
+ DESTROY_REGISTRY_FAILED,
+ /** registry cannot be opened with readwrite access because the registry is already
+ open with readwrite access anywhere.
+ */
+ CANNOT_OPEN_FOR_READWRITE,
+ /** registry is in an invalid state or the registry does not point to
+ a valid registry data file.
+ */
+ INVALID_REGISTRY,
+
+ /// the key or key handle points to an invalid key or closed key.
+ KEY_NOT_OPEN,
+ /// the specified keyname points to a nonexisting key.
+ KEY_NOT_EXISTS,
+ /// the key with the specified keyname cannot be created.
+ CREATE_KEY_FAILED,
+ /// the specified key cannot be deleted. Maybe an open key handle exists to this key.
+ 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.
+ */
+ INVALID_KEYNAME,
+ /// the key is not in a valid state.
+ INVALID_KEY,
+
+ /// the key has no value
+ VALUE_NOT_EXISTS,
+ /// setting the specified value of a key failed.
+ SET_VALUE_FAILED,
+ /// deleting of the key value failed.
+ DELETE_VALUE_FAILED,
+ /// the key has an invalid value or the value type is unknown.
+ INVALID_VALUE,
+
+ /// merging a key, the value and all subkeys failed.
+ 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.
+ */
+ MERGE_CONFLICT,
+};
+
+/// 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/typereg_reader.hxx b/include/registry/typereg_reader.hxx
new file mode 100644
index 000000000..a0af800f0
--- /dev/null
+++ b/include/registry/typereg_reader.hxx
@@ -0,0 +1,565 @@
+/* -*- 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.hxx>
+#include <registry/version.h>
+
+#include <rtl/ustring.h>
+#include <sal/types.h>
+
+/**
+ 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&ndash;safe.</p>
+
+ The type reader works directly on the given buffer, which must remain
+ available unmodified until the type reader is destroyed
+
+ @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 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 bool typereg_reader_create(
+ void const * buffer, sal_uInt32 length,
+ void ** result);
+
+/**
+ 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 typereg_reader_acquire(void * handle);
+
+/**
+ 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 typereg_reader_release(void * handle);
+
+/**
+ 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 typereg_Version typereg_reader_getVersion(void const * handle);
+
+/**
+ 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 typereg_reader_getDocumentation(
+ void * handle, rtl_uString ** result);
+
+/**
+ 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 typereg_reader_getFileName(void * handle, rtl_uString ** result);
+
+/**
+ 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 RTTypeClass typereg_reader_getTypeClass(void * handle);
+
+/**
+ 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,
+ false is returned
+
+ @since UDK 3.2.0
+ */
+REG_DLLPUBLIC bool typereg_reader_isPublished(void * handle);
+
+/**
+ 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 typereg_reader_getTypeName(void * handle, rtl_uString ** result);
+
+/**
+ 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 typereg_reader_getSuperTypeCount(void * handle);
+
+/**
+ 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 typereg_reader_getSuperTypeName(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getFieldCount(void * handle);
+
+/**
+ 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 typereg_reader_getFieldDocumentation(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getFieldFileName(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getFieldFlags(
+ void * handle, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getFieldName(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getFieldTypeName(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 bool typereg_reader_getFieldValue(
+ void * handle, sal_uInt16 index, RTValueType * type,
+ union RTConstValueUnion * value);
+
+/**
+ 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 typereg_reader_getMethodCount(void * handle);
+
+/**
+ 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 typereg_reader_getMethodDocumentation(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 RTMethodMode typereg_reader_getMethodFlags(
+ void * handle, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getMethodName(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getMethodReturnTypeName(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getMethodParameterCount(
+ void * handle, sal_uInt16 index);
+
+/**
+ 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 RTParamMode typereg_reader_getMethodParameterFlags(
+ void * handle, sal_uInt16 methodIndex, sal_uInt16 parameterIndex);
+
+/**
+ 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 typereg_reader_getMethodParameterName(
+ void * handle, rtl_uString ** result, sal_uInt16 methodIndex,
+ sal_uInt16 parameterIndex);
+
+/**
+ 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 typereg_reader_getMethodParameterTypeName(
+ void * handle, rtl_uString ** result, sal_uInt16 methodIndex,
+ sal_uInt16 parameterIndex);
+
+/**
+ 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 typereg_reader_getMethodExceptionCount(
+ void * handle, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getMethodExceptionTypeName(
+ void * handle, rtl_uString ** result, sal_uInt16 methodIndex,
+ sal_uInt16 exceptionIndex);
+
+/**
+ 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 typereg_reader_getReferenceCount(void * handle);
+
+/**
+ 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 typereg_reader_getReferenceDocumentation(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getReferenceFlags(
+ void * handle, sal_uInt16 index);
+
+/**
+ 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 RTReferenceType typereg_reader_getReferenceSort(
+ void * handle, sal_uInt16 index);
+
+/**
+ 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 typereg_reader_getReferenceTypeName(
+ void * handle, rtl_uString ** result, sal_uInt16 index);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/registry/types.hxx b/include/registry/types.hxx
new file mode 100644
index 000000000..a9763f5ea
--- /dev/null
+++ b/include/registry/types.hxx
@@ -0,0 +1,339 @@
+/* -*- 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>
+#include <o3tl/typed_flags_set.hxx>
+
+/** 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 properties can have several flags.
+
+ @see RTFieldAccess::INVALID
+ @see RTFieldAccess::READONLY
+ @see RTFieldAccess::OPTIONAL
+ @see RTFieldAccess::MAYBEVOID
+ @see RTFieldAccess::BOUND
+ @see RTFieldAccess::CONSTRAINED
+ @see RTFieldAccess::TRANSIENT
+ @see RTFieldAccess::MAYBEAMBIGUOUS
+ @see RTFieldAccess::MAYBEDEFAULT
+ @see RTFieldAccess::REMOVABLE
+ @see RTFieldAccess::ATTRIBUTE
+ @see RTFieldAccess::PROPERTY
+ @see RTFieldAccess::CONST
+ @see RTFieldAccess::READWRITE
+ @see RTFieldAccess::DEFAULT
+ @see RTFieldAccess::PARAMETERIZED_TYPE
+ @see RTFieldAccess::PUBLISHED
+ */
+enum class RTFieldAccess
+{
+ NONE = 0x0000,
+ /// specifies an unknown flag
+ INVALID = 0x0000,
+ /// specifies a readonly property/attribute
+ READONLY = 0x0001,
+ /// specifies a property as optional that means that it must not be implemented.
+ OPTIONAL = 0x0002,
+ /// @see com::sun::star::beans::PropertyAttribute
+ MAYBEVOID = 0x0004,
+ /// @see com::sun::star::beans::PropertyAttribute
+ BOUND = 0x0008,
+ /// @see com::sun::star::beans::PropertyAttribute
+ CONSTRAINED = 0x0010,
+ /// @see com::sun::star::beans::PropertyAttribute
+ TRANSIENT = 0x0020,
+ /// @see com::sun::star::beans::PropertyAttribute
+ MAYBEAMBIGUOUS = 0x0040,
+ /// @see com::sun::star::beans::PropertyAttribute
+ MAYBEDEFAULT = 0x0080,
+ /// @see com::sun::star::beans::PropertyAttribute
+ REMOVABLE = 0x0100,
+ /// @see com::sun::star::beans::PropertyAttribute
+ ATTRIBUTE = 0x0200,
+ /// specifies that the field is a property
+ PROPERTY = 0x0400,
+ /// specifies that the field is a constant or enum value
+ CONST = 0x0800,
+ /// specifies that the property/attribute has read/write access
+ READWRITE = 0x1000,
+ /// only to describe a union default label
+ 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
+ */
+ PARAMETERIZED_TYPE = 0x4000,
+ /**
+ Flag for published individual constants.
+
+ Used in combination with RTFieldAccess::CONST for individual constants (which are
+ not members of constant groups).
+
+ @since UDK 3.2.0
+ */
+ PUBLISHED = 0x8000,
+
+};
+namespace o3tl
+{
+template <> struct typed_flags<RTFieldAccess> : is_typed_flags<RTFieldAccess, 0xffff>
+{
+};
+}
+
+/** specifies the type of a field value.
+
+ A field can have a value if it represents 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 {
+ 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 class RTMethodMode
+{
+ /// indicates an invalid mode
+ INVALID,
+
+ /// indicates the asynchronous mode of a method
+ ONEWAY,
+
+ /// @deprecated
+ ONEWAY_CONST,
+
+ /// indicated the synchronous mode of a method
+ TWOWAY,
+
+ /// @deprecated
+ TWOWAY_CONST,
+
+ /**
+ Indicates an extended attribute getter (that has a 'raises' clause) of an
+ interface type.
+
+ @since UDK 3.2.0
+ */
+ ATTRIBUTE_GET,
+
+ /**
+ Indicates an extended attribute setter (that has a 'raises' clause) of an
+ interface type.
+
+ @since UDK 3.2.0
+ */
+ ATTRIBUTE_SET
+};
+
+/** specifies the mode of a parameter.
+
+ There are three parameter modes which have impact of the handling of the
+ parameter 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 class RTReferenceType
+{
+ /// the reference type is unknown
+ INVALID,
+
+ /** the service support the interface that means an implementation of this
+ service must implement this interface.
+ */
+ SUPPORTS,
+
+ /** @deprecated
+ the service observes the interface.
+ */
+ OBSERVES,
+
+ /** the service exports the specified service that means this service
+ provides also the specified service.
+ */
+ 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.
+ */
+ NEEDS,
+
+ /**
+ Indicates a type parameter of a polymorphic struct type template.
+
+ @since UDK 3.2.0
+ */
+ TYPE_PARAMETER
+};
+
+#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 000000000..b7c066d41
--- /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&ndash;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 000000000..8f07437c5
--- /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.hxx>
+#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&ndash;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 * 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 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 occurred, in which case the type
+ writer is not modified
+
+ @since UDK 3.2.0
+ */
+REG_DLLPUBLIC sal_Bool typereg_writer_setSuperTypeName(
+ void const * 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 occurred, in which case the type
+ writer is not modified
+
+ @since UDK 3.2.0
+ */
+REG_DLLPUBLIC sal_Bool 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 occurred, in which case the type
+ writer is not modified
+
+ @since UDK 3.2.0
+ */
+REG_DLLPUBLIC sal_Bool 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 occurred, in which case the type
+ writer is not modified
+
+ @since UDK 3.2.0
+ */
+REG_DLLPUBLIC sal_Bool typereg_writer_setMethodParameterData(
+ void const * 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 occurred, in which case the type
+ writer is not modified
+
+ @since UDK 3.2.0
+ */
+REG_DLLPUBLIC sal_Bool typereg_writer_setMethodExceptionTypeName(
+ void const * 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 occurred, in which case the type
+ writer is not modified
+
+ @since UDK 3.2.0
+ */
+REG_DLLPUBLIC sal_Bool 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 * 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 000000000..4bf672461
--- /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.hxx>
+#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&ndash;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 == nullptr) {
+ 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) const
+ {
+ 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>size</code> is not modified
+ */
+ void const * getBlob(sal_uInt32 * size) {
+ void const * p = typereg_writer_getBlob(m_handle, size);
+ if (p == nullptr) {
+ throw std::bad_alloc();
+ }
+ return p;
+ }
+
+private:
+ Writer(Writer const &) = delete;
+ Writer& operator =(Writer const &) = delete;
+
+ void * m_handle;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */