xref: /aoo42x/main/registry/inc/registry/registry.hxx (revision f006f9b4)
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_REGISTRY_HXX_
25 #define _REGISTRY_REGISTRY_HXX_
26 
27 #include <registry/regtype.h>
28 #include <rtl/ustring.hxx>
29 #include "registry/registrydllapi.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /** specifies a collection of function pointers which represents the complete registry C-API.
36 
37     This funtions pointers are used by the C++ wrapper to call the C-API.
38 */
39 struct Registry_Api
40 {
41 	void	  	(REGISTRY_CALLTYPE *acquire) 			(RegHandle);
42 	void	  	(REGISTRY_CALLTYPE *release) 			(RegHandle);
43 	sal_Bool 	(REGISTRY_CALLTYPE *isReadOnly)			(RegHandle);
44 	RegError 	(REGISTRY_CALLTYPE *openRootKey)		(RegHandle, RegKeyHandle*);
45 	RegError	(REGISTRY_CALLTYPE *getName)			(RegHandle, rtl_uString**);
46 	RegError 	(REGISTRY_CALLTYPE *createRegistry)		(rtl_uString*, RegHandle*);
47 	RegError 	(REGISTRY_CALLTYPE *openRegistry)		(rtl_uString*, RegHandle*, RegAccessMode);
48 	RegError 	(REGISTRY_CALLTYPE *closeRegistry)		(RegHandle);
49 	RegError 	(REGISTRY_CALLTYPE *destroyRegistry)	(RegHandle,	rtl_uString*);
50 	RegError 	(REGISTRY_CALLTYPE *loadKey)			(RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*);
51 	RegError 	(REGISTRY_CALLTYPE *saveKey)			(RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*);
52 	RegError 	(REGISTRY_CALLTYPE *mergeKey)			(RegHandle, RegKeyHandle, rtl_uString*, rtl_uString*, sal_Bool, sal_Bool);
53 	RegError 	(REGISTRY_CALLTYPE *dumpRegistry) 		(RegHandle, RegKeyHandle);
54 	void	  	(REGISTRY_CALLTYPE *acquireKey) 	  	(RegKeyHandle);
55 	void	  	(REGISTRY_CALLTYPE *releaseKey) 	  	(RegKeyHandle);
56 	sal_Bool 	(REGISTRY_CALLTYPE *isKeyReadOnly)	  	(RegKeyHandle);
57 	RegError  	(REGISTRY_CALLTYPE *getKeyName)			(RegKeyHandle, rtl_uString**);
58 	RegError 	(REGISTRY_CALLTYPE *createKey)			(RegKeyHandle, rtl_uString*, RegKeyHandle*);
59 	RegError 	(REGISTRY_CALLTYPE *openKey)			(RegKeyHandle, rtl_uString*, RegKeyHandle*);
60 	RegError 	(REGISTRY_CALLTYPE *openSubKeys)		(RegKeyHandle, rtl_uString*, RegKeyHandle**, sal_uInt32*);
61 	RegError 	(REGISTRY_CALLTYPE *closeSubKeys)		(RegKeyHandle*, sal_uInt32);
62 	RegError 	(REGISTRY_CALLTYPE *deleteKey)			(RegKeyHandle, rtl_uString*);
63 	RegError 	(REGISTRY_CALLTYPE *closeKey)			(RegKeyHandle);
64 	RegError 	(REGISTRY_CALLTYPE *setValue)			(RegKeyHandle, rtl_uString*, RegValueType, RegValue, sal_uInt32);
65 	RegError 	(REGISTRY_CALLTYPE *setLongListValue)	(RegKeyHandle, rtl_uString*, sal_Int32*, sal_uInt32);
66 	RegError 	(REGISTRY_CALLTYPE *setStringListValue)	(RegKeyHandle, rtl_uString*, sal_Char**, sal_uInt32);
67 	RegError 	(REGISTRY_CALLTYPE *setUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode**, sal_uInt32);
68 	RegError 	(REGISTRY_CALLTYPE *getValueInfo)		(RegKeyHandle, rtl_uString*, RegValueType*, sal_uInt32*);
69 	RegError 	(REGISTRY_CALLTYPE *getValue)			(RegKeyHandle, rtl_uString*, RegValue);
70 	RegError 	(REGISTRY_CALLTYPE *getLongListValue)	(RegKeyHandle, rtl_uString*, sal_Int32**, sal_uInt32*);
71 	RegError 	(REGISTRY_CALLTYPE *getStringListValue)	(RegKeyHandle, rtl_uString*, sal_Char***, sal_uInt32*);
72 	RegError 	(REGISTRY_CALLTYPE *getUnicodeListValue)(RegKeyHandle, rtl_uString*, sal_Unicode***, sal_uInt32*);
73 	RegError 	(REGISTRY_CALLTYPE *freeValueList)		(RegValueType, RegValue, sal_uInt32);
74 	RegError 	(REGISTRY_CALLTYPE *createLink) 		(RegKeyHandle, rtl_uString*, rtl_uString*);
75 	RegError 	(REGISTRY_CALLTYPE *deleteLink)			(RegKeyHandle, rtl_uString*);
76 	RegError 	(REGISTRY_CALLTYPE *getKeyType)			(RegKeyHandle, rtl_uString*, RegKeyType*);
77 	RegError 	(REGISTRY_CALLTYPE *getLinkTarget)		(RegKeyHandle, rtl_uString*, rtl_uString**);
78 	RegError 	(REGISTRY_CALLTYPE *getResolvedKeyName)	(RegKeyHandle, rtl_uString*, sal_Bool, rtl_uString**);
79 	RegError 	(REGISTRY_CALLTYPE *getKeyNames)		(RegKeyHandle, rtl_uString*, rtl_uString***, sal_uInt32*);
80 	RegError 	(REGISTRY_CALLTYPE *freeKeyNames)		(rtl_uString**, sal_uInt32);
81 };
82 
83 /** the API initialization function.
84 */
85 REGISTRY_DLLPUBLIC Registry_Api* REGISTRY_CALLTYPE initRegistry_Api(void);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 
92 class RegistryKey;
93 
94 //-----------------------------------------------------------------------------
95 
96 /** The Registry provides the functionality to read and write information in a registry file.
97 
98 	The class is implemented inline and use a C-Api.
99 */
100 class Registry
101 {
102 public:
103 	/** Default constructor.
104 	 */
105 	inline Registry();
106 
107 	/// Copy constructcor
108 	inline Registry(const Registry& toCopy);
109 
110 	/// Destructor. The Destructor close the registry if it is open.
111 	inline ~Registry();
112 
113 	/// Assign operator
114 	inline Registry& operator = (const Registry& toAssign);
115 
116 	/// checks if the registry points to a valid registry data file.
117 	inline sal_Bool	isValid() const;
118 
119 	/**	returns the access mode of the registry.
120 
121 		@return	TRUE if the access mode is readonly else FALSE.
122 	*/
123 	inline sal_Bool 	isReadOnly() const;
124 
125 	/**	opens the root key of the registry.
126 
127 		@param 	rRootKey reference to a RegistryKey which is filled with the rootkey.
128 		@return	REG_NO_ERROR if succeeds else an error code.
129 	*/
130 	inline RegError openRootKey(RegistryKey& rRootKey);
131 
132 	/// returns the name of the current registry data file.
133 	inline ::rtl::OUString getName();
134 
135 	/**	creates a new registry with the specified name and creates a root key.
136 
137 		@param	registryName specifies the name of the new registry.
138 		@return	REG_NO_ERROR if succeeds else an error code.
139 	*/
140 	inline RegError create(const ::rtl::OUString& registryName);
141 
142 	/**	opens a registry with the specified name.
143 
144         If the registry already points to a valid registry, the old registry will be closed.
145 		@param	registryName specifies a registry name.
146 		@param 	accessMode specifies the access mode for the registry, REG_READONLY or REG_READWRITE.
147 		@return	REG_NO_ERROR if succeeds else an error code.
148 	*/
149 	inline RegError open(const ::rtl::OUString& registryName,
150 					   	 RegAccessMode accessMode);
151 
152 	/// closes explicitly the current registry data file.
153 	inline RegError close();
154 
155 	/**	destroys a registry.
156 
157 		@param registryName specifies a registry name, if the name is an empty string the registry
158                             itselfs will be destroyed.
159 		@return	REG_NO_ERROR if succeeds else an error code.
160 	*/
161 	inline RegError destroy(const ::rtl::OUString& registryName);
162 
163 	/**	loads registry information from a specified file and save it under the
164 		specified keyName.
165 
166         @param	rKey references a currently open key. The key which should store the registry information
167                      is a subkey of this key.
168         @param	keyName	specifies the name of the key which stores the registry information. If keyName is
169                         is an empty string the registry information will be saved under the key specified
170                         by rKey.
171 		@param	regFileName	specifies the file containing the registry information.
172 		@return	REG_NO_ERROR if succeeds else an error code.
173 	*/
174 	inline RegError loadKey(RegistryKey& rKey,
175 				  			 const ::rtl::OUString& keyName,
176 				  			 const ::rtl::OUString& regFileName);
177 
178 	/**	saves the registry information of the specified key and all subkeys and save
179 		it in the specified file.
180 
181 		@param	rKey references a currently open key. The key which information is saved by this
182                      function is a subkey of this key.
183 		@param	keyName	specifies the name of the key which information should be stored.
184                         If keyName is an empty string the registry information under the key specified
185                         by rKey is saved in the specified file.
186 		@param	regFileName	specifies the file containing the registry information.
187 		@return	REG_NO_ERROR if succeeds else an error code.
188 	*/
189 	inline RegError saveKey(RegistryKey& rKey,
190 				  			 const ::rtl::OUString& keyName,
191 				  			 const ::rtl::OUString& regFileName);
192 
193 	/**	merges the registry information of the specified key with the registry
194 		information of the specified file.
195 
196         All existing keys will be extended and existing key values will be overwritten.
197 		@param	rKey references a currently open key. The key which information is merged by this
198                      function is a subkey of this key
199 		@param	keyName	specifies the name of the key which will be merged.
200                         If keyName is an empty string the registry information under the key specified
201                         by rKey is merged with the information from the specified file.
202 		@param	regFileName	specifies the file containing the registry information.
203 		@param	bWarnings if TRUE the function returns an error if a key already exists.
204 		@param	bReport if TRUE the function reports warnings on stdout if a key already exists.
205 		@return	REG_NO_ERROR if succeeds else an error code. If it returns an error the registry will
206                 restore the state before merging.
207 	*/
208 	inline RegError mergeKey(RegistryKey& rKey,
209 				   			 const ::rtl::OUString& keyName,
210 				   			 const ::rtl::OUString& regFileName,
211 							 sal_Bool bWarnings = sal_False,
212 				   			 sal_Bool bReport = sal_False);
213 
214     /**	This function reports the complete registry information of a key and all of its subkeys.
215 
216         All information which are available (keynames, value types, values, ...)
217         will be printed to stdout for report issues only.
218 	    @param	rKey references a currently open key which content will be reported.
219 	    @return	REG_NO_ERROR if succeeds else an error code.
220     */
221 	inline RegError dumpRegistry(RegistryKey& rKey);
222 
223 	friend class RegistryKey;
224 	friend class RegistryKeyArray;
225 	friend class RegistryKeyNames;
226 
227     /// returns the used registry Api.
getApi()228 	const Registry_Api* getApi() { return m_pApi; }
229 protected:
230 
231     /// stores the used and initialized registry Api.
232 	const Registry_Api*							 m_pApi;
233     /// stores the handle of the underlying registry file on which most of the functions work.
234 	RegHandle									 m_hImpl;
235 };
236 
237 
238 //-----------------------------------------------------------------------------
239 
240 /** RegistryKeyArray represents an array of open keys.
241 
242 	RegistryKeyArray is a helper class to work with an array of keys.
243 */
244 class RegistryKeyArray
245 {
246 public:
247 	/// Default constructor
248 	inline RegistryKeyArray();
249 
250 	/// Destructor, all subkeys will be closed.
251 	inline ~RegistryKeyArray();
252 
253 	/// returns the open key specified by index.
254 	inline RegistryKey getElement(sal_uInt32 index);
255 
256 	/// returns the length of the array.
257 	inline sal_uInt32 getLength();
258 
259 	friend class RegistryKey;
260 protected:
261     /** sets the data of the key array.
262 
263         @param registry specifies the registry files where the keys are located.
264         @param phKeys points to an array of open keys.
265         @param length specifies the length of the array specified by phKeys.
266      */
267 	inline void setKeyHandles(Registry& registry, RegKeyHandle* phKeys, sal_uInt32 length);
268     /// close all subkeys
269 	inline RegError closeKeyHandles();
270 
271     /// stores the number of open subkeys, the number of elements.
272 	sal_uInt32 	   	m_length;
273     /// stores an array of open subkeys.
274 	RegKeyHandle*	m_phKeys;
275     /// stores the handle to the registry file where the appropriate keys are located.
276 	Registry		m_registry;
277 };
278 
279 
280 /** RegistryKeyNames represents an array of key names.
281 
282 	RegistryKeyNames is a helper class to work with an array of key names.
283 */
284 class RegistryKeyNames
285 {
286 public:
287 	/// Default constructor
288 	inline RegistryKeyNames();
289 
290 	/// Destructor, the internal array with key names will be deleted.
291 	inline ~RegistryKeyNames();
292 
293 	/// returns the name of the key sepecified by index.
294 	inline ::rtl::OUString getElement(sal_uInt32 index);
295 
296 	/// returns the length of the array.
297 	inline sal_uInt32 getLength();
298 
299 	friend class RegistryKey;
300 protected:
301     /** sets the data of the array.
302 
303         @param registry specifies the registry files where the keys are located.
304         @param pKeyNames points to an array of key names.
305         @param length specifies the length of the array specified by pKeyNames.
306      */
307 	inline void setKeyNames(Registry& registry, rtl_uString** pKeyNames, sal_uInt32 length);
308     /// delete the array of key names.
309 	inline RegError freeKeyNames();
310 
311     /// stores the number of key names, the number of elements.
312 	sal_uInt32 		m_length;
313     /// stores an array of key names.
314 	rtl_uString**	m_pKeyNames;
315     /// stores the handle to the registry file where the appropriate keys are located.
316 	Registry		m_registry;
317 };
318 
319 //-----------------------------------------------------------------------------
320 
321 /** RegistryValueList represents a value list of the specified type.
322 
323 	RegistryValueList is a helper class to work with a list value.
324 */
325 template<class ValueType>
326 class RegistryValueList
327 {
328 public:
329 	/// Default constructor
RegistryValueList()330 	RegistryValueList()
331 		: m_length(0)
332 		, m_pValueList(NULL)
333 		, m_valueType(RG_VALUETYPE_NOT_DEFINED)
334 		{}
335 
336 	/// Destructor, the internal value list will be freed.
~RegistryValueList()337 	~RegistryValueList()
338 	{
339 		if (m_pValueList)
340 		{
341 			m_registry.getApi()->freeValueList(m_valueType, m_pValueList, m_length);
342 		}
343 	}
344 
345 	/// returns the value of the list specified by index.
getElement(sal_uInt32 index)346 	ValueType getElement(sal_uInt32 index)
347 	{
348 		if (m_registry.isValid() && index < m_length)
349 		{
350 			return m_pValueList[index];
351 		} else
352 		{
353 			return 0;
354 		}
355 	}
356 
357 	/// returns the length of the list.
getLength()358 	sal_uInt32 getLength()
359 	{
360 		return m_length;
361 	}
362 
363 	friend class RegistryKey;
364 protected:
365     /** sets the data of the value list.
366 
367         @param registry specifies the registry files where the appropriate key is located.
368         @param valueType specifies the type of the list values.
369         @param pValueList points to a value list.
370         @param length specifies the length of the list.
371      */
setValueList(Registry & registry,RegValueType valueType,ValueType * pValueList,sal_uInt32 length)372 	void setValueList(Registry& registry, RegValueType valueType,
373 					  ValueType* pValueList, sal_uInt32 length)
374 	{
375 		m_length = length;
376 		m_pValueList = pValueList;
377 		m_valueType = valueType;
378 		m_registry = registry;
379 	}
380 
381     /// stores the length of the list, the number of elements.
382 	sal_uInt32 		m_length;
383     /// stores the value list.
384 	ValueType*		m_pValueList;
385     /// stores the type of the list elements
386 	RegValueType	m_valueType;
387     /** stores the handle to the registry file where the appropriate key to this
388         value is located.
389     */
390 	Registry		m_registry;
391 };
392 
393 //-----------------------------------------------------------------------------
394 
395 /** RegistryKey reads or writes information of the underlying key in a registry.
396 
397 	Class is inline and use a load on call C-Api.
398 */
399 class RegistryKey
400 {
401 public:
402 	/// Default constructor
403 	inline RegistryKey();
404 
405 	/// Copy constructor
406 	inline RegistryKey(const RegistryKey& toCopy);
407 
408 	/// Destructor, close the key if it references an open one.
409 	inline ~RegistryKey();
410 
411 	/// Assign operator
412 	inline RegistryKey& operator = (const RegistryKey& toAssign);
413 
414 	/// checks if the key points to a valid registry key.
415 	inline sal_Bool	isValid() const;
416 
417 	/**	returns the access mode of the key.
418 
419 		@return	TRUE if access mode is read only else FALSE.
420 	*/
421 	inline sal_Bool 	isReadOnly() const;
422 
423 	/// returns the full qualified name of the key beginning with the rootkey.
424 	inline ::rtl::OUString getName();
425 
426 	/**	creates a new key or opens a key if the specified key already exists.
427 
428         The specified keyname is relativ to this key.
429 		@param	keyName	specifies the name of the key which will be opened or created.
430 		@param	rNewKey	references a RegistryKey which will be filled with the new or open key.
431 		@return	REG_NO_ERROR if succeeds else an error code.
432 	*/
433 	inline RegError createKey(const ::rtl::OUString& keyName,
434 							  RegistryKey& rNewKey);
435 
436 	/**	opens the specified key.
437 
438         The specified keyname is relativ to this key.
439 		@param	keyName	specifies the name of the key which will be opened.
440 		@param	rOpenKey references a RegistryKey which will be filled with the open key.
441 		@return	REG_NO_ERROR if succeeds else an error code.
442 	*/
443 	inline RegError openKey(const ::rtl::OUString& keyName,
444 				  			RegistryKey& rOpenKey);
445 
446 	/**	opens all subkeys of the specified key.
447 
448         The specified keyname is relativ to this key.
449 		@param	keyName	specifies the name of the key which subkeys will be opened.
450 		@param	rSubKeys reference a RegistryKeyArray which will be filled with the open subkeys.
451 		@return	REG_NO_ERROR if succeeds else an error code.
452 	*/
453 	inline RegError openSubKeys(const ::rtl::OUString& keyName,
454 					  	  		RegistryKeyArray& rSubKeys);
455 
456 	/**	returns an array with the names of all subkeys of the specified key.
457 
458         The specified keyname is relativ to this key.
459 		@param	keyName	specifies the name of the key which subkey names will be returned.
460 		@param	rSubKeyNames reference a RegistryKeyNames array which will be filled with the subkey names.
461 		@return	REG_NO_ERROR if succeeds else an error code.
462 	*/
463 	inline RegError getKeyNames(const ::rtl::OUString& keyName,
464 					  	  		RegistryKeyNames& rSubKeyNames);
465 
466 	/**	closes all keys specified in the array.
467 
468 		@param	rSubKeys reference a RegistryKeyArray which contains the open keys.
469 		@return	REG_NO_ERROR if succeeds else an error code.
470 	*/
471 	inline RegError closeSubKeys(RegistryKeyArray& rSubKeys);
472 
473 	/**	deletes the specified key.
474 
475 		@param	keyName	specifies the name of the key which will be deleted.
476 		@return	REG_NO_ERROR if succeeds else an error code.
477 	*/
478 	inline RegError deleteKey(const ::rtl::OUString& keyName);
479 
480 	/// closes explicitly the current key
481 	inline RegError closeKey();
482 
483 	/// releases the current key
484 	inline void releaseKey();
485 
486 	/**	sets a value of a key.
487 
488 		@param	keyName	specifies the name of the key which value will be set.
489                         If keyName is an empty string, the value will be set for the key
490                         specified by hKey.
491 		@param	valueType specifies the type of the value.
492 		@param	pData points to a memory block containing the data for the value.
493 		@param	valueSize specifies the size of pData in bytes
494 		@return	REG_NO_ERROR if succeeds else an error code.
495 	*/
496 	inline RegError setValue(const ::rtl::OUString& keyName,
497 				   			 RegValueType valueType,
498 				   			 RegValue pValue,
499 				   			 sal_uInt32 valueSize);
500 
501 	/**	sets a long list value of a key.
502 
503 		@param	keyName	specifies the name of the key which value will be set.
504                         If keyName is an empty string, the value will be set for the key
505                         specified by hKey.
506 		@param	pValueList points to an array of longs containing the data for the value.
507 		@param	len specifies the length of the list (the array referenced by pValueList).
508 		@return	REG_NO_ERROR if succeeds else an error code.
509 	*/
510 	inline RegError setLongListValue(const ::rtl::OUString& keyName,
511 				   			 		 sal_Int32* pValueList,
512 				   			 		 sal_uInt32 len);
513 
514 	/**	sets an ascii list value of a key.
515 
516 		@param	keyName	specifies the name of the key which value will be set.
517                         If keyName is an empty string, the value will be set for the key
518                         specified by hKey.
519 		@param	pValueList points to an array of sal_Char* containing the data for the value.
520 		@param	len specifies the length of the list (the array referenced by pValueList).
521 		@return	REG_NO_ERROR if succeeds else an error code.
522 	*/
523 	inline RegError setStringListValue(const ::rtl::OUString& keyName,
524 				   			 		   sal_Char** pValueList,
525 				   			 		   sal_uInt32 len);
526 
527 	/**	sets an unicode string list value of a key.
528 
529 		@param	keyName	specifies the name of the key which value will be set.
530                         If keyName is an empty string, the value will be set for the key
531                         specified by hKey.
532 		@param	pValueList points to an array of sal_Unicode* containing the data for the value.
533 		@param	len specifies the length of the list (the array referenced by pValueList).
534 		@return	REG_NO_ERROR if succeeds else an error code.
535 	*/
536 	inline RegError setUnicodeListValue(const ::rtl::OUString& keyName,
537 				   			 		    sal_Unicode** pValueList,
538 				   			 		  	sal_uInt32 len);
539 
540 	/**	gets info about type and size of a value.
541 
542 		@param	keyName	specifies the name of the key which value info will be returned.
543                         If keyName is an empty string, the value info of the key
544                         specified by hKey will be returned.
545 		@param	pValueType returns the type of the value.
546 		@param	pValueSize returns the size of the value in bytes or the length of a list value.
547 		@return	REG_NO_ERROR if succeeds else an error code.
548 	*/
549 	inline RegError getValueInfo(const ::rtl::OUString& keyName,
550 					   			 RegValueType* pValueType,
551 					   			 sal_uInt32* pValueSize);
552 
553 	/**	gets the value of a key.
554 
555 		@param	keyName	specifies the name of the key which value will be returned.
556                         If keyName is an empty string, the value is get from the key
557                         specified by hKey.
558 		@param	pValue points to an allocated memory block receiving the data of the value.
559 		@return	REG_NO_ERROR if succeeds else an error code.
560 	*/
561 	inline RegError getValue(const ::rtl::OUString& keyName,
562 				   			 RegValue pValue);
563 
564 	/**	gets a long list value of a key.
565 
566 		@param	keyName	specifies the name of the key which value will be returned.
567                         If keyName is an empty string, the value is get from the key
568                         specified by hKey.
569 		@param	rValueList references a RegistryValueList which will be filled with the long values.
570 		@return	REG_NO_ERROR if succeeds else an error code.
571 	*/
572 	inline RegError getLongListValue(const ::rtl::OUString& keyName,
573 					  	  			  RegistryValueList<sal_Int32>& rValueList);
574 
575 	/**	gets an ascii list value of a key.
576 
577 		@param	keyName	specifies the name of the key which value will be returned.
578                         If keyName is an empty string, the value is get from the key
579                         specified by hKey.
580 		@param	rValueList references a RegistryValueList which will be filled with the ascii values.
581 		@return	REG_NO_ERROR if succeeds else an error code.
582 	*/
583 	inline RegError getStringListValue(const ::rtl::OUString& keyName,
584 					  	  			   RegistryValueList<sal_Char*>& rValueList);
585 
586 	/**	gets a unicode value of a key.
587 
588 		@param	keyName	specifies the name of the key which value will be returned.
589                         If keyName is an empty string, the value is get from the key
590                         specified by hKey.
591 		@param	rValueList reference a RegistryValueList which will be filled with the unicode values.
592 		@return	REG_NO_ERROR if succeeds else an error code.
593 	*/
594 	inline RegError getUnicodeListValue(const ::rtl::OUString& keyName,
595 					  	  			  	RegistryValueList<sal_Unicode*>& rValueList);
596 
597     /** used to create a link.
598 
599         @obsolete Links are no longer supported.
600 
601         @return	REG_INVALID_LINK
602      */
603 	inline RegError	createLink(const ::rtl::OUString& linkName,
604 							   const ::rtl::OUString& linkTarget);
605 
606     /** used to delete a link.
607 
608         @obsolete Links are no longer supported.
609 
610         @return	REG_INVALID_LINK
611      */
612 	inline RegError	deleteLink(const ::rtl::OUString& linkName);
613 
614     /** returns the type of the specified key.
615 
616         @param name specifies the name of the key or link.
617         @param pKeyType returns the type of the key (always RG_KEYTYPE).
618 		@return	REG_NO_ERROR if succeeds else an error code.
619      */
620 	inline RegError	getKeyType(const ::rtl::OUString& name,
621 						   	   RegKeyType* pKeyType) const;
622 
623     /** used to return the target of a link.
624 
625         @obsolete Links are no longer supported.
626 
627         @return	REG_INVALID_LINK
628      */
629 	inline RegError getLinkTarget(const ::rtl::OUString& linkName,
630 							  	  ::rtl::OUString& rLinkTarget) const;
631 
632 	/** resolves a keyname.
633 
634 		@param	keyName specifies the name of the key which will be resolved relativ to this key.
635                         The resolved name will be prefixed with the name of this key.
636         @param firstLinkOnly ignored
637 		@return	REG_NO_ERROR if succeeds else an error code.
638 	 */
639 	inline RegError getResolvedKeyName(const ::rtl::OUString& keyName,
640 									   sal_Bool firstLinkOnly,
641 						  	  		   ::rtl::OUString& rResolvedName) const;
642 
643 	/// returns the name of the registry in which the key is defined.
644 	inline ::rtl::OUString getRegistryName();
645 
646 	/// returns the registry in which the key is defined.
getRegistry() const647 	Registry getRegistry() const { return m_registry; }
648 
649 	friend class Registry;
650 public:
651     /** Constructor, which initialize a RegistryKey with registry and an valid key handle.
652 
653         This constructor is internal only.
654         @internal
655     */
656 	inline RegistryKey(Registry&	registry,
657 					   RegKeyHandle hKey);
658 
659     /** returns the internal key handle.
660 
661         @internal
662      */
getKeyHandle() const663 	RegKeyHandle getKeyHandle() const { return m_hImpl; }
664 
665 protected:
666     /** sets the internal registry on which this key should work.
667 
668         @internal
669      */
670 	inline void setRegistry(Registry& registry);
671 
672     /// stores the registry on which this key works
673 	Registry		m_registry;
674     /// stores the current key handle of this key
675 	RegKeyHandle	m_hImpl;
676 };
677 
678 
679 //-----------------------------------------------------------------------------
680 
RegistryKeyArray()681 inline RegistryKeyArray::RegistryKeyArray()
682 	: m_length(0)
683 	, m_phKeys(NULL)
684 {
685 }
686 
~RegistryKeyArray()687 inline RegistryKeyArray::~RegistryKeyArray()
688 {
689 	if (m_phKeys)
690 		m_registry.m_pApi->closeSubKeys(m_phKeys, m_length);
691 }
692 
getElement(sal_uInt32 index)693 inline RegistryKey RegistryKeyArray::getElement(sal_uInt32 index)
694 {
695 	if (m_registry.isValid() && index < m_length)
696 		return RegistryKey(m_registry, m_phKeys[index]);
697 	else
698 		return RegistryKey();
699 }
700 
getLength()701 inline sal_uInt32 RegistryKeyArray::getLength()
702 {
703 	return m_length;
704 }
705 
setKeyHandles(Registry & registry,RegKeyHandle * phKeys,sal_uInt32 length)706 inline void RegistryKeyArray::setKeyHandles(Registry& registry,
707 											RegKeyHandle* phKeys,
708 											sal_uInt32 length)
709 {
710 	m_phKeys = phKeys;
711 	m_length = length;
712 	m_registry = registry;
713 }
714 
closeKeyHandles()715 inline RegError RegistryKeyArray::closeKeyHandles()
716 {
717 	if (m_registry.isValid() && m_phKeys)
718 	{
719 		RegError ret;
720 		ret = m_registry.m_pApi->closeSubKeys(m_phKeys, m_length);
721 		m_registry = Registry();
722 		m_length = 0;
723 		m_phKeys = NULL;
724 		return ret;
725 	} else
726 		return(REG_INVALID_KEY);
727 }
728 
729 //-----------------------------------------------------------------------------
730 
RegistryKeyNames()731 inline RegistryKeyNames::RegistryKeyNames()
732 	: m_length(0)
733 	, m_pKeyNames(NULL)
734 {
735 }
736 
~RegistryKeyNames()737 inline RegistryKeyNames::~RegistryKeyNames()
738 {
739 	if (m_pKeyNames)
740 		m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length);
741 }
742 
getElement(sal_uInt32 index)743 inline ::rtl::OUString RegistryKeyNames::getElement(sal_uInt32 index)
744 {
745 
746 	if (m_pKeyNames && index < m_length)
747 		return m_pKeyNames[index];
748 	else
749 		return ::rtl::OUString();
750 }
751 
getLength()752 inline sal_uInt32 RegistryKeyNames::getLength()
753 {
754 	return m_length;
755 }
756 
setKeyNames(Registry & registry,rtl_uString ** pKeyNames,sal_uInt32 length)757 inline void RegistryKeyNames::setKeyNames(Registry& registry,
758 										  rtl_uString** pKeyNames,
759 										  sal_uInt32 length)
760 {
761 	m_pKeyNames = pKeyNames;
762 	m_length = length;
763 	m_registry = registry;
764 }
765 
freeKeyNames()766 inline RegError RegistryKeyNames::freeKeyNames()
767 {
768 	if (m_registry.isValid() && m_pKeyNames)
769 	{
770 		RegError ret = REG_NO_ERROR;
771 		ret = m_registry.m_pApi->freeKeyNames(m_pKeyNames, m_length);
772 		m_registry = Registry();
773 		m_length = 0;
774 		m_pKeyNames = NULL;
775 		return ret;
776 	} else
777 		return REG_INVALID_KEY;
778 }
779 
780 //-----------------------------------------------------------------------------
781 
RegistryKey()782 inline RegistryKey::RegistryKey()
783 	: m_hImpl(NULL)
784 	{ }
785 
RegistryKey(Registry & registry,RegKeyHandle hKey)786 inline RegistryKey::RegistryKey(Registry& registry, RegKeyHandle hKey)
787 	: m_registry(registry)
788 	, m_hImpl(hKey)
789 	{
790 		if (m_hImpl)
791 			m_registry.m_pApi->acquireKey(m_hImpl);
792 	}
793 
RegistryKey(const RegistryKey & toCopy)794 inline RegistryKey::RegistryKey(const RegistryKey& toCopy)
795 	: m_registry(toCopy.m_registry)
796 	, m_hImpl(toCopy.m_hImpl)
797 	{
798 		if (m_hImpl)
799 			m_registry.m_pApi->acquireKey(m_hImpl);
800 	}
801 
setRegistry(Registry & registry)802 inline void RegistryKey::setRegistry(Registry& registry)
803 	{
804 		m_registry = registry;
805 	}
806 
~RegistryKey()807 inline RegistryKey::~RegistryKey()
808 	{
809 		if (m_hImpl)
810 			m_registry.m_pApi->releaseKey(m_hImpl);
811 	}
812 
operator =(const RegistryKey & toAssign)813 inline RegistryKey& RegistryKey::operator = (const RegistryKey& toAssign)
814 {
815 	m_registry = toAssign.m_registry;
816 
817 	if (toAssign.m_hImpl)
818 		m_registry.m_pApi->acquireKey(toAssign.m_hImpl);
819 	if (m_hImpl)
820 		m_registry.m_pApi->releaseKey(m_hImpl);
821 	m_hImpl = toAssign.m_hImpl;
822 
823 	return *this;
824 }
825 
isValid() const826 inline sal_Bool RegistryKey::isValid() const
827 	{  return (m_hImpl != NULL); }
828 
isReadOnly() const829 inline sal_Bool RegistryKey::isReadOnly() const
830 	{
831 		if 	(m_registry.isValid())
832 			return (m_registry.m_pApi)->isKeyReadOnly(m_hImpl);
833 		else
834 			return sal_False;
835 	}
836 
getName()837 inline ::rtl::OUString RegistryKey::getName()
838 	{
839 		::rtl::OUString sRet;
840 		if (m_registry.isValid())
841 			m_registry.m_pApi->getKeyName(m_hImpl, &sRet.pData);
842 		return sRet;;
843 	}
844 
createKey(const::rtl::OUString & keyName,RegistryKey & rNewKey)845 inline RegError RegistryKey::createKey(const ::rtl::OUString& keyName,
846 						   			   RegistryKey& rNewKey)
847 	{
848 		if (rNewKey.isValid()) rNewKey.closeKey();
849 		if (m_registry.isValid())
850 		{
851 			RegError ret = m_registry.m_pApi->createKey(m_hImpl, keyName.pData, &rNewKey.m_hImpl);
852 			if (!ret) rNewKey.setRegistry(m_registry);
853 			return ret;
854 		} else
855 			return REG_INVALID_KEY;
856 	}
857 
openKey(const::rtl::OUString & keyName,RegistryKey & rOpenKey)858 inline RegError RegistryKey::openKey(const ::rtl::OUString& keyName,
859 			  			 		  RegistryKey& rOpenKey)
860 	{
861 		if (rOpenKey.isValid()) rOpenKey.closeKey();
862 		if (m_registry.isValid())
863 		{
864 			RegError ret = m_registry.m_pApi->openKey(m_hImpl, keyName.pData,
865 													&rOpenKey.m_hImpl);
866 			if (!ret) rOpenKey.setRegistry(m_registry);
867 			return ret;
868 		} else
869 			return REG_INVALID_KEY;
870 	}
871 
openSubKeys(const::rtl::OUString & keyName,RegistryKeyArray & rSubKeys)872 inline RegError RegistryKey::openSubKeys(const ::rtl::OUString& keyName,
873 										 RegistryKeyArray& rSubKeys)
874 	{
875 		if (m_registry.isValid())
876 		{
877 			RegError 		ret = REG_NO_ERROR;
878 			RegKeyHandle* 	pSubKeys;
879 			sal_uInt32 		nSubKeys;
880 	 		ret = m_registry.m_pApi->openSubKeys(m_hImpl, keyName.pData,
881 	 												 &pSubKeys, &nSubKeys);
882 	 		if ( ret )
883 			{
884 				return ret;
885 			} else
886 			{
887 				rSubKeys.setKeyHandles(m_registry, pSubKeys, nSubKeys);
888 				return ret;
889 			}
890 		} else
891 			return REG_INVALID_KEY;
892 	}
893 
getKeyNames(const::rtl::OUString & keyName,RegistryKeyNames & rSubKeyNames)894 inline RegError RegistryKey::getKeyNames(const ::rtl::OUString& keyName,
895 					  	  				 RegistryKeyNames& rSubKeyNames)
896 	{
897 		if (m_registry.isValid())
898 		{
899 			RegError 		ret = REG_NO_ERROR;
900 			rtl_uString**	pSubKeyNames;
901 			sal_uInt32 		nSubKeys;
902 	 		ret = m_registry.m_pApi->getKeyNames(m_hImpl, keyName.pData,
903 	 											 &pSubKeyNames, &nSubKeys);
904 	 		if ( ret )
905 			{
906 				return ret;
907 			} else
908 			{
909 				rSubKeyNames.setKeyNames(m_registry, pSubKeyNames, nSubKeys);
910 				return ret;
911 			}
912 		} else
913 			return REG_INVALID_KEY;
914 	}
915 
closeSubKeys(RegistryKeyArray & rSubKeys)916 inline RegError RegistryKey::closeSubKeys(RegistryKeyArray& rSubKeys)
917 	{
918 		if (m_registry.isValid())
919 			return rSubKeys.closeKeyHandles();
920 		else
921 			return REG_INVALID_KEY;
922 	}
923 
deleteKey(const::rtl::OUString & keyName)924 inline RegError RegistryKey::deleteKey(const ::rtl::OUString& keyName)
925 	{
926 		if (m_registry.isValid())
927 			return m_registry.m_pApi->deleteKey(m_hImpl, keyName.pData);
928 		else
929 			return REG_INVALID_KEY;
930 	}
931 
closeKey()932 inline RegError RegistryKey::closeKey()
933 	{
934 		if (m_registry.isValid())
935 		{
936 			RegError ret = m_registry.m_pApi->closeKey(m_hImpl);
937 			if (!ret)
938 			{
939 				m_hImpl = NULL;
940 				m_registry = Registry();
941 			}
942 			return ret;
943 		} else
944 			return REG_INVALID_KEY;
945 	}
946 
releaseKey()947 inline void RegistryKey::releaseKey()
948 {
949 	if (m_registry.isValid() && (m_hImpl != 0))
950 	{
951 		m_registry.m_pApi->releaseKey(m_hImpl), m_hImpl = 0;
952 	}
953 }
954 
setValue(const::rtl::OUString & keyName,RegValueType valueType,RegValue pValue,sal_uInt32 valueSize)955 inline RegError RegistryKey::setValue(const ::rtl::OUString& keyName,
956 			   			  		   	  RegValueType valueType,
957 			   			  		      RegValue pValue,
958 			   			  		   	  sal_uInt32 valueSize)
959 	{
960 		if (m_registry.isValid())
961 			return m_registry.m_pApi->setValue(m_hImpl, keyName.pData, valueType,
962 								 			   pValue, valueSize);
963 		else
964 			return REG_INVALID_KEY;
965 	}
966 
setLongListValue(const::rtl::OUString & keyName,sal_Int32 * pValueList,sal_uInt32 len)967 inline RegError RegistryKey::setLongListValue(const ::rtl::OUString& keyName,
968 			   			 					  sal_Int32* pValueList,
969 						   			 		  sal_uInt32 len)
970 	{
971 		if (m_registry.isValid())
972 			return m_registry.m_pApi->setLongListValue(m_hImpl, keyName.pData,
973 								 			   		   pValueList, len);
974 		else
975 			return REG_INVALID_KEY;
976 	}
977 
setStringListValue(const::rtl::OUString & keyName,sal_Char ** pValueList,sal_uInt32 len)978 inline RegError RegistryKey::setStringListValue(const ::rtl::OUString& keyName,
979 			   			 					   sal_Char** pValueList,
980 						   			 		   sal_uInt32 len)
981 	{
982 		if (m_registry.isValid())
983 			return m_registry.m_pApi->setStringListValue(m_hImpl, keyName.pData,
984 								 			   			pValueList, len);
985 		else
986 			return REG_INVALID_KEY;
987 	}
988 
setUnicodeListValue(const::rtl::OUString & keyName,sal_Unicode ** pValueList,sal_uInt32 len)989 inline RegError RegistryKey::setUnicodeListValue(const ::rtl::OUString& keyName,
990 			   			 					   	 sal_Unicode** pValueList,
991 						   			 		   	 sal_uInt32 len)
992 	{
993 		if (m_registry.isValid())
994 			return m_registry.m_pApi->setUnicodeListValue(m_hImpl, keyName.pData,
995 								 			   			  pValueList, len);
996 		else
997 			return REG_INVALID_KEY;
998 	}
999 
getValueInfo(const::rtl::OUString & keyName,RegValueType * pValueType,sal_uInt32 * pValueSize)1000 inline RegError RegistryKey::getValueInfo(const ::rtl::OUString& keyName,
1001 				   			  		   	  RegValueType* pValueType,
1002 				   			  		   	  sal_uInt32* pValueSize)
1003 	{
1004 		if (m_registry.isValid())
1005 			return m_registry.m_pApi->getValueInfo(m_hImpl, keyName.pData, pValueType, pValueSize);
1006 		else
1007 			return REG_INVALID_KEY;
1008 	}
1009 
getValue(const::rtl::OUString & keyName,RegValue pValue)1010 inline RegError RegistryKey::getValue(const ::rtl::OUString& keyName,
1011 			   			  		   RegValue pValue)
1012 	{
1013 		if (m_registry.isValid())
1014 			return m_registry.m_pApi->getValue(m_hImpl, keyName.pData, pValue);
1015 		else
1016 			return REG_INVALID_KEY;
1017 	}
1018 
getLongListValue(const::rtl::OUString & keyName,RegistryValueList<sal_Int32> & rValueList)1019 inline RegError RegistryKey::getLongListValue(const ::rtl::OUString& keyName,
1020 				  	  			  		RegistryValueList<sal_Int32>& rValueList)
1021 	{
1022 		if (m_registry.isValid())
1023 		{
1024 			RegError 	ret = REG_NO_ERROR;
1025 			sal_Int32* 	pValueList;
1026 			sal_uInt32 	length;
1027 	 		ret = m_registry.m_pApi->getLongListValue(m_hImpl, keyName.pData,
1028 	 												 &pValueList, &length);
1029 	 		if ( ret )
1030 			{
1031 				return ret;
1032 			} else
1033 			{
1034 				rValueList.setValueList(m_registry, RG_VALUETYPE_LONGLIST,
1035 										pValueList, length);
1036 				return ret;
1037 			}
1038 		} else
1039 			return REG_INVALID_KEY;
1040 	}
1041 
getStringListValue(const::rtl::OUString & keyName,RegistryValueList<sal_Char * > & rValueList)1042 inline RegError RegistryKey::getStringListValue(const ::rtl::OUString& keyName,
1043 				  	  			  				RegistryValueList<sal_Char*>& rValueList)
1044 	{
1045 		if (m_registry.isValid())
1046 		{
1047 			RegError 	ret = REG_NO_ERROR;
1048 			sal_Char** 	pValueList;
1049 			sal_uInt32 	length;
1050 	 		ret = m_registry.m_pApi->getStringListValue(m_hImpl, keyName.pData,
1051 	 												 &pValueList, &length);
1052 	 		if ( ret )
1053 			{
1054 				return ret;
1055 			} else
1056 			{
1057 				rValueList.setValueList(m_registry, RG_VALUETYPE_STRINGLIST,
1058 										pValueList, length);
1059 				return ret;
1060 			}
1061 		} else
1062 			return REG_INVALID_KEY;
1063 	}
1064 
getUnicodeListValue(const::rtl::OUString & keyName,RegistryValueList<sal_Unicode * > & rValueList)1065 inline RegError RegistryKey::getUnicodeListValue(const ::rtl::OUString& keyName,
1066 				  	  			  		RegistryValueList<sal_Unicode*>& rValueList)
1067 	{
1068 		if (m_registry.isValid())
1069 		{
1070 			RegError 		ret = REG_NO_ERROR;
1071 			sal_Unicode** 	pValueList;
1072 			sal_uInt32 		length;
1073 	 		ret = m_registry.m_pApi->getUnicodeListValue(m_hImpl, keyName.pData,
1074 	 												 &pValueList, &length);
1075 	 		if ( ret )
1076 			{
1077 				return ret;
1078 			} else
1079 			{
1080 				rValueList.setValueList(m_registry, RG_VALUETYPE_UNICODELIST,
1081 										pValueList, length);
1082 				return ret;
1083 			}
1084 		} else
1085 			return REG_INVALID_KEY;
1086 	}
1087 
createLink(const::rtl::OUString & linkName,const::rtl::OUString & linkTarget)1088 inline RegError	RegistryKey::createLink(const ::rtl::OUString& linkName,
1089 						   				const ::rtl::OUString& linkTarget)
1090 	{
1091 		if (m_registry.isValid())
1092 			return m_registry.m_pApi->createLink(m_hImpl, linkName.pData, linkTarget.pData);
1093 		else
1094 			return REG_INVALID_KEY;
1095 	}
1096 
deleteLink(const::rtl::OUString & linkName)1097 inline RegError	RegistryKey::deleteLink(const ::rtl::OUString& linkName)
1098 	{
1099 		if (m_registry.isValid())
1100 			return m_registry.m_pApi->deleteLink(m_hImpl, linkName.pData);
1101 		else
1102 			return REG_INVALID_KEY;
1103 	}
1104 
getKeyType(const::rtl::OUString & keyName,RegKeyType * pKeyType) const1105 inline RegError	RegistryKey::getKeyType(const ::rtl::OUString& keyName,
1106 					   	   				RegKeyType* pKeyType) const
1107 	{
1108 		if (m_registry.isValid())
1109 			return m_registry.m_pApi->getKeyType(m_hImpl, keyName.pData, pKeyType);
1110 		else
1111 			return REG_INVALID_KEY;
1112 	}
1113 
getLinkTarget(const::rtl::OUString & linkName,::rtl::OUString & rLinkTarget) const1114 inline RegError RegistryKey::getLinkTarget(const ::rtl::OUString& linkName,
1115 						  	  			   ::rtl::OUString& rLinkTarget) const
1116 	{
1117 		if (m_registry.isValid())
1118 		{
1119 			return m_registry.m_pApi->getLinkTarget(m_hImpl,
1120 													linkName.pData,
1121 													&rLinkTarget.pData);
1122 		} else
1123 			return REG_INVALID_KEY;
1124 	}
1125 
1126 
getResolvedKeyName(const::rtl::OUString & keyName,sal_Bool firstLinkOnly,::rtl::OUString & rResolvedName) const1127 inline RegError RegistryKey::getResolvedKeyName(const ::rtl::OUString& keyName,
1128 								   				sal_Bool firstLinkOnly,
1129 					  	  		   				::rtl::OUString& rResolvedName) const
1130 	{
1131 		if (m_registry.isValid())
1132 			return m_registry.m_pApi->getResolvedKeyName(m_hImpl,
1133 														 keyName.pData,
1134 														 firstLinkOnly,
1135 														 &rResolvedName.pData);
1136 		else
1137 			return REG_INVALID_KEY;
1138 	}
1139 
getRegistryName()1140 inline ::rtl::OUString RegistryKey::getRegistryName()
1141 	{
1142 		if (m_registry.isValid())
1143 		{
1144 			return m_registry.getName();
1145 		} else
1146 			return ::rtl::OUString();
1147 	}
1148 
1149 //-----------------------------------------------------------------------------
1150 
Registry()1151 inline Registry::Registry()
1152 	: m_pApi(initRegistry_Api())
1153 	, m_hImpl(NULL)
1154 	{ }
1155 
Registry(const Registry & toCopy)1156 inline Registry::Registry(const Registry& toCopy)
1157 	: m_pApi(toCopy.m_pApi)
1158 	, m_hImpl(toCopy.m_hImpl)
1159 	{
1160 		if (m_hImpl)
1161 			m_pApi->acquire(m_hImpl);
1162 	}
1163 
1164 
~Registry()1165 inline Registry::~Registry()
1166 	{
1167 		if (m_hImpl)
1168 			m_pApi->release(m_hImpl);
1169 	}
1170 
operator =(const Registry & toAssign)1171 inline Registry& Registry::operator = (const Registry& toAssign)
1172 {
1173 	if (toAssign.m_hImpl)
1174 		toAssign.m_pApi->acquire(toAssign.m_hImpl);
1175 	if (m_hImpl)
1176 		m_pApi->release(m_hImpl);
1177 
1178 	m_pApi  = toAssign.m_pApi;
1179 	m_hImpl = toAssign.m_hImpl;
1180 
1181 	return *this;
1182 }
1183 
isValid() const1184 inline sal_Bool Registry::isValid() const
1185 	{  return ( m_hImpl != NULL ); }
1186 
isReadOnly() const1187 inline sal_Bool Registry::isReadOnly() const
1188 	{  return m_pApi->isReadOnly(m_hImpl); }
1189 
openRootKey(RegistryKey & rRootKey)1190 inline RegError Registry::openRootKey(RegistryKey& rRootKey)
1191 	{
1192 		rRootKey.setRegistry(*this);
1193 		return m_pApi->openRootKey(m_hImpl, &rRootKey.m_hImpl);
1194 	}
1195 
getName()1196 inline ::rtl::OUString Registry::getName()
1197 	{
1198 		::rtl::OUString sRet;
1199 		m_pApi->getName(m_hImpl, &sRet.pData);
1200 		return sRet;
1201 	}
1202 
create(const::rtl::OUString & registryName)1203 inline RegError Registry::create(const ::rtl::OUString& registryName)
1204 	{
1205 		if (m_hImpl)
1206 			m_pApi->release(m_hImpl);
1207 		return m_pApi->createRegistry(registryName.pData, &m_hImpl);
1208 	}
1209 
open(const::rtl::OUString & registryName,RegAccessMode accessMode)1210 inline RegError Registry::open(const ::rtl::OUString& registryName,
1211 				   			   RegAccessMode accessMode)
1212 	{
1213 		if (m_hImpl)
1214 			m_pApi->release(m_hImpl);
1215 		return m_pApi->openRegistry(registryName.pData, &m_hImpl, accessMode);
1216 	}
1217 
close()1218 inline RegError Registry::close()
1219 	{
1220 		RegError ret = m_pApi->closeRegistry(m_hImpl);
1221 		if (!ret)
1222 			m_hImpl = NULL;
1223 		return ret;
1224 	}
1225 
destroy(const::rtl::OUString & registryName)1226 inline RegError Registry::destroy(const ::rtl::OUString& registryName)
1227 	{
1228 		RegError ret = m_pApi->destroyRegistry(m_hImpl, registryName.pData);
1229 		if ( !ret && (registryName.getLength() == 0) )
1230 			m_hImpl = NULL;
1231 		return ret;
1232 	}
1233 
loadKey(RegistryKey & rKey,const::rtl::OUString & keyName,const::rtl::OUString & regFileName)1234 inline RegError Registry::loadKey(RegistryKey& rKey,
1235 			  			 		   const ::rtl::OUString& keyName,
1236 			  			 		   const ::rtl::OUString& regFileName)
1237 	{  return m_pApi->loadKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); }
1238 
saveKey(RegistryKey & rKey,const::rtl::OUString & keyName,const::rtl::OUString & regFileName)1239 inline RegError Registry::saveKey(RegistryKey& rKey,
1240 			  			 		  const ::rtl::OUString& keyName,
1241 			  			 		  const ::rtl::OUString& regFileName)
1242 	{  return m_pApi->saveKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData); }
1243 
mergeKey(RegistryKey & rKey,const::rtl::OUString & keyName,const::rtl::OUString & regFileName,sal_Bool bWarnings,sal_Bool bReport)1244 inline RegError Registry::mergeKey(RegistryKey& rKey,
1245 			   			  			const ::rtl::OUString& keyName,
1246 			   			  			const ::rtl::OUString& regFileName,
1247 			   			  			sal_Bool bWarnings,
1248 			   			  			sal_Bool bReport)
1249 	{  return m_pApi->mergeKey(m_hImpl, rKey.m_hImpl, keyName.pData, regFileName.pData, bWarnings, bReport); }
1250 
dumpRegistry(RegistryKey & rKey)1251 inline RegError Registry::dumpRegistry(RegistryKey& rKey)
1252 	{  return m_pApi->dumpRegistry(m_hImpl, rKey.m_hImpl); }
1253 
1254 
1255 #endif
1256