registry_key.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 
00033 #pragma once
00034 
00035 #ifdef WIN32
00036 
00037 #include "../api_core.h"
00038 #include "databuffer.h"
00039 #include <vector>
00040 
00041 class CL_RegistryKey_Impl;
00042 
00044 
00046 class CL_API_CORE CL_RegistryKey
00047 {
00050 
00051 public:
00052         enum PredefinedKey
00053         {
00054                 key_classes_root,
00055                 key_current_config,
00056                 key_current_user,
00057                 key_local_machine,
00058                 key_users
00059         };
00060 
00061         enum CreateFlags
00062         {
00063                 create_always    = 0,
00064                 create_new       = 1,
00065                 create_volatile  = 2
00066         };
00067 
00068         CL_RegistryKey();
00069 
00070         CL_RegistryKey(PredefinedKey key, const CL_StringRef &subkey, unsigned int access_rights = KEY_ALL_ACCESS, unsigned int create_flags = create_always);
00071 
00072         CL_RegistryKey(HKEY key);
00073 
00074         ~CL_RegistryKey();
00075 
00076 
00080 
00081 public:
00082         HKEY get_key() const;
00083 
00084         std::vector<CL_String> get_subkey_names() const;
00085 
00086         std::vector<CL_String> get_value_names() const;
00087 
00088         int get_value_int(const CL_StringRef &name, int default_value = 0) const;
00089 
00090         CL_DataBuffer get_value_binary(const CL_StringRef &name, const CL_DataBuffer &default_value = CL_DataBuffer()) const;
00091 
00092         CL_String get_value_string(const CL_StringRef &name, const CL_StringRef &default_value = CL_StringRef()) const;
00093 
00094         std::vector<CL_String> get_value_multi_string(const CL_StringRef &name, const std::vector<CL_String> &default_value = std::vector<CL_String>()) const;
00095 
00096 
00100 
00101 public:
00102         CL_RegistryKey open_key(const CL_StringRef &subkey, unsigned int access_rights = KEY_ALL_ACCESS);
00103 
00104         CL_RegistryKey create_key(const CL_StringRef &subkey, unsigned int access_rights = KEY_ALL_ACCESS, CreateFlags create_flags = create_always);
00105 
00106         void delete_key(const CL_StringRef &subkey, bool recursive);
00107 
00108         static void delete_key(PredefinedKey key, const CL_StringRef &subkey, bool recursive);
00109 
00110         void set_value_int(const CL_StringRef &name, int value);
00111 
00112         void set_value_binary(const CL_StringRef &name, const CL_DataBuffer &value);
00113 
00114         void set_value_string(const CL_StringRef &name, const CL_StringRef &value);
00115 
00116 //      void set_value_multi_string(const CL_StringRef &name, const std::vector<CL_String> &value);
00117 
00118         void delete_value(const CL_StringRef &name);
00119 
00120 
00124 
00125 private:
00126         CL_SharedPtr<CL_RegistryKey_Impl> impl;
00128 };
00129 
00130 #endif
00131 

Generated on Thu Dec 3 02:39:30 2009 for ClanLib by  doxygen 1.4.6