]> git.saurik.com Git - wxWidgets.git/commitdiff
changed wxString::StartsWidth/EndsWidth to take wxString argument instead of wxChar*
authorVáclav Slavík <vslavik@fastmail.fm>
Wed, 9 May 2007 21:07:08 +0000 (21:07 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Wed, 9 May 2007 21:07:08 +0000 (21:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45922 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/wxstring.tex
include/wx/string.h
src/common/string.cpp

index 20b9f19f698990986422dcc27fe52fba16dbaba2..57504f03e6199adbf2f75523e02eb469f9fcb40d 100644 (file)
@@ -1110,7 +1110,7 @@ Minimizes the string's memory. This can be useful after a call to
 
 \membersection{wxString::StartsWith}\label{wxstringstartswith}
 
-\constfunc{bool}{StartsWith}{\param{const wxChar }{*prefix}, \param{wxString }{*rest = NULL}}
+\constfunc{bool}{StartsWith}{\param{const wxString\& }{prefix}, \param{wxString }{*rest = NULL}}
 
 This function can be used to test if the string starts with the specified 
 {\it prefix}. If it does, the function will return \true and put the rest
@@ -1121,7 +1121,7 @@ of the string (i.e. after the prefix) into {\it rest} string if it is not
 
 \membersection{wxString::EndsWith}\label{wxstringendswith}
 
-\constfunc{bool}{EndsWith}{\param{const wxChar }{*suffix}, \param{wxString }{*rest = NULL}}
+\constfunc{bool}{EndsWith}{\param{const wxString\& }{suffix}, \param{wxString }{*rest = NULL}}
 
 This function can be used to test if the string ends with the specified 
 {\it suffix}. If it does, the function will return \true and put the
index dac27573fa722cdd517a24d943101786b4fc0716..c1cfbb5aa2fa920403770e5a9ac446934527c375 100644 (file)
@@ -1464,11 +1464,11 @@ public:
       // check if the string starts with the given prefix and return the rest
       // of the string in the provided pointer if it is not NULL; otherwise
       // return false
-  bool StartsWith(const wxChar *prefix, wxString *rest = NULL) const;
+  bool StartsWith(const wxString& prefix, wxString *rest = NULL) const;
       // check if the string ends with the given suffix and return the
       // beginning of the string before the suffix in the provided pointer if
       // it is not NULL; otherwise return false
-  bool EndsWith(const wxChar *suffix, wxString *rest = NULL) const;
+  bool EndsWith(const wxString& suffix, wxString *rest = NULL) const;
 
       // get first nCount characters
   wxString Left(size_t nCount) const;
index dac95cc926ead09641f74274df6d2c882317609a..3ae68d82e6786b9958b5c4d8516da8c599ceaf3c 100644 (file)
@@ -1065,28 +1065,15 @@ wxString wxString::Mid(size_t nFirst, size_t nCount) const
 
 // check that the string starts with prefix and return the rest of the string
 // in the provided pointer if it is not NULL, otherwise return false
-bool wxString::StartsWith(const wxChar *prefix, wxString *rest) const
+bool wxString::StartsWith(const wxString& prefix, wxString *rest) const
 {
-    wxASSERT_MSG( prefix, _T("invalid parameter in wxString::StartsWith") );
-
-    // first check if the beginning of the string matches the prefix: note
-    // that we don't have to check that we don't run out of this string as
-    // when we reach the terminating NUL, either prefix string ends too (and
-    // then it's ok) or we break out of the loop because there is no match
-    const wxChar *p = c_str();
-    while ( *prefix )
-    {
-        if ( *prefix++ != *p++ )
-        {
-            // no match
-            return false;
-        }
-    }
+    if ( compare(0, prefix.length(), prefix) != 0 )
+        return false;
 
     if ( rest )
     {
         // put the rest of the string into provided pointer
-        *rest = p;
+        rest->assign(*this, prefix.length(), npos);
     }
 
     return true;
@@ -1095,11 +1082,9 @@ bool wxString::StartsWith(const wxChar *prefix, wxString *rest) const
 
 // check that the string ends with suffix and return the rest of it in the
 // provided pointer if it is not NULL, otherwise return false
-bool wxString::EndsWith(const wxChar *suffix, wxString *rest) const
+bool wxString::EndsWith(const wxString& suffix, wxString *rest) const
 {
-    wxASSERT_MSG( suffix, _T("invalid parameter in wxString::EndssWith") );
-
-    int start = length() - wxStrlen(suffix);
+    int start = length() - suffix.length();
 
     if ( start < 0 || compare(start, npos, suffix) != 0 )
         return false;