From: Václav Slavík Date: Mon, 11 Jun 2007 12:11:15 +0000 (+0000) Subject: use wxString argument and not wxChar* in wxHtmlParser::AddText(), for compatibility... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5bce3e6feb143c3ef8d6002a90f743e2d7782532 use wxString argument and not wxChar* in wxHtmlParser::AddText(), for compatibility with STL build without implicit wxString conversions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46403 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index 15e0d55488..7bbd2f16c0 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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 ----------------------------------------- diff --git a/docs/latex/wx/htparser.tex b/docs/latex/wx/htparser.tex index bc373af4be..91b94ea4dc 100644 --- a/docs/latex/wx/htparser.tex +++ b/docs/latex/wx/htparser.tex @@ -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. diff --git a/include/wx/html/htmlpars.h b/include/wx/html/htmlpars.h index b5c6c6830f..c71c3958eb 100644 --- a/include/wx/html/htmlpars.h +++ b/include/wx/html/htmlpars.h @@ -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. diff --git a/include/wx/html/winpars.h b/include/wx/html/winpars.h index c5d6f337dd..26780b540e 100644 --- a/include/wx/html/winpars.h +++ b/include/wx/html/winpars.h @@ -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); diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index 801882e10d..0e8bc843df 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -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) }; diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index f53ee5fdab..9d3bf3cb8e 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -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) }; diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index bc530f2896..229bdac946 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -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) {