]> git.saurik.com Git - wxWidgets.git/commitdiff
wxConfig::GetEntryType() added
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Apr 1999 10:23:31 +0000 (10:23 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Apr 1999 10:23:31 +0000 (10:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2049 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/config.tex
include/wx/confbase.h

index a36d300cc0b1eabbc512351085cadd70f5970d15..7b6e150960694ce1b227444f9d2dd4e89e39b38c 100644 (file)
@@ -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\&}{
index edbe8ca2ca18da5204c426cca281c9db838cf920..2c31f070ef730401ebf317dace5658a9f93810c9 100644 (file)
@@ -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