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
23 #include <unordered_map>
26 #include <registry/regtype.h>
27 #include <rtl/ustring.hxx>
28 #include <osl/mutex.hxx>
29 #include <store/store.hxx>
31 // 5 bytes = 1 (byte for the type) + 4 (bytes for the size of the data)
32 #define VALUE_HEADERSIZE 5
33 #define VALUE_TYPEOFFSET 1
34 #define VALUE_HEADEROFFSET 5
36 #define REG_GUARD(mutex) \
37 osl::Guard< osl::Mutex > aGuard( mutex );
40 class RegistryTypeReader
;
48 { return ++m_refCount
; }
51 { return --m_refCount
; }
53 RegError
initRegistry(const OUString
& name
,
54 RegAccessMode accessMode
,
55 bool bCreate
= false);
57 RegError
closeRegistry();
59 RegError
destroyRegistry(const OUString
& name
);
61 RegError
acquireKey(RegKeyHandle hKey
);
62 RegError
releaseKey(RegKeyHandle hKey
);
64 RegError
createKey(RegKeyHandle hKey
,
65 const OUString
& keyName
,
66 RegKeyHandle
* phNewKey
);
68 RegError
openKey(RegKeyHandle hKey
,
69 const OUString
& keyName
,
70 RegKeyHandle
* phOpenKey
);
72 RegError
closeKey(RegKeyHandle hKey
);
74 RegError
deleteKey(RegKeyHandle hKey
, const OUString
& keyName
);
76 RegError
loadKey(RegKeyHandle hKey
,
77 const OUString
& regFileName
,
81 RegError
dumpRegistry(RegKeyHandle hKey
) const;
85 bool isReadOnly() const
86 { return m_readOnly
; }
91 ORegKey
* getRootKey();
93 const store::OStoreFile
& getStoreFile() const
96 const OUString
& getName() const
102 RegError
eraseKey(ORegKey
* pKey
, const OUString
& keyName
);
104 RegError
deleteSubkeysAndValues(ORegKey
* pKey
);
106 static RegError
loadAndSaveValue(ORegKey
* pTargetKey
,
107 ORegKey
const * pSourceKey
,
108 const OUString
& valueName
,
113 static RegError
checkBlop(store::OStoreStream
& rValue
,
114 const OUString
& sTargetPath
,
115 sal_uInt32 srcValueSize
,
116 sal_uInt8
const * pSrcBuffer
,
119 static RegError
mergeModuleValue(store::OStoreStream
& rTargetValue
,
120 RegistryTypeReader
const & reader
,
121 RegistryTypeReader
const & reader2
);
123 RegError
loadAndSaveKeys(ORegKey
* pTargetKey
,
125 const OUString
& keyName
,
130 RegError
dumpValue(const OUString
& sPath
,
131 const OUString
& sName
,
132 sal_Int16 nSpace
) const;
134 RegError
dumpKey(const OUString
& sPath
,
135 const OUString
& sName
,
136 sal_Int16 nSpace
) const;
138 typedef std::unordered_map
< OUString
, ORegKey
* > KeyMap
;
140 sal_uInt32 m_refCount
;
145 store::OStoreFile m_file
;
146 KeyMap m_openKeyTable
;
148 static constexpr OUStringLiteral ROOT
{ "/" };
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */