// headers
// ----------------------------------------------------------------------------
-#ifdef __WXMAC__
+#if defined(__WXMAC__) || defined(__VISAGECPP__)
#include <ctype.h>
#endif
#include <std.h>
#endif
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <stdlib.h>
+#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
+ // problem in VACPP V4 with including stdlib.h multiple times
+ // strconv includes it anyway
+# include <stdio.h>
+# include <string.h>
+# include <stdarg.h>
+# include <limits.h>
+#else
+# include <string.h>
+# include <stdio.h>
+# include <stdarg.h>
+# include <limits.h>
+# include <stdlib.h>
+#endif
#ifdef HAVE_STRINGS_H
#include <strings.h> // for strcasecmp()
#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; }
//
// try `s << i' or `s.Printf("%d", i)' instead
wxString(int);
+ wxString(unsigned int);
wxString(long);
+ wxString(unsigned long);
public:
// constructors and destructor
wxString(const unsigned char* psz, size_t nLength = wxSTRING_MAXLEN)
{ InitWith((const char*)psz, 0, nLength); }
// from multibyte string
- wxString(const char *psz, wxMBConv& WXUNUSED(conv), size_t nLength = wxSTRING_MAXLEN)
+ wxString(const char *psz, wxMBConv& WXUNUSED(conv) , size_t nLength = wxSTRING_MAXLEN)
{ InitWith(psz, 0, nLength); }
#if wxUSE_WCHAR_T
// operator version of GetChar
wxChar operator[](int n) const
{ ASSERT_VALID_INDEX( n ); return m_pchData[n]; }
- // This is a rather ugly hack, but needed to resolve overloading
- // conflicts on the AXP architecture:
#ifdef __alpha__
// operator version of GetChar
wxChar operator[](unsigned int n) const
{ ASSERT_VALID_INDEX( n ); return m_pchData[n]; }
#endif
- // operator version of GetWritableChar
+
+ // operator version of GetWriteableChar
wxChar& operator[](size_t n)
{ ASSERT_VALID_INDEX( n ); CopyBeforeWrite(); return m_pchData[n]; }
+#ifdef __alpha__
+ // operator version of GetWriteableChar
+ wxChar& operator[](unsigned int n)
+ { ASSERT_VALID_INDEX( n ); CopyBeforeWrite(); return m_pchData[n]; }
+#endif
// implicit conversion to C string
operator const wxChar*() const { return m_pchData; }
// stream-like functions
// insert an int into string
- wxString& operator<<(int i);
+ wxString& operator<<(int i)
+ { return (*this) << Format(_T("%d"), i); }
+ // insert an unsigned int into string
+ wxString& operator<<(unsigned int ui)
+ { return (*this) << Format(_T("%u"), ui); }
+ // insert a long into string
+ wxString& operator<<(long l)
+ { return (*this) << Format(_T("%ld"), l); }
+ // insert an unsigned long into string
+ wxString& operator<<(unsigned long ul)
+ { return (*this) << Format(_T("%lu"), ul); }
// insert a float into string
- wxString& operator<<(float f);
+ wxString& operator<<(float f)
+ { return (*this) << Format(_T("%f"), f); }
// insert a double into string
- wxString& operator<<(double d);
+ wxString& operator<<(double d)
+ { return (*this) << Format(_T("%g"), d); }
// string comparison
// case-sensitive comparison (returns a value < 0, = 0 or > 0)
// check if the string contents matches a mask containing '*' and '?'
bool Matches(const wxChar *szMask) const;
+ // conversion to numbers: all functions return TRUE only if the whole string
+ // is a number and put the value of this number into the pointer provided
+ // convert to a signed integer
+ bool ToLong(long *val) const;
+ // convert to an unsigned integer
+ bool ToULong(unsigned long *val) const;
+ // convert to a double
+ bool ToDouble(double *val) const;
+
// formated input/output
// as sprintf(), returns the number of characters written or < 0 on error
int Printf(const wxChar *pszFormat, ...);
// 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, ...);
+ // the same as above, but takes a va_list
+ static wxString FormatV(const wxChar *pszFormat, va_list argptr);
+
// raw access to string memory
// ensure that string has space for at least nLen characters
// only works if the data of this string is not shared
void clear() { Empty(); }
// returns true if the string is empty
bool empty() const { return IsEmpty(); }
+ // inform string about planned change in size
+ void reserve(size_t size) { Alloc(size); }
// lib.string.access
// return the character at position n
const wxChar* sz, size_t nCount = npos) const;
// substring extraction
- wxString substr(size_t nStart = 0, size_t nLen = npos) const;
+ wxString substr(size_t nStart = 0, size_t nLen = npos) const
+ { return Mid(nStart, nLen); }
#endif // wxSTD_STRING_COMPATIBILITY
};