]>
Commit | Line | Data |
---|---|---|
45c28815 | 1 | /////////////////////////////////////////////////////////////////////////////// |
9869734d | 2 | // Name: msw/regconf.h |
8f494e5d | 3 | // Purpose: Registry based implementation of wxConfigBase |
45c28815 | 4 | // Author: Vadim Zeitlin |
9869734d | 5 | // Modified by: |
45c28815 VZ |
6 | // Created: 27.04.98 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
65571936 | 9 | // Licence: wxWindows licence |
45c28815 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _REGCONF_H | |
13 | #define _REGCONF_H | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
0d3820b3 JS |
16 | #pragma interface "regconf.h" |
17 | #endif | |
18 | ||
8f494e5d | 19 | #ifndef _REGISTRY_H |
85d4fc42 | 20 | #include "wx/msw/registry.h" |
8f494e5d | 21 | #endif |
fdd74b41 | 22 | |
85d4fc42 | 23 | #include "wx/object.h" |
fdd74b41 | 24 | #include "wx/confbase.h" |
8f494e5d | 25 | |
45c28815 VZ |
26 | // ---------------------------------------------------------------------------- |
27 | // wxRegConfig | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
40a88328 | 30 | class WXDLLIMPEXP_BASE wxRegConfig : public wxConfigBase |
45c28815 VZ |
31 | { |
32 | public: | |
33 | // ctor & dtor | |
18244936 | 34 | // will store data in HKLM\appName and HKCU\appName |
fda7962d JS |
35 | wxRegConfig(const wxString& appName = wxEmptyString, |
36 | const wxString& vendorName = wxEmptyString, | |
37 | const wxString& localFilename = wxEmptyString, | |
38 | const wxString& globalFilename = wxEmptyString, | |
fa2d17ac | 39 | long style = wxCONFIG_USE_GLOBAL_FILE); |
18244936 | 40 | |
45c28815 VZ |
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 | ||
8f494e5d VZ |
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; | |
45c28815 | 57 | |
8f494e5d | 58 | // tests for existence |
6d833566 VZ |
59 | virtual bool HasGroup(const wxString& strName) const; |
60 | virtual bool HasEntry(const wxString& strName) const; | |
61ba49f2 | 61 | virtual EntryType GetEntryType(const wxString& name) const; |
6d833566 | 62 | |
a37e8836 JS |
63 | // get number of entries/subgroups in the current group, with or without |
64 | // it's subgroups | |
4d08943e WS |
65 | virtual size_t GetNumberOfEntries(bool bRecursive = false) const; |
66 | virtual size_t GetNumberOfGroups(bool bRecursive = false) const; | |
a37e8836 | 67 | |
4d08943e | 68 | virtual bool Flush(bool WXUNUSED(bCurrentOnly) = false) { return true; } |
45c28815 | 69 | |
5d1902d6 VZ |
70 | // rename |
71 | virtual bool RenameEntry(const wxString& oldName, const wxString& newName); | |
72 | virtual bool RenameGroup(const wxString& oldName, const wxString& newName); | |
73 | ||
45c28815 | 74 | // delete |
4d08943e | 75 | virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = true); |
18244936 | 76 | virtual bool DeleteGroup(const wxString& key); |
45c28815 VZ |
77 | virtual bool DeleteAll(); |
78 | ||
807a903e VZ |
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 | ||
2ba41305 VZ |
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 | ||
45c28815 | 101 | private: |
fd3f686c VZ |
102 | // no copy ctor/assignment operator |
103 | wxRegConfig(const wxRegConfig&); | |
104 | wxRegConfig& operator=(const wxRegConfig&); | |
105 | ||
45c28815 VZ |
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 | ||
cf447356 | 114 | #endif //_REGCONF_H |