Empty container and design description for native PalmOS wxPrefConfig. Remove MSW configs from PalmOS.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31188 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-12-29 09:48:43 +00:00
parent 6d63e2fc16
commit 23a59c2cbe
13 changed files with 289 additions and 797 deletions

View File

@@ -4,11 +4,13 @@
#include "wx/confbase.h"
#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
# ifdef __WIN32__
# include "wx/msw/regconf.h"
#else
# include "wx/msw/iniconf.h"
# endif
# ifdef __WIN32__
# include "wx/msw/regconf.h"
# else
# include "wx/msw/iniconf.h"
# endif
#elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
# include "wx/palmos/prefconf.h"
#else
# include "wx/fileconf.h"
#endif

View File

@@ -18,6 +18,11 @@
#error "wxPalmOS port was introduced after 2.4.X"
#endif
#ifdef wxUSE_FILECONFIG
#undef wxUSE_FILECONFIG
#endif
#define wxUSE_FILECONFIG 0
/*
* disable the settings which don't work for some compilers
*/

View File

@@ -1,95 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: include/wx/palmos/iniconf.h
// Purpose: INI-file based wxConfigBase implementation
// Author: William Osborne
// Modified by:
// Created: 10/13/04
// RCS-ID: $Id:
// Copyright: (c) William Osborne
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _INICONF_H
#define _INICONF_H
// ----------------------------------------------------------------------------
// wxIniConfig is a wxConfig implementation which uses MS Windows INI files to
// store the data. Because INI files don't really support arbitrary nesting of
// groups, we do the following:
// (1) in win.ini file we store all entries in the [vendor] section and
// the value group1/group2/key is mapped to the value group1_group2_key
// in this section, i.e. all path separators are replaced with underscore
// (2) in appname.ini file we map group1/group2/group3/key to the entry
// group2_group3_key in [group1]
//
// Of course, it might lead to indesirable results if '_' is also used in key
// names (i.e. group/key is the same as group_key) and also GetPath() result
// may be not what you would expect it to be.
//
// Another limitation: the keys and section names are never case-sensitive
// which might differ from wxFileConfig it it was compiled with
// wxCONFIG_CASE_SENSITIVE option.
// ----------------------------------------------------------------------------
// for this class, "local" file is the file appname.ini and the global file
// is the [vendor] subsection of win.ini (default for "vendor" is to be the
// same as appname). The file name (strAppName parameter) may, in fact,
// contain the full path to the file. If it doesn't, the file is searched for
// in the Windows directory.
class WXDLLEXPORT wxIniConfig : public wxConfigBase
{
public:
// ctor & dtor
// if strAppName doesn't contain the extension and is not an absolute path,
// ".ini" is appended to it. if strVendor is empty, it's taken to be the
// same as strAppName.
wxIniConfig(const wxString& strAppName = wxEmptyString, const wxString& strVendor = wxEmptyString,
const wxString& localFilename = wxEmptyString, const wxString& globalFilename = wxEmptyString, long style = wxCONFIG_USE_LOCAL_FILE);
virtual ~wxIniConfig();
// implement inherited pure virtual functions
virtual void SetPath(const wxString& strPath);
virtual const wxString& GetPath() const;
virtual bool GetFirstGroup(wxString& str, long& lIndex) const;
virtual bool GetNextGroup (wxString& str, long& lIndex) const;
virtual bool GetFirstEntry(wxString& str, long& lIndex) const;
virtual bool GetNextEntry (wxString& str, long& lIndex) const;
virtual size_t GetNumberOfEntries(bool bRecursive = FALSE) const;
virtual size_t GetNumberOfGroups(bool bRecursive = FALSE) const;
virtual bool HasGroup(const wxString& strName) const;
virtual bool HasEntry(const wxString& strName) const;
// return TRUE if the current group is empty
bool IsEmpty() const;
virtual bool Flush(bool bCurrentOnly = FALSE);
virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
virtual bool DeleteEntry(const wxString& Key, bool bGroupIfEmptyAlso = TRUE);
virtual bool DeleteGroup(const wxString& szKey);
virtual bool DeleteAll();
protected:
// read/write
bool DoReadString(const wxString& key, wxString *pStr) const;
bool DoReadLong(const wxString& key, long *plResult) const;
bool DoWriteString(const wxString& key, const wxString& szValue);
bool DoWriteLong(const wxString& key, long lValue);
private:
// helpers
wxString GetPrivateKeyName(const wxString& szKey) const;
wxString GetKeyName(const wxString& szKey) const;
wxString m_strLocalFilename; // name of the private INI file
wxString m_strGroup, // current group in appname.ini file
m_strPath; // the rest of the path (no trailing '_'!)
};
#endif //_INICONF_H

