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