]> git.saurik.com Git - wxWidgets.git/commitdiff
1) Right(char ch) now returns the part of the string after the last
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 18 Jun 1998 13:20:42 +0000 (13:20 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 18 Jun 1998 13:20:42 +0000 (13:20 +0000)
   occurence of ch _without_ ch itself (like Left(char ch))
2) Added wxString::Scanf() and wxString::ScanfV()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@108 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/string.h
src/common/string.cpp

index 0b413e841fa66652e030d6f87d9eb3a69d029ec9..2b65099b97ad0bc9eabe59df05564b66e3bb4a4d 100644 (file)
@@ -349,12 +349,16 @@ public:
     //@}
   //@}
 
-  /** @name formated output */
+  /** @name formated input/output */
   //@{
     /// as sprintf(), returns the number of characters written or < 0 on error
   int Printf(const char *pszFormat, ...);
     /// as vprintf(), returns the number of characters written or < 0 on error
   int PrintfV(const char* pszFormat, va_list argptr);
+    /// as sscanf()
+  int Scanf(const char *pszFormat, ...) const;
+    /// as vsscanf()
+  int ScanfV(const char *pszFormat, va_list argptr) const;
   //@}
   
   // get writable buffer of at least nLen characters
index 92573c4d4be8059fad1f371f0ee6ddc719ada6fd..10e64bad12762504489c2aa6672d2b2f119192e9 100644 (file)
@@ -569,7 +569,7 @@ wxString wxString::Right(char ch) const
   if ( iPos == NOT_FOUND )
     str = *this;
   else
-    str = c_str() + iPos;
+    str = c_str() + iPos + 1;
 
   return str;
 }
@@ -837,7 +837,7 @@ int wxString::Find(const char *pszSub) const
 }
 
 // ---------------------------------------------------------------------------
-// formatted output
+// formatted input/output
 // ---------------------------------------------------------------------------
 int wxString::Printf(const char *pszFormat, ...)
 {
@@ -853,7 +853,7 @@ int wxString::Printf(const char *pszFormat, ...)
 
 int wxString::PrintfV(const char* pszFormat, va_list argptr)
 {
-  static char s_szScratch[1024];
+  static char s_szScratch[1024]; // @@@@ shouldn't use fixed-size buffer!
 
   int iLen = vsprintf(s_szScratch, pszFormat, argptr);
   AllocBeforeWrite(iLen);
@@ -862,6 +862,23 @@ int wxString::PrintfV(const char* pszFormat, va_list argptr)
   return iLen;
 }
 
+int wxString::Scanf(const char *pszFormat, ...) const
+{
+  va_list argptr;
+  va_start(argptr, pszFormat);
+
+  int iLen = ScanfV(pszFormat, argptr);
+
+  va_end(argptr);
+
+  return iLen;
+}
+
+int wxString::ScanfV(const char *pszFormat, va_list argptr) const
+{
+  return vsscanf(c_str(), pszFormat, argptr);
+}
+
 // ---------------------------------------------------------------------------
 // standard C++ library string functions
 // ---------------------------------------------------------------------------