]> git.saurik.com Git - wxWidgets.git/commitdiff
use wxString argument and not wxChar* in wxHtmlParser::AddText(), for compatibility...
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 11 Jun 2007 12:11:15 +0000 (12:11 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 11 Jun 2007 12:11:15 +0000 (12:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46403 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/htparser.tex
include/wx/html/htmlpars.h
include/wx/html/winpars.h
src/html/helpdata.cpp
src/html/htmlpars.cpp
src/html/winpars.cpp

index 15e0d55488307565a6670981d2c084f24d6f1f13..7bbd2f16c0bec8a7a15180bfd1571276711d5572 100644 (file)
@@ -60,7 +60,7 @@ Changes in behaviour which may result in compilation errors
      wxLogError(_("error: %s"), !err.empty() ? (const wxChar*)err.c_str() : "")
 
 - wxCtime() and wxAsctime() return char*; this is incompatible with Unicode
-  build in wxWidgets 2.8 that returned wchar_t*. 
+  build in wxWidgets 2.8 that returned wchar_t*.
 
 - DigitalMars compiler has a bug that prevents it from using
   wxUniChar::operator bool in conditions and it erroneously reports type
@@ -69,6 +69,8 @@ Changes in behaviour which may result in compilation errors
   This can be worked around by explicitly casting to bool:
      for ( wxString::const_iterator p = s.begin(); (bool)*p; ++p )
 
+- virtual wxHtmlParser::AddText() takes wxString, not wxChar*, argument now.
+
 Deprecated methods and their replacements
 -----------------------------------------
 
index bc373af4be7d1fae66828dedf25457b5263ab87f..91b94ea4dc16dc621cd77d90dc814298dcb55bcf 100644 (file)
@@ -74,7 +74,7 @@ All handlers are deleted on object deletion.
 
 \membersection{wxHtmlParser::AddText}\label{wxhtmlparseraddword}
 
-\func{virtual void}{AddWord}{\param{const char* }{txt}}
+\func{virtual void}{AddWord}{\param{const wxString\& }{txt}}
 
 Must be overwritten in derived class.
 
index b5c6c6830f722352023ccc780840f2930e8fa595..c71c3958ebd01216ad67445beb20b5ccf60974bb 100644 (file)
@@ -145,10 +145,9 @@ protected:
 
     // Adds text to the output.
     // This is called from Parse() and must be overriden in derived classes.
-    // txt is not guaranteed to be only one word. It is largest continuous part of text
-    // (= not broken by tags)
-    // NOTE : using char* because of speed improvements
-    virtual void AddText(const wxChar* txt) = 0;
+    // txt is not guaranteed to be only one word. It is largest continuous part
+    // of text (= not broken by tags)
+    virtual void AddText(const wxString& txt) = 0;
 
     // Adds tag and proceeds it. Parse() may (and usually is) called from this method.
     // This is called from Parse() and may be overriden.
index c5d6f337dd90830292ce66a7bf8d4f94f1d0a4cb..26780b540e94e4639147e5247cabe74a7a08c452 100644 (file)
@@ -146,7 +146,7 @@ public:
     virtual wxFont* CreateCurrentFont();
 
 protected:
-    virtual void AddText(const wxChar* txt);
+    virtual void AddText(const wxString& txt);
 
 private:
     void DoAddText(wxChar *temp, int& templen, wxChar nbsp);
index 801882e10d157913441b0985df594172943c3235..0e8bc843df64bbbdbf9a6e3f5ff0b66e1b867916 100644 (file)
@@ -125,7 +125,7 @@ public:
     wxObject* GetProduct() { return NULL; }
 
 protected:
-    virtual void AddText(const wxChar* WXUNUSED(txt)) {}
+    virtual void AddText(const wxString& WXUNUSED(txt)) {}
 
     DECLARE_NO_COPY_CLASS(HP_Parser)
 };
index f53ee5fdaba637e6725da7d081169683cfab9cd9..9d3bf3cb8e0f61275e9ffc617d6c263b84e48c13 100644 (file)
@@ -888,7 +888,7 @@ public:
     wxObject* GetProduct() { return NULL; }
 
 protected:
-    virtual void AddText(const wxChar* WXUNUSED(txt)) {}
+    virtual void AddText(const wxString& WXUNUSED(txt)) {}
 
     DECLARE_NO_COPY_CLASS(wxMetaTagParser)
 };
index bc530f289657d1d142b3743225cf7de324ed58a3..229bdac946ebd25639a0604a6ab4dc375dedf3b8 100644 (file)
@@ -342,15 +342,13 @@ wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type,
     return GetFS()->OpenFile(myurl, flags);
 }
 
-void wxHtmlWinParser::AddText(const wxChar* txt)
+void wxHtmlWinParser::AddText(const wxString& txt)
 {
-    size_t i = 0,
-           x,
-           lng = wxStrlen(txt);
     register wxChar d;
     int templen = 0;
     wxChar nbsp = GetEntitiesParser()->GetCharForCode(160 /* nbsp */);
 
+    size_t lng = txt.length();
     if (lng+1 > m_tmpStrBufSize)
     {
         delete[] m_tmpStrBuf;
@@ -359,24 +357,36 @@ void wxHtmlWinParser::AddText(const wxChar* txt)
     }
     wxChar *temp = m_tmpStrBuf;
 
+    wxString::const_iterator i = txt.begin();
+    wxString::const_iterator end = txt.end();
+
     if (m_tmpLastWasSpace)
     {
-        while ((i < lng) &&
-               ((txt[i] == wxT('\n')) || (txt[i] == wxT('\r')) || (txt[i] == wxT(' ')) ||
-                (txt[i] == wxT('\t')))) i++;
+        while ( (i < end) &&
+                (*i == wxT('\n') || *i == wxT('\r') || *i == wxT(' ') ||
+                 *i == wxT('\t')) )
+        {
+            ++i;
+        }
     }
 
-    while (i < lng)
+    while (i < end)
     {
-        x = 0;
-        d = temp[templen++] = txt[i];
+        size_t x = 0;
+        d = temp[templen++] = *i;
         if ((d == wxT('\n')) || (d == wxT('\r')) || (d == wxT(' ')) || (d == wxT('\t')))
         {
-            i++, x++;
-            while ((i < lng) && ((txt[i] == wxT('\n')) || (txt[i] == wxT('\r')) ||
-                                 (txt[i] == wxT(' ')) || (txt[i] == wxT('\t')))) i++, x++;
+            ++i, ++x;
+            while ( (i < end) &&
+                    (*i == wxT('\n') || *i == wxT('\r') ||
+                     *i == wxT(' ')) || *i == wxT('\t') )
+            {
+                ++i;
+                ++x;
+            }
         }
-        else i++;
+        else
+            ++i;
 
         if (x)
         {