]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/iniconf.h
Add wxComboBox-compatible Popup() and Dismiss() functions in wxComboCtrl
[wxWidgets.git] / include / wx / msw / iniconf.h
CommitLineData
8f494e5d 1///////////////////////////////////////////////////////////////////////////////
233f5738 2// Name: wx/msw/iniconf.h
8f494e5d
VZ
3// Purpose: INI-file based wxConfigBase implementation
4// Author: Vadim Zeitlin
59af881e 5// Modified by:
8f494e5d
VZ
6// Created: 27.07.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// Licence: wxWindows licence
8f494e5d
VZ
10///////////////////////////////////////////////////////////////////////////////
11
61873536
VZ
12#ifndef _WX_MSW_INICONF_H_
13#define _WX_MSW_INICONF_H_
14
101b2420
VZ
15#include "wx/defs.h"
16
17#if wxUSE_CONFIG && wxUSE_INICONF
8f494e5d
VZ
18
19// ----------------------------------------------------------------------------
20// wxIniConfig is a wxConfig implementation which uses MS Windows INI files to
21// store the data. Because INI files don't really support arbitrary nesting of
22// groups, we do the following:
23// (1) in win.ini file we store all entries in the [vendor] section and
24// the value group1/group2/key is mapped to the value group1_group2_key
25// in this section, i.e. all path separators are replaced with underscore
26// (2) in appname.ini file we map group1/group2/group3/key to the entry
27// group2_group3_key in [group1]
28//
29// Of course, it might lead to indesirable results if '_' is also used in key
30// names (i.e. group/key is the same as group_key) and also GetPath() result
31// may be not what you would expect it to be.
32//
33// Another limitation: the keys and section names are never case-sensitive
34// which might differ from wxFileConfig it it was compiled with
35// wxCONFIG_CASE_SENSITIVE option.
36// ----------------------------------------------------------------------------
37
38// for this class, "local" file is the file appname.ini and the global file
39// is the [vendor] subsection of win.ini (default for "vendor" is to be the
40// same as appname). The file name (strAppName parameter) may, in fact,
41// contain the full path to the file. If it doesn't, the file is searched for
42// in the Windows directory.
53a2db12 43class WXDLLIMPEXP_CORE wxIniConfig : public wxConfigBase
8f494e5d
VZ
44{
45public:
46 // ctor & dtor
47 // if strAppName doesn't contain the extension and is not an absolute path,
48 // ".ini" is appended to it. if strVendor is empty, it's taken to be the
49 // same as strAppName.
18244936
JS
50 wxIniConfig(const wxString& strAppName = wxEmptyString, const wxString& strVendor = wxEmptyString,
51 const wxString& localFilename = wxEmptyString, const wxString& globalFilename = wxEmptyString, long style = wxCONFIG_USE_LOCAL_FILE);
8f494e5d
VZ
52 virtual ~wxIniConfig();
53
54 // implement inherited pure virtual functions
55 virtual void SetPath(const wxString& strPath);
56 virtual const wxString& GetPath() const;
57
58 virtual bool GetFirstGroup(wxString& str, long& lIndex) const;
59 virtual bool GetNextGroup (wxString& str, long& lIndex) const;
60 virtual bool GetFirstEntry(wxString& str, long& lIndex) const;
61 virtual bool GetNextEntry (wxString& str, long& lIndex) const;
62
59af881e
WS
63 virtual size_t GetNumberOfEntries(bool bRecursive = false) const;
64 virtual size_t GetNumberOfGroups(bool bRecursive = false) const;
8f494e5d
VZ
65
66 virtual bool HasGroup(const wxString& strName) const;
67 virtual bool HasEntry(const wxString& strName) const;
68
59af881e 69 // return true if the current group is empty
8f494e5d
VZ
70 bool IsEmpty() const;
71
59af881e 72 virtual bool Flush(bool bCurrentOnly = false);
8f494e5d 73
5d1902d6
VZ
74 virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
75 virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
76
59af881e 77 virtual bool DeleteEntry(const wxString& Key, bool bGroupIfEmptyAlso = true);
1e6d9499 78 virtual bool DeleteGroup(const wxString& szKey);
8f494e5d
VZ
79 virtual bool DeleteAll();
80
2ba41305
VZ
81protected:
82 // read/write
83 bool DoReadString(const wxString& key, wxString *pStr) const;
84 bool DoReadLong(const wxString& key, long *plResult) const;
5814e8ba 85 bool DoReadBinary(const wxString& key, wxMemoryBuffer *buf) const;
2ba41305
VZ
86
87 bool DoWriteString(const wxString& key, const wxString& szValue);
88 bool DoWriteLong(const wxString& key, long lValue);
5814e8ba 89 bool DoWriteBinary(const wxString& key, const wxMemoryBuffer& buf);
2ba41305 90
8f494e5d
VZ
91private:
92 // helpers
18244936
JS
93 wxString GetPrivateKeyName(const wxString& szKey) const;
94 wxString GetKeyName(const wxString& szKey) const;
8f494e5d 95
18244936 96 wxString m_strLocalFilename; // name of the private INI file
8f494e5d
VZ
97 wxString m_strGroup, // current group in appname.ini file
98 m_strPath; // the rest of the path (no trailing '_'!)
c4ec0ce8 99
c0c133e1 100 wxDECLARE_NO_COPY_CLASS(wxIniConfig);
c4ec0ce8 101 DECLARE_ABSTRACT_CLASS(wxIniConfig)
8f494e5d
VZ
102};
103
101b2420 104#endif // wxUSE_CONFIG && wxUSE_INICONF
61873536 105
101b2420 106#endif // _WX_MSW_INICONF_H_