registry_key.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2016 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 #pragma once
30 
31 #if defined(WIN32) || defined(DOXYGEN)
32 
33 #include "databuffer.h"
34 #include <vector>
35 
36 namespace clan
37 {
40 
41  class RegistryKey_Impl;
42 
44 
47  {
48  public:
50  {
56  };
57 
59  {
63  };
64 
65  RegistryKey();
66  RegistryKey(PredefinedKey key, const std::string &subkey, unsigned int access_rights = KEY_ALL_ACCESS, unsigned int create_flags = create_always);
67  RegistryKey(HKEY key);
68  ~RegistryKey();
69 
71  bool is_null() const { return !impl; }
72 
74  void throw_if_null() const;
75 
76  HKEY get_key() const;
77  std::vector<std::string> get_subkey_names() const;
78  std::vector<std::string> get_value_names() const;
79  int get_value_int(const std::string &name, int default_value = 0) const;
80  DataBuffer get_value_binary(const std::string &name, const DataBuffer &default_value = DataBuffer()) const;
81  std::string get_value_string(const std::string &name, const std::string &default_value = std::string()) const;
82  std::vector<std::string> get_value_multi_string(const std::string &name, const std::vector<std::string> &default_value = std::vector<std::string>()) const;
83 
84  RegistryKey open_key(const std::string &subkey, unsigned int access_rights = KEY_ALL_ACCESS);
85  RegistryKey create_key(const std::string &subkey, unsigned int access_rights = KEY_ALL_ACCESS, CreateFlags create_flags = create_always);
86  void delete_key(const std::string &subkey, bool recursive);
87  static void delete_key(PredefinedKey key, const std::string &subkey, bool recursive);
88  void set_value_int(const std::string &name, int value);
89  void set_value_binary(const std::string &name, const DataBuffer &value);
90  void set_value_string(const std::string &name, const std::string &value);
91  // void set_value_multi_string(const std::string &name, const std::vector<std::string> &value);
92  void delete_value(const std::string &name);
93 
94  private:
95  std::shared_ptr<RegistryKey_Impl> impl;
96  };
97 
99 }
100 
101 #endif
void set_value_binary(const std::string &name, const DataBuffer &value)
void set_value_int(const std::string &name, int value)
Definition: clanapp.h:35
std::string get_value_string(const std::string &name, const std::string &default_value=std::string()) const
void throw_if_null() const
Throw an exception if this object is invalid.
bool is_null() const
Returns true if this object is invalid.
Definition: registry_key.h:71
void delete_key(const std::string &subkey, bool recursive)
Definition: registry_key.h:55
Definition: registry_key.h:60
void set_value_string(const std::string &name, const std::string &value)
Definition: registry_key.h:53
PredefinedKey
Definition: registry_key.h:49
Registry key class.
Definition: registry_key.h:46
RegistryKey create_key(const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS, CreateFlags create_flags=create_always)
CreateFlags
Definition: registry_key.h:58
int get_value_int(const std::string &name, int default_value=0) const
void delete_value(const std::string &name)
DataBuffer get_value_binary(const std::string &name, const DataBuffer &default_value=DataBuffer()) const
Definition: registry_key.h:54
Definition: registry_key.h:51
std::vector< std::string > get_subkey_names() const
Definition: registry_key.h:61
Definition: registry_key.h:52
RegistryKey open_key(const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS)
HKEY get_key() const
General purpose data buffer.
Definition: databuffer.h:41
Definition: registry_key.h:62
std::vector< std::string > get_value_multi_string(const std::string &name, const std::vector< std::string > &default_value=std::vector< std::string >()) const
std::vector< std::string > get_value_names() const