LibreOffice Module registry (master)  1
writer.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_REGISTRY_WRITER_HXX
21 #define INCLUDED_REGISTRY_WRITER_HXX
22 
23 #include <registry/writer.h>
24 #include <registry/refltype.hxx>
25 #include <registry/types.hxx>
26 #include <registry/version.h>
27 
28 #include <rtl/ustring.hxx>
29 #include <sal/types.h>
30 
31 #include <new>
32 
33 namespace typereg {
34 
42 class Writer {
43 public:
73  typereg_Version version, OUString const & documentation,
74  OUString const & fileName, RTTypeClass typeClass, bool published,
75  OUString const & typeName, sal_uInt16 superTypeCount,
76  sal_uInt16 fieldCount, sal_uInt16 methodCount,
77  sal_uInt16 referenceCount):
78  m_handle(
80  version, documentation.pData, fileName.pData, typeClass,
81  published, typeName.pData, superTypeCount, fieldCount,
82  methodCount, referenceCount))
83  {
84  if (m_handle == nullptr) {
85  throw std::bad_alloc();
86  }
87  }
88 
92  ~Writer() {
94  }
95 
106  void setSuperTypeName(sal_uInt16 index, OUString const & typeName) {
107  if (!typereg_writer_setSuperTypeName(m_handle, index, typeName.pData)) {
108  throw std::bad_alloc();
109  }
110  }
111 
132  sal_uInt16 index, OUString const & documentation,
133  OUString const & fileName, RTFieldAccess flags, OUString const & name,
134  OUString const & typeName, RTConstValue const & value)
135  {
137  m_handle, index, documentation.pData, fileName.pData, flags,
138  name.pData, typeName.pData, value.m_type, value.m_value))
139  {
140  throw std::bad_alloc();
141  }
142  }
143 
164  sal_uInt16 index, OUString const & documentation,
165  RTMethodMode flags, OUString const & name,
166  OUString const & returnTypeName, sal_uInt16 parameterCount,
167  sal_uInt16 exceptionCount)
168  {
170  m_handle, index, documentation.pData, flags, name.pData,
171  returnTypeName.pData, parameterCount, exceptionCount))
172  {
173  throw std::bad_alloc();
174  }
175  }
176 
195  sal_uInt16 methodIndex, sal_uInt16 parameterIndex,
196  RTParamMode flags, OUString const & name,
197  OUString const & typeName) const
198  {
200  m_handle, methodIndex, parameterIndex, flags, name.pData,
201  typeName.pData))
202  {
203  throw std::bad_alloc();
204  }
205  }
206 
221  sal_uInt16 methodIndex, sal_uInt16 exceptionIndex,
222  OUString const & typeName)
223  {
225  m_handle, methodIndex, exceptionIndex, typeName.pData))
226  {
227  throw std::bad_alloc();
228  }
229  }
230 
248  sal_uInt16 index, OUString const & documentation,
249  RTReferenceType sort, RTFieldAccess flags,
250  OUString const & typeName)
251  {
253  m_handle, index, documentation.pData, sort, flags,
254  typeName.pData))
255  {
256  throw std::bad_alloc();
257  }
258  }
259 
272  void const * getBlob(sal_uInt32 * size) {
273  void const * p = typereg_writer_getBlob(m_handle, size);
274  if (p == nullptr) {
275  throw std::bad_alloc();
276  }
277  return p;
278  }
279 
280 private:
281  Writer(Writer const &) = delete;
282  Writer& operator =(Writer const &) = delete;
283 
284  void * m_handle;
285 };
286 
287 }
288 
289 #endif
290 
291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setMethodExceptionTypeName(sal_uInt16 methodIndex, sal_uInt16 exceptionIndex, OUString const &typeName)
Sets an exception type name of a method of this type writer.
Definition: writer.hxx:220
RTParamMode
specifies the mode of a parameter.
Definition: types.hxx:269
RTReferenceType
specifies the type of a reference used in a service description.
Definition: types.hxx:297
void TYPEREG_CALLTYPE typereg_writer_destroy(void *handle) SAL_THROW_EXTERN_C()
Destroys a type writer.
Definition: reflwrit.cxx:1262
std::unique_ptr< ContentProperties > pData
RTValueType m_type
stores the type of the constant value.
Definition: refltype.hxx:46
sal_Bool TYPEREG_CALLTYPE 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 field of a type writer.
Definition: reflwrit.cxx:1123
sal_Bool TYPEREG_CALLTYPE typereg_writer_setMethodExceptionTypeName(void const *handle, sal_uInt16 methodIndex, sal_uInt16 exceptionIndex, rtl_uString const *typeName) SAL_THROW_EXTERN_C()
Sets an exception type name of a method of a type writer.
Definition: reflwrit.cxx:1188
void setMethodParameterData(sal_uInt16 methodIndex, sal_uInt16 parameterIndex, RTParamMode flags, OUString const &name, OUString const &typeName) const
Sets the data of a parameter of a method of this type writer.
Definition: writer.hxx:194
typereg_Version
The version of a binary blob that represents a UNOIDL type.
Definition: version.h:41
RTConstValueUnion m_value
stores the value of the constant.
Definition: refltype.hxx:48
void setReferenceData(sal_uInt16 index, OUString const &documentation, RTReferenceType sort, RTFieldAccess flags, OUString const &typeName)
Sets the data of a reference of this type writer.
Definition: writer.hxx:247
void const *TYPEREG_CALLTYPE typereg_writer_getBlob(void *handle, sal_uInt32 *size) SAL_THROW_EXTERN_C()
Returns the blob of a type writer.
Definition: reflwrit.cxx:1202
A type writer working on a binary blob that represents a UNOIDL type.
Definition: writer.hxx:42
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)
Creates a type writer.
Definition: writer.hxx:72
void setMethodData(sal_uInt16 index, OUString const &documentation, RTMethodMode flags, OUString const &name, OUString const &returnTypeName, sal_uInt16 parameterCount, sal_uInt16 exceptionCount)
Sets the data of a method of this type writer.
Definition: writer.hxx:163
void * m_handle
Definition: writer.hxx:284
RTTypeClass
specifies the typeclass of a binary type blob.
Definition: types.hxx:31
void const * getBlob(sal_uInt32 *size)
Returns the blob of this type writer.
Definition: writer.hxx:272
~Writer()
Destroys this Writer instance.
Definition: writer.hxx:92
Writer & operator=(Writer const &)=delete
void setSuperTypeName(sal_uInt16 index, OUString const &typeName)
Sets the type name of a super type of this type writer.
Definition: writer.hxx:106
void *TYPEREG_CALLTYPE 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()
Creates a type writer working on a binary blob that represents a UNOIDL type.
Definition: reflwrit.cxx:1245
sal_Bool TYPEREG_CALLTYPE typereg_writer_setReferenceData(void *handle, sal_uInt16 index, rtl_uString const *documentation, RTReferenceType sort, RTFieldAccess flags, rtl_uString const *typeName) SAL_THROW_EXTERN_C()
Sets the data of a reference of a type writer.
Definition: reflwrit.cxx:1231
RTMethodMode
specifies the mode of a method.
Definition: types.hxx:231
sal_Bool TYPEREG_CALLTYPE typereg_writer_setSuperTypeName(void const *handle, sal_uInt16 index, rtl_uString const *typeName) SAL_THROW_EXTERN_C()
Sets the type name of a super type of a type writer.
Definition: reflwrit.cxx:1266
void * p
sal_Bool TYPEREG_CALLTYPE 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 method of a type writer.
Definition: reflwrit.cxx:1156
RTFieldAccess
specifies the type for the field access.
Definition: types.hxx:132
void setFieldData(sal_uInt16 index, OUString const &documentation, OUString const &fileName, RTFieldAccess flags, OUString const &name, OUString const &typeName, RTConstValue const &value)
Sets the data of a field of this type writer.
Definition: writer.hxx:131
sal_Bool TYPEREG_CALLTYPE 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 the data of a parameter of a method of a type writer.
Definition: reflwrit.cxx:1173
specifies a helper class for const values.
Definition: refltype.hxx:42