1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: reflcnst.hxx,v $
10 * $Revision: 1.6.10.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _REFLCNST_HXX_
32 #define _REFLCNST_HXX_
34 #include <registry/refltype.hxx>
35 #include <sal/macros.h>
39 #define REGTYPE_IEEE_NATIVE 1
41 extern const sal_uInt32 magic
;
42 extern const sal_uInt16 minorVersion
;
43 extern const sal_uInt16 majorVersion
;
45 #define OFFSET_MAGIC 0
46 #define OFFSET_SIZE (OFFSET_MAGIC + sizeof(magic))
47 #define OFFSET_MINOR_VERSION (OFFSET_SIZE + sizeof(sal_uInt32))
48 #define OFFSET_MAJOR_VERSION (OFFSET_MINOR_VERSION + sizeof(minorVersion))
49 #define OFFSET_N_ENTRIES (OFFSET_MAJOR_VERSION + sizeof(sal_uInt16))
50 #define OFFSET_TYPE_SOURCE (OFFSET_N_ENTRIES + sizeof(sal_uInt16))
51 #define OFFSET_TYPE_CLASS (OFFSET_TYPE_SOURCE + sizeof(sal_uInt16))
52 #define OFFSET_THIS_TYPE (OFFSET_TYPE_CLASS + sizeof(sal_uInt16))
53 #define OFFSET_UIK (OFFSET_THIS_TYPE + sizeof(sal_uInt16))
54 #define OFFSET_DOKU (OFFSET_UIK + sizeof(sal_uInt16))
55 #define OFFSET_FILENAME (OFFSET_DOKU + sizeof(sal_uInt16))
57 #define OFFSET_N_SUPERTYPES (OFFSET_FILENAME + sizeof(sal_uInt16))
58 #define OFFSET_SUPERTYPES (OFFSET_N_SUPERTYPES + sizeof(sal_uInt16))
60 #define OFFSET_CP_SIZE (OFFSET_SUPERTYPES + sizeof(sal_uInt16))
61 #define OFFSET_CP (OFFSET_CP_SIZE + sizeof(sal_uInt16))
63 #define CP_OFFSET_ENTRY_SIZE 0
64 #define CP_OFFSET_ENTRY_TAG (CP_OFFSET_ENTRY_SIZE + sizeof(sal_uInt32))
65 #define CP_OFFSET_ENTRY_DATA (CP_OFFSET_ENTRY_TAG + sizeof(sal_uInt16))
66 #define CP_OFFSET_ENTRY_UIK1 CP_OFFSET_ENTRY_DATA
67 #define CP_OFFSET_ENTRY_UIK2 (CP_OFFSET_ENTRY_UIK1 + sizeof(sal_uInt32))
68 #define CP_OFFSET_ENTRY_UIK3 (CP_OFFSET_ENTRY_UIK2 + sizeof(sal_uInt16))
69 #define CP_OFFSET_ENTRY_UIK4 (CP_OFFSET_ENTRY_UIK3 + sizeof(sal_uInt16))
70 #define CP_OFFSET_ENTRY_UIK5 (CP_OFFSET_ENTRY_UIK4 + sizeof(sal_uInt32))
72 #define FIELD_OFFSET_ACCESS 0
73 #define FIELD_OFFSET_NAME (FIELD_OFFSET_ACCESS + sizeof(sal_uInt16))
74 #define FIELD_OFFSET_TYPE (FIELD_OFFSET_NAME + sizeof(sal_uInt16))
75 #define FIELD_OFFSET_VALUE (FIELD_OFFSET_TYPE + sizeof(sal_uInt16))
76 #define FIELD_OFFSET_DOKU (FIELD_OFFSET_VALUE + sizeof(sal_uInt16))
77 #define FIELD_OFFSET_FILENAME (FIELD_OFFSET_DOKU + sizeof(sal_uInt16))
78 //#define FIELD_ENTRY_SIZE (FIELD_OFFSET_FILENAME + sizeof(sal_uInt16))
80 #define PARAM_OFFSET_TYPE 0
81 #define PARAM_OFFSET_MODE (PARAM_OFFSET_TYPE + sizeof(sal_uInt16))
82 #define PARAM_OFFSET_NAME (PARAM_OFFSET_MODE + sizeof(sal_uInt16))
83 //#define PARAM_ENTRY_SIZE (PARAM_OFFSET_NAME + sizeof(sal_uInt16))
85 #define METHOD_OFFSET_SIZE 0
86 #define METHOD_OFFSET_MODE (METHOD_OFFSET_SIZE + sizeof(sal_uInt16))
87 #define METHOD_OFFSET_NAME (METHOD_OFFSET_MODE + sizeof(sal_uInt16))
88 #define METHOD_OFFSET_RETURN (METHOD_OFFSET_NAME + sizeof(sal_uInt16))
89 #define METHOD_OFFSET_DOKU (METHOD_OFFSET_RETURN + sizeof(sal_uInt16))
90 #define METHOD_OFFSET_PARAM_COUNT (METHOD_OFFSET_DOKU + sizeof(sal_uInt16))
91 //#define METHOD_OFFSET_PARAM(i) (METHOD_OFFSET_PARAM_COUNT + sizeof(sal_uInt16) + (i * PARAM_ENTRY_SIZE))
93 #define REFERENCE_OFFSET_TYPE 0
94 #define REFERENCE_OFFSET_NAME (REFERENCE_OFFSET_TYPE + sizeof(sal_uInt16))
95 #define REFERENCE_OFFSET_DOKU (REFERENCE_OFFSET_NAME + sizeof(sal_uInt16))
96 #define REFERENCE_OFFSET_ACCESS (REFERENCE_OFFSET_DOKU + sizeof(sal_uInt16))
97 //#define REFERENCE_ENTRY_SIZE (REFERENCE_OFFSET_ACCESS + sizeof(sal_uInt16))
101 CP_TAG_INVALID
= RT_TYPE_NONE
,
102 CP_TAG_CONST_BOOL
= RT_TYPE_BOOL
,
103 CP_TAG_CONST_BYTE
= RT_TYPE_BYTE
,
104 CP_TAG_CONST_INT16
= RT_TYPE_INT16
,
105 CP_TAG_CONST_UINT16
= RT_TYPE_UINT16
,
106 CP_TAG_CONST_INT32
= RT_TYPE_INT32
,
107 CP_TAG_CONST_UINT32
= RT_TYPE_UINT32
,
108 CP_TAG_CONST_INT64
= RT_TYPE_INT64
,
109 CP_TAG_CONST_UINT64
= RT_TYPE_UINT64
,
110 CP_TAG_CONST_FLOAT
= RT_TYPE_FLOAT
,
111 CP_TAG_CONST_DOUBLE
= RT_TYPE_DOUBLE
,
112 CP_TAG_CONST_STRING
= RT_TYPE_STRING
,
117 inline sal_uInt32
writeBYTE(sal_uInt8
* buffer
, sal_uInt8 v
)
121 return sizeof(sal_uInt8
);
124 inline sal_uInt16
readBYTE(const sal_uInt8
* buffer
, sal_uInt8
& v
)
128 return sizeof(sal_uInt8
);
131 inline sal_uInt32
writeINT16(sal_uInt8
* buffer
, sal_Int16 v
)
133 buffer
[0] = (sal_uInt8
)((v
>> 8) & 0xFF);
134 buffer
[1] = (sal_uInt8
)((v
>> 0) & 0xFF);
136 return sizeof(sal_Int16
);
139 inline sal_uInt32
readINT16(const sal_uInt8
* buffer
, sal_Int16
& v
)
141 v
= ((buffer
[0] << 8) | (buffer
[1] << 0));
143 return sizeof(sal_Int16
);
146 inline sal_uInt32
writeUINT16(sal_uInt8
* buffer
, sal_uInt16 v
)
148 buffer
[0] = (sal_uInt8
)((v
>> 8) & 0xFF);
149 buffer
[1] = (sal_uInt8
)((v
>> 0) & 0xFF);
151 return sizeof(sal_uInt16
);
154 inline sal_uInt32
readUINT16(const sal_uInt8
* buffer
, sal_uInt16
& v
)
156 v
= ((buffer
[0] << 8) | (buffer
[1] << 0));
158 return sizeof(sal_uInt16
);
161 inline sal_uInt32
writeINT32(sal_uInt8
* buffer
, sal_Int32 v
)
163 buffer
[0] = (sal_uInt8
)((v
>> 24) & 0xFF);
164 buffer
[1] = (sal_uInt8
)((v
>> 16) & 0xFF);
165 buffer
[2] = (sal_uInt8
)((v
>> 8) & 0xFF);
166 buffer
[3] = (sal_uInt8
)((v
>> 0) & 0xFF);
168 return sizeof(sal_Int32
);
171 inline sal_uInt32
readINT32(const sal_uInt8
* buffer
, sal_Int32
& v
)
180 return sizeof(sal_Int32
);
183 inline sal_uInt32
writeUINT32(sal_uInt8
* buffer
, sal_uInt32 v
)
185 buffer
[0] = (sal_uInt8
)((v
>> 24) & 0xFF);
186 buffer
[1] = (sal_uInt8
)((v
>> 16) & 0xFF);
187 buffer
[2] = (sal_uInt8
)((v
>> 8) & 0xFF);
188 buffer
[3] = (sal_uInt8
)((v
>> 0) & 0xFF);
190 return sizeof(sal_uInt32
);
193 inline sal_uInt32
readUINT32(const sal_uInt8
* buffer
, sal_uInt32
& v
)
202 return sizeof(sal_uInt32
);
205 inline sal_uInt32
writeINT64(sal_uInt8
* buffer
, sal_Int64 v
)
207 buffer
[0] = (sal_uInt8
)((v
>> 56) & 0xFF);
208 buffer
[1] = (sal_uInt8
)((v
>> 48) & 0xFF);
209 buffer
[2] = (sal_uInt8
)((v
>> 40) & 0xFF);
210 buffer
[3] = (sal_uInt8
)((v
>> 32) & 0xFF);
211 buffer
[4] = (sal_uInt8
)((v
>> 24) & 0xFF);
212 buffer
[5] = (sal_uInt8
)((v
>> 16) & 0xFF);
213 buffer
[6] = (sal_uInt8
)((v
>> 8) & 0xFF);
214 buffer
[7] = (sal_uInt8
)((v
>> 0) & 0xFF);
216 return sizeof(sal_Int64
);
219 inline sal_uInt32
readINT64(const sal_uInt8
* buffer
, sal_Int64
& v
)
222 ((sal_Int64
)buffer
[0] << 56) |
223 ((sal_Int64
)buffer
[1] << 48) |
224 ((sal_Int64
)buffer
[2] << 40) |
225 ((sal_Int64
)buffer
[3] << 32) |
226 ((sal_Int64
)buffer
[4] << 24) |
227 ((sal_Int64
)buffer
[5] << 16) |
228 ((sal_Int64
)buffer
[6] << 8) |
229 ((sal_Int64
)buffer
[7] << 0)
232 return sizeof(sal_Int64
);
235 inline sal_uInt32
writeUINT64(sal_uInt8
* buffer
, sal_uInt64 v
)
237 buffer
[0] = (sal_uInt8
)((v
>> 56) & 0xFF);
238 buffer
[1] = (sal_uInt8
)((v
>> 48) & 0xFF);
239 buffer
[2] = (sal_uInt8
)((v
>> 40) & 0xFF);
240 buffer
[3] = (sal_uInt8
)((v
>> 32) & 0xFF);
241 buffer
[4] = (sal_uInt8
)((v
>> 24) & 0xFF);
242 buffer
[5] = (sal_uInt8
)((v
>> 16) & 0xFF);
243 buffer
[6] = (sal_uInt8
)((v
>> 8) & 0xFF);
244 buffer
[7] = (sal_uInt8
)((v
>> 0) & 0xFF);
246 return sizeof(sal_uInt64
);
249 inline sal_uInt32
readUINT64(const sal_uInt8
* buffer
, sal_uInt64
& v
)
252 ((sal_uInt64
)buffer
[0] << 56) |
253 ((sal_uInt64
)buffer
[1] << 48) |
254 ((sal_uInt64
)buffer
[2] << 40) |
255 ((sal_uInt64
)buffer
[3] << 32) |
256 ((sal_uInt64
)buffer
[4] << 24) |
257 ((sal_uInt64
)buffer
[5] << 16) |
258 ((sal_uInt64
)buffer
[6] << 8) |
259 ((sal_uInt64
)buffer
[7] << 0)
262 return sizeof(sal_uInt64
);
265 inline sal_uInt32
writeUtf8(sal_uInt8
* buffer
, const sal_Char
* v
)
267 sal_uInt32 size
= strlen(v
) + 1;
269 memcpy(buffer
, v
, size
);
274 inline sal_uInt32
readUtf8(const sal_uInt8
* buffer
, sal_Char
* v
, sal_uInt32 maxSize
)
276 sal_uInt32 size
= SAL_MIN(strlen((const sal_Char
*) buffer
) + 1, maxSize
);
278 memcpy(v
, buffer
, size
);
280 if (size
== maxSize
) v
[size
- 1] = '\0';
286 sal_uInt32
writeFloat(sal_uInt8
* buffer
, float v
);
287 sal_uInt32
writeDouble(sal_uInt8
* buffer
, double v
);
288 sal_uInt32
writeString(sal_uInt8
* buffer
, const sal_Unicode
* v
);
289 sal_uInt32
readString(const sal_uInt8
* buffer
, sal_Unicode
* v
, sal_uInt32 maxSize
);
291 sal_uInt32
UINT16StringLen(const sal_uInt8
* wstring
);