X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9dea36ef6d117e0562f0079345a77ff1696d3a49..faab619a858952eb2a46a22234ee42a73bb10bfd:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index 1bd7e000b2..5d605f2e76 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -94,10 +94,17 @@ // constants // ---------------------------------------------------------------------------- +#if defined(__VISAGECPP__) && __IBMCPP__ >= 400 +// must define this in .cpp 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 // ---------------------------------------------------------------------------- @@ -280,7 +287,9 @@ private: // // try `s << i' or `s.Printf("%d", i)' instead wxString(int); + wxString(unsigned int); wxString(long); + wxString(unsigned long); public: // constructors and destructor @@ -400,7 +409,7 @@ public: 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]; } @@ -530,11 +539,23 @@ public: // 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) @@ -615,12 +636,26 @@ public: // 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