]> git.saurik.com Git - wxWidgets.git/commitdiff
no more SetAppName/SetVendor in the config classes
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 7 Apr 1999 13:01:50 +0000 (13:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 7 Apr 1999 13:01:50 +0000 (13:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/config.tex
include/wx/confbase.h
include/wx/fileconf.h
include/wx/msw/regconf.h
src/common/config.cpp
src/common/fileconf.cpp
src/msw/iniconf.cpp

index 7b6e150960694ce1b227444f9d2dd4e89e39b38c..30a6a6aeab704898b2a705c45c5317beeb334c9d 100644 (file)
@@ -235,9 +235,7 @@ actually enumerating them, but you will probably never need them.
 
 \membersection{Miscellaneous accessors}
 
-\helpref{SetAppName}{wxconfigbasesetappname}\\
 \helpref{GetAppName}{wxconfigbasegetappname}\\
-\helpref{SetVendorName}{wxconfigbasesetvendorname}\\
 \helpref{GetVendorName}{wxconfigbasegetvendorname}
 
 \membersection{Key access}
@@ -658,12 +656,6 @@ exists.
 Sets the config object as the current one, returns the pointer to the previous
 current object (both the parameter and returned value may be NULL)
 
-\membersection{wxConfigBase::SetAppName}\label{wxconfigbasesetappname}
-
-\func{void }{SetAppName}{\param{const wxString\&}{ appName}}
-
-Sets the application name.
-
 \membersection{wxConfigBase::SetExpandingEnvVars}\label{wxconfigbasesetexpandingenvvars}
 
 \func{void}{SetExpandEnvVars }{\param{bool }{bDoIt = TRUE}}
@@ -688,12 +680,6 @@ If on (default is off) all default values are written back to the config file.
 This allows the user to see what config options may be changed and is probably
 useful only for wxFileConfig.
 
-\membersection{wxConfigBase::SetVendorName}\label{wxconfigbasesetvendorname}
-
-\func{void}{SetVendorName}{\param{const wxString\&}{ vendorName}}
-
-Sets the vendor name.
-
 \membersection{wxConfigBase::Write}\label{wxconfigbasewrite}
 
 \func{bool}{Write}{\param{const wxString\& }{ key}, \param{const wxString\& }{
index e849917ffb47e8d303f1ae51606ee1fc50efc728..c2b371f88c0f81e9ed84c77173b73539edab2aed 100644 (file)
 #endif
 
 // Style flags for constructor style parameter
-#define wxCONFIG_USE_LOCAL_FILE         1
-#define wxCONFIG_USE_GLOBAL_FILE        2
+enum
+{
+    wxCONFIG_USE_LOCAL_FILE = 1,
+    wxCONFIG_USE_GLOBAL_FILE = 2
+};
 
 // ----------------------------------------------------------------------------
 // various helper global functions
@@ -81,7 +84,7 @@ extern void wxSplitPath(wxArrayString& aParts, const char *sz);
 // There is always one current group given by the current path.
 //
 // Keys are pairs "key_name = value" where value may be of string or integer
-// (long) type (@@@ doubles and other types such as wxDate coming soon).
+// (long) type (TODO doubles and other types such as wxDate coming soon).
 // ----------------------------------------------------------------------------
 class WXDLLEXPORT wxConfigBase
 {
@@ -111,7 +114,9 @@ public:
     // should Get() try to create a new log object if the current one is NULL?
   static void DontCreateOnDemand() { ms_bAutoCreate = FALSE; }
 
-  // ctors & virtual dtor
+  // ctor & virtual dtor
+      // ctor (can be used as default ctor too)
+      //
       // Not all args will always be used by derived classes, but including
       // them all in each class ensures compatibility. If appName is empty,
       // uses wxApp name
@@ -235,11 +240,6 @@ public:
   wxString GetAppName() const { return m_appName; }
   wxString GetVendorName() const { return m_vendorName; }
 
-  virtual void SetAppName(const wxString& appName)
-    { m_appName = appName; }
-  virtual void SetVendorName(const wxString& vendorName)
-    { m_vendorName = vendorName; }
-
   void SetStyle(long style) { m_style = style; }
   long GetStyle() const { return m_style; }
 
index c4712f714795de2e3aca278850ddf4c9582ce69b..13b6cfaf65308641b14edadaa5419d7f8e77435e 100644 (file)
@@ -144,25 +144,12 @@ public:
   static wxString GetLocalFileName(const char *szFile);
 
   // ctor & dtor
-
-#if 0
-    // the names of local and global (if not disabled) config files are
-    // constructed using Get{Local|Global}FileName functions described above
-    // (szAppName is just the (short) name of your application)
-  wxFileConfig(const char *szAppName, bool bLocalOnly = FALSE);
-    // this ctor allows you to specify custom names for both files (if strGlobal
-    // isn't a full path, it's considered to be relative to the standard
-    // directory, i.e. /etc under Unix and %windir% under Windows, if strLocal
-    // is not an absolute path, it's considered to be relative to the user's
-    // directory). If either of strings is empty, the corresponding file is not
-    // used.
-  wxFileConfig(const wxString& strLocal, const wxString& strGlobal);
-#endif
-
-   // New constructor: one size fits all. Specify wxCONFIG_USE_LOCAL_FILE
-   // or wxCONFIG_USE_GLOBAL_FILE to say which files should be used.
-  wxFileConfig(const wxString& appName, const wxString& vendorName = "",
-               const wxString& localFilename = "", const wxString& globalFilename = "",
+    // New constructor: one size fits all. Specify wxCONFIG_USE_LOCAL_FILE or
+    // wxCONFIG_USE_GLOBAL_FILE to say which files should be used.
+  wxFileConfig(const wxString& appName,
+               const wxString& vendorName = "",
+               const wxString& localFilename = "",
+               const wxString& globalFilename = "",
                long style = wxCONFIG_USE_LOCAL_FILE);
 
     // dtor will save unsaved data
index ed611151176ae1261e43168bc688d3928b58798a..681f2a620173e6b5f3d69845f5a1766699fe4641 100644 (file)
@@ -1,8 +1,8 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        msw/regconf.h  
+// Name:        msw/regconf.h
 // Purpose:     Registry based implementation of wxConfigBase
 // Author:      Vadim Zeitlin
-// Modified by: 
+// Modified by:
 // Created:     27.04.98
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
@@ -29,8 +29,10 @@ class WXDLLEXPORT wxRegConfig : public wxConfigBase
 public:
   // ctor & dtor
     // will store data in HKLM\appName and HKCU\appName
-  wxRegConfig(const wxString& appName = "", const wxString& vendorName = "",
-              const wxString& localFilename = "", const wxString& globalFilename = "",
+  wxRegConfig(const wxString& appName = "",
+              const wxString& vendorName = "",
+              const wxString& localFilename = "",
+              const wxString& globalFilename = "",
               long style = 0);
 
     // dtor will save unsaved data
index 66e8d2017f6e066198dd3c16d45e54162aa8d3ea..4a0935b93ca1a2c012d9d87c6a556ffa92ea3a54 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 #ifdef __GNUG__
-  #pragma implementation "confbase.h"
+    #pragma implementation "confbase.h"
 #endif
 
-#include  "wx/wxprec.h"
+#include "wx/wxprec.h"
 
 #ifndef WX_PRECOMP
-#include  "wx/wx.h"
+    #include  "wx/wx.h"
 #endif
 
-#include  <wx/confbase.h>
-
 #if wxUSE_CONFIG
 
 #ifdef    __BORLANDC__
   #pragma hdrstop
 #endif  //__BORLANDC__
 
-#include  <wx/app.h>
-#include  <wx/file.h>
-#include  <wx/log.h>
-#include  <wx/textfile.h>
-#include  <wx/utils.h>
-
-// we must include (one of) these files for wxConfigBase::Create
-#if defined(__WXMSW__) && defined(wxCONFIG_WIN32_NATIVE)
-  #ifdef __WIN32__
-    #include  <wx/msw/regconf.h>
-  #else  //WIN16
-    #include  <wx/msw/iniconf.h>
-  #endif
-#else // either we're under Unix or wish to use files even under Windows
-  #include  <wx/fileconf.h>
-#endif
+#include "wx/app.h"
+#include "wx/file.h"
+#include "wx/log.h"
+#include "wx/textfile.h"
+#include "wx/utils.h"
+
+#include "wx/config.h"
 
-#include  <stdlib.h>
-#include  <math.h>
-#include  <ctype.h>       // for isalnum()
+#include <stdlib.h>
+#include <math.h>
+#include <ctype.h>    // for isalnum()
 
 // ----------------------------------------------------------------------------
 // global and class static variables
@@ -413,7 +402,5 @@ void wxSplitPath(wxArrayString& aParts, const char *sz)
   }
 }
 
-#endif
-
-  // wxUSE_CONFIG
+#endif // wxUSE_CONFIG
 
index 8c6ddeac2e6df86048e051957a50bf8dad1612a9..cc1567b4eeadc7cec1d39bde3a6ce930154b9e85 100644 (file)
@@ -198,15 +198,11 @@ void wxFileConfig::Init()
 wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
                            const wxString& strLocal, const wxString& strGlobal,
                            long style)
-            : wxConfigBase(appName, vendorName, strLocal, strGlobal, style),
+            : wxConfigBase(!appName && wxTheApp ? wxTheApp->GetAppName()
+                                                : appName,
+                           vendorName, strLocal, strGlobal, style),
               m_strLocalFile(strLocal), m_strGlobalFile(strGlobal)
 {
-  // Make up an application name if not supplied
-  if (appName.IsEmpty() && wxTheApp)
-  {
-    SetAppName(wxTheApp->GetAppName());
-  }
-
   // Make up names for files if empty
   if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) )
   {
@@ -1106,18 +1102,11 @@ bool ConfigGroup::DeleteSubgroup(ConfigGroup *pGroup)
   }
 
   // and subgroups of this sungroup
-#if 0
-  // pGroup->m_aSubgroups.Count() gets decremented in DeleteSubgroup(),
-  // so we cannot do this.
-                        
   nCount = pGroup->m_aSubgroups.Count();
   for ( size_t nGroup = 0; nGroup < nCount; nGroup++ ) {
-    pGroup->DeleteSubgroup(pGroup->m_aSubgroups[nGroup]);
+    pGroup->DeleteSubgroup(pGroup->m_aSubgroups[0]);
   }
-#endif
-  while(pGroup->m_aSubgroups.Count() > 0)
-     pGroup->DeleteSubgroup(pGroup->m_aSubgroups[0]);
-     
+
   LineList *pLine = pGroup->m_pLine;
   if ( pLine != NULL ) {
     // notice that we may do this test inside the previous "if" because the
index 0bf6bf2ab48664c4975efbd6b0761a3a2bcd8984..f5c1162378f673cc63ef3680bd3f4ef467338761 100644 (file)
@@ -2,7 +2,7 @@
 // Name:        src/msw/iniconf.cpp
 // Purpose:     implementation of wxIniConfig class
 // Author:      Vadim Zeitlin
-// Modified by: 
+// Modified by:
 // Created:     27.07.98
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
 // ctor & dtor
 // ----------------------------------------------------------------------------
 
-wxIniConfig::wxIniConfig(const wxString& strAppName, const wxString& strVendor,
-    const wxString& localFilename, const wxString& globalFilename, long style):
-     wxConfigBase(strAppName, strVendor, localFilename, globalFilename, style)
+wxIniConfig::wxIniConfig(const wxString& strAppName,
+                         const wxString& strVendor,
+                         const wxString& localFilename,
+                         const wxString& globalFilename,
+                         long style)
+           : wxConfigBase(!appName && wxTheApp ? wxTheApp->GetAppName()
+                                               : appName,
+                          !vendorName ? (wxTheApp ? wxTheApp->GetVendorName()
+                                                  : appName)
+                                      : vendorName,
+                          strLocal, strGlobal, style),
 {
-    if ( GetAppName().IsEmpty() )
-    {
-        wxString app;
-        if (wxTheApp)
-            app = wxTheApp->GetAppName();
-        wxASSERT( !app.IsEmpty() );
-        SetAppName(app);
-    }
-
-    // Vendor name is required in wxIniConfig.
-    // TODO: should it be required? Why isn't appName used instead? -- JACS
-    if ( GetVendorName().IsEmpty() )
-    {
-        wxString vendor;
-        if (wxTheApp)
-            vendor = wxTheApp->GetVendorName();
-        else
-            vendor = strAppName;
-        SetVendorName(vendor);
-    }
-
     m_strLocalFilename = localFilename;
     if (m_strLocalFilename.IsEmpty())
     {
@@ -304,7 +291,7 @@ bool wxIniConfig::Read(const wxString& szKey, wxString *pstr) const
     return FALSE;
   }
   else {
-       *pstr = szBuf ;
+    *pstr = szBuf ;
     return TRUE;
   }
 }
@@ -333,7 +320,7 @@ bool wxIniConfig::Read(const wxString& szKey, wxString *pstr,
     return FALSE;
   }
   else {
-       *pstr = szBuf ;
+    *pstr = szBuf ;
     return TRUE;
   }
 }
@@ -431,7 +418,7 @@ bool wxIniConfig::DeleteGroup(const wxString& szKey)
 {
   wxConfigPathChanger path(this, szKey);
 
-  // passing NULL as section name to WritePrivateProfileString deletes the 
+  // passing NULL as section name to WritePrivateProfileString deletes the
   // whole section according to the docs
   bool bOk = WritePrivateProfileString(path.Name(), NULL,
                                        NULL, m_strLocalFilename) != 0;