Version: 2.9.4
Public Member Functions | Static Public Member Functions
wxFileConfig Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/fileconf.h>

Inheritance diagram for wxFileConfig:

Detailed Description

wxFileConfig implements wxConfigBase interface for storing and retrieving configuration information using plain text files.

The files have a simple format reminiscent of Windows INI files with lines of the form "key = value" defining the keys and lines of special form "[group]" indicating the start of each group.

This class is used by default for wxConfig on Unix platforms but may also be used explicitly if you want to use files and not the registry even under Windows.

Library:  wxBase
Category:  Application and System configuration
参照:
wxFileConfig::Save

Public Member Functions

 wxFileConfig (const wxString &appName=wxEmptyString, const wxString &vendorName=wxEmptyString, const wxString &localFilename=wxEmptyString, const wxString &globalFilename=wxEmptyString, long style=wxCONFIG_USE_LOCAL_FILE|wxCONFIG_USE_GLOBAL_FILE, const wxMBConv &conv=wxConvAuto())
 Constructor allowing to choose the file names to use.
 wxFileConfig (wxInputStream &is, const wxMBConv &conv=wxConvAuto())
 Read the config data from the specified stream instead of the associated file, as usual.
virtual bool Save (wxOutputStream &os, const wxMBConv &conv=wxConvAuto())
 Saves all config data to the given stream, returns true if data was saved successfully or false on error.
void SetUmask (int mode)
 Allows to set the mode to be used for the config file creation.
virtual void SetPath (const wxString &strPath)
 Set current path: if the first character is '/', it is the absolute path, otherwise it is a relative path.
virtual const wxStringGetPath () const
 Retrieve the current path (always as absolute path).
virtual bool GetFirstGroup (wxString &str, long &lIndex) const
 Gets the first group.
virtual bool GetNextGroup (wxString &str, long &lIndex) const
 Gets the next group.
virtual bool GetFirstEntry (wxString &str, long &lIndex) const
 Gets the first entry.
virtual bool GetNextEntry (wxString &str, long &lIndex) const
 Gets the next entry.
virtual size_t GetNumberOfEntries (bool bRecursive=false) const
 Get number of entries in the current group.
virtual size_t GetNumberOfGroups (bool bRecursive=false) const
 Get number of entries/subgroups in the current group, with or without its subgroups.
virtual bool HasGroup (const wxString &strName) const
virtual bool HasEntry (const wxString &strName) const
virtual bool Flush (bool bCurrentOnly=false)
 Permanently writes all changes (otherwise, they're only written from object's destructor).
virtual bool RenameEntry (const wxString &oldName, const wxString &newName)
 Renames an entry in the current group.
virtual bool RenameGroup (const wxString &oldName, const wxString &newName)
 Renames a subgroup of the current group.
virtual bool DeleteEntry (const wxString &key, bool bGroupIfEmptyAlso=true)
 Deletes the specified entry and the group it belongs to if it was the last key in it and the second parameter is true.
virtual bool DeleteGroup (const wxString &szKey)
 Delete the group (with all subgroups).
virtual bool DeleteAll ()
 Delete the whole underlying object (disk file, registry key, ...).

Static Public Member Functions

static wxFileName GetGlobalFile (const wxString &basename)
 Return the full path to the file which would be used by wxFileConfig as global, system-wide, file if it were constructed with basename as "global filename" parameter in the constructor.
static wxFileName GetLocalFile (const wxString &basename, int style=0)
 Return the full path to the file which would be used by wxFileConfig as local, user-specific, file if it were constructed with basename as "local filename" parameter in the constructor.
static wxString GetGlobalFileName (const wxString &szFile)
static wxString GetLocalFileName (const wxString &szFile, int style=0)

List of all members.


Constructor & Destructor Documentation

wxFileConfig::wxFileConfig ( const wxString appName = wxEmptyString,
const wxString vendorName = wxEmptyString,
const wxString localFilename = wxEmptyString,
const wxString globalFilename = wxEmptyString,
long  style = wxCONFIG_USE_LOCAL_FILE|wxCONFIG_USE_GLOBAL_FILE,
const wxMBConv conv = wxConvAuto() 
)

Constructor allowing to choose the file names to use.

If localFilename and/or globalFilename are explicitly specified, they are used as the names of the user and system-wide configuration files (the latter is only read by the program while the former is read from and written to). Otherwise the behaviour depends on style parameter. If it includes ::wxCONFIG_USE_LOCAL_FILE, then the local file name is constructed from the information in appName and vendorName arguments in a system-dependent way. If ::wxCONFIG_USE_GLOBAL_FILE is not specified at all (and globalFilename is empty) then the system-wide file is not used at all. Otherwise its name and path are also constructed in the way appropriate for the current platform from the application and vendor names.

wxFileConfig::wxFileConfig ( wxInputStream is,
const wxMBConv conv = wxConvAuto() 
)

Read the config data from the specified stream instead of the associated file, as usual.

参照:
Save()

Member Function Documentation

virtual bool wxFileConfig::DeleteAll ( ) [virtual]

Delete the whole underlying object (disk file, registry key, ...).

Primarily for use by uninstallation routine.

Implements wxConfigBase.

virtual bool wxFileConfig::DeleteEntry ( const wxString key,
bool  bDeleteGroupIfEmpty = true 
) [virtual]

