]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/regconf.h
Notebook, Listbox, and Checklst updates
[wxWidgets.git] / include / wx / msw / regconf.h
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/regconf.h
3// Purpose: Registry based implementation of wxConfigBase
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 27.04.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _REGCONF_H
13#define _REGCONF_H
14
15#ifdef __GNUG__
16#pragma interface "regconf.h"
17#endif
18
19#ifndef _REGISTRY_H
20 #include "wx/msw/registry.h"
21#endif
22#include "wx/object.h"
23
24// ----------------------------------------------------------------------------
25// wxRegConfig
26// ----------------------------------------------------------------------------
27
28class WXDLLEXPORT wxRegConfig : public wxConfigBase
29{
30public:
31 // ctor & dtor
32 // will store data in HKLM\appName and HKCU\appName
33 wxRegConfig(const wxString& appName = _T(""),
34 const wxString& vendorName = _T(""),
35 const wxString& localFilename = _T(""),
36 const wxString& globalFilename = _T(""),
37 long style = 0);
38
39 // dtor will save unsaved data
40 virtual ~wxRegConfig();
41
42 // implement inherited pure virtual functions
43 // ------------------------------------------
44
45 // path management
46 virtual void SetPath(const wxString& strPath);
47 virtual const wxString& GetPath() const { return m_strPath; }
48
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;
55
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;
60
61 // get number of entries/subgroups in the current group, with or without
62 // it's subgroups
63 virtual size_t GetNumberOfEntries(bool bRecursive = FALSE) const;
64 virtual size_t GetNumberOfGroups(bool bRecursive = FALSE) const;
65
66 virtual bool Flush(bool WXUNUSED(bCurrentOnly) = FALSE) { return TRUE; }
67
68 // rename
69 virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
70 virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
71
72 // delete
73 virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = TRUE);
74 virtual bool DeleteGroup(const wxString& key);
75 virtual bool DeleteAll();
76
77protected:
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
80 {
81 wxRegConfig* self = wxConstCast(this, wxRegConfig);
82
83 if ( !m_keyLocal.IsOpened() )
84 {
85 // create on demand
86 self->m_keyLocal.Create();
87 }
88
89 return self->m_keyLocal;
90 }
91
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
96 virtual bool DoWriteString(const wxString& key, const wxString& szValue);
97 virtual bool DoWriteLong(const wxString& key, long lValue);
98
99private:
100 // no copy ctor/assignment operator
101 wxRegConfig(const wxRegConfig&);
102 wxRegConfig& operator=(const wxRegConfig&);
103
104 // these keys are opened during all lifetime of wxRegConfig object
105 wxRegKey m_keyLocalRoot, m_keyLocal,
106 m_keyGlobalRoot, m_keyGlobal;
107
108 // current path (not '/' terminated)
109 wxString m_strPath;
110};
111
112#endif //_REGCONF_H