fixed wxHTML parsing to run in O(n) even in UTF8 build
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -73,7 +73,8 @@ public:
|
||||
|
||||
// Parses the m_Source from begin_pos to end_pos-1.
|
||||
// (in noparams version it parses whole m_Source)
|
||||
void DoParsing(int begin_pos, int end_pos);
|
||||
void DoParsing(const wxString::const_iterator& begin_pos,
|
||||
const wxString::const_iterator& end_pos);
|
||||
void DoParsing();
|
||||
|
||||
// Returns pointer to the tag at parser's current position
|
||||
@@ -104,7 +105,7 @@ public:
|
||||
// Restores state before last call to PushTagHandler
|
||||
void PopTagHandler();
|
||||
|
||||
wxString* GetSource() {return &m_Source;}
|
||||
const wxString* GetSource() {return m_Source;}
|
||||
void SetSource(const wxString& src);
|
||||
|
||||
// Sets HTML source and remembers current parser's state so that it can
|
||||
@@ -140,7 +141,8 @@ protected:
|
||||
void CreateDOMTree();
|
||||
void DestroyDOMTree();
|
||||
void CreateDOMSubTree(wxHtmlTag *cur,
|
||||
int begin_pos, int end_pos,
|
||||
const wxString::const_iterator& begin_pos,
|
||||
const wxString::const_iterator& end_pos,
|
||||
wxHtmlTagsCache *cache);
|
||||
|
||||
// Adds text to the output.
|
||||
@@ -163,7 +165,7 @@ protected:
|
||||
wxHtmlTextPieces *m_TextPieces;
|
||||
size_t m_CurTextPiece;
|
||||
|
||||
wxString m_Source;
|
||||
const wxString *m_Source;
|
||||
|
||||
wxHtmlParserState *m_SavedStates;
|
||||
|
||||
@@ -232,7 +234,7 @@ protected:
|
||||
// parses input between beginning and ending tag.
|
||||
// m_Parser must be set.
|
||||
void ParseInner(const wxHtmlTag& tag)
|
||||
{ m_Parser->DoParsing(tag.GetBeginPos(), tag.GetEndPos1()); }
|
||||
{ m_Parser->DoParsing(tag.GetBeginIter(), tag.GetEndIter1()); }
|
||||
|
||||
// Parses given source as if it was tag's inner code (see
|
||||
// wxHtmlParser::GetInnerSource). Unlike ParseInner(), this method lets
|
||||
|
@@ -31,7 +31,7 @@ class WXDLLIMPEXP_HTML wxHtmlTagsCache
|
||||
{
|
||||
private:
|
||||
wxHtmlTagsCacheData *m_Cache;
|
||||
size_t m_CachePos;
|
||||
int m_CachePos;
|
||||
|
||||
wxHtmlTagsCacheData& Cache() { return *m_Cache; }
|
||||
|
||||
@@ -41,7 +41,11 @@ public:
|
||||
virtual ~wxHtmlTagsCache();
|
||||
|
||||
// Finds parameters for tag starting at at and fills the variables
|
||||
void QueryTag(int at, int* end1, int* end2);
|
||||
void QueryTag(const wxString::const_iterator& at,
|
||||
const wxString::const_iterator& inputEnd,
|
||||
wxString::const_iterator *end1,
|
||||
wxString::const_iterator *end2,
|
||||
bool *hasEnding);
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxHtmlTagsCache)
|
||||
};
|
||||
@@ -60,7 +64,9 @@ protected:
|
||||
// The tag begins (with '<' character) at position pos in source
|
||||
// end_pos is position where parsing ends (usually end of document)
|
||||
wxHtmlTag(wxHtmlTag *parent,
|
||||
const wxString& source, int pos, int end_pos,
|
||||
const wxString *source,
|
||||
const wxString::const_iterator& pos,
|
||||
const wxString::const_iterator& end_pos,
|
||||
wxHtmlTagsCache *cache,
|
||||
wxHtmlEntitiesParser *entParser);
|
||||
friend class wxHtmlParser;
|
||||
@@ -108,24 +114,37 @@ public:
|
||||
// Returns string containing all params.
|
||||
wxString GetAllParams() const;
|
||||
|
||||
// return true if this there is matching ending tag
|
||||
inline bool HasEnding() const {return m_End1 >= 0;}
|
||||
// return true if there is matching ending tag
|
||||
inline bool HasEnding() const {return m_hasEnding;}
|
||||
|
||||
// returns beginning position of _internal_ block of text
|
||||
// See explanation (returned value is marked with *):
|
||||
// bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
|
||||
inline int GetBeginPos() const {return m_Begin;}
|
||||
wxString::const_iterator GetBeginIter() const
|
||||
{ return m_Begin; }
|
||||
// returns ending position of _internal_ block of text.
|
||||
// bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
|
||||
inline int GetEndPos1() const {return m_End1;}
|
||||
wxString::const_iterator GetEndIter1() const
|
||||
{ wxASSERT(m_hasEnding); return m_End1; }
|
||||
// returns end position 2 :
|
||||
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
|
||||
inline int GetEndPos2() const {return m_End2;}
|
||||
wxString::const_iterator GetEndIter2() const
|
||||
{ wxASSERT(m_hasEnding); return m_End2; }
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
wxDEPRECATED( inline int GetBeginPos() const );
|
||||
wxDEPRECATED( inline int GetEndPos1() const );
|
||||
wxDEPRECATED( inline int GetEndPos2() const );
|
||||
#endif // WXWIN_COMPATIBILITY_2_8
|
||||
|
||||
private:
|
||||
wxString m_Name;
|
||||
int m_Begin, m_End1, m_End2;
|
||||
bool m_hasEnding;
|
||||
wxString::const_iterator m_Begin, m_End1, m_End2;
|
||||
wxArrayString m_ParamNames, m_ParamValues;
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
wxString::const_iterator m_sourceStart;
|
||||
#endif
|
||||
|
||||
// DOM tree relations:
|
||||
wxHtmlTag *m_Next;
|
||||
@@ -137,10 +156,16 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
inline int wxHtmlTag::GetBeginPos() const { return m_Begin - m_sourceStart; }
|
||||
inline int wxHtmlTag::GetEndPos1() const { return m_End1 - m_sourceStart; }
|
||||
inline int wxHtmlTag::GetEndPos2() const { return m_End2 - m_sourceStart; }
|
||||
#endif // WXWIN_COMPATIBILITY_2_8
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_HTML
|
||||
|
||||
#endif // _WX_HTMLTAG_H_
|
||||
|
||||
|
Reference in New Issue
Block a user