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