svx: maLocalListner -> maLocalListener
[LibreOffice.git] / registry / source / regimpl.hxx
blobd13d42b6d3dcc315c842c4292c2763787b632a5b
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 #pragma once
22 #include <sal/config.h>
24 #include <string_view>
25 #include <unordered_map>
27 #include <regapi.hxx>
28 #include <registry/regtype.h>
29 #include <rtl/ustring.hxx>
30 #include <osl/mutex.hxx>
31 #include <store/store.hxx>
33 // 5 bytes = 1 (byte for the type) + 4 (bytes for the size of the data)
34 #define VALUE_HEADERSIZE 5
35 #define VALUE_TYPEOFFSET 1
36 #define VALUE_HEADEROFFSET 5
38 #define REG_GUARD(mutex) \
39 osl::Guard< osl::Mutex > aGuard( mutex );
41 class ORegKey;
43 class ORegistry
45 public:
46 ORegistry();
48 sal_uInt32 acquire()
49 { return ++m_refCount; }
51 sal_uInt32 release()
52 { return --m_refCount; }
54 RegError initRegistry(const OUString& name,
55 RegAccessMode accessMode,
56 bool bCreate = false);
58 RegError closeRegistry();
60 RegError destroyRegistry(const OUString& name);
62 RegError acquireKey(RegKeyHandle hKey);
63 RegError releaseKey(RegKeyHandle hKey);
65 RegError createKey(RegKeyHandle hKey,
66 std::u16string_view keyName,
67 RegKeyHandle* phNewKey);
69 RegError openKey(RegKeyHandle hKey,
70 std::u16string_view keyName,
71 RegKeyHandle* phOpenKey);
73 RegError closeKey(RegKeyHandle hKey);
75 RegError deleteKey(RegKeyHandle hKey, std::u16string_view keyName);
77 RegError dumpRegistry(RegKeyHandle hKey) const;
79 ~ORegistry();
81 bool isReadOnly() const
82 { return m_readOnly; }
84 bool isOpen() const
85 { return m_isOpen; }
87 ORegKey* getRootKey();
89 const store::OStoreFile& getStoreFile() const
90 { return m_file; }
92 const OUString& getName() const
93 { return m_name; }
95 friend class ORegKey;
97 private:
98 RegError eraseKey(ORegKey* pKey, std::u16string_view keyName);
100 RegError deleteSubkeysAndValues(ORegKey* pKey);
102 RegError dumpValue(const OUString& sPath,
103 const OUString& sName,
104 sal_Int16 nSpace) const;
106 RegError dumpKey(const OUString& sPath,
107 const OUString& sName,
108 sal_Int16 nSpace) const;
110 typedef std::unordered_map< OUString, ORegKey* > KeyMap;
112 sal_uInt32 m_refCount;
113 osl::Mutex m_mutex;
114 bool m_readOnly;
115 bool m_isOpen;
116 OUString m_name;
117 store::OStoreFile m_file;
118 KeyMap m_openKeyTable;
120 static constexpr OUString ROOT { u"/"_ustr };
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */