1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Registry based implementation of wxConfigBase
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "regconf.h"
20 #include "wx/msw/registry.h"
23 #include "wx/object.h"
24 #include "wx/confbase.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class WXDLLIMPEXP_BASE wxRegConfig
: public wxConfigBase
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
);
41 // dtor will save unsaved data
42 virtual ~wxRegConfig(){}
44 // implement inherited pure virtual functions
45 // ------------------------------------------
48 virtual void SetPath(const wxString
& strPath
);
49 virtual const wxString
& GetPath() const { return m_strPath
; }
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;
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;
63 // get number of entries/subgroups in the current group, with or without
65 virtual size_t GetNumberOfEntries(bool bRecursive
= false) const;
66 virtual size_t GetNumberOfGroups(bool bRecursive
= false) const;
68 virtual bool Flush(bool WXUNUSED(bCurrentOnly
) = false) { return true; }
71 virtual bool RenameEntry(const wxString
& oldName
, const wxString
& newName
);
72 virtual bool RenameGroup(const wxString
& oldName
, const wxString
& newName
);
75 virtual bool DeleteEntry(const wxString
& key
, bool bGroupIfEmptyAlso
= true);
76 virtual bool DeleteGroup(const wxString
& key
);
77 virtual bool DeleteAll();
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
83 wxRegConfig
* self
= wxConstCast(this, wxRegConfig
);
85 if ( !m_keyLocal
.IsOpened() )
88 self
->m_keyLocal
.Create();
91 return self
->m_keyLocal
;
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;
98 virtual bool DoWriteString(const wxString
& key
, const wxString
& szValue
);
99 virtual bool DoWriteLong(const wxString
& key
, long lValue
);
102 // no copy ctor/assignment operator
103 wxRegConfig(const wxRegConfig
&);
104 wxRegConfig
& operator=(const wxRegConfig
&);
106 // these keys are opened during all lifetime of wxRegConfig object
107 wxRegKey m_keyLocalRoot
, m_keyLocal
,
108 m_keyGlobalRoot
, m_keyGlobal
;
110 // current path (not '/' terminated)