Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / kwsys / Registry.hxx.in
1 /*============================================================================
2   KWSys - Kitware System Library
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef @KWSYS_NAMESPACE@_Registry_hxx
13 #define @KWSYS_NAMESPACE@_Registry_hxx
14
15 #include <@KWSYS_NAMESPACE@/Configure.h>
16
17 #include <@KWSYS_NAMESPACE@/stl/string>
18
19 namespace @KWSYS_NAMESPACE@
20 {
21
22 class RegistryHelper;
23
24 /** \class Registry
25  * \brief Portable registry class
26  *
27  * This class abstracts the storing of data that can be restored
28  * when the program executes again. On Win32 platform it is
29  * implemented using the registry and on unix as a file in
30  * the user's home directory.
31  */
32 class @KWSYS_NAMESPACE@_EXPORT Registry
33 {
34 public:
35   enum RegistryType
36     {
37 #ifdef _WIN32
38     WIN32_REGISTRY,
39 #endif
40     FILE_REGISTRY
41     };
42
43 #ifdef _WIN32
44   Registry(RegistryType registryType = WIN32_REGISTRY);
45 #else
46   Registry(RegistryType registryType = FILE_REGISTRY);
47 #endif
48
49   virtual ~Registry();
50
51   //! Read a value from the registry.
52   bool ReadValue(const char *subkey, const char *key, const char **value);
53
54   //! Delete a key from the registry.
55   bool DeleteKey(const char *subkey, const char *key);
56
57   //! Delete a value from a given key.
58   bool DeleteValue(const char *subkey, const char *key);
59
60   //! Set value in a given key.
61   bool SetValue(const char *subkey, const char *key,
62                const char *value);
63
64   //! Open the registry at toplevel/subkey.
65   bool Open(const char *toplevel, const char *subkey,
66            int readonly);
67
68   //! Close the registry.
69   bool Close();
70
71   //! Read from local or global scope. On Windows this mean from local machine
72   // or local user. On unix this will read from $HOME/.Projectrc or
73   // /etc/Project
74   void GlobalScopeOn() { this->SetGlobalScope(1); }
75   void GlobalScopeOff() { this->SetGlobalScope(0); }
76   void SetGlobalScope(bool b);
77   bool GetGlobalScope();
78
79   // Set or get the toplevel registry key.
80   void SetTopLevel(const char* tl);
81   const char* GetTopLevel();
82
83   // Return true if registry opened
84   bool GetOpened() { return m_Opened; }
85
86   // Should the registry be locked?
87   bool GetLocked() { return m_Locked; }
88
89   enum {
90     READONLY,
91     READWRITE
92   };
93
94   // Return true if the character is space.
95   int IsSpace(char c);
96
97 private:
98   RegistryHelper* Helper;
99
100   bool m_Opened;
101
102   bool m_Locked;
103 }; // End Class: Registry
104
105 } // namespace @KWSYS_NAMESPACE@
106
107 #endif