+// ----------------------------------------------------------------------------
+// misc other operations
+// ----------------------------------------------------------------------------
+bool wxString::Matches(const char *pszMask) const
+{
+ // check char by char
+ const char *pszTxt;
+ for ( pszTxt = c_str(); *pszMask != '\0'; pszMask++, pszTxt++ ) {
+ switch ( *pszMask ) {
+ case '?':
+ if ( *pszTxt == '\0' )
+ return FALSE;
+
+ pszTxt++;
+ pszMask++;
+ break;
+
+ case '*':
+ {
+ // ignore special chars immediately following this one
+ while ( *pszMask == '*' || *pszMask == '?' )
+ pszMask++;
+
+ // if there is nothing more, match
+ if ( *pszMask == '\0' )
+ return TRUE;
+
+ // are there any other metacharacters in the mask?
+ size_t uiLenMask;
+ const char *pEndMask = strpbrk(pszMask, "*?");
+
+ if ( pEndMask != NULL ) {
+ // we have to match the string between two metachars
+ uiLenMask = pEndMask - pszMask;
+ }
+ else {
+ // we have to match the remainder of the string
+ uiLenMask = strlen(pszMask);
+ }
+
+ wxString strToMatch(pszMask, uiLenMask);
+ const char* pMatch = strstr(pszTxt, strToMatch);
+ if ( pMatch == NULL )
+ return FALSE;
+
+ // -1 to compensate "++" in the loop
+ pszTxt = pMatch + uiLenMask - 1;
+ pszMask += uiLenMask - 1;
+ }
+ break;
+
+ default:
+ if ( *pszMask != *pszTxt )
+ return FALSE;
+ break;
+ }
+ }
+
+ // match only if nothing left
+ return *pszTxt == '\0';
+}
+
+// Count the number of chars
+int wxString::Freq(char ch) const
+{
+ int count = 0;
+ int len = Len();
+ for (int i = 0; i < len; i++)
+ {
+ if (GetChar(i) == ch)
+ count ++;
+ }
+ return count;
+}
+
+// convert to upper case, return the copy of the string
+wxString wxString::Upper() const
+{ wxString s(*this); return s.MakeUpper(); }
+
+// convert to lower case, return the copy of the string
+wxString wxString::Lower() const { wxString s(*this); return s.MakeLower(); }
+
+int wxString::sprintf(const char *pszFormat, ...)
+ {
+ va_list argptr;
+ va_start(argptr, pszFormat);
+ int iLen = PrintfV(pszFormat, argptr);
+ va_end(argptr);
+ return iLen;
+ }
+