registry_key.h Source File - ClanLib SDK
Description: registry_key.h Source File

registry_key.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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
36namespace clan
37{
40
41 class RegistryKey_Impl;
42
44
46 class RegistryKey
47 {
48 public:
49 enum PredefinedKey
50 {
51 key_classes_root,
52 key_current_config,
53 key_current_user,
54 key_local_machine,
55 key_users
56 };
57
58 enum CreateFlags
59 {
60 create_always = 0,
61 create_new = 1,
62 create_volatile = 2
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
clan::DataBuffer
General purpose data buffer.
Definition databuffer.h:42
clan::RegistryKey
Registry key class.
Definition registry_key.h:47
clan::RegistryKey::CreateFlags
CreateFlags
Definition registry_key.h:59
clan::RegistryKey::create_volatile
@ create_volatile
Definition registry_key.h:62
clan::RegistryKey::create_always
@ create_always
Definition registry_key.h:60
clan::RegistryKey::create_new
@ create_new
Definition registry_key.h:61
clan::RegistryKey::set_value_string
void set_value_string(const std::string &name, const std::string &value)
clan::RegistryKey::RegistryKey
RegistryKey(PredefinedKey key, const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS, unsigned int create_flags=create_always)
clan::RegistryKey::get_value_binary
DataBuffer get_value_binary(const std::string &name, const DataBuffer &default_value=DataBuffer()) const
clan::RegistryKey::get_value_int
int get_value_int(const std::string &name, int default_value=0) const
clan::RegistryKey::get_key
HKEY get_key() const
clan::RegistryKey::get_value_string
std::string get_value_string(const std::string &name, const std::string &default_value=std::string()) const
clan::RegistryKey::open_key
RegistryKey open_key(const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS)
clan::RegistryKey::PredefinedKey
PredefinedKey
Definition registry_key.h:50
clan::RegistryKey::key_current_config
@ key_current_config
Definition registry_key.h:52
clan::RegistryKey::key_local_machine
@ key_local_machine
Definition registry_key.h:54
clan::RegistryKey::key_users
@ key_users
Definition registry_key.h:55
clan::RegistryKey::key_classes_root
@ key_classes_root
Definition registry_key.h:51
clan::RegistryKey::key_current_user
@ key_current_user
Definition registry_key.h:53
clan::RegistryKey::set_value_int
void set_value_int(const std::string &name, int value)
clan::RegistryKey::create_key
RegistryKey create_key(const std::string &subkey, unsigned int access_rights=KEY_ALL_ACCESS, CreateFlags create_flags=create_always)
clan::RegistryKey::is_null
bool is_null() const
Returns true if this object is invalid.
Definition registry_key.h:71
clan::RegistryKey::~RegistryKey
~RegistryKey()
clan::RegistryKey::RegistryKey
RegistryKey()
clan::RegistryKey::RegistryKey
RegistryKey(HKEY key)
clan::RegistryKey::get_value_multi_string
std::vector< std::string > get_value_multi_string(const std::string &name, const std::vector< std::string > &default_value=std::vector< std::string >()) const
clan::RegistryKey::set_value_binary
void set_value_binary(const std::string &name, const DataBuffer &value)
clan::RegistryKey::throw_if_null
void throw_if_null() const
Throw an exception if this object is invalid.
clan::RegistryKey::delete_value
void delete_value(const std::string &name)
clan::RegistryKey::get_value_names
std::vector< std::string > get_value_names() const
clan::RegistryKey::get_subkey_names
std::vector< std::string > get_subkey_names() const
clan::RegistryKey::delete_key
static void delete_key(PredefinedKey key, const std::string &subkey, bool recursive)
clan::RegistryKey::delete_key
void delete_key(const std::string &subkey, bool recursive)
clan
Definition clanapp.h:36