xref: /AOO41X/main/setup_native/source/win32/customactions/reg4msdoc/registrywnt.hxx (revision 2c7984ea0c4616a89884b967ddada32b9292a6ce)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _REGISTRYWNT_HXX_
25 #define _REGISTRYWNT_HXX_
26 
27 #include "registry.hxx"
28 
29 //---------------------------------------
30 // constants
31 //---------------------------------------
32 
33 class RegistryKeyImplWinNT : public RegistryKeyImpl
34 {
35 public:
36 
37     //############################################
38     // Queries
39     //############################################
40 
41     /** The number of sub values of the key at hand
42 
43         @precond IsOpen = true
44 
45         @throws
46     */
47     virtual size_t GetSubValueCount() const;
48 
49     /** The number of sub-keys of the key at hand
50 
51         @precond IsOpen = true
52 
53         @throws
54     */
55     virtual size_t GetSubKeyCount() const;
56 
57     virtual StringListPtr GetSubKeyNames() const;
58 
59     virtual StringListPtr GetSubValueNames() const;
60 
61     /** Get the specified registry value
62 
63         @precond IsOpen = true
64     */
65     virtual RegistryValue GetValue(const std::wstring& Name) const;
66 
67     /** Get the specified registry value, return the given
68         default value if value not found
69 
70         @precond IsOpen = true
71     */
72     virtual RegistryValue GetValue(const std::wstring& Name, const RegistryValue& Default) const;
73 
74     //############################################
75     // Commands
76     //############################################
77 
78     /** Open the registry key, has no effect if
79         the key is already open
80 
81         @precond IsOpen = false
82 
83         @throws RegistryWriteAccessDenyException
84                 RegistryAccessDenyException
85     */
86     virtual void Open(bool Writeable = true);
87 
88     /** Open the specified sub-key of the registry key
89         at hand
90 
91         @precond IsOpen = true
92                  HasSubKey(Name) = true
93 
94         @throws RegistryIOException
95                 RegistryKeyNotFoundException
96                 RegistryAccessDeniedException
97     */
98     virtual RegistryKey OpenSubKey(const std::wstring& Name, bool Writeable = true);
99 
100     /** Creates a new sub-key below the key at hand
101 
102         @precond IsOpen = true
103                  IsWriteable = true
104 
105         @throws  RegistryIOException
106                  RegistryWriteAccessDenyException
107     */
108     virtual RegistryKey CreateSubKey(const std::wstring& Name);
109 
110     /** Deletes a sub-key below the key at hand, the
111         key must not have sub-keys
112 
113         @precond IsOpen = true
114                  IsWriteable = true
115 
116         @throws  RegistryIOException
117                  RegistryWriteAccessDenyException
118     */
119     virtual void DeleteSubKey(const std::wstring& Name);
120 
121     /** Deletes a sub-key below the key at hand with all
122         its sub-keys
123 
124         @precond IsOpen = true
125                  IsWriteable = true;
126 
127         @throws  RegistryIOException
128                  RegistryWriteAccessDenyException
129     */
130     virtual void DeleteSubKeyTree(const std::wstring& Name);
131 
132     /** Delete the specified value
133 
134         @precond IsOpen = true
135                  IsWriteable = true
136                  HasValue(Name) = true
137 
138         @throws RegistryIOException
139                 RegistryWriteAccessDeniedException
140                 RegistryValueNotFoundException
141     */
142     virtual void DeleteValue(const std::wstring& Name);
143 
144     /** Set the specified registry value
145 
146         @precond IsOpen = true
147                  IsWriteable = true
148 
149         @throws  RegistryIOException
150                  RegistryWriteAccessDenyException
151     */
152     virtual void SetValue(const RegistryValue& Value);
153 
154     //############################################
155     // Creation
156     //
157     // only possible through WindowsRegistry class
158     //############################################
159 
160 protected:
161     /** Create instance and open the specified Registry key
162 
163         @throws  RegistryWriteAccessDenyException
164                  RegistryAccessDenyException
165                  RegistryKeyNotFoundException
166     */
167     RegistryKeyImplWinNT(HKEY RootKey, const std::wstring& KeyName);
168 
169     /** Create instance and open the specified Registry key
170 
171         @throws  RegistryWriteAccessDenyException
172                  RegistryAccessDenyException
173                  RegistryKeyNotFoundException
174     */
175     RegistryKeyImplWinNT(HKEY RootKey);
176 
177     /** Create an instances of the specified Registry key,
178     the key is assumed to be already opened.
179     */
180     RegistryKeyImplWinNT(HKEY RootKey, HKEY SubKey, const std::wstring& KeyName, bool Writeable = true);
181 
182 private:
183 
184     LONG ImplDeleteSubKeyTree(HKEY RootKey, const std::wstring& Name);
185 
186 //prevent copy and assignment
187 private:
188     RegistryKeyImplWinNT(const RegistryKeyImplWinNT&);
189     RegistryKeyImplWinNT& operator=(const RegistryKeyImplWinNT&);
190 
191 //######################################
192 // Friend declarations
193 //######################################
194 
195 friend class WindowsRegistry;
196 };
197 
198 #endif
199