1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/msw/iniconf.h
3 // Purpose: INI-file based wxConfigBase implementation
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_INICONF_H_
13 #define _WX_MSW_INICONF_H_
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]
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.
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 // ----------------------------------------------------------------------------
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.
41 class WXDLLIMPEXP_CORE wxIniConfig
: public wxConfigBase
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.
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
);
50 virtual ~wxIniConfig();
52 // implement inherited pure virtual functions
53 virtual void SetPath(const wxString
& strPath
);
54 virtual const wxString
& GetPath() const;
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;
61 virtual size_t GetNumberOfEntries(bool bRecursive
= false) const;
62 virtual size_t GetNumberOfGroups(bool bRecursive
= false) const;
64 virtual bool HasGroup(const wxString
& strName
) const;
65 virtual bool HasEntry(const wxString
& strName
) const;
67 // return true if the current group is empty
70 virtual bool Flush(bool bCurrentOnly
= false);
72 virtual bool RenameEntry(const wxString
& oldName
, const wxString
& newName
);
73 virtual bool RenameGroup(const wxString
& oldName
, const wxString
& newName
);
75 virtual bool DeleteEntry(const wxString
& Key
, bool bGroupIfEmptyAlso
= true);
76 virtual bool DeleteGroup(const wxString
& szKey
);
77 virtual bool DeleteAll();
81 bool DoReadString(const wxString
& key
, wxString
*pStr
) const;
82 bool DoReadLong(const wxString
& key
, long *plResult
) const;
83 bool DoReadBinary(const wxString
& key
, wxMemoryBuffer
*buf
) const;
85 bool DoWriteString(const wxString
& key
, const wxString
& szValue
);
86 bool DoWriteLong(const wxString
& key
, long lValue
);
87 bool DoWriteBinary(const wxString
& key
, const wxMemoryBuffer
& buf
);
91 wxString
GetPrivateKeyName(const wxString
& szKey
) const;
92 wxString
GetKeyName(const wxString
& szKey
) const;
94 wxString m_strLocalFilename
; // name of the private INI file
95 wxString m_strGroup
, // current group in appname.ini file
96 m_strPath
; // the rest of the path (no trailing '_'!)
98 DECLARE_NO_COPY_CLASS(wxIniConfig
)
99 DECLARE_ABSTRACT_CLASS(wxIniConfig
)
102 #endif // wxUSE_INICONF
104 #endif //_WX_MSW_INICONF_H_