1*5a5f4a75SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5a5f4a75SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5a5f4a75SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5a5f4a75SAndrew Rist * distributed with this work for additional information
6*5a5f4a75SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5a5f4a75SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5a5f4a75SAndrew Rist * "License"); you may not use this file except in compliance
9*5a5f4a75SAndrew Rist * with the License. You may obtain a copy of the License at
10*5a5f4a75SAndrew Rist *
11*5a5f4a75SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5a5f4a75SAndrew Rist *
13*5a5f4a75SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5a5f4a75SAndrew Rist * software distributed under the License is distributed on an
15*5a5f4a75SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5a5f4a75SAndrew Rist * KIND, either express or implied. See the License for the
17*5a5f4a75SAndrew Rist * specific language governing permissions and limitations
18*5a5f4a75SAndrew Rist * under the License.
19*5a5f4a75SAndrew Rist *
20*5a5f4a75SAndrew Rist *************************************************************/
21*5a5f4a75SAndrew Rist
22*5a5f4a75SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _REFLCNST_HXX_
25cdf0e10cSrcweir #define _REFLCNST_HXX_
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <registry/refltype.hxx>
28cdf0e10cSrcweir #include <sal/macros.h>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <string.h>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #define REGTYPE_IEEE_NATIVE 1
33cdf0e10cSrcweir
34cdf0e10cSrcweir extern const sal_uInt32 magic;
35cdf0e10cSrcweir extern const sal_uInt16 minorVersion;
36cdf0e10cSrcweir extern const sal_uInt16 majorVersion;
37cdf0e10cSrcweir
38cdf0e10cSrcweir #define OFFSET_MAGIC 0
39cdf0e10cSrcweir #define OFFSET_SIZE (OFFSET_MAGIC + sizeof(magic))
40cdf0e10cSrcweir #define OFFSET_MINOR_VERSION (OFFSET_SIZE + sizeof(sal_uInt32))
41cdf0e10cSrcweir #define OFFSET_MAJOR_VERSION (OFFSET_MINOR_VERSION + sizeof(minorVersion))
42cdf0e10cSrcweir #define OFFSET_N_ENTRIES (OFFSET_MAJOR_VERSION + sizeof(sal_uInt16))
43cdf0e10cSrcweir #define OFFSET_TYPE_SOURCE (OFFSET_N_ENTRIES + sizeof(sal_uInt16))
44cdf0e10cSrcweir #define OFFSET_TYPE_CLASS (OFFSET_TYPE_SOURCE + sizeof(sal_uInt16))
45cdf0e10cSrcweir #define OFFSET_THIS_TYPE (OFFSET_TYPE_CLASS + sizeof(sal_uInt16))
46cdf0e10cSrcweir #define OFFSET_UIK (OFFSET_THIS_TYPE + sizeof(sal_uInt16))
47cdf0e10cSrcweir #define OFFSET_DOKU (OFFSET_UIK + sizeof(sal_uInt16))
48cdf0e10cSrcweir #define OFFSET_FILENAME (OFFSET_DOKU + sizeof(sal_uInt16))
49cdf0e10cSrcweir
50cdf0e10cSrcweir #define OFFSET_N_SUPERTYPES (OFFSET_FILENAME + sizeof(sal_uInt16))
51cdf0e10cSrcweir #define OFFSET_SUPERTYPES (OFFSET_N_SUPERTYPES + sizeof(sal_uInt16))
52cdf0e10cSrcweir
53cdf0e10cSrcweir #define OFFSET_CP_SIZE (OFFSET_SUPERTYPES + sizeof(sal_uInt16))
54cdf0e10cSrcweir #define OFFSET_CP (OFFSET_CP_SIZE + sizeof(sal_uInt16))
55cdf0e10cSrcweir
56cdf0e10cSrcweir #define CP_OFFSET_ENTRY_SIZE 0
57cdf0e10cSrcweir #define CP_OFFSET_ENTRY_TAG (CP_OFFSET_ENTRY_SIZE + sizeof(sal_uInt32))
58cdf0e10cSrcweir #define CP_OFFSET_ENTRY_DATA (CP_OFFSET_ENTRY_TAG + sizeof(sal_uInt16))
59cdf0e10cSrcweir #define CP_OFFSET_ENTRY_UIK1 CP_OFFSET_ENTRY_DATA
60cdf0e10cSrcweir #define CP_OFFSET_ENTRY_UIK2 (CP_OFFSET_ENTRY_UIK1 + sizeof(sal_uInt32))
61cdf0e10cSrcweir #define CP_OFFSET_ENTRY_UIK3 (CP_OFFSET_ENTRY_UIK2 + sizeof(sal_uInt16))
62cdf0e10cSrcweir #define CP_OFFSET_ENTRY_UIK4 (CP_OFFSET_ENTRY_UIK3 + sizeof(sal_uInt16))
63cdf0e10cSrcweir #define CP_OFFSET_ENTRY_UIK5 (CP_OFFSET_ENTRY_UIK4 + sizeof(sal_uInt32))
64cdf0e10cSrcweir
65cdf0e10cSrcweir #define FIELD_OFFSET_ACCESS 0
66cdf0e10cSrcweir #define FIELD_OFFSET_NAME (FIELD_OFFSET_ACCESS + sizeof(sal_uInt16))
67cdf0e10cSrcweir #define FIELD_OFFSET_TYPE (FIELD_OFFSET_NAME + sizeof(sal_uInt16))
68cdf0e10cSrcweir #define FIELD_OFFSET_VALUE (FIELD_OFFSET_TYPE + sizeof(sal_uInt16))
69cdf0e10cSrcweir #define FIELD_OFFSET_DOKU (FIELD_OFFSET_VALUE + sizeof(sal_uInt16))
70cdf0e10cSrcweir #define FIELD_OFFSET_FILENAME (FIELD_OFFSET_DOKU + sizeof(sal_uInt16))
71cdf0e10cSrcweir //#define FIELD_ENTRY_SIZE (FIELD_OFFSET_FILENAME + sizeof(sal_uInt16))
72cdf0e10cSrcweir
73cdf0e10cSrcweir #define PARAM_OFFSET_TYPE 0
74cdf0e10cSrcweir #define PARAM_OFFSET_MODE (PARAM_OFFSET_TYPE + sizeof(sal_uInt16))
75cdf0e10cSrcweir #define PARAM_OFFSET_NAME (PARAM_OFFSET_MODE + sizeof(sal_uInt16))
76cdf0e10cSrcweir //#define PARAM_ENTRY_SIZE (PARAM_OFFSET_NAME + sizeof(sal_uInt16))
77cdf0e10cSrcweir
78cdf0e10cSrcweir #define METHOD_OFFSET_SIZE 0
79cdf0e10cSrcweir #define METHOD_OFFSET_MODE (METHOD_OFFSET_SIZE + sizeof(sal_uInt16))
80cdf0e10cSrcweir #define METHOD_OFFSET_NAME (METHOD_OFFSET_MODE + sizeof(sal_uInt16))
81cdf0e10cSrcweir #define METHOD_OFFSET_RETURN (METHOD_OFFSET_NAME + sizeof(sal_uInt16))
82cdf0e10cSrcweir #define METHOD_OFFSET_DOKU (METHOD_OFFSET_RETURN + sizeof(sal_uInt16))
83cdf0e10cSrcweir #define METHOD_OFFSET_PARAM_COUNT (METHOD_OFFSET_DOKU + sizeof(sal_uInt16))
84cdf0e10cSrcweir //#define METHOD_OFFSET_PARAM(i) (METHOD_OFFSET_PARAM_COUNT + sizeof(sal_uInt16) + (i * PARAM_ENTRY_SIZE))
85cdf0e10cSrcweir
86cdf0e10cSrcweir #define REFERENCE_OFFSET_TYPE 0
87cdf0e10cSrcweir #define REFERENCE_OFFSET_NAME (REFERENCE_OFFSET_TYPE + sizeof(sal_uInt16))
88cdf0e10cSrcweir #define REFERENCE_OFFSET_DOKU (REFERENCE_OFFSET_NAME + sizeof(sal_uInt16))
89cdf0e10cSrcweir #define REFERENCE_OFFSET_ACCESS (REFERENCE_OFFSET_DOKU + sizeof(sal_uInt16))
90cdf0e10cSrcweir //#define REFERENCE_ENTRY_SIZE (REFERENCE_OFFSET_ACCESS + sizeof(sal_uInt16))
91cdf0e10cSrcweir
92cdf0e10cSrcweir enum CPInfoTag
93cdf0e10cSrcweir {
94cdf0e10cSrcweir CP_TAG_INVALID = RT_TYPE_NONE,
95cdf0e10cSrcweir CP_TAG_CONST_BOOL = RT_TYPE_BOOL,
96cdf0e10cSrcweir CP_TAG_CONST_BYTE = RT_TYPE_BYTE,
97cdf0e10cSrcweir CP_TAG_CONST_INT16 = RT_TYPE_INT16,
98cdf0e10cSrcweir CP_TAG_CONST_UINT16 = RT_TYPE_UINT16,
99cdf0e10cSrcweir CP_TAG_CONST_INT32 = RT_TYPE_INT32,
100cdf0e10cSrcweir CP_TAG_CONST_UINT32 = RT_TYPE_UINT32,
101cdf0e10cSrcweir CP_TAG_CONST_INT64 = RT_TYPE_INT64,
102cdf0e10cSrcweir CP_TAG_CONST_UINT64 = RT_TYPE_UINT64,
103cdf0e10cSrcweir CP_TAG_CONST_FLOAT = RT_TYPE_FLOAT,
104cdf0e10cSrcweir CP_TAG_CONST_DOUBLE = RT_TYPE_DOUBLE,
105cdf0e10cSrcweir CP_TAG_CONST_STRING = RT_TYPE_STRING,
106cdf0e10cSrcweir CP_TAG_UTF8_NAME,
107cdf0e10cSrcweir CP_TAG_UIK
108cdf0e10cSrcweir };
109cdf0e10cSrcweir
writeBYTE(sal_uInt8 * buffer,sal_uInt8 v)110cdf0e10cSrcweir inline sal_uInt32 writeBYTE(sal_uInt8* buffer, sal_uInt8 v)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir buffer[0] = v;
113cdf0e10cSrcweir
114cdf0e10cSrcweir return sizeof(sal_uInt8);
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
readBYTE(const sal_uInt8 * buffer,sal_uInt8 & v)117cdf0e10cSrcweir inline sal_uInt16 readBYTE(const sal_uInt8* buffer, sal_uInt8& v)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir v = buffer[0];
120cdf0e10cSrcweir
121cdf0e10cSrcweir return sizeof(sal_uInt8);
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
writeINT16(sal_uInt8 * buffer,sal_Int16 v)124cdf0e10cSrcweir inline sal_uInt32 writeINT16(sal_uInt8* buffer, sal_Int16 v)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir buffer[0] = (sal_uInt8)((v >> 8) & 0xFF);
127cdf0e10cSrcweir buffer[1] = (sal_uInt8)((v >> 0) & 0xFF);
128cdf0e10cSrcweir
129cdf0e10cSrcweir return sizeof(sal_Int16);
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
readINT16(const sal_uInt8 * buffer,sal_Int16 & v)132cdf0e10cSrcweir inline sal_uInt32 readINT16(const sal_uInt8* buffer, sal_Int16& v)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir v = ((buffer[0] << 8) | (buffer[1] << 0));
135cdf0e10cSrcweir
136cdf0e10cSrcweir return sizeof(sal_Int16);
137cdf0e10cSrcweir }
138cdf0e10cSrcweir
writeUINT16(sal_uInt8 * buffer,sal_uInt16 v)139cdf0e10cSrcweir inline sal_uInt32 writeUINT16(sal_uInt8* buffer, sal_uInt16 v)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir buffer[0] = (sal_uInt8)((v >> 8) & 0xFF);
142cdf0e10cSrcweir buffer[1] = (sal_uInt8)((v >> 0) & 0xFF);
143cdf0e10cSrcweir
144cdf0e10cSrcweir return sizeof(sal_uInt16);
145cdf0e10cSrcweir }
146cdf0e10cSrcweir
readUINT16(const sal_uInt8 * buffer,sal_uInt16 & v)147cdf0e10cSrcweir inline sal_uInt32 readUINT16(const sal_uInt8* buffer, sal_uInt16& v)
148cdf0e10cSrcweir {
149cdf0e10cSrcweir v = ((buffer[0] << 8) | (buffer[1] << 0));
150cdf0e10cSrcweir
151cdf0e10cSrcweir return sizeof(sal_uInt16);
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
writeINT32(sal_uInt8 * buffer,sal_Int32 v)154cdf0e10cSrcweir inline sal_uInt32 writeINT32(sal_uInt8* buffer, sal_Int32 v)
155cdf0e10cSrcweir {
156cdf0e10cSrcweir buffer[0] = (sal_uInt8)((v >> 24) & 0xFF);
157cdf0e10cSrcweir buffer[1] = (sal_uInt8)((v >> 16) & 0xFF);
158cdf0e10cSrcweir buffer[2] = (sal_uInt8)((v >> 8) & 0xFF);
159cdf0e10cSrcweir buffer[3] = (sal_uInt8)((v >> 0) & 0xFF);
160cdf0e10cSrcweir
161cdf0e10cSrcweir return sizeof(sal_Int32);
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
readINT32(const sal_uInt8 * buffer,sal_Int32 & v)164cdf0e10cSrcweir inline sal_uInt32 readINT32(const sal_uInt8* buffer, sal_Int32& v)
165cdf0e10cSrcweir {
166cdf0e10cSrcweir v = (
167cdf0e10cSrcweir (buffer[0] << 24) |
168cdf0e10cSrcweir (buffer[1] << 16) |
169cdf0e10cSrcweir (buffer[2] << 8) |
170cdf0e10cSrcweir (buffer[3] << 0)
171cdf0e10cSrcweir );
172cdf0e10cSrcweir
173cdf0e10cSrcweir return sizeof(sal_Int32);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
writeUINT32(sal_uInt8 * buffer,sal_uInt32 v)176cdf0e10cSrcweir inline sal_uInt32 writeUINT32(sal_uInt8* buffer, sal_uInt32 v)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir buffer[0] = (sal_uInt8)((v >> 24) & 0xFF);
179cdf0e10cSrcweir buffer[1] = (sal_uInt8)((v >> 16) & 0xFF);
180cdf0e10cSrcweir buffer[2] = (sal_uInt8)((v >> 8) & 0xFF);
181cdf0e10cSrcweir buffer[3] = (sal_uInt8)((v >> 0) & 0xFF);
182cdf0e10cSrcweir
183cdf0e10cSrcweir return sizeof(sal_uInt32);
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
readUINT32(const sal_uInt8 * buffer,sal_uInt32 & v)186cdf0e10cSrcweir inline sal_uInt32 readUINT32(const sal_uInt8* buffer, sal_uInt32& v)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir v = (
189cdf0e10cSrcweir (buffer[0] << 24) |
190cdf0e10cSrcweir (buffer[1] << 16) |
191cdf0e10cSrcweir (buffer[2] << 8) |
192cdf0e10cSrcweir (buffer[3] << 0)
193cdf0e10cSrcweir );
194cdf0e10cSrcweir
195cdf0e10cSrcweir return sizeof(sal_uInt32);
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
writeINT64(sal_uInt8 * buffer,sal_Int64 v)198cdf0e10cSrcweir inline sal_uInt32 writeINT64(sal_uInt8* buffer, sal_Int64 v)
199cdf0e10cSrcweir {
200cdf0e10cSrcweir buffer[0] = (sal_uInt8)((v >> 56) & 0xFF);
201cdf0e10cSrcweir buffer[1] = (sal_uInt8)((v >> 48) & 0xFF);
202cdf0e10cSrcweir buffer[2] = (sal_uInt8)((v >> 40) & 0xFF);
203cdf0e10cSrcweir buffer[3] = (sal_uInt8)((v >> 32) & 0xFF);
204cdf0e10cSrcweir buffer[4] = (sal_uInt8)((v >> 24) & 0xFF);
205cdf0e10cSrcweir buffer[5] = (sal_uInt8)((v >> 16) & 0xFF);
206cdf0e10cSrcweir buffer[6] = (sal_uInt8)((v >> 8) & 0xFF);
207cdf0e10cSrcweir buffer[7] = (sal_uInt8)((v >> 0) & 0xFF);
208cdf0e10cSrcweir
209cdf0e10cSrcweir return sizeof(sal_Int64);
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
readINT64(const sal_uInt8 * buffer,sal_Int64 & v)212cdf0e10cSrcweir inline sal_uInt32 readINT64(const sal_uInt8* buffer, sal_Int64& v)
213cdf0e10cSrcweir {
214cdf0e10cSrcweir v = (
215cdf0e10cSrcweir ((sal_Int64)buffer[0] << 56) |
216cdf0e10cSrcweir ((sal_Int64)buffer[1] << 48) |
217cdf0e10cSrcweir ((sal_Int64)buffer[2] << 40) |
218cdf0e10cSrcweir ((sal_Int64)buffer[3] << 32) |
219cdf0e10cSrcweir ((sal_Int64)buffer[4] << 24) |
220cdf0e10cSrcweir ((sal_Int64)buffer[5] << 16) |
221cdf0e10cSrcweir ((sal_Int64)buffer[6] << 8) |
222cdf0e10cSrcweir ((sal_Int64)buffer[7] << 0)
223cdf0e10cSrcweir );
224cdf0e10cSrcweir
225cdf0e10cSrcweir return sizeof(sal_Int64);
226cdf0e10cSrcweir }
227cdf0e10cSrcweir
writeUINT64(sal_uInt8 * buffer,sal_uInt64 v)228cdf0e10cSrcweir inline sal_uInt32 writeUINT64(sal_uInt8* buffer, sal_uInt64 v)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir buffer[0] = (sal_uInt8)((v >> 56) & 0xFF);
231cdf0e10cSrcweir buffer[1] = (sal_uInt8)((v >> 48) & 0xFF);
232cdf0e10cSrcweir buffer[2] = (sal_uInt8)((v >> 40) & 0xFF);
233cdf0e10cSrcweir buffer[3] = (sal_uInt8)((v >> 32) & 0xFF);
234cdf0e10cSrcweir buffer[4] = (sal_uInt8)((v >> 24) & 0xFF);
235cdf0e10cSrcweir buffer[5] = (sal_uInt8)((v >> 16) & 0xFF);
236cdf0e10cSrcweir buffer[6] = (sal_uInt8)((v >> 8) & 0xFF);
237cdf0e10cSrcweir buffer[7] = (sal_uInt8)((v >> 0) & 0xFF);
238cdf0e10cSrcweir
239cdf0e10cSrcweir return sizeof(sal_uInt64);
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
readUINT64(const sal_uInt8 * buffer,sal_uInt64 & v)242cdf0e10cSrcweir inline sal_uInt32 readUINT64(const sal_uInt8* buffer, sal_uInt64& v)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir v = (
245cdf0e10cSrcweir ((sal_uInt64)buffer[0] << 56) |
246cdf0e10cSrcweir ((sal_uInt64)buffer[1] << 48) |
247cdf0e10cSrcweir ((sal_uInt64)buffer[2] << 40) |
248cdf0e10cSrcweir ((sal_uInt64)buffer[3] << 32) |
249cdf0e10cSrcweir ((sal_uInt64)buffer[4] << 24) |
250cdf0e10cSrcweir ((sal_uInt64)buffer[5] << 16) |
251cdf0e10cSrcweir ((sal_uInt64)buffer[6] << 8) |
252cdf0e10cSrcweir ((sal_uInt64)buffer[7] << 0)
253cdf0e10cSrcweir );
254cdf0e10cSrcweir
255cdf0e10cSrcweir return sizeof(sal_uInt64);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
writeUtf8(sal_uInt8 * buffer,const sal_Char * v)258cdf0e10cSrcweir inline sal_uInt32 writeUtf8(sal_uInt8* buffer, const sal_Char* v)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir sal_uInt32 size = strlen(v) + 1;
261cdf0e10cSrcweir
262cdf0e10cSrcweir memcpy(buffer, v, size);
263cdf0e10cSrcweir
264cdf0e10cSrcweir return (size);
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
readUtf8(const sal_uInt8 * buffer,sal_Char * v,sal_uInt32 maxSize)267cdf0e10cSrcweir inline sal_uInt32 readUtf8(const sal_uInt8* buffer, sal_Char* v, sal_uInt32 maxSize)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir sal_uInt32 size = SAL_MIN(strlen((const sal_Char*) buffer) + 1, maxSize);
270cdf0e10cSrcweir
271cdf0e10cSrcweir memcpy(v, buffer, size);
272cdf0e10cSrcweir
273cdf0e10cSrcweir if (size == maxSize) v[size - 1] = '\0';
274cdf0e10cSrcweir
275cdf0e10cSrcweir return (size);
276cdf0e10cSrcweir }
277cdf0e10cSrcweir
278cdf0e10cSrcweir
279cdf0e10cSrcweir sal_uInt32 writeFloat(sal_uInt8* buffer, float v);
280cdf0e10cSrcweir sal_uInt32 writeDouble(sal_uInt8* buffer, double v);
281cdf0e10cSrcweir sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v);
282cdf0e10cSrcweir sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 maxSize);
283cdf0e10cSrcweir
284cdf0e10cSrcweir sal_uInt32 UINT16StringLen(const sal_uInt8* wstring);
285cdf0e10cSrcweir
286cdf0e10cSrcweir #endif
287cdf0e10cSrcweir
288cdf0e10cSrcweir
289cdf0e10cSrcweir
290cdf0e10cSrcweir
291cdf0e10cSrcweir
292