LibreOffice Module registry (master) 1
regimpl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <string_view>
25#include <unordered_map>
26
27#include <regapi.hxx>
28#include <registry/regtype.h>
29#include <rtl/ustring.hxx>
30#include <osl/mutex.hxx>
31#include <store/store.hxx>
32
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
37
38#define REG_GUARD(mutex) \
39 osl::Guard< osl::Mutex > aGuard( mutex );
40
41class ORegKey;
42
44{
45public:
46 ORegistry();
47
48 sal_uInt32 acquire()
49 { return ++m_refCount; }
50
51 sal_uInt32 release()
52 { return --m_refCount; }
53
54 RegError initRegistry(const OUString& name,
55 RegAccessMode accessMode,
56 bool bCreate = false);
57
59
60 RegError destroyRegistry(const OUString& name);
61
64
66 std::u16string_view keyName,
67 RegKeyHandle* phNewKey);
68
70 std::u16string_view keyName,
71 RegKeyHandle* phOpenKey);
72
74
75 RegError deleteKey(RegKeyHandle hKey, std::u16string_view keyName);
76
78
79 ~ORegistry();
80
81 bool isReadOnly() const
82 { return m_readOnly; }
83
84 bool isOpen() const
85 { return m_isOpen; }
86
88
90 { return m_file; }
91
92 const OUString& getName() const
93 { return m_name; }
94
95 friend class ORegKey;
96
97private:
98 RegError eraseKey(ORegKey* pKey, std::u16string_view keyName);
99
101
102 RegError dumpValue(const OUString& sPath,
103 const OUString& sName,
104 sal_Int16 nSpace) const;
105
106 RegError dumpKey(const OUString& sPath,
107 const OUString& sName,
108 sal_Int16 nSpace) const;
109
110 typedef std::unordered_map< OUString, ORegKey* > KeyMap;
111
112 sal_uInt32 m_refCount;
113 osl::Mutex m_mutex;
116 OUString m_name;
119
120 static constexpr OUStringLiteral ROOT { u"/" };
121};
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 m_refCount
Definition: regimpl.hxx:112
RegError dumpKey(const OUString &sPath, const OUString &sName, sal_Int16 nSpace) const
Definition: regimpl.cxx:1119
const store::OStoreFile & getStoreFile() const
Definition: regimpl.hxx:89
ORegKey * getRootKey()
Definition: regimpl.cxx:849
RegError initRegistry(const OUString &name, RegAccessMode accessMode, bool bCreate=false)
Definition: regimpl.cxx:437
bool isOpen() const
Definition: regimpl.hxx:84
~ORegistry()
Definition: regimpl.cxx:427
RegError closeKey(RegKeyHandle hKey)
Definition: regimpl.cxx:704
RegError openKey(RegKeyHandle hKey, std::u16string_view keyName, RegKeyHandle *phOpenKey)
Definition: regimpl.cxx:658
RegError eraseKey(ORegKey *pKey, std::u16string_view keyName)
Definition: regimpl.cxx:749
RegError dumpRegistry(RegKeyHandle hKey) const
Definition: regimpl.cxx:855
bool m_isOpen
Definition: regimpl.hxx:115
osl::Mutex m_mutex
Definition: regimpl.hxx:113
sal_uInt32 acquire()
Definition: regimpl.hxx:48
RegError dumpValue(const OUString &sPath, const OUString &sName, sal_Int16 nSpace) const
Definition: regimpl.cxx:891
RegError deleteKey(RegKeyHandle hKey, std::u16string_view keyName)
Definition: regimpl.cxx:734
std::unordered_map< OUString, ORegKey * > KeyMap
Definition: regimpl.hxx:110
bool isReadOnly() const
Definition: regimpl.hxx:81
bool m_readOnly
Definition: regimpl.hxx:114
store::OStoreFile m_file
Definition: regimpl.hxx:117
OUString m_name
Definition: regimpl.hxx:116
sal_uInt32 release()
Definition: regimpl.hxx:51
RegError acquireKey(RegKeyHandle hKey)
Definition: regimpl.cxx:575
const OUString & getName() const
Definition: regimpl.hxx:92
KeyMap m_openKeyTable
Definition: regimpl.hxx:118
RegError destroyRegistry(const OUString &name)
Definition: regimpl.cxx:516
static constexpr OUStringLiteral ROOT
Definition: regimpl.hxx:120
RegError deleteSubkeysAndValues(ORegKey *pKey)
Definition: regimpl.cxx:812
RegError closeRegistry()
Definition: regimpl.cxx:500
RegError createKey(RegKeyHandle hKey, std::u16string_view keyName, RegKeyHandle *phNewKey)
Definition: regimpl.cxx:602
RegError releaseKey(RegKeyHandle hKey)
Definition: regimpl.cxx:587
float u
void * RegKeyHandle
defines the type of a registry key handle used in the C API.
Definition: regtype.h:29
RegAccessMode
defines the open/access mode of the registry.
Definition: regtype.h:41
enum SAL_DLLPUBLIC_RTTI RegError
specifies the possible error codes which can occur using the registry API.
Definition: regtype.h:82