Line data Source code
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_REFLWRIT_HXX
21 : #define INCLUDED_REGISTRY_REFLWRIT_HXX
22 :
23 : #include <registry/regdllapi.h>
24 : #include <registry/refltype.hxx>
25 : #include <registry/regtype.h>
26 : #include <rtl/ustring.hxx>
27 :
28 : /// Implememetation handle
29 : typedef void* TypeWriterImpl;
30 :
31 : /****************************************************************************
32 :
33 : C-Api
34 :
35 : *****************************************************************************/
36 :
37 : #ifdef __cplusplus
38 : extern "C" {
39 : #endif
40 :
41 : /** specifies a collection of function pointers which represents the complete registry type writer C-API.
42 :
43 : This funtions pointers are used by the C++ wrapper to call the C-API.
44 : */
45 : struct RegistryTypeWriter_Api
46 : {
47 : TypeWriterImpl (TYPEREG_CALLTYPE *createEntry) (RTTypeClass, rtl_uString*, rtl_uString*, sal_uInt16, sal_uInt16, sal_uInt16);
48 : void (TYPEREG_CALLTYPE *acquire) (TypeWriterImpl);
49 : void (TYPEREG_CALLTYPE *release) (TypeWriterImpl);
50 : void (TYPEREG_CALLTYPE *setUik) (TypeWriterImpl, const RTUik*);
51 : void (TYPEREG_CALLTYPE *setDoku) (TypeWriterImpl, rtl_uString*);
52 : void (TYPEREG_CALLTYPE *setFileName) (TypeWriterImpl, rtl_uString*);
53 : void (TYPEREG_CALLTYPE *setFieldData) (TypeWriterImpl, sal_uInt16, rtl_uString*, rtl_uString*, rtl_uString*, rtl_uString*, RTFieldAccess, RTValueType, RTConstValueUnion);
54 : void (TYPEREG_CALLTYPE *setMethodData) (TypeWriterImpl, sal_uInt16, rtl_uString*, rtl_uString*, RTMethodMode, sal_uInt16, sal_uInt16, rtl_uString*);
55 : void (TYPEREG_CALLTYPE *setParamData) (TypeWriterImpl, sal_uInt16, sal_uInt16, rtl_uString*, rtl_uString*, RTParamMode);
56 : void (TYPEREG_CALLTYPE *setExcData) (TypeWriterImpl, sal_uInt16, sal_uInt16, rtl_uString*);
57 : const sal_uInt8* (TYPEREG_CALLTYPE *getBlop) (TypeWriterImpl);
58 : sal_uInt32 (TYPEREG_CALLTYPE *getBlopSize) (TypeWriterImpl);
59 :
60 : void (TYPEREG_CALLTYPE *setReferenceData) (TypeWriterImpl, sal_uInt16, rtl_uString*, RTReferenceType, rtl_uString*, RTFieldAccess);
61 : };
62 :
63 : /** the API initialization function.
64 : */
65 : REG_DLLPUBLIC RegistryTypeWriter_Api* TYPEREG_CALLTYPE initRegistryTypeWriter_Api();
66 :
67 : #ifdef __cplusplus
68 : }
69 : #endif
70 :
71 : /** RegistryTypeWriter writes/creates a binary type blob.
72 :
73 : This class provides the necessary functions to write type information
74 : for all kinds of types into a blob.
75 : The class is inline and use a C-Api.
76 :
77 : @deprecated
78 : use typereg::Writer instead
79 : */
80 : class RegistryTypeWriter
81 : {
82 : public:
83 :
84 : /** Constructor.
85 :
86 : @param RTTypeClass specifies the type of the new blob.
87 : @param typeName specifies the full qualified type name with '/' as separator.
88 : @param superTypeName specifies the full qualified type name of the base type
89 : with '/' as separator.
90 : @param fieldCount specifies the number of fields (eg. number of attrbutes/properties,
91 : enum values or constants).
92 : @param methodCount specifies the number of methods.
93 : @param referenceCount specifies the number of references (eg. number of supported interfaces,
94 : exported services ...)
95 : */
96 : inline RegistryTypeWriter(RTTypeClass RTTypeClass,
97 : const rtl::OUString& typeName,
98 : const rtl::OUString& superTypeName,
99 : sal_uInt16 fieldCount,
100 : sal_uInt16 methodCount,
101 : sal_uInt16 referenceCount);
102 :
103 : /// Copy constructcor
104 : inline RegistryTypeWriter(const RegistryTypeWriter& toCopy);
105 :
106 : /** Destructor. The Destructor frees the internal data block.
107 :
108 : The pointer (returned by getBlop) will be set to NULL.
109 : */
110 : inline ~RegistryTypeWriter();
111 :
112 : /// Assign operator
113 : inline RegistryTypeWriter& operator == (const RegistryTypeWriter& toAssign);
114 :
115 : /** @deprecated
116 : sets the unique identifier for an interface type.
117 :
118 : An earlier version of UNO used an unique identifier for interfaces. In the
119 : current version of UNO this uik was eliminated and this function is
120 : not longer used.
121 : */
122 : inline void setUik(const RTUik& uik);
123 :
124 : /** sets a documentation string for the type.
125 :
126 : This documentation should be the same as the documentation which is provided
127 : for this type in IDL.
128 : */
129 : inline void setDoku(const rtl::OUString& doku);
130 :
131 : /** sets the IDL filename where this type is defined.
132 : */
133 : inline void setFileName(const rtl::OUString& fileName);
134 :
135 : /** sets the data for a field member of a type blob.
136 :
137 : @param index indicates the index of the field.
138 : @param name specifies the name.
139 : @param typeName specifies the full qualified typename.
140 : @param doku specifies the documentation string of the field.
141 : @param fileName specifies the name of the IDL file where the field is defined.
142 : @param access specifies the access mode of the field.
143 : @param constValue specifies the value of the field. The value is only interesting
144 : for enum values or constants.
145 : */
146 : inline void setFieldData( sal_uInt16 index,
147 : const rtl::OUString& name,
148 : const rtl::OUString& typeName,
149 : const rtl::OUString& doku,
150 : const rtl::OUString& fileName,
151 : RTFieldAccess access,
152 : const RTConstValue& constValue = RTConstValue());
153 :
154 : /** sets the data for a method.
155 :
156 : @param index indicates the index of the method.
157 : @param name specifies the name.
158 : @param returnTypeName specifies the full qualified return typename.
159 : @param mode specifies the method mode.
160 : @param paramCount specifies the number of parameters.
161 : @param excCount specifies the number of exceptions.
162 : @param doku specifies the documentation string of the field.
163 : */
164 : inline void setMethodData(sal_uInt16 index,
165 : const rtl::OUString& name,
166 : const rtl::OUString& returnTypeName,
167 : RTMethodMode mode,
168 : sal_uInt16 paramCount,
169 : sal_uInt16 excCount,
170 : const rtl::OUString& doku);
171 :
172 : /** sets the data for the specified parameter of a method.
173 :
174 : @param index indicates the index of the method.
175 : @param paramIndex specifies the index of the parameter.
176 : @param type specifies the full qualified typename.
177 : @param name specifies the name.
178 : @param mode specifies the parameter mode.
179 : */
180 : inline void setParamData(sal_uInt16 index,
181 : sal_uInt16 paramIndex,
182 : const rtl::OUString& type,
183 : const rtl::OUString& name,
184 : RTParamMode mode);
185 :
186 : /** sets the data for the specified exception of a method.
187 :
188 : @param index indicates the index of the method.
189 : @param excIndex specifies the index of the exception.
190 : @param type specifies the full qualified typename of the exception.
191 : */
192 : inline void setExcData(sal_uInt16 index,
193 : sal_uInt16 excIndex,
194 : const rtl::OUString& type);
195 :
196 : /** returns a pointer to the new type blob.
197 :
198 : The pointer will be invalid (NULL) if the instance of
199 : the RegistryTypeWriter will be destroyed.
200 : */
201 : inline const sal_uInt8* getBlop();
202 :
203 : /** returns the size of the new type blob in bytes.
204 : */
205 : inline sal_uInt32 getBlopSize();
206 :
207 : /** sets the data for a reference member.
208 :
209 : @param index indicates the index of the reference.
210 : @param name specifies the name.
211 : @param refType specifies the full qualified typename of the reference.
212 : @param doku specifies the documentation string of the reference.
213 : @param access specifies the access mode of the reference.
214 : */
215 : inline void setReferenceData( sal_uInt16 index,
216 : const rtl::OUString& name,
217 : RTReferenceType refType,
218 : const rtl::OUString& doku,
219 : RTFieldAccess access = RTFieldAccess::INVALID);
220 :
221 : protected:
222 :
223 : /// stores the registry type writer Api.
224 : const RegistryTypeWriter_Api* m_pApi;
225 : /// stores the handle of an implementation class
226 : TypeWriterImpl m_hImpl;
227 : };
228 :
229 :
230 :
231 0 : inline RegistryTypeWriter::RegistryTypeWriter(RTTypeClass RTTypeClass,
232 : const rtl::OUString& typeName,
233 : const rtl::OUString& superTypeName,
234 : sal_uInt16 fieldCount,
235 : sal_uInt16 methodCount,
236 : sal_uInt16 referenceCount)
237 0 : : m_pApi(initRegistryTypeWriter_Api())
238 0 : , m_hImpl(NULL)
239 : {
240 : m_hImpl = m_pApi->createEntry(RTTypeClass,
241 : typeName.pData,
242 : superTypeName.pData,
243 : fieldCount,
244 : methodCount,
245 0 : referenceCount);
246 0 : }
247 :
248 :
249 : inline RegistryTypeWriter::RegistryTypeWriter(const RegistryTypeWriter& toCopy)
250 : : m_pApi(toCopy.m_pApi)
251 : , m_hImpl(toCopy.m_hImpl)
252 : {
253 : m_pApi->acquire(m_hImpl);
254 : }
255 :
256 0 : inline RegistryTypeWriter::~RegistryTypeWriter()
257 : {
258 0 : m_pApi->release(m_hImpl);
259 0 : }
260 :
261 : inline RegistryTypeWriter& RegistryTypeWriter::operator == (const RegistryTypeWriter& toAssign)
262 : {
263 : if (m_hImpl != toAssign.m_hImpl)
264 : {
265 : m_pApi->release(m_hImpl);
266 : m_hImpl = toAssign.m_hImpl;
267 : m_pApi->acquire(m_hImpl);
268 : }
269 :
270 : return *this;
271 : }
272 :
273 0 : inline void RegistryTypeWriter::setFieldData( sal_uInt16 index,
274 : const rtl::OUString& name,
275 : const rtl::OUString& typeName,
276 : const rtl::OUString& doku,
277 : const rtl::OUString& fileName,
278 : RTFieldAccess access,
279 : const RTConstValue& constValue)
280 : {
281 0 : m_pApi->setFieldData(m_hImpl, index, name.pData, typeName.pData, doku.pData, fileName.pData, access, constValue.m_type, constValue.m_value);
282 0 : }
283 :
284 :
285 : inline void RegistryTypeWriter::setMethodData(sal_uInt16 index,
286 : const rtl::OUString& name,
287 : const rtl::OUString& returnTypeName,
288 : RTMethodMode mode,
289 : sal_uInt16 paramCount,
290 : sal_uInt16 excCount,
291 : const rtl::OUString& doku)
292 : {
293 : m_pApi->setMethodData(m_hImpl, index, name.pData, returnTypeName.pData, mode, paramCount, excCount, doku.pData);
294 : }
295 :
296 :
297 : inline void RegistryTypeWriter::setUik(const RTUik& uik)
298 : {
299 : m_pApi->setUik(m_hImpl, &uik);
300 : }
301 :
302 : inline void RegistryTypeWriter::setDoku(const rtl::OUString& doku)
303 : {
304 : m_pApi->setDoku(m_hImpl, doku.pData);
305 : }
306 :
307 : inline void RegistryTypeWriter::setFileName(const rtl::OUString& doku)
308 : {
309 : m_pApi->setFileName(m_hImpl, doku.pData);
310 : }
311 :
312 : inline void RegistryTypeWriter::setParamData(sal_uInt16 index,
313 : sal_uInt16 paramIndex,
314 : const rtl::OUString& type,
315 : const rtl::OUString& name,
316 : RTParamMode mode)
317 : {
318 : m_pApi->setParamData(m_hImpl, index, paramIndex, type.pData, name.pData, mode);
319 : }
320 :
321 : inline void RegistryTypeWriter::setExcData(sal_uInt16 index,
322 : sal_uInt16 excIndex,
323 : const rtl::OUString& type)
324 : {
325 : m_pApi->setExcData(m_hImpl, index, excIndex, type.pData);
326 : }
327 :
328 0 : inline const sal_uInt8* RegistryTypeWriter::getBlop()
329 : {
330 0 : return m_pApi->getBlop(m_hImpl);
331 : }
332 :
333 0 : inline sal_uInt32 RegistryTypeWriter::getBlopSize()
334 : {
335 0 : return m_pApi->getBlopSize(m_hImpl);
336 : }
337 :
338 :
339 : inline void RegistryTypeWriter::setReferenceData( sal_uInt16 index,
340 : const rtl::OUString& name,
341 : RTReferenceType refType,
342 : const rtl::OUString& doku,
343 : RTFieldAccess access)
344 : {
345 : m_pApi->setReferenceData(m_hImpl, index, name.pData, refType, doku.pData, access);
346 : }
347 :
348 : #endif
349 :
350 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|