X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6d60815d749bfd728b6b62cbd699578a9c60bf3a..d894c201132341a31790bba39a0c33d03d71aeb8:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index 988937c581..c9169837c7 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -18,7 +18,7 @@ #ifndef _WX_WXSTRINGH__ #define _WX_WXSTRINGH__ -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "string.h" #endif @@ -314,7 +314,7 @@ public: // from multibyte string // (NB: nLength is right now number of Unicode characters, not // characters in psz! So try not to use it yet!) - wxString(const char *psz, wxMBConv& conv = wxConvLibc, size_t nLength = wxSTRING_MAXLEN); + wxString(const char *psz, wxMBConv& conv, size_t nLength = wxSTRING_MAXLEN); // from wxWCharBuffer (i.e. return from wxGetString) wxString(const wxWCharBuffer& psz) { InitWith(psz, 0, wxSTRING_MAXLEN); } @@ -446,26 +446,31 @@ public: // 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 plain ascii: this is usefull for - // converting numbers or strings which are certain - // not to contain special chars (typically system - // functions, X atoms, environment variables etc.) + // 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( char *ascii ); + static wxString FromAscii(const char *ascii); // string + static wxString FromAscii(const char ascii); // char const wxCharBuffer ToAscii() const; -#else - static wxString FromAscii( char *ascii ) { return wxString( ascii ); } - const char *ToAscii() const { return m_pchData; } -#endif +#else // ANSI + static wxString FromAscii(const char *ascii) { return wxString( ascii ); } + 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 + // conversions with (possible) format conversions: have to return a // buffer with temporary data // // the functions defined (in either Unicode or ANSI) mode are mb_str() to @@ -830,7 +835,7 @@ public: // 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); } + void reserve(size_t sz) { Alloc(sz); } // lib.string.access // return the character at position n @@ -1147,20 +1152,20 @@ public: 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) }; // --------------------------------------------------------------------------- @@ -1256,7 +1261,7 @@ inline wxString operator+(const wxCharBuffer& buf, const wxString& string) #if defined(wxSTD_STRING_COMPATIBILITY) && wxUSE_STD_IOSTREAM -#include "wx/ioswrap.h" +#include "wx/iosfwrap.h" WXDLLEXPORT wxSTD istream& operator>>(wxSTD istream&, wxString&); WXDLLEXPORT wxSTD ostream& operator<<(wxSTD ostream&, const wxString&);