//@}
//@}
- /** @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
if ( iPos == NOT_FOUND )
str = *this;
else
- str = c_str() + iPos;
+ str = c_str() + iPos + 1;
return str;
}
}
// ---------------------------------------------------------------------------
-// formatted output
+// formatted input/output
// ---------------------------------------------------------------------------
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);
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
// ---------------------------------------------------------------------------