View File

@@ -1,43 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Name: palmos/regconf.h
// Purpose: Registry based implementation of wxConfigBase
// Author: William Osborne
// Name: wx/palmos/prefconf.h
// Purpose: wxPrefConfig interface
// Author: Wlodzimierz ABX Skiba
// Modified by:
// Created: 10/13/04
// RCS-ID: $Id:
// Copyright: (c) William Osborne
// Licence: wxWindows licence
// Created: 28.12.2004
// RCS-ID: $Id$
// Copyright: (c) Wlodzimierz Skiba
// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _REGCONF_H
#define _REGCONF_H
#ifndef _PREFCONF_H_
#define _PREFCONF_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "regconf.h"
#pragma interface "prefconf.h"
#endif
#ifndef _REGISTRY_H
#include "wx/palmos/registry.h"
#endif
#include "wx/object.h"
// ----------------------------------------------------------------------------
// wxRegConfig
// wxPrefConfig
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxRegConfig : public wxConfigBase
class WXDLLIMPEXP_BASE wxPrefConfig : public wxConfigBase
{
public:
// ctor & dtor
// will store data in HKLM\appName and HKCU\appName
wxRegConfig(const wxString& appName = wxEmptyString,
const wxString& vendorName = wxEmptyString,
const wxString& localFilename = wxEmptyString,
const wxString& globalFilename = wxEmptyString,
long style = wxCONFIG_USE_GLOBAL_FILE);
wxPrefConfig(const wxString& appName = wxEmptyString,
const wxString& vendorName = wxEmptyString,
const wxString& localFilename = wxEmptyString,
const wxString& globalFilename = wxEmptyString,
long style = wxCONFIG_USE_GLOBAL_FILE);
// dtor will save unsaved data
virtual ~wxRegConfig();
// dtor will save unsaved data
virtual ~wxPrefConfig(){}
// implement inherited pure virtual functions
// ------------------------------------------
@@ -47,48 +41,33 @@ public:
virtual const wxString& GetPath() const { return m_strPath; }
// entry/subgroup info
// enumerate all of them
virtual bool GetFirstGroup(wxString& str, long& lIndex) const;
virtual bool GetNextGroup (wxString& str, long& lIndex) const;
virtual bool GetFirstEntry(wxString& str, long& lIndex) const;
virtual bool GetNextEntry (wxString& str, long& lIndex) const;
// tests for existence
// tests for existence
virtual bool HasGroup(const wxString& strName) const;
virtual bool HasEntry(const wxString& strName) const;
virtual EntryType GetEntryType(const wxString& name) const;
// get number of entries/subgroups in the current group, with or without
// it's subgroups
virtual size_t GetNumberOfEntries(bool bRecursive = FALSE) const;
virtual size_t GetNumberOfGroups(bool bRecursive = FALSE) const;
// get number of entries/subgroups in the current group, with or without
// it's subgroups
virtual size_t GetNumberOfEntries(bool bRecursive = false) const;
virtual size_t GetNumberOfGroups(bool bRecursive = false) const;
virtual bool Flush(bool WXUNUSED(bCurrentOnly) = FALSE) { return TRUE; }
virtual bool Flush(bool WXUNUSED(bCurrentOnly) = false) { return true; }
// rename
virtual bool RenameEntry(const wxString& oldName, const wxString& newName);
virtual bool RenameGroup(const wxString& oldName, const wxString& newName);
// delete
virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = TRUE);
virtual bool DeleteEntry(const wxString& key, bool bGroupIfEmptyAlso = true);
virtual bool DeleteGroup(const wxString& key);
virtual bool DeleteAll();
protected:
// opens the local key creating it if necessary and returns it
wxRegKey& LocalKey() const // must be const to be callable from const funcs
{
wxRegConfig* self = wxConstCast(this, wxRegConfig);
if ( !m_keyLocal.IsOpened() )
{
// create on demand
self->m_keyLocal.Create();
}
return self->m_keyLocal;
}
// implement read/write methods
virtual bool DoReadString(const wxString& key, wxString *pStr) const;
virtual bool DoReadLong(const wxString& key, long *plResult) const;
@@ -98,15 +77,18 @@ protected:
private:
// no copy ctor/assignment operator
wxRegConfig(const wxRegConfig&);
wxRegConfig& operator=(const wxRegConfig&);
// these keys are opened during all lifetime of wxRegConfig object
wxRegKey m_keyLocalRoot, m_keyLocal,
m_keyGlobalRoot, m_keyGlobal;
wxPrefConfig(const wxPrefConfig&);
wxPrefConfig& operator=(const wxPrefConfig&);
// current path (not '/' terminated)
wxString m_strPath;
// current path (group) content (cache for read/write)
wxString m_strGroup;
// current group modified ?
bool m_modGroup;
};
#endif //_REGCONF_H
#endif // _PREFCONF_H_

