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