]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/regconf.h
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 #pragma interface "regconf.h"
20 #include <wx/msw/registry.h>
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxRegConfig
: public wxConfigBase
31 // will store data in HKLM\appName and HKCU\appName
32 wxRegConfig(const wxString
& appName
= _T(""),
33 const wxString
& vendorName
= _T(""),
34 const wxString
& localFilename
= _T(""),
35 const wxString
& globalFilename
= _T(""),
38 // dtor will save unsaved data
39 virtual ~wxRegConfig();
41 // implement inherited pure virtual functions
42 // ------------------------------------------
45 virtual void SetPath(const wxString
& strPath
);
46 virtual const wxString
& GetPath() const { return m_strPath
; }
48 // entry/subgroup info
49 // enumerate all of them
50 virtual bool GetFirstGroup(wxString
& str
, long& lIndex
) const;
51 virtual bool GetNextGroup (wxString
& str
, long& lIndex
) const;
52 virtual bool GetFirstEntry(wxString
& str
, long& lIndex
) const;
53 virtual bool GetNextEntry (wxString
& str
, long& lIndex
) const;
55 // tests for existence
56 virtual bool HasGroup(const wxString
& strName
) const;
57 virtual bool HasEntry(const wxString
& strName
) const;
58 virtual EntryType
GetEntryType(const wxString
& name
) const;
60 // get number of entries/subgroups in the current group, with or without
62 virtual size_t GetNumberOfEntries(bool bRecursive
= FALSE
) const;
63 virtual size_t GetNumberOfGroups(bool bRecursive
= FALSE
) const;
66 bool Read(const wxString
& key
, wxString
*pStr
) const;
67 bool Read(const wxString
& key
, wxString
*pStr
, const wxString
& szDefault
) const;
68 wxString
Read(const wxString
& key
, const wxString
& defVal
) const
69 { return wxConfigBase::Read(key
, defVal
); }
71 bool Read(const wxString
& key
, long *plResult
) const;
72 bool Read(const wxString
& key
, long *pl
, long defVal
) const
73 { return wxConfigBase::Read(key
, pl
, defVal
); }
74 long Read(const wxString
& key
, long defVal
) const
75 { return wxConfigBase::Read(key
, defVal
); }
77 // The following are necessary to satisfy the compiler
78 bool Read(const wxString
& key
, int *pi
, int defVal
) const
79 { return wxConfigBase::Read(key
, pi
, defVal
); }
80 bool Read(const wxString
& key
, int *pi
) const
81 { return wxConfigBase::Read(key
, pi
); }
83 bool Read(const wxString
& key
, double* val
, double defVal
) const
84 { return wxConfigBase::Read(key
, val
, defVal
); }
85 bool Read(const wxString
& key
, double* val
) const
86 { return wxConfigBase::Read(key
, val
); }
88 bool Read(const wxString
& key
, bool *pb
, bool defVal
) const
89 { return wxConfigBase::Read(key
, pb
, defVal
); }
90 bool Read(const wxString
& key
, bool *pb
) const
91 { return wxConfigBase::Read(key
, pb
); }
93 bool Write(const wxString
& key
, const wxString
& szValue
);
94 bool Write(const wxString
& key
, long lValue
);
95 bool Write(const wxString
& key
, double dValue
)
96 { return wxConfigBase::Write(key
, dValue
); }
97 bool Write(const wxString
& key
, bool bValue
)
98 { return wxConfigBase::Write(key
, bValue
); }
100 virtual bool Flush(bool /* bCurrentOnly = FALSE */ ) { return TRUE
; }
103 virtual bool RenameEntry(const wxString
& oldName
, const wxString
& newName
);
104 virtual bool RenameGroup(const wxString
& oldName
, const wxString
& newName
);
107 virtual bool DeleteEntry(const wxString
& key
, bool bGroupIfEmptyAlso
);
108 virtual bool DeleteGroup(const wxString
& key
);
109 virtual bool DeleteAll();
112 // opens the local key creating it if necessary and returns it
113 wxRegKey
& LocalKey() const // must be const to be callable from const funcs
115 wxRegConfig
* self
= wxConstCast(this, wxRegConfig
);
117 if ( !m_keyLocal
.IsOpened() )
120 self
->m_keyLocal
.Create();
123 return self
->m_keyLocal
;
127 // no copy ctor/assignment operator
128 wxRegConfig(const wxRegConfig
&);
129 wxRegConfig
& operator=(const wxRegConfig
&);
131 // these keys are opened during all lifetime of wxRegConfig object
132 wxRegKey m_keyLocalRoot
, m_keyLocal
,
133 m_keyGlobalRoot
, m_keyGlobal
;
135 // current path (not '/' terminated)