View File

@@ -1,209 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: palmos/registry.h
// Purpose: Registry classes and functions
// Author: William Osborne
// Modified by:
// Created: 10/13/04
// RCS-ID: $Id:
// Copyright: (c) William Osborne
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _REGISTRY_H
#define _REGISTRY_H
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "registry.h"
#endif
// ----------------------------------------------------------------------------
// types used in this module
// ----------------------------------------------------------------------------
/*
#ifndef HKEY_DEFINED
#define HKEY_DEFINED
#define HKEY unsigned long
#endif
*/
typedef unsigned long ulong;
// ----------------------------------------------------------------------------
// class wxRegKey encapsulates window HKEY handle
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxRegKey
{
public:
// NB: do _not_ change the values of elements in these enumerations!
// registry value types (with comments from winnt.h)
enum ValueType
{
Type_None, // No value type
Type_String, // Unicode nul terminated string
};
// predefined registry keys
enum StdKey
{
HKCR // classes root
};
// access mode for the key
enum AccessMode
{
Read, // read-only
Write // read and write
};
// information about standard (predefined) registry keys
// number of standard keys
static const size_t nStdKeys;
// get the name of a standard key
static const wxChar *GetStdKeyName(size_t key);
// get the short name of a standard key
static const wxChar *GetStdKeyShortName(size_t key);
// get StdKey from root HKEY
static StdKey GetStdKeyFromHkey(WXHKEY hkey);
// extacts the std key prefix from the string (return value) and
// leaves only the part after it (i.e. modifies the string passed!)
static StdKey ExtractKeyName(wxString& str);
// ctors
// root key is set to HKCR (the only root key under Win16)
wxRegKey();
// strKey is the full name of the key (i.e. starting with HKEY_xxx...)
wxRegKey(const wxString& strKey);
// strKey is the name of key under (standard key) keyParent
wxRegKey(StdKey keyParent, const wxString& strKey);
// strKey is the name of key under (previously created) keyParent
wxRegKey(const wxRegKey& keyParent, const wxString& strKey);
// dtor closes the key
~wxRegKey();
// change key (closes the previously opened key if any)
// the name is absolute, i.e. should start with HKEY_xxx
void SetName(const wxString& strKey);
// the name is relative to the parent key
void SetName(StdKey keyParent, const wxString& strKey);
// the name is relative to the parent key
void SetName(const wxRegKey& keyParent, const wxString& strKey);
// hKey should be opened and will be closed in wxRegKey dtor
void SetHkey(WXHKEY hKey);
// get infomation about the key
// get the (full) key name. Abbreviate std root keys if bShortPrefix.
wxString GetName(bool bShortPrefix = true) const;
// return true if the key exists
bool Exists() const;
// get the info about key (any number of these pointers may be NULL)
bool GetKeyInfo(size_t *pnSubKeys, // number of subkeys
size_t *pnMaxKeyLen, // max len of subkey name
size_t *pnValues, // number of values
size_t *pnMaxValueLen) const;
// return true if the key is opened
bool IsOpened() const { return m_hKey != 0; }
// for "if ( !key ) wxLogError(...)" kind of expressions
operator bool() const { return m_dwLastError == 0; }
// operations on the key itself
// explicitly open the key (will be automatically done by all functions
// which need the key to be opened if the key is not opened yet)
bool Open(AccessMode mode = Write);
// create the key: will fail if the key already exists and !bOkIfExists
bool Create(bool bOkIfExists = true);
// rename a value from old name to new one
bool RenameValue(const wxChar *szValueOld, const wxChar *szValueNew);
// rename the key
bool Rename(const wxChar *szNewName);
// copy value to another key possibly changing its name (by default it will
// remain the same)
bool CopyValue(const wxChar *szValue, wxRegKey& keyDst,
const wxChar *szNewName = NULL);
// copy the entire contents of the key recursively to another location
bool Copy(const wxChar *szNewName);
// same as Copy() but using a key and not the name
bool Copy(wxRegKey& keyDst);
// close the key (will be automatically done in dtor)
bool Close();
// deleting keys/values
// deletes this key and all of it's subkeys/values
bool DeleteSelf();
// deletes the subkey with all of it's subkeys/values recursively
bool DeleteKey(const wxChar *szKey);
// deletes the named value (may be NULL to remove the default value)
bool DeleteValue(const wxChar *szValue);
// access to values and subkeys
// get value type
ValueType GetValueType(const wxChar *szValue) const;
// returns true if the value contains a number (else it's some string)
bool IsNumericValue(const wxChar *szValue) const;
// assignment operators set the default value of the key
wxRegKey& operator=(const wxString& strValue)
{ SetValue(NULL, strValue); return *this; }
// query the default value of the key: implicitly or explicitly
wxString QueryDefaultValue() const;
operator wxString() const { return QueryDefaultValue(); }
// named values
// set the string value
bool SetValue(const wxChar *szValue, const wxString& strValue);
// retrieve the string value
bool QueryValue(const wxChar *szValue, wxString& strValue) const
{ return QueryValue(szValue, strValue, false); }
// retrieve raw string value
bool QueryRawValue(const wxChar *szValue, wxString& strValue) const
{ return QueryValue(szValue, strValue, true); }
// retrieve either raw or expanded string value
bool QueryValue(const wxChar *szValue, wxString& strValue, bool raw) const;
// query existence of a key/value
// return true if value exists
bool HasValue(const wxChar *szKey) const;
// return true if given subkey exists
bool HasSubKey(const wxChar *szKey) const;
// return true if any subkeys exist
bool HasSubkeys() const;
// return true if any values exist
bool HasValues() const;
// return true if the key is empty (nothing under this key)
bool IsEmpty() const { return !HasSubkeys() && !HasValues(); }
// enumerate values and subkeys
bool GetFirstValue(wxString& strValueName, long& lIndex);
bool GetNextValue (wxString& strValueName, long& lIndex) const;
bool GetFirstKey (wxString& strKeyName , long& lIndex);
bool GetNextKey (wxString& strKeyName , long& lIndex) const;
// for wxRegConfig usage only: preallocate some memory for the name
void ReserveMemoryForName(size_t bytes) { m_strKey.reserve(bytes); }
private:
// common part of all ctors
void Init()
{
m_hKey = (WXHKEY) NULL;
m_dwLastError = 0;
}
// no copy ctor/assignment operator
wxRegKey(const wxRegKey& key); // not implemented
wxRegKey& operator=(const wxRegKey& key); // not implemented
WXHKEY m_hKey, // our handle
m_hRootKey; // handle of the top key (i.e. StdKey)
wxString m_strKey; // key name (relative to m_hRootKey)
long m_dwLastError; // last error (0 if none)
};
#endif //_REGISTRY_H

View File

@@ -335,7 +335,7 @@
// See also wxUSE_CONFIG_NATIVE below.
//
// Recommended setting: 1
#define wxUSE_CONFIG 0
#define wxUSE_CONFIG 1
// If wxUSE_CONFIG is 1, you may choose to use either the native config
// classes under Windows (using .INI files under Win16 and the registry under
@@ -348,7 +348,7 @@
// not wxFileConfig.
//
// Recommended setting: 1
#define wxUSE_CONFIG_NATIVE 0
#define wxUSE_CONFIG_NATIVE 1
// If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows
// to connect/disconnect from the network and be notified whenever the dial-up
@@ -928,7 +928,7 @@
// that use the connection) should support forward only scrolling of cursors,
// or both forward and backward support for backward scrolling cursors is
// dependent on the data source as well as the ODBC driver being used.
#define wxODBC_FWD_ONLY_CURSORS 0
#define wxODBC_FWD_ONLY_CURSORS 0
// Default is 0. Set to 1 to use the deprecated classes, enum types, function,
// member variables. With a setting of 1, full backward compatability with the