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