From 19d40bab31d5addfa75e7671c3b8914c7b797a8f Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Tue, 6 Apr 1999 10:23:31 +0000
Subject: [PATCH] wxConfig::GetEntryType() added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2049 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/config.tex | 26 +++++++++++++++++++++++++-
 include/wx/confbase.h    | 36 +++++++++++++++++++++++++++---------
 2 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/docs/latex/wx/config.tex b/docs/latex/wx/config.tex
index a36d300cc0..7b6e150960 100644
--- a/docs/latex/wx/config.tex
+++ b/docs/latex/wx/config.tex
@@ -230,7 +230,8 @@ actually enumerating them, but you will probably never need them.
 
 \helpref{HasGroup}{wxconfigbasehasgroup}\\
 \helpref{HasEntry}{wxconfigbasehasentry}\\
-\helpref{Exists}{wxconfigbaseexists}
+\helpref{Exists}{wxconfigbaseexists}\\
+\helpref{GetEntryType}{wxconfigbasegetentrytype}
 
 \membersection{Miscellaneous accessors}
 
@@ -436,6 +437,29 @@ Get the current config object. If there is no current object, creates one
 
 Returns the application name.
 
+\membersection{wxConfigBase::GetEntryType}\label{wxconfigbasegetentrytype}
+
+\constfunc{enum wxConfigBase::EntryType}{GetEntryType}{\param{const wxString\& }{name}}
+
+Returns the type of the given entry or {\it Unknown} if the entry doesn't
+exist. This function should be used to decide which version of Read() should
+be used because some of wxConfig implementations will complain about type
+mismatch otherwise: e.g., an attempt to read a string value from an integer
+key with \helpref{wxRegConfig}{wxregconfig} will fail.
+
+The result is an element of enum EntryType:
+
+\begin{verbatim}
+  enum EntryType
+  {
+    Unknown,
+    String,
+    Boolean,
+    Integer,
+    Float
+  };
+\end{verbatim}
+
 \membersection{wxConfigBase::GetFirstGroup}\label{wxconfigbasegetfirstgroup}
 
 \constfunc{bool}{GetFirstGroup}{\param{wxString\& }{str}, \param{long\&}{
diff --git a/include/wx/confbase.h b/include/wx/confbase.h
index edbe8ca2ca..2c31f070ef 100644
--- a/include/wx/confbase.h
+++ b/include/wx/confbase.h
@@ -1,7 +1,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Name:        confbase.h
 // Purpose:     declaration of the base class of all config implementations
-//              (see also: fileconf.h and msw/regconf.h)
+//              (see also: fileconf.h and msw/regconf.h and iniconf.h)
 // Author:      Karsten Ballüder & Vadim Zeitlin
 // Modified by:
 // Created:     07.04.98 (adapted from appconf.h)
@@ -86,6 +86,17 @@ extern void wxSplitPath(wxArrayString& aParts, const char *sz);
 class WXDLLEXPORT wxConfigBase
 {
 public:
+  // constants
+    // the type of an entry
+  enum EntryType
+  {
+    Unknown,
+    String,
+    Boolean,
+    Integer,    // use Read(long *)
+    Float       // use Read(double *)
+  };
+
   // static functions
     // sets the config object, returns the previous pointer
   static wxConfigBase *Set(wxConfigBase *pConfig);
@@ -146,6 +157,13 @@ public:
   bool Exists(const wxString& strName) const
     { return HasGroup(strName) || HasEntry(strName); }
 
+    // get the entry type
+  virtual EntryType GetEntryType(const wxString& name) const
+  {
+    // by default all entries are strings
+    return HasEntry(name) ? String : Unknown;
+  }
+
   // key access: returns TRUE if value was really read, FALSE if default used
   // (and if the key is not found the default value is returned.)
     // read a string from the key
@@ -217,14 +235,14 @@ public:
   wxString ExpandEnvVars(const wxString& str) const;
 
     // misc accessors
-  inline wxString GetAppName() const { return m_appName; }
-  inline wxString GetVendorName() const { return m_vendorName; }
+  wxString GetAppName() const { return m_appName; }
+  wxString GetVendorName() const { return m_vendorName; }
 
-  inline void SetAppName(const wxString& appName) { m_appName = appName; }
-  inline void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
+  void SetAppName(const wxString& appName) { m_appName = appName; }
+  void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
 
-  inline void SetStyle(long style) { m_style = style; }
-  inline long GetStyle() const { return m_style; }
+  void SetStyle(long style) { m_style = style; }
+  long GetStyle() const { return m_style; }
 
 protected:
   static bool IsImmutable(const wxString& key)
@@ -293,8 +311,8 @@ private:
   #define sm_classwxConfig sm_classwxFileConfig
 #endif
 
-#endif 
- 
+#endif
+
   // wxUSE_CONFIG
 
 #endif
-- 
2.50.0

