1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_REGISTRY_SOURCE_REGIMPL_HXX
21 #define INCLUDED_REGISTRY_SOURCE_REGIMPL_HXX
24 #include <unordered_map>
26 #include <registry/registry.h>
27 #include <rtl/ustring.hxx>
28 #include <osl/mutex.hxx>
29 #include <store/store.hxx>
31 #define REG_PAGESIZE 512
33 #define REG_MODE_CREATE store_AccessCreate
34 #define REG_MODE_OPEN store_AccessReadWrite
35 #define REG_MODE_OPENREAD store_AccessReadOnly
37 #define KEY_MODE_CREATE store_AccessCreate
38 #define KEY_MODE_OPEN store_AccessReadWrite
39 #define KEY_MODE_OPENREAD store_AccessReadOnly
42 #define VALUE_MODE_CREATE store_AccessCreate
43 #define VALUE_MODE_OPEN store_AccessReadWrite
44 #define VALUE_MODE_OPENREAD store_AccessReadOnly
46 // 5 bytes = 1 (byte for the type) + 4 (bytes for the size of the data)
47 #define VALUE_HEADERSIZE 5
48 #define VALUE_TYPEOFFSET 1
49 #define VALUE_HEADEROFFSET 5
51 #define REG_GUARD(mutex) \
52 osl::Guard< osl::Mutex > aGuard( mutex );
55 class RegistryTypeReader
;
63 { return ++m_refCount
; }
66 { return --m_refCount
; }
68 RegError
initRegistry(const OUString
& name
,
69 RegAccessMode accessMode
,
70 bool bCreate
= false);
72 RegError
closeRegistry();
74 RegError
destroyRegistry(const OUString
& name
);
76 RegError
acquireKey(RegKeyHandle hKey
);
77 RegError
releaseKey(RegKeyHandle hKey
);
79 RegError
createKey(RegKeyHandle hKey
,
80 const OUString
& keyName
,
81 RegKeyHandle
* phNewKey
);
83 RegError
openKey(RegKeyHandle hKey
,
84 const OUString
& keyName
,
85 RegKeyHandle
* phOpenKey
);
87 RegError
closeKey(RegKeyHandle hKey
);
89 RegError
deleteKey(RegKeyHandle hKey
, const OUString
& keyName
);
91 RegError
loadKey(RegKeyHandle hKey
,
92 const OUString
& regFileName
,
96 RegError
saveKey(RegKeyHandle hKey
,
97 const OUString
& regFileName
,
101 RegError
dumpRegistry(RegKeyHandle hKey
) const;
105 bool isReadOnly() const
106 { return m_readOnly
; }
111 ORegKey
* getRootKey();
113 const store::OStoreFile
& getStoreFile() const
116 const OUString
& getName() const
119 friend class ORegKey
;
122 RegError
eraseKey(ORegKey
* pKey
, const OUString
& keyName
);
124 RegError
deleteSubkeysAndValues(ORegKey
* pKey
);
126 RegError
loadAndSaveValue(ORegKey
* pTargetKey
,
128 const OUString
& valueName
,
130 bool bWarnings
=false,
133 static RegError
checkBlop(store::OStoreStream
& rValue
,
134 const OUString
& sTargetPath
,
135 sal_uInt32 srcValueSize
,
136 sal_uInt8
* pSrcBuffer
,
139 static RegError
mergeModuleValue(store::OStoreStream
& rTargetValue
,
140 RegistryTypeReader
& reader
,
141 RegistryTypeReader
& reader2
);
143 RegError
loadAndSaveKeys(ORegKey
* pTargetKey
,
145 const OUString
& keyName
,
147 bool bWarnings
=false,
150 RegError
dumpValue(const OUString
& sPath
,
151 const OUString
& sName
,
152 sal_Int16 nSpace
) const;
154 RegError
dumpKey(const OUString
& sPath
,
155 const OUString
& sName
,
156 sal_Int16 nSpace
) const;
158 typedef std::unordered_map
< OUString
, ORegKey
*, OUStringHash
> KeyMap
;
160 sal_uInt32 m_refCount
;
165 store::OStoreFile m_file
;
166 KeyMap m_openKeyTable
;
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */