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