X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c8cfb486fbb0b901295ab19c4e0b31bc6526f7a3..524761867cd4ebcb4e421ccc9879f95a851e764a:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index 2b65099b97..a6282ddbaa 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -13,7 +13,7 @@ #define __WXSTRINGH__ #ifdef __GNUG__ -#pragma interface +#pragma interface "string.h" #endif /* Dependencies (should be included before this header): @@ -27,8 +27,11 @@ #include #include -#include "wx/defs.h" // Robert Roebling -#include "wx/object.h" +#ifndef WX_PRECOMP + #include "wx/defs.h" // Robert Roebling + #include "wx/object.h" +#endif + #include "wx/debug.h" /** @name wxString library @@ -84,7 +87,7 @@ int WXDLLEXPORT Stricmp(const char *, const char *); struct WXDLLEXPORT wxStringData { int nRefs; // reference count - size_t nDataLength, // actual string length + uint nDataLength, // actual string length nAllocLength; // allocated memory size // mimics declaration 'char data[nAllocLength]' @@ -93,11 +96,15 @@ struct WXDLLEXPORT wxStringData // empty string has a special ref count so it's never deleted bool IsEmpty() const { return nRefs == -1; } bool IsShared() const { return nRefs > 1; } - bool IsValid() const { return nRefs != 0; } // lock/unlock void Lock() { if ( !IsEmpty() ) nRefs++; } void Unlock() { if ( !IsEmpty() && --nRefs == 0) delete (char *)this; } + + // if we had taken control over string memory (GetWriteBuf), it's + // intentionally put in invalid state + void Validate(bool b) { nRefs = b ? 1 : 0; } + bool IsValid() const { return nRefs != 0; } }; extern const char *g_szNul; // global pointer to empty string @@ -347,6 +354,9 @@ public: */ uint Replace(const char *szOld, const char *szNew, bool bReplaceAll = TRUE); //@} + + /// check if the string contents matches a mask containing '*' and '?' + bool Matches(const char *szMask) const; //@} /** @name formated input/output */ @@ -355,14 +365,19 @@ public: int Printf(const char *pszFormat, ...); /// as vprintf(), returns the number of characters written or < 0 on error int PrintfV(const char* pszFormat, va_list argptr); - /// as sscanf() - int Scanf(const char *pszFormat, ...) const; - /// as vsscanf() - int ScanfV(const char *pszFormat, va_list argptr) const; //@} - // get writable buffer of at least nLen characters - char *GetWriteBuf(size_t nLen); + /** @name raw access to string memory */ + //@{ + /** + get writable buffer of at least nLen bytes. + Unget() *must* be called a.s.a.p. to put string back in a reasonable + state! + */ + char *GetWriteBuf(int nLen); + /// call this immediately after GetWriteBuf() has been used + void UngetWriteBuf(); + //@} /** @name wxWindows compatibility functions */ //@{