// 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()
// constants
// ----------------------------------------------------------------------------
+#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
+// must define this static for VA or else you get multiply defined symbols everywhere
+extern const unsigned int wxSTRING_MAXLEN;
+
+#else
// maximum possible length for a string means "take all string" everywhere
// (as sizeof(StringData) is unknown here, we substract 100)
const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100;
+#endif
+
// ----------------------------------------------------------------------------
// global data
// ----------------------------------------------------------------------------
#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]; }
- // operator version of GetWritableChar
+#ifdef __alpha__
+ // operator version of GetChar
+ wxChar operator[](unsigned int n) const
+ { ASSERT_VALID_INDEX( n ); return m_pchData[n]; }
+#endif
+
+ // 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; }
// append count copies of given character
wxString& Append(wxChar ch, size_t count = 1u)
{ wxString str(ch, count); return *this << str; }
+ wxString& Append(const wxChar* psz, size_t nLen)
+ { ConcatSelf(nLen, psz); return *this; }
// prepend a string, return the string itself
wxString& Prepend(const wxString& str)
// 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
wxChar *GetWriteBuf(size_t nLen);
// call this immediately after GetWriteBuf() has been used
void UngetWriteBuf();
+ void UngetWriteBuf(size_t nLen);
// wxWindows version 1 compatibility functions
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
};
#include "wx/ioswrap.h"
-WXDLLEXPORT istream& operator>>(istream& is, wxString& str);
+WXDLLEXPORT istream& operator>>(istream&, wxString&);
+WXDLLEXPORT ostream& operator<<(ostream&, const wxString&);
#endif // wxSTD_STRING_COMPATIBILITY