1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #ifndef _REGISTRY_REFLWRIT_HXX_
23 #define _REGISTRY_REFLWRIT_HXX_
24
25 #include <registry/refltype.hxx>
26 #include <registry/regtype.h>
27 #include "registry/registrydllapi.h"
28 #include <rtl/ustring.hxx>
29
30 // Implememetation handle
31 typedef void* TypeWriterImpl;
32
33 /****************************************************************************
34 C-Api
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 REGISTRY_DLLPUBLIC RegistryTypeWriter_Api* TYPEREG_CALLTYPE initRegistryTypeWriter_Api(void);
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 informations
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 (e.g. number of attributes/properties,
91 enum values or constants).
92 @param methodCount specifies the number of methods.
93 @param referenceCount specifies the number of references (e.g. 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 constructor
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 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 typeName 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 = RT_ACCESS_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
RegistryTypeWriter(RTTypeClass RTTypeClass,const::rtl::OUString & typeName,const::rtl::OUString & superTypeName,sal_uInt16 fieldCount,sal_uInt16 methodCount,sal_uInt16 referenceCount)231 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 : m_pApi(initRegistryTypeWriter_Api())
238 , m_hImpl(NULL)
239 {
240 m_hImpl = m_pApi->createEntry(RTTypeClass,
241 typeName.pData,
242 superTypeName.pData,
243 fieldCount,
244 methodCount,
245 referenceCount);
246 }
247
248
RegistryTypeWriter(const RegistryTypeWriter & toCopy)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
~RegistryTypeWriter()256 inline RegistryTypeWriter::~RegistryTypeWriter()
257 {
258 m_pApi->release(m_hImpl);
259 }
260
operator ==(const RegistryTypeWriter & toAssign)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
setFieldData(sal_uInt16 index,const::rtl::OUString & name,const::rtl::OUString & typeName,const::rtl::OUString & doku,const::rtl::OUString & fileName,RTFieldAccess access,RTConstValue constValue)273 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 RTConstValue constValue)
280 {
281 m_pApi->setFieldData(m_hImpl, index, name.pData, typeName.pData, doku.pData, fileName.pData, access, constValue.m_type, constValue.m_value);
282 }
283
284
setMethodData(sal_uInt16 index,const::rtl::OUString & name,const::rtl::OUString & returnTypeName,RTMethodMode mode,sal_uInt16 paramCount,sal_uInt16 excCount,const::rtl::OUString & doku)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
setUik(const RTUik & uik)297 inline void RegistryTypeWriter::setUik(const RTUik& uik)
298 {
299 m_pApi->setUik(m_hImpl, &uik);
300 }
301
setDoku(const::rtl::OUString & doku)302 inline void RegistryTypeWriter::setDoku(const ::rtl::OUString& doku)
303 {
304 m_pApi->setDoku(m_hImpl, doku.pData);
305 }
306
setFileName(const::rtl::OUString & doku)307 inline void RegistryTypeWriter::setFileName(const ::rtl::OUString& doku)
308 {
309 m_pApi->setFileName(m_hImpl, doku.pData);
310 }
311
setParamData(sal_uInt16 index,sal_uInt16 paramIndex,const::rtl::OUString & type,const::rtl::OUString & name,RTParamMode mode)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
setExcData(sal_uInt16 index,sal_uInt16 excIndex,const::rtl::OUString & type)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
getBlop()328 inline const sal_uInt8* RegistryTypeWriter::getBlop()
329 {
330 return m_pApi->getBlop(m_hImpl);
331 }
332
getBlopSize()333 inline sal_uInt32 RegistryTypeWriter::getBlopSize()
334 {
335 return m_pApi->getBlopSize(m_hImpl);
336 }
337
338
setReferenceData(sal_uInt16 index,const::rtl::OUString & name,RTReferenceType refType,const::rtl::OUString & doku,RTFieldAccess access)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 noet sw=4 ts=4: */
351