Bump version to 6.4-15
[LibreOffice.git] / include / registry / writer.hxx
blob4bf6724610cf474e2b7e78e0a22b16236506d110
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_REGISTRY_WRITER_HXX
21 #define INCLUDED_REGISTRY_WRITER_HXX
23 #include <registry/writer.h>
24 #include <registry/refltype.hxx>
25 #include <registry/types.hxx>
26 #include <registry/version.h>
28 #include <rtl/ustring.hxx>
29 #include <sal/types.h>
31 #include <new>
33 namespace typereg {
35 /**
36 A type writer working on a binary blob that represents a UNOIDL type.
38 <p>Instances of this class are not multi-thread&ndash;safe.</p>
40 @since UDK 3.2.0
42 class Writer {
43 public:
44 /**
45 Creates a type writer.
47 @param version the version of the created type writer; must not be
48 negative
50 @param documentation the documentation
52 @param fileName the file name (deprecated, use an empty string)
54 @param typeClass the type class of the created type writer
56 @param published whether the created type writer is published; for a type
57 class that cannot be published, this should be false
59 @param typeName the type name of the created type writer
61 @param superTypeCount the number of super types of the created type
62 writer
64 @param fieldCount the number of fields of the created type writer
66 @param methodCount the number of methods of the created type writer
68 @param referenceCount the number of references of the created type writer
70 @exception std::bad_alloc is raised if an out-of-memory condition occurs
72 Writer(
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(
79 typereg_writer_create(
80 version, documentation.pData, fileName.pData, typeClass,
81 published, typeName.pData, superTypeCount, fieldCount,
82 methodCount, referenceCount))
84 if (m_handle == nullptr) {
85 throw std::bad_alloc();
89 /**
90 Destroys this <code>Writer</code> instance.
92 ~Writer() {
93 typereg_writer_destroy(m_handle);
96 /**
97 Sets the type name of a super type of this type writer.
99 @param index a valid index into the range of super types of this type
100 writer
102 @param typeName the super type name
104 @exception std::bad_alloc is raised if an out-of-memory condition occurs
106 void setSuperTypeName(sal_uInt16 index, OUString const & typeName) {
107 if (!typereg_writer_setSuperTypeName(m_handle, index, typeName.pData)) {
108 throw std::bad_alloc();
113 Sets the data of a field of this type writer.
115 @param index a valid index into the range of fields of this type writer
117 @param documentation the documentation of the field
119 @param fileName the file name of the field (deprecated, use an empty string)
121 @param flags the flags of the field
123 @param name the name of the field
125 @param typeName the type name of the field
127 @param value the value of the field
129 @exception std::bad_alloc is raised if an out-of-memory condition occurs
131 void setFieldData(
132 sal_uInt16 index, OUString const & documentation,
133 OUString const & fileName, RTFieldAccess flags, OUString const & name,
134 OUString const & typeName, RTConstValue const & value)
136 if (!typereg_writer_setFieldData(
137 m_handle, index, documentation.pData, fileName.pData, flags,
138 name.pData, typeName.pData, value.m_type, value.m_value))
140 throw std::bad_alloc();
145 Sets the data of a method of this type writer.
147 @param index a valid index into the range of methods of this type writer
149 @param documentation the documentation of the method
151 @param flags the flags of the method
153 @param name the name of the method
155 @param returnTypeName the return type name of the method
157 @param parameterCount the number of parameters of the method
159 @param exceptionCount the number of exceptions of the method
161 @exception std::bad_alloc is raised if an out-of-memory condition occurs
163 void setMethodData(
164 sal_uInt16 index, OUString const & documentation,
165 RTMethodMode flags, OUString const & name,
166 OUString const & returnTypeName, sal_uInt16 parameterCount,
167 sal_uInt16 exceptionCount)
169 if (!typereg_writer_setMethodData(
170 m_handle, index, documentation.pData, flags, name.pData,
171 returnTypeName.pData, parameterCount, exceptionCount))
173 throw std::bad_alloc();
178 Sets the data of a parameter of a method of this type writer.
180 @param methodIndex a valid index into the range of methods of this type
181 writer
183 @param parameterIndex a valid index into the range of parameters of the
184 given method
186 @param flags the flags of the parameter
188 @param name the name of the parameter
190 @param typeName the type name of the parameter
192 @exception std::bad_alloc is raised if an out-of-memory condition occurs
194 void setMethodParameterData(
195 sal_uInt16 methodIndex, sal_uInt16 parameterIndex,
196 RTParamMode flags, OUString const & name,
197 OUString const & typeName) const
199 if (!typereg_writer_setMethodParameterData(
200 m_handle, methodIndex, parameterIndex, flags, name.pData,
201 typeName.pData))
203 throw std::bad_alloc();
208 Sets an exception type name of a method of this type writer.
210 @param methodIndex a valid index into the range of methods of this type
211 writer
213 @param exceptionIndex a valid index into the range of exceptions of the
214 given method
216 @param typeName the exception type name
218 @exception std::bad_alloc is raised if an out-of-memory condition occurs
220 void setMethodExceptionTypeName(
221 sal_uInt16 methodIndex, sal_uInt16 exceptionIndex,
222 OUString const & typeName)
224 if (!typereg_writer_setMethodExceptionTypeName(
225 m_handle, methodIndex, exceptionIndex, typeName.pData))
227 throw std::bad_alloc();
232 Sets the data of a reference of this type writer.
234 @param index a valid index into the range of references of this type
235 writer
237 @param documentation the documentation of the reference
239 @param sort the sort of the reference
241 @param flags the flags of the reference
243 @param typeName the type name of the reference
245 @exception std::bad_alloc is raised if an out-of-memory condition occurs
247 void setReferenceData(
248 sal_uInt16 index, OUString const & documentation,
249 RTReferenceType sort, RTFieldAccess flags,
250 OUString const & typeName)
252 if (!typereg_writer_setReferenceData(
253 m_handle, index, documentation.pData, sort, flags,
254 typeName.pData))
256 throw std::bad_alloc();
261 Returns the blob of this type writer.
263 @param size an out-parameter obtaining the size of the blob
265 @return a (byte-aligned) pointer to the blob; the returned pointer and
266 the returned <code>size</code> remain valid until the next function is
267 called on this type writer
269 @exception std::bad_alloc is raised if an out-of-memory condition occurs
270 (in which case <code>size</code> is not modified
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();
277 return p;
280 private:
281 Writer(Writer const &) = delete;
282 Writer& operator =(Writer const &) = delete;
284 void * m_handle;
289 #endif
291 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */