#ifndef _WX_WXSTRINGH__
#define _WX_WXSTRINGH__
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "string.h"
#endif
#endif // OS/compiler
}
-// wxSnprintf() is like snprintf() if it's available and sprintf() (always
-// available, but dangerous!) if not
-extern int WXDLLEXPORT wxSnprintf(wxChar *buf, size_t len,
- const wxChar *format, ...);
-
-// and wxVsnprintf() is like vsnprintf() or vsprintf()
-extern int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len,
- const wxChar *format, va_list argptr);
-
// return an empty wxString
class WXDLLEXPORT wxString; // not yet defined
inline const wxString& wxGetEmptyString() { return *(wxString *)&wxEmptyString; }
// implicit conversion to C string
operator const wxChar*() const { return m_pchData; }
+
// explicit conversion to C string (use this with printf()!)
const wxChar* c_str() const { return m_pchData; }
- // identical to c_str()
+ // identical to c_str(), for wxWin 1.6x compatibility
const wxChar* wx_str() const { return m_pchData; }
- // identical to c_str()
+ // identical to c_str(), for MFC compatibility
const wxChar* GetData() const { return m_pchData; }
+ // conversion to/from plain (i.e. 7 bit) ASCII: this is useful for
+ // converting numbers or strings which are certain not to contain special
+ // chars (typically system functions, X atoms, environment variables etc.)
+ //
+ // the behaviour of these functions with the strings containing anything
+ // else than 7 bit ASCII characters is undefined, use at your own risk.
+#if wxUSE_UNICODE
+ static wxString FromAscii(const char *ascii);
+ const wxCharBuffer ToAscii() const;
+#else // ANSI
+ static wxString FromAscii(const char *ascii) { return wxString( ascii ); }
+ const char *ToAscii() const { return c_str(); }
+#endif // Unicode/!Unicode
+
// conversions with (possible) format convertions: have to return a
// buffer with temporary data
//
// formated input/output
// as sprintf(), returns the number of characters written or < 0 on error
- int Printf(const wxChar *pszFormat, ...);
+ // (take 'this' into account in attribute parameter count)
+ int Printf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2;
// as vprintf(), returns the number of characters written or < 0 on error
int PrintfV(const wxChar* pszFormat, va_list argptr);
// returns the string containing the result of Printf() to it
- static wxString Format(const wxChar *pszFormat, ...);
+ static wxString Format(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_1;
// the same as above, but takes a va_list
static wxString FormatV(const wxChar *pszFormat, va_list argptr);
// values for first parameter of Strip function
enum stripType {leading = 0x1, trailing = 0x2, both = 0x3};
- // use Printf()
- int sprintf(const wxChar *pszFormat, ...);
+ // use Printf()
+ // (take 'this' into account in attribute parameter count)
+ int sprintf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2;
// use Cmp()
inline int CompareTo(const wxChar* psz, caseCompare cmp = exact) const
class WXDLLEXPORT wxStringBuffer
{
- DECLARE_NO_COPY_CLASS(wxStringBuffer)
-
public:
wxStringBuffer(wxString& str, size_t lenWanted = 1024)
: m_str(str), m_buf(NULL)
{ m_buf = m_str.GetWriteBuf(lenWanted); }
-
+
~wxStringBuffer() { m_str.UngetWriteBuf(); }
-
+
operator wxChar*() const { return m_buf; }
-
+
private:
wxString& m_str;
wxChar *m_buf;
+
+ DECLARE_NO_COPY_CLASS(wxStringBuffer)
};
// ---------------------------------------------------------------------------