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 ///////////////////////////////////////////////////////////////////////////////
16 #include "wx/msw/registry.h"
19 #include "wx/object.h"
20 #include "wx/confbase.h"
22 // ----------------------------------------------------------------------------
24 // ----------------------------------------------------------------------------
26 class WXDLLIMPEXP_BASE wxRegConfig
: public wxConfigBase
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
);
37 // dtor will save unsaved data
38 virtual ~wxRegConfig(){}
40 // implement inherited pure virtual functions
41 // ------------------------------------------
44 virtual void SetPath(const wxString
& strPath
);
45 virtual const wxString
& GetPath() const { return m_strPath
; }
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;
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;
59 // get number of entries/subgroups in the current group, with or without
61 virtual size_t GetNumberOfEntries(bool bRecursive
= false) const;
62 virtual size_t GetNumberOfGroups(bool bRecursive
= false) const;
64 virtual bool Flush(bool WXUNUSED(bCurrentOnly
) = false) { return true; }
67 virtual bool RenameEntry(const wxString
& oldName
, const wxString
& newName
);
68 virtual bool RenameGroup(const wxString
& oldName
, const wxString
& newName
);
71 virtual bool DeleteEntry(const wxString
& key
, bool bGroupIfEmptyAlso
= true);
72 virtual bool DeleteGroup(const wxString
& key
);
73 virtual bool DeleteAll();
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
79 wxRegConfig
* self
= wxConstCast(this, wxRegConfig
);
81 if ( !m_keyLocal
.IsOpened() )
84 self
->m_keyLocal
.Create();
87 return self
->m_keyLocal
;
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;
94 virtual bool DoWriteString(const wxString
& key
, const wxString
& szValue
);
95 virtual bool DoWriteLong(const wxString
& key
, long lValue
);
98 // no copy ctor/assignment operator
99 wxRegConfig(const wxRegConfig
&);
100 wxRegConfig
& operator=(const wxRegConfig
&);
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)