X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f81e22cf6e38294a87fe10359ac6523a48ef11ee..cbeda384e51acb82e13994cb67ac1714669cae10:/include/wx/confbase.h diff --git a/include/wx/confbase.h b/include/wx/confbase.h index 9d97e49680..ff50f65f4b 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -2,11 +2,11 @@ // Name: confbase.h // Purpose: declaration of the base class of all config implementations // (see also: fileconf.h and msw/regconf.h and iniconf.h) -// Author: Karsten Ballüder & Vadim Zeitlin +// Author: Karsten Ballueder & Vadim Zeitlin // Modified by: // Created: 07.04.98 (adapted from appconf.h) // RCS-ID: $Id$ -// Copyright: (c) 1997 Karsten Ballüder Ballueder@usa.net +// Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net // Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -43,8 +43,6 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; #if wxUSE_CONFIG -#include "wx/string.h" - /// should we use registry instead of configuration files under Windows? // (i.e. whether wxConfigBase::Create() will create a wxFileConfig (if it's // false) or wxRegConfig (if it's true and we're under Win32)) @@ -52,6 +50,15 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString; #define wxUSE_CONFIG_NATIVE 1 #endif +// not all compilers can deal with template Read/Write() methods, define this +// symbol if the template functions are available +#if (!defined(__VISUALC__) || __VISUALC__ > 1200) && \ + !defined( __VMS ) && \ + !(defined(__HP_aCC) && defined(__hppa)) && \ + !defined (__DMC__) + #define wxHAS_CONFIG_TEMPLATE_RW +#endif + // Style flags for constructor style parameter enum { @@ -185,8 +192,7 @@ public: // no default version since it does not make sense for binary data #endif // wxUSE_BASE64 - // Causes ambiguities in VC++ 6 (at least) -#if (!defined(__VISUALC__) || __VISUALC__ > 1200) +#ifdef wxHAS_CONFIG_TEMPLATE_RW // read other types, for which wxFromString is defined template bool Read(const wxString& key, T* value) const @@ -209,10 +215,9 @@ public: } return found; } -#endif +#endif // wxHAS_CONFIG_TEMPLATE_RW - // convenience functions returning directly the value (we don't have them for - // int/double/bool as there would be ambiguities with the long one then) + // convenience functions returning directly the value wxString Read(const wxString& key, const wxString& defVal = wxEmptyString) const { wxString s; (void)Read(key, &s, defVal); return s; } @@ -226,10 +231,25 @@ public: { return Read(key, wxString(defVal)); } #endif - long Read(const wxString& key, long defVal) const + long ReadLong(const wxString& key, long defVal) const { long l; (void)Read(key, &l, defVal); return l; } - // write the value (return true on success) + double ReadDouble(const wxString& key, double defVal) const + { double d; (void)Read(key, &d, defVal); return d; } + + bool ReadBool(const wxString& key, bool defVal) const + { bool b; (void)Read(key, &b, defVal); return b; } + + template + T ReadObject(const wxString& key, T const& defVal) const + { T t; (void)Read(key, &t, defVal); return t; } + + // for compatibility with wx 2.8 + long Read(const wxString& key, long defVal) const + { return ReadLong(key, defVal); } + + + // write the value (return true on success) bool Write(const wxString& key, const wxString& value) { return DoWriteString(key, value); } @@ -262,6 +282,12 @@ public: // we also have to provide specializations for other types which we want to // handle using the specialized DoWriteXXX() instead of the generic template // version below + bool Write(const wxString& key, char value) + { return DoWriteLong(key, value); } + + bool Write(const wxString& key, unsigned char value) + { return DoWriteLong(key, value); } + bool Write(const wxString& key, short value) { return DoWriteLong(key, value); } @@ -280,8 +306,8 @@ public: bool Write(const wxString& key, float value) { return DoWriteDouble(key, value); } - // Causes ambiguities in VC++ 6 (at least) -#if (!defined(__VISUALC__) || __VISUALC__ > 1200) + // Causes ambiguities in VC++ 6 and OpenVMS (at least) +#if ( (!defined(__VISUALC__) || __VISUALC__ > 1200) && !defined( __VMS ) && !defined (__DMC__)) // for other types, use wxToString() template bool Write(const wxString& key, T const& value) @@ -410,22 +436,10 @@ private: m_strOldPath; // saved path bool m_bChanged; // was the path changed? - DECLARE_NO_COPY_CLASS(wxConfigPathChanger) + wxDECLARE_NO_COPY_CLASS(wxConfigPathChanger); }; -// ---------------------------------------------------------------------------- -// the native wxConfigBase implementation -// ---------------------------------------------------------------------------- - -// under Windows we prefer to use the native implementation -// wxIniConfig isn't native anywhere after droping win16 in wxWidgets 2.6 -#if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE - #define wxConfig wxRegConfig -#else // either we're under Unix or wish to use files even under Windows - #define wxConfig wxFileConfig -#endif - #endif // wxUSE_CONFIG /*