From 8fd0f20ba47c3a04f57ac270407f3e4dbe67926a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Jul 1998 22:21:11 +0000 Subject: [PATCH] 1) some size_t replaced with uint - does it now compile under Alpha?? 2) added Matches(const char *mask) function which checks if the string matches the mask possibly containing '?' and '*' wildchars 3) GetWriteBuf complemented with UngetWriteBuf git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@198 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/include/wx/string.h b/include/wx/string.h index 62a5730f58..a6282ddbaa 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -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 */ @@ -357,8 +367,17 @@ public: int PrintfV(const char* pszFormat, va_list argptr); //@} - // 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 */ //@{ -- 2.47.2