bump product version to 6.3.0.0.beta1
[LibreOffice.git] / registry / source / regimpl.hxx
blobd8a77394f2ac62b266e3afcc3351272b1010fca3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
25 #include <regapi.hxx>
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 );
39 class ORegKey;
40 class RegistryTypeReader;
42 class ORegistry
44 public:
45 ORegistry();
47 sal_uInt32 acquire()
48 { return ++m_refCount; }
50 sal_uInt32 release()
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,
78 bool bWarnings,
79 bool bReport);
81 RegError dumpRegistry(RegKeyHandle hKey) const;
83 ~ORegistry();
85 bool isReadOnly() const
86 { return m_readOnly; }
88 bool isOpen() const
89 { return m_isOpen; }
91 ORegKey* getRootKey();
93 const store::OStoreFile& getStoreFile() const
94 { return m_file; }
96 const OUString& getName() const
97 { return m_name; }
99 friend class ORegKey;
101 private:
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,
109 sal_uInt32 nCut,
110 bool bWarnings,
111 bool bReport);
113 static RegError checkBlop(store::OStoreStream& rValue,
114 const OUString& sTargetPath,
115 sal_uInt32 srcValueSize,
116 sal_uInt8 const * pSrcBuffer,
117 bool bReport);
119 static RegError mergeModuleValue(store::OStoreStream& rTargetValue,
120 RegistryTypeReader const & reader,
121 RegistryTypeReader const & reader2);
123 RegError loadAndSaveKeys(ORegKey* pTargetKey,
124 ORegKey* pSourceKey,
125 const OUString& keyName,
126 sal_uInt32 nCut,
127 bool bWarnings,
128 bool bReport);
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;
141 osl::Mutex m_mutex;
142 bool m_readOnly;
143 bool m_isOpen;
144 OUString m_name;
145 store::OStoreFile m_file;
146 KeyMap m_openKeyTable;
148 static constexpr OUStringLiteral ROOT { "/" };
151 #endif
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */