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