]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/fileconf.h
Make storing non-trivial data in wxThreadSpecificInfo possible.
[wxWidgets.git] / interface / wx / fileconf.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: fileconf.h
e54c96f1 3// Purpose: interface of wxFileConfig
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxFileConfig
7c913512 10
23324ae1
FM
11 wxFileConfig implements wxConfigBase interface for
12 storing and retrieving configuration information using plain text files. The
13 files have a simple format reminiscent of Windows INI files with lines of the
ea6a2ccb
FM
14 form @c "key = value" defining the keys and lines of special form
15 @c "[group]" indicating the start of each group.
7c913512 16
23324ae1
FM
17 This class is used by default for wxConfig on Unix platforms but may also be
18 used explicitly if you want to use files and not the registry even under
19 Windows.
7c913512 20
23324ae1 21 @library{wxbase}
3c99e2fd 22 @category{cfg}
7c913512 23
e54c96f1 24 @see wxFileConfig::Save
23324ae1
FM
25*/
26class wxFileConfig : public wxConfigBase
27{
28public:
a4a06df3
VZ
29 /**
30 Constructor allowing to choose the file names to use.
31
32 If @a localFilename and/or @a globalFilename are explicitly specified,
33 they are used as the names of the user and system-wide configuration
34 files (the latter is only read by the program while the former is read
35 from and written to). Otherwise the behaviour depends on @a style
36 parameter. If it includes ::wxCONFIG_USE_LOCAL_FILE, then the local
37 file name is constructed from the information in @a appName and @a
38 vendorName arguments in a system-dependent way. If
39 ::wxCONFIG_USE_GLOBAL_FILE is not specified at all (and @a
40 globalFilename is empty) then the system-wide file is not used at all.
41 Otherwise its name and path are also constructed in the way appropriate
42 for the current platform from the application and vendor names.
43 */
e9321277
RD
44 wxFileConfig(const wxString& appName = wxEmptyString,
45 const wxString& vendorName = wxEmptyString,
46 const wxString& localFilename = wxEmptyString,
47 const wxString& globalFilename = wxEmptyString,
48 long style = wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_GLOBAL_FILE,
49 const wxMBConv& conv = wxConvAuto());
50
23324ae1 51 /**
23324ae1
FM
52 Read the config data from the specified stream instead of the associated file,
53 as usual.
3c4f71cc 54
4cc4bfaf 55 @see Save()
23324ae1 56 */
0ce6d6c8 57 wxFileConfig(wxInputStream& is, const wxMBConv& conv = wxConvAuto());
23324ae1
FM
58
59 /**
60 Return the full path to the file which would be used by wxFileConfig as global,
0ce6d6c8
FM
61 system-wide, file if it were constructed with @a basename as "global filename"
62 parameter in the constructor.
63
64 Notice that this function cannot be used if @a basename is already a full path name.
23324ae1
FM
65 */
66 static wxFileName GetGlobalFile(const wxString& basename);
67
68 /**
69 Return the full path to the file which would be used by wxFileConfig as local,
0ce6d6c8
FM
70 user-specific, file if it were constructed with @a basename as "local filename"
71 parameter in the constructor.
72
ea6a2ccb 73 @a style has the same meaning as in @ref wxConfigBase::wxConfigBase "wxConfig constructor"
23324ae1
FM
74 and can contain any combination of styles but only wxCONFIG_USE_SUBDIR bit is
75 examined by this function.
0ce6d6c8
FM
76
77 Notice that this function cannot be used if @a basename is already a full path name.
23324ae1 78 */
ea6a2ccb 79 static wxFileName GetLocalFile(const wxString& basename, int style = 0);
23324ae1 80
e9321277
RD
81 static wxString GetGlobalFileName(const wxString& szFile);
82 static wxString GetLocalFileName(const wxString& szFile, int style = 0);
83
23324ae1 84 /**
23324ae1
FM
85 Saves all config data to the given stream, returns @true if data was saved
86 successfully or @false on error.
0ce6d6c8
FM
87
88 Note the interaction of this function with the internal "dirty flag": the
23324ae1
FM
89 data is saved unconditionally, i.e. even if the object is not dirty. However
90 after saving it successfully, the dirty flag is reset so no changes will be
91 written back to the file this object is associated with until you change its
92 contents again.
3c4f71cc 93
4cc4bfaf 94 @see wxConfigBase::Flush
23324ae1 95 */
9f5737d7 96 virtual bool Save(wxOutputStream& os, const wxMBConv& conv = wxConvAuto());
23324ae1
FM
97
98 /**
99 Allows to set the mode to be used for the config file creation. For example, to
100 create a config file which is not readable by other users (useful if it stores
0ce6d6c8
FM
101 some sensitive information, such as passwords), you could use @c SetUmask(0077).
102
23324ae1 103 This function doesn't do anything on non-Unix platforms.
3c4f71cc 104
e54c96f1 105 @see wxCHANGE_UMASK()
23324ae1
FM
106 */
107 void SetUmask(int mode);
e9321277
RD
108
109 // implement inherited pure virtual functions
110 virtual void SetPath(const wxString& strPath);
111 virtual const wxString& GetPath() const;
112
113 virtual bool GetFirstGroup(wxString& str, long& lIndex) const;
114 virtual bool GetNextGroup (wxString& str, long& lIndex) const;
115 virtual bool GetFirstEntry(wxString& str, long& lIndex) const;
116 virtual bool GetNextEntry (wxString& str, long& lIndex) const;
117
118 virtual size_t GetNumberOfEntries(bool bRecursive = false) const;
119 virtual size_t GetNumberOfGroups(bool bRecursive = false) const;
120
121 virtual bool HasGroup(const wxString& strName) const;
122 virtual bool HasEntry(const wxString& strName) const;
123
124 virtual bool Flush(bool bCurrentOnly = false);
125
126 virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
127 virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
128
129 virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = true);
130 virtual bool DeleteGroup(const wxString& szKey);
131 virtual bool DeleteAll();
23324ae1 132};
e54c96f1 133