]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/regconf.h
restored const operator[]s for the compilers which need them
[wxWidgets.git] / include / wx / msw / regconf.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/regconf.h
3 // Purpose: Registry based implementation of wxConfigBase
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 27.04.98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _REGCONF_H
13 #define _REGCONF_H
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "regconf.h"
17 #endif
18
19 #ifndef _REGISTRY_H
20 #include "wx/msw/registry.h"
21 #endif
22
23 #include "wx/object.h"
24 #include "wx/confbase.h"
25
26 // ----------------------------------------------------------------------------
27 // wxRegConfig
28 // ----------------------------------------------------------------------------
29
30 class WXDLLIMPEXP_BASE wxRegConfig : public wxConfigBase
31 {
32 public:
33 // ctor & dtor
34 // will store data in HKLM\appName and HKCU\appName
35 wxRegConfig(const wxString& appName = wxEmptyString,
36 const wxString& vendorName = wxEmptyString,
37 const wxString& localFilename = wxEmptyString,
38 const wxString& globalFilename = wxEmptyString,
39 long style = wxCONFIG_USE_GLOBAL_FILE);
40
41 // dtor will save unsaved data
42 virtual ~wxRegConfig(){}
43
44 // implement inherited pure virtual functions
45 // ------------------------------------------
46
47 // path management
48 virtual void SetPath(const wxString& strPath);
49 virtual const wxString& GetPath() const { return m_strPath; }
50
51 // entry/subgroup info
52 // enumerate all of them
53 virtual bool GetFirstGroup(wxString& str, long& lIndex) const;
54 virtual bool GetNextGroup (wxString& str, long& lIndex) const;
55 virtual bool GetFirstEntry(wxString& str, long& lIndex) const;
56 virtual bool GetNextEntry (wxString& str, long& lIndex) const;
57
58 // tests for existence
59 virtual bool HasGroup(const wxString& strName) const;
60 virtual bool HasEntry(const wxString& strName) const;
61 virtual EntryType GetEntryType(const wxString& name) const;
62
63 // get number of entries/subgroups in the current group, with or without
64 // it's subgroups
65 virtual size_t GetNumberOfEntries(bool bRecursive = false) const;
66 virtual size_t GetNumberOfGroups(bool bRecursive = false) const;
67
68 virtual bool Flush(bool WXUNUSED(bCurrentOnly) = false) { return true; }
69
70 // rename
71 virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
72 virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
73
74 // delete
75 virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = true);
76 virtual bool DeleteGroup(const wxString& key);
77 virtual bool DeleteAll();
78
79 protected:
80 // opens the local key creating it if necessary and returns it
81 wxRegKey& LocalKey() const // must be const to be callable from const funcs
82 {
83 wxRegConfig* self = wxConstCast(this, wxRegConfig);
84
85 if ( !m_keyLocal.IsOpened() )
86 {
87 // create on demand
88 self->m_keyLocal.Create();
89 }
90
91 return self->m_keyLocal;
92 }
93
94 // implement read/write methods
95 virtual bool DoReadString(const wxString& key, wxString *pStr) const;
96 virtual bool DoReadLong(const wxString& key, long *plResult) const;
97
98 virtual bool DoWriteString(const wxString& key, const wxString& szValue);
99 virtual bool DoWriteLong(const wxString& key, long lValue);
100
101 private:
102 // no copy ctor/assignment operator
103 wxRegConfig(const wxRegConfig&);
104 wxRegConfig& operator=(const wxRegConfig&);
105
106 // these keys are opened during all lifetime of wxRegConfig object
107 wxRegKey m_keyLocalRoot, m_keyLocal,
108 m_keyGlobalRoot, m_keyGlobal;
109
110 // current path (not '/' terminated)
111 wxString m_strPath;
112 };
113
114 #endif //_REGCONF_H