// Modified by:
// Created: 07.04.98
// RCS-ID: $Id$
-// Copyright: (c) 1997 Karsten Ballüder Ballueder@usa.net
+// Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net
// Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
IMPLEMENT_READ_FOR_TYPE(String, wxString, const wxString&, ExpandEnvVars)
IMPLEMENT_READ_FOR_TYPE(Long, long, long, long)
-IMPLEMENT_READ_FOR_TYPE(Int, int, int, int)
IMPLEMENT_READ_FOR_TYPE(Double, double, double, double)
IMPLEMENT_READ_FOR_TYPE(Bool, bool, bool, bool)
#undef IMPLEMENT_READ_FOR_TYPE
-// the DoReadXXX() for the other types have implementation in the base class
-// but can be overridden in the derived ones
-bool wxConfigBase::DoReadInt(const wxString& key, int *pi) const
+// int is stored as long
+bool wxConfigBase::Read(const wxString& key, int *pi) const
{
- wxCHECK_MSG( pi, false, _T("wxConfig::Read(): NULL parameter") );
-
- long l;
- if ( !DoReadLong(key, &l) )
- return false;
-
- wxASSERT_MSG( l < INT_MAX, _T("overflow in wxConfig::DoReadInt") );
-
+ long l = *pi;
+ bool r = Read(key, &l);
+ wxASSERT_MSG( l < INT_MAX, _T("int overflow in wxConfig::Read") );
*pi = (int)l;
+ return r;
+}
- return true;
+bool wxConfigBase::Read(const wxString& key, int *pi, int defVal) const
+{
+ long l = *pi;
+ bool r = Read(key, &l, defVal);
+ wxASSERT_MSG( l < INT_MAX, _T("int overflow in wxConfig::Read") );
+ *pi = (int)l;
+ return r;
}
+// the DoReadXXX() for the other types have implementation in the base class
+// but can be overridden in the derived ones
bool wxConfigBase::DoReadBool(const wxString& key, bool* val) const
{
wxCHECK_MSG( val, false, _T("wxConfig::Read(): NULL parameter") );
return DoWriteString(key, wxString::Format(_T("%g"), val));
}
-bool wxConfigBase::DoWriteInt(const wxString& key, int value)
-{
- return DoWriteLong(key, (long)value);
-}
-
bool wxConfigBase::DoWriteBool(const wxString& key, bool value)
{
return DoWriteLong(key, value ? 1l : 0l);