]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/regconf.h
use GlobalPtrLock (modified to allow not initializing it if the ptr is NULL) in wxGet...
[wxWidgets.git] / include / wx / msw / regconf.h
CommitLineData
45c28815 1///////////////////////////////////////////////////////////////////////////////
9869734d 2// Name: msw/regconf.h
8f494e5d 3// Purpose: Registry based implementation of wxConfigBase
45c28815 4// Author: Vadim Zeitlin
9869734d 5// Modified by:
45c28815
VZ
6// Created: 27.04.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// Licence: wxWindows licence
45c28815
VZ
10///////////////////////////////////////////////////////////////////////////////
11
d501d4ef
VS
12#ifndef _WX_MSW_REGCONF_H_
13#define _WX_MSW_REGCONF_H_
45c28815 14
d501d4ef 15#include "wx/defs.h"
fdd74b41 16
d501d4ef
VS
17#if wxUSE_CONFIG && wxUSE_REGKEY
18
19#include "wx/msw/registry.h"
85d4fc42 20#include "wx/object.h"
fdd74b41 21#include "wx/confbase.h"
f24fc836 22#include "wx/buffer.h"
8f494e5d 23
45c28815
VZ
24// ----------------------------------------------------------------------------
25// wxRegConfig
26// ----------------------------------------------------------------------------
27
40a88328 28class WXDLLIMPEXP_BASE wxRegConfig : public wxConfigBase
45c28815
VZ
29{
30public:
31 // ctor & dtor
18244936 32 // will store data in HKLM\appName and HKCU\appName
fda7962d
JS
33 wxRegConfig(const wxString& appName = wxEmptyString,
34 const wxString& vendorName = wxEmptyString,
35 const wxString& localFilename = wxEmptyString,
36 const wxString& globalFilename = wxEmptyString,
fa2d17ac 37 long style = wxCONFIG_USE_GLOBAL_FILE);
18244936 38
45c28815 39 // dtor will save unsaved data
6fb99eb3 40 virtual ~wxRegConfig(){}
45c28815
VZ
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
8f494e5d
VZ
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;
45c28815 55
8f494e5d 56 // tests for existence
6d833566
VZ
57 virtual bool HasGroup(const wxString& strName) const;
58 virtual bool HasEntry(const wxString& strName) const;
61ba49f2 59 virtual EntryType GetEntryType(const wxString& name) const;
6d833566 60
a37e8836
JS
61 // get number of entries/subgroups in the current group, with or without
62 // it's subgroups
4d08943e
WS
63 virtual size_t GetNumberOfEntries(bool bRecursive = false) const;
64 virtual size_t GetNumberOfGroups(bool bRecursive = false) const;
a37e8836 65
4d08943e 66 virtual bool Flush(bool WXUNUSED(bCurrentOnly) = false) { return true; }
45c28815 67
5d1902d6
VZ
68 // rename
69 virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
70 virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
71
45c28815 72 // delete
4d08943e 73 virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = true);
18244936 74 virtual bool DeleteGroup(const wxString& key);
45c28815
VZ
75 virtual bool DeleteAll();
76
807a903e
VZ
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
2ba41305
VZ
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;
5814e8ba 95 virtual bool DoReadBinary(const wxString& key, wxMemoryBuffer* buf) const;
2ba41305
VZ
96
97 virtual bool DoWriteString(const wxString& key, const wxString& szValue);
98 virtual bool DoWriteLong(const wxString& key, long lValue);
5814e8ba 99 virtual bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf);
2ba41305 100
45c28815
VZ
101private:
102 // these keys are opened during all lifetime of wxRegConfig object
103 wxRegKey m_keyLocalRoot, m_keyLocal,
104 m_keyGlobalRoot, m_keyGlobal;
105
106 // current path (not '/' terminated)
107 wxString m_strPath;
c4ec0ce8
VZ
108
109 DECLARE_NO_COPY_CLASS(wxRegConfig)
110 DECLARE_ABSTRACT_CLASS(wxRegConfig)
45c28815
VZ
111};
112
d501d4ef
VS
113#endif // wxUSE_CONFIG && wxUSE_REGKEY
114
115#endif // _WX_MSW_REGCONF_H_