Deletes the specified entry and the group it belongs to if it was the last key in it and the second parameter is true.

Implements wxConfigBase.

virtual bool wxFileConfig::DeleteGroup ( const wxString key) [virtual]

Delete the group (with all subgroups).

If the current path is under the group being deleted it is changed to its deepest still existing component. E.g. if the current path is "/A/B/C/D" and the group C is deleted, the path becomes "/A/B".

Implements wxConfigBase.

virtual bool wxFileConfig::Flush ( bool  bCurrentOnly = false) [virtual]

Permanently writes all changes (otherwise, they're only written from object's destructor).

Implements wxConfigBase.

virtual bool wxFileConfig::GetFirstEntry ( wxString str,
long &  index 
) const [virtual]

Gets the first entry.

wxPerl Note: In wxPerl this method takes no parameters and returns a 3-element list (continue_flag, string, index_for_getnextentry).

Implements wxConfigBase.

virtual bool wxFileConfig::GetFirstGroup ( wxString str,
long &  index 
) const [virtual]

Gets the first group.

wxPerl Note: In wxPerl this method takes no parameters and returns a 3-element list (continue_flag, string, index_for_getnextentry).

Implements wxConfigBase.

static wxFileName wxFileConfig::GetGlobalFile ( const wxString basename) [static]

Return the full path to the file which would be used by wxFileConfig as global, system-wide, file if it were constructed with basename as "global filename" parameter in the constructor.

Notice that this function cannot be used if basename is already a full path name.

static wxString wxFileConfig::GetGlobalFileName ( const wxString szFile) [static]
static wxFileName wxFileConfig::GetLocalFile ( const wxString basename,
int  style = 0 
) [static]

Return the full path to the file which would be used by wxFileConfig as local, user-specific, file if it were constructed with basename as "local filename" parameter in the constructor.

style has the same meaning as in wxConfig constructor and can contain any combination of styles but only wxCONFIG_USE_SUBDIR bit is examined by this function.

Notice that this function cannot be used if basename is already a full path name.

static wxString wxFileConfig::GetLocalFileName ( const wxString szFile,
int  style = 0 
) [static]
virtual bool wxFileConfig::GetNextEntry ( wxString str,
long &  index 
) const [virtual]

Gets the next entry.

wxPerl Note: In wxPerl this method only takes the index parameter and returns a 3-element list (continue_flag, string, index_for_getnextentry).

Implements wxConfigBase.

virtual bool wxFileConfig::GetNextGroup ( wxString str,
long &  index 
) const [virtual]

Gets the next group.

wxPerl Note: In wxPerl this method only takes the index parameter and returns a 3-element list (continue_flag, string, index_for_getnextentry).

Implements wxConfigBase.

virtual size_t wxFileConfig::GetNumberOfEntries ( bool  bRecursive = false) const [virtual]

Get number of entries in the current group.

Implements wxConfigBase.

virtual size_t wxFileConfig::GetNumberOfGroups ( bool  bRecursive = false) const [virtual]

Get number of entries/subgroups in the current group, with or without its subgroups.

Implements wxConfigBase.

virtual const wxString& wxFileConfig::GetPath ( ) const [virtual]

Retrieve the current path (always as absolute path).

Implements wxConfigBase.

virtual bool wxFileConfig::HasEntry ( const wxString strName) const [virtual]
Returns:
true if the entry by this name exists.

Implements wxConfigBase.

virtual bool wxFileConfig::HasGroup ( const wxString strName) const [virtual]
Returns:
true if the group by this name exists.

Implements wxConfigBase.

virtual bool wxFileConfig::RenameEntry ( const wxString oldName,
const wxString newName 
) [virtual]

Renames an entry in the current group.

The entries names (both the old and the new one) shouldn't contain backslashes, i.e. only simple names and not arbitrary paths are accepted by this function.

Returns:
false if oldName doesn't exist or if newName already exists.

Implements wxConfigBase.

virtual bool wxFileConfig::RenameGroup ( const wxString oldName,
const wxString newName 
) [virtual]

Renames a subgroup of the current group.

The subgroup names (both the old and the new one) shouldn't contain backslashes, i.e. only simple names and not arbitrary paths are accepted by this function.

Returns:
false if oldName doesn't exist or if newName already exists.

Implements wxConfigBase.

virtual bool wxFileConfig::Save ( wxOutputStream os,
const wxMBConv conv = wxConvAuto() 
) [virtual]

Saves all config data to the given stream, returns true if data was saved successfully or false on error.

Note the interaction of this function with the internal "dirty flag": the data is saved unconditionally, i.e. even if the object is not dirty. However after saving it successfully, the dirty flag is reset so no changes will be written back to the file this object is associated with until you change its contents again.

参照:
wxConfigBase::Flush
virtual void wxFileConfig::SetPath ( const wxString strPath) [virtual]

Set current path: if the first character is '/', it is the absolute path, otherwise it is a relative path.

'..' is supported. If strPath doesn't exist, it is created.

参照:
wxConfigPathChanger

Implements wxConfigBase.

void wxFileConfig::SetUmask ( int  mode)

Allows to set the mode to be used for the config file creation.

For example, to create a config file which is not readable by other users (useful if it stores some sensitive information, such as passwords), you could use SetUmask(0077).

This function doesn't do anything on non-Unix platforms.

参照:
wxCHANGE_UMASK()
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines