2005-09-16 16:20:48 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: KWSys - Kitware System Library
|
|
|
|
Module: $RCSfile$
|
|
|
|
|
|
|
|
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#ifndef @KWSYS_NAMESPACE@_Registry_hxx
|
|
|
|
#define @KWSYS_NAMESPACE@_Registry_hxx
|
|
|
|
|
|
|
|
#include <@KWSYS_NAMESPACE@/Configure.h>
|
|
|
|
|
|
|
|
#include <@KWSYS_NAMESPACE@/stl/string>
|
|
|
|
|
|
|
|
namespace @KWSYS_NAMESPACE@
|
|
|
|
{
|
|
|
|
|
|
|
|
class RegistryHelper;
|
|
|
|
|
|
|
|
/** \class Registry
|
|
|
|
* \brief Portable registry class
|
|
|
|
*
|
|
|
|
* This class abstracts the storing of data that can be restored
|
2006-03-10 00:40:00 +03:00
|
|
|
* when the program executes again. On Win32 platform it is
|
2005-09-16 16:20:48 +04:00
|
|
|
* implemented using the registry and on unix as a file in
|
|
|
|
* the user's home directory.
|
|
|
|
*/
|
|
|
|
class @KWSYS_NAMESPACE@_EXPORT Registry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum RegistryType
|
|
|
|
{
|
2005-09-16 17:15:52 +04:00
|
|
|
#ifdef _WIN32
|
2005-09-16 16:20:48 +04:00
|
|
|
WIN32_REGISTRY,
|
|
|
|
#endif
|
2005-09-16 21:38:25 +04:00
|
|
|
FILE_REGISTRY
|
2005-09-16 16:20:48 +04:00
|
|
|
};
|
|
|
|
|
2005-09-16 17:15:52 +04:00
|
|
|
#ifdef _WIN32
|
2005-09-16 16:20:48 +04:00
|
|
|
Registry(RegistryType registryType = WIN32_REGISTRY);
|
|
|
|
#else
|
2005-09-16 21:38:25 +04:00
|
|
|
Registry(RegistryType registryType = FILE_REGISTRY);
|
2005-09-16 16:20:48 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual ~Registry();
|
|
|
|
|
|
|
|
//! Read a value from the registry.
|
2005-09-16 21:38:25 +04:00
|
|
|
bool ReadValue(const char *subkey, const char *key, const char **value);
|
2005-09-16 16:20:48 +04:00
|
|
|
|
|
|
|
//! Delete a key from the registry.
|
|
|
|
bool DeleteKey(const char *subkey, const char *key);
|
|
|
|
|
|
|
|
//! Delete a value from a given key.
|
|
|
|
bool DeleteValue(const char *subkey, const char *key);
|
|
|
|
|
|
|
|
//! Set value in a given key.
|
2006-03-10 00:40:00 +03:00
|
|
|
bool SetValue(const char *subkey, const char *key,
|
2005-09-16 16:20:48 +04:00
|
|
|
const char *value);
|
|
|
|
|
|
|
|
//! Open the registry at toplevel/subkey.
|
2006-03-10 00:40:00 +03:00
|
|
|
bool Open(const char *toplevel, const char *subkey,
|
2005-09-16 16:20:48 +04:00
|
|
|
int readonly);
|
2006-03-10 00:40:00 +03:00
|
|
|
|
|
|
|
//! Close the registry.
|
2005-09-16 16:20:48 +04:00
|
|
|
bool Close();
|
|
|
|
|
|
|
|
//! Read from local or global scope. On Windows this mean from local machine
|
2006-03-10 00:40:00 +03:00
|
|
|
// or local user. On unix this will read from $HOME/.Projectrc or
|
2005-09-16 16:20:48 +04:00
|
|
|
// /etc/Project
|
|
|
|
void GlobalScopeOn() { this->SetGlobalScope(1); }
|
|
|
|
void GlobalScopeOff() { this->SetGlobalScope(0); }
|
2005-09-16 17:08:40 +04:00
|
|
|
void SetGlobalScope(bool b);
|
|
|
|
bool GetGlobalScope();
|
2006-03-10 00:40:00 +03:00
|
|
|
|
2005-09-16 16:20:48 +04:00
|
|
|
// Set or get the toplevel registry key.
|
|
|
|
void SetTopLevel(const char* tl);
|
|
|
|
const char* GetTopLevel();
|
|
|
|
|
|
|
|
// Return true if registry opened
|
|
|
|
bool GetOpened() { return m_Opened; }
|
|
|
|
|
|
|
|
// Should the registry be locked?
|
|
|
|
bool GetLocked() { return m_Locked; }
|
|
|
|
|
|
|
|
enum {
|
|
|
|
READONLY,
|
|
|
|
READWRITE
|
|
|
|
};
|
|
|
|
|
|
|
|
// Return true if the character is space.
|
|
|
|
int IsSpace(char c);
|
|
|
|
|
|
|
|
private:
|
|
|
|
RegistryHelper* Helper;
|
|
|
|
|
|
|
|
bool m_Opened;
|
2006-03-10 00:40:00 +03:00
|
|
|
|
2005-09-16 16:20:48 +04:00
|
|
|
bool m_Locked;
|
|
|
|
}; // End Class: Registry
|
|
|
|
|
|
|
|
} // namespace @KWSYS_NAMESPACE@
|
|
|
|
|
|
|
|
#endif
|