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 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_REGCONF_H_
13 #define _WX_MSW_REGCONF_H_
17 #if wxUSE_CONFIG && wxUSE_REGKEY
19 #include "wx/msw/registry.h"
20 #include "wx/object.h"
21 #include "wx/confbase.h"
22 #include "wx/buffer.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 class WXDLLIMPEXP_BASE wxRegConfig
: public wxConfigBase
32 // will store data in HKLM\appName and HKCU\appName
33 wxRegConfig(const wxString
& appName
= wxEmptyString
,
34 const wxString
& vendorName
= wxEmptyString
,
35 const wxString
& localFilename
= wxEmptyString
,
36 const wxString
& globalFilename
= wxEmptyString
,
37 long style
= wxCONFIG_USE_GLOBAL_FILE
);
39 // dtor will save unsaved data
40 virtual ~wxRegConfig(){}
42 // implement inherited pure virtual functions
43 // ------------------------------------------
46 virtual void SetPath(const wxString
& strPath
);
47 virtual const wxString
& GetPath() const { return m_strPath
; }
49 // entry/subgroup info
50 // enumerate all of them
51 virtual bool GetFirstGroup(wxString
& str
, long& lIndex
) const;
52 virtual bool GetNextGroup (wxString
& str
, long& lIndex
) const;
53 virtual bool GetFirstEntry(wxString
& str
, long& lIndex
) const;
54 virtual bool GetNextEntry (wxString
& str
, long& lIndex
) const;
56 // tests for existence
57 virtual bool HasGroup(const wxString
& strName
) const;
58 virtual bool HasEntry(const wxString
& strName
) const;
59 virtual EntryType
GetEntryType(const wxString
& name
) const;
61 // get number of entries/subgroups in the current group, with or without
63 virtual size_t GetNumberOfEntries(bool bRecursive
= false) const;
64 virtual size_t GetNumberOfGroups(bool bRecursive
= false) const;
66 virtual bool Flush(bool WXUNUSED(bCurrentOnly
) = false) { return true; }
69 virtual bool RenameEntry(const wxString
& oldName
, const wxString
& newName
);
70 virtual bool RenameGroup(const wxString
& oldName
, const wxString
& newName
);
73 virtual bool DeleteEntry(const wxString
& key
, bool bGroupIfEmptyAlso
= true);
74 virtual bool DeleteGroup(const wxString
& key
);
75 virtual bool DeleteAll();
78 // opens the local key creating it if necessary and returns it
79 wxRegKey
& LocalKey() const // must be const to be callable from const funcs
81 wxRegConfig
* self
= wxConstCast(this, wxRegConfig
);
83 if ( !m_keyLocal
.IsOpened() )
86 self
->m_keyLocal
.Create();
89 return self
->m_keyLocal
;
92 // implement read/write methods
93 virtual bool DoReadString(const wxString
& key
, wxString
*pStr
) const;
94 virtual bool DoReadLong(const wxString
& key
, long *plResult
) const;
95 virtual bool DoReadBinary(const wxString
& key
, wxMemoryBuffer
* buf
) const;
97 virtual bool DoWriteString(const wxString
& key
, const wxString
& szValue
);
98 virtual bool DoWriteLong(const wxString
& key
, long lValue
);
99 virtual bool DoWriteBinary(const wxString
& key
, const wxMemoryBuffer
& buf
);
102 // these keys are opened during all lifetime of wxRegConfig object
103 wxRegKey m_keyLocalRoot
, m_keyLocal
,
104 m_keyGlobalRoot
, m_keyGlobal
;
106 // current path (not '/' terminated)
109 wxDECLARE_NO_COPY_CLASS(wxRegConfig
);
110 DECLARE_ABSTRACT_CLASS(wxRegConfig
)
113 #endif // wxUSE_CONFIG && wxUSE_REGKEY
115 #endif // _WX_MSW_REGCONF_H_