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#ifndef INCLUDED_REGISTRY_SOURCE_REGIMPL_HXX
21#define INCLUDED_REGISTRY_SOURCE_REGIMPL_HXX
22
23#include <sal/config.h>
24
25#include <string_view>
26#include <unordered_map>
27
28#include <regapi.hxx>
29#include <registry/regtype.h>
30#include <rtl/ustring.hxx>
31#include <osl/mutex.hxx>
32#include <store/store.hxx>
33
34// 5 bytes = 1 (byte for the type) + 4 (bytes for the size of the data)
35#define VALUE_HEADERSIZE 5
36#define VALUE_TYPEOFFSET 1
37#define VALUE_HEADEROFFSET 5
38
39#define REG_GUARD(mutex) \
40 osl::Guard< osl::Mutex > aGuard( mutex );
41
42class ORegKey;
43
45{
46public:
47 ORegistry();
48
49 sal_uInt32 acquire()
50 { return ++m_refCount; }
51
52 sal_uInt32 release()
53 { return --m_refCount; }
54
55 RegError initRegistry(const OUString& name,
56 RegAccessMode accessMode,
57 bool bCreate = false);
58
60
61 RegError destroyRegistry(const OUString& name);
62
65
67 std::u16string_view keyName,
68 RegKeyHandle* phNewKey);
69
71 std::u16string_view keyName,
72 RegKeyHandle* phOpenKey);
73
75
76 RegError deleteKey(RegKeyHandle hKey, std::u16string_view keyName);
77
79
80 ~ORegistry();
81
82 bool isReadOnly() const
83 { return m_readOnly; }
84
85 bool isOpen() const
86 { return m_isOpen; }
87
89
91 { return m_file; }
92
93 const OUString& getName() const
94 { return m_name; }
95
96 friend class ORegKey;
97
98private:
99 RegError eraseKey(ORegKey* pKey, std::u16string_view keyName);
100
102
103 RegError dumpValue(const OUString& sPath,
104 const OUString& sName,
105 sal_Int16 nSpace) const;
106
107 RegError dumpKey(const OUString& sPath,
108 const OUString& sName,
109 sal_Int16 nSpace) const;
110
111 typedef std::unordered_map< OUString, ORegKey* > KeyMap;
112
113 sal_uInt32 m_refCount;
114 osl::Mutex m_mutex;
117 OUString m_name;
120
121 static constexpr OUStringLiteral ROOT { u"/" };
122};
123
124#endif
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt32 m_refCount
Definition: regimpl.hxx:113
RegError dumpKey(const OUString &sPath, const OUString &sName, sal_Int16 nSpace) const
Definition: regimpl.cxx:1119
const store::OStoreFile & getStoreFile() const
Definition: regimpl.hxx:90
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:85
~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:659
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:116
osl::Mutex m_mutex
Definition: regimpl.hxx:114
sal_uInt32 acquire()
Definition: regimpl.hxx:49
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:111
bool isReadOnly() const
Definition: regimpl.hxx:82
bool m_readOnly
Definition: regimpl.hxx:115
store::OStoreFile m_file
Definition: regimpl.hxx:118
OUString m_name
Definition: regimpl.hxx:117
sal_uInt32 release()
Definition: regimpl.hxx:52
RegError acquireKey(RegKeyHandle hKey)
Definition: regimpl.cxx:575
const OUString & getName() const
Definition: regimpl.hxx:93
KeyMap m_openKeyTable
Definition: regimpl.hxx:119
RegError destroyRegistry(const OUString &name)
Definition: regimpl.cxx:516
static constexpr OUStringLiteral ROOT
Definition: regimpl.hxx:121
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:30
RegAccessMode
defines the open/access mode of the registry.
Definition: regtype.h:42
enum SAL_DLLPUBLIC_RTTI RegError
specifies the possible error codes which can occur using the registry API.
Definition: regtype.h:83