]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/regconf.h
wxConfig changes to be more logical.
[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 #ifdef __GNUG__
16 #pragma interface "regconf.h"
17 #endif
18
19 #ifndef _REGISTRY_H
20 #include <wx/msw/registry.h>
21 #endif
22
23 // ----------------------------------------------------------------------------
24 // wxRegConfig
25 // ----------------------------------------------------------------------------
26
27 class wxRegConfig : public wxConfigBase
28 {
29 public:
30 // ctor & dtor
31 // will store data in HKLM\appName and HKCU\appName
32 wxRegConfig(const wxString& appName = wxEmptyString, const wxString& vendorName = wxEmptyString,
33 const wxString& localFilename = wxEmptyString, const wxString& globalFilename = wxEmptyString,
34 long style = 0);
35
36 // dtor will save unsaved data
37 virtual ~wxRegConfig();
38
39 // implement inherited pure virtual functions
40 // ------------------------------------------
41
42 // path management
43 virtual void SetPath(const wxString& strPath);
44 virtual const wxString& GetPath() const { return m_strPath; }
45
46 // entry/subgroup info
47 // enumerate all of them
48 virtual bool GetFirstGroup(wxString& str, long& lIndex) const;
49 virtual bool GetNextGroup (wxString& str, long& lIndex) const;
50 virtual bool GetFirstEntry(wxString& str, long& lIndex) const;
51 virtual bool GetNextEntry (wxString& str, long& lIndex) const;
52
53 // tests for existence
54 virtual bool HasGroup(const wxString& strName) const;
55 virtual bool HasEntry(const wxString& strName) const;
56
57 // get number of entries/subgroups in the current group, with or without
58 // it's subgroups
59 virtual size_t GetNumberOfEntries(bool bRecursive = FALSE) const;
60 virtual size_t GetNumberOfGroups(bool bRecursive = FALSE) const;
61
62 // read/write
63 bool Read(const wxString& key, wxString *pStr) const;
64 bool Read(const wxString& key, wxString *pStr, const wxString& szDefault) const;
65 bool Read(const wxString& key, long *plResult) const;
66
67 // The following are necessary to satisfy the compiler
68 wxString Read(const wxString& key, const wxString& defVal) const
69 { return wxConfigBase::Read(key, defVal); }
70 bool Read(const wxString& key, long *pl, long defVal) const
71 { return wxConfigBase::Read(key, pl, defVal); }
72 long Read(const wxString& key, long defVal) const
73 { return wxConfigBase::Read(key, defVal); }
74 bool Read(const wxString& key, double* val) const
75 { return wxConfigBase::Read(key, val); }
76 bool Read(const wxString& key, double* val, double defVal) const
77 { return wxConfigBase::Read(key, val, defVal); }
78
79 bool Write(const wxString& key, const wxString& szValue);
80 bool Write(const wxString& key, long lValue);
81
82 virtual bool Flush(bool /* bCurrentOnly = FALSE */ ) { return TRUE; }
83
84 // delete
85 virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso);
86 virtual bool DeleteGroup(const wxString& key);
87 virtual bool DeleteAll();
88
89 private:
90 // these keys are opened during all lifetime of wxRegConfig object
91 wxRegKey m_keyLocalRoot, m_keyLocal,
92 m_keyGlobalRoot, m_keyGlobal;
93
94 // current path (not '/' terminated)
95 wxString m_strPath;
96 };
97
98 #endif //_REGCONF_H