]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/htparser.tex
Fixed crash-on-exit bug due to status bar being deleted twice (MDI apps);
[wxWidgets.git] / docs / latex / wx / htparser.tex
CommitLineData
704a4b75
VS
1%
2% automatically generated by HelpGen from
3% htmlparser.tex at 14/Mar/99 20:13:37
4%
5
704a4b75
VS
6\section{\class{wxHtmlParser}}\label{wxhtmlparser}
7
22d6efa8 8This class handles the {\bf generic} parsing of HTML document: it scans
704a4b75
VS
9the document and divide it into blocks of tags (where one block
10consists of begining and ending tag and of text between these
22d6efa8 11two tags).
704a4b75
VS
12
13It is independent from wxHtmlWindow and can be used as stand-alone parser
14(Julian Smart's idea of speech-only HTML viewer or wget-like utility -
3660fc40 15see InetGet sample for example).
704a4b75
VS
16
17It uses system of tag handlers to parse the HTML document. Tag handlers
3660fc40 18are not staticaly shared by all instances but are created for each
704a4b75
VS
19wxHtmlParser instance. The reason is that the handler may contain
20document-specific temporary data used during parsing (e.g. complicated
22d6efa8 21structures like tables).
704a4b75 22
22d6efa8 23Typically the user calls only the \helpref{Parse}{wxhtmlparserparse} method.
704a4b75
VS
24
25\wxheading{Derived from}
26
27wxObject
28
9704b250
VS
29\wxheading{Include files}
30
31<wx/html/htmlpars.h>
32
33
704a4b75
VS
34\wxheading{See also}
35
36\helpref{Cells Overview}{cells},
37\helpref{Tag Handlers Overview}{handlers},
38\helpref{wxHtmlTag}{wxhtmltag}
39
40\latexignore{\rtfignore{\wxheading{Members}}}
41
704a4b75
VS
42\membersection{wxHtmlParser::wxHtmlParser}\label{wxhtmlparserwxhtmlparser}
43
44\func{}{wxHtmlParser}{\void}
45
3660fc40 46Constructor.
704a4b75 47
559fe022 48\membersection{wxHtmlParser::AddTag}\label{wxhtmlparseraddtag}
704a4b75 49
559fe022 50\func{void}{AddTag}{\param{const wxHtmlTag\& }{tag}}
704a4b75 51
559fe022 52This may (and may not) be overwriten in derived class.
704a4b75 53
559fe022
VS
54This method is called each time new tag is about to be added.
55{\it tag} contains information about the tag. (See \helpref{wxHtmlTag}{wxhtmltag}
56for details.)
704a4b75 57
559fe022
VS
58Default (wxHtmlParser) behaviour is this:
59First it finds a handler capable of handling this tag and then it calls
60handler's HandleTag method.
704a4b75 61
559fe022 62\membersection{wxHtmlParser::AddTagHandler}\label{wxhtmlparseraddtaghandler}
704a4b75 63
559fe022 64\func{virtual void}{AddTagHandler}{\param{wxHtmlTagHandler }{*handler}}
704a4b75 65
559fe022
VS
66Adds handler to the internal list (\& hash table) of handlers. This
67method should not be called directly by user but rather by derived class'
68constructor.
704a4b75 69
559fe022
VS
70This adds the handler to this {\bf instance} of wxHtmlParser, not to
71all objects of this class! (Static front-end to AddTagHandler is provided
72by wxHtmlWinParser).
704a4b75 73
559fe022 74All handlers are deleted on object deletion.
704a4b75 75
559fe022 76\membersection{wxHtmlParser::AddText}\label{wxhtmlparseraddword}
704a4b75 77
559fe022 78\func{virtual void}{AddWord}{\param{const char* }{txt}}
704a4b75 79
559fe022 80Must be overwriten in derived class.
704a4b75 81
559fe022
VS
82This method is called by \helpref{DoParsing}{wxhtmlparserdoparsing}
83each time a part of text is parsed. {\it txt} is NOT only one word, it is
84substring of input. It is not formatted or preprocessed (so white spaces are
85unmodified).
704a4b75 86
559fe022 87\membersection{wxHtmlParser::DoParsing}\label{wxhtmlparserdoparsing}
704a4b75 88
559fe022
VS
89\func{void}{DoParsing}{\param{int }{begin\_pos}, \param{int }{end\_pos}}
90
91\func{void}{DoParsing}{\void}
92
93Parses the m\_Source from begin\_pos to end\_pos-1.
94(in noparams version it parses whole m\_Source)
704a4b75 95
704a4b75
VS
96\membersection{wxHtmlParser::DoneParser}\label{wxhtmlparserdoneparser}
97
98\func{virtual void}{DoneParser}{\void}
99
100This must be called after DoParsing().
101
559fe022 102\membersection{wxHtmlParser::GetFS}\label{wxhtmlparsergetfs}
704a4b75 103
559fe022 104\constfunc{wxFileSystem*}{GetFS}{\void}
704a4b75 105
559fe022
VS
106Returns pointer to the file system. Because each tag handler has
107reference to it's parent parser it can easily request the file by
108calling
704a4b75 109
559fe022
VS
110\begin{verbatim}
111wxFSFile *f = m_Parser -> GetFS() -> OpenFile("image.jpg");
112\end{verbatim}
704a4b75
VS
113
114\membersection{wxHtmlParser::GetProduct}\label{wxhtmlparsergetproduct}
115
116\func{virtual wxObject*}{GetProduct}{\void}
117
3660fc40
RD
118Returns product of parsing. Returned value is result of parsing
119of the document. The type of this result depends on internal
704a4b75
VS
120representation in derived parser (but it must be derived from wxObject!).
121
122See wxHtmlWinParser for details.
123
704a4b75
VS
124\membersection{wxHtmlParser::GetSource}\label{wxhtmlparsergetsource}
125
126\func{wxString*}{GetSource}{\void}
127
128Returns pointer to the source being parsed.
129
704a4b75 130
559fe022 131\membersection{wxHtmlParser::InitParser}\label{wxhtmlparserinitparser}
704a4b75 132
559fe022 133\func{virtual void}{InitParser}{\param{const wxString\& }{source}}
704a4b75 134
559fe022
VS
135Setups the parser for parsing the {\it source} string. (Should be overriden
136in derived class)
704a4b75 137
559fe022 138\membersection{wxHtmlParser::Parse}\label{wxhtmlparserparse}
704a4b75 139
559fe022 140\func{wxObject*}{Parse}{\param{const wxString\& }{source}}
704a4b75 141
559fe022
VS
142Proceeds parsing of the document. This is end-user method. You can simply
143call it when you need to obtain parsed output (which is parser-specific)
704a4b75 144
559fe022 145The method does these things:
704a4b75 146
448af9a4 147\begin{enumerate}\itemsep=0pt
559fe022
VS
148\item calls \helpref{InitParser(source)}{wxhtmlparserinitparser}
149\item calls \helpref{DoParsing}{wxhtmlparserdoparsing}
150\item calls \helpref{GetProduct}{wxhtmlparsergetproduct}
151\item calls \helpref{DoneParser}{wxhtmlparserdoneparser}
152\item returns value returned by GetProduct
153\end{enumerate}
704a4b75 154
559fe022
VS
155You shouldn't use InitParser, DoParsing, GetProduct or DoneParser directly.
156
0eb8c938
VS
157
158
159\membersection{wxHtmlParser::PushTagHandler}\label{wxhtmlparserpushtaghandler}
160
161\func{void}{PushTagHandler}{\param{wxHtmlTagHandler* }{handler}, \param{wxString }{tags}}
162
163Forces the handler to handle additional tags
164(not returned by \helpref{GetSupportedTags}{wxhtmltaghandlergetsupportedtags}).
165The handler should already be added to this parser.
166
167\wxheading{Parameters}
168
169\docparam{handler}{the handler}
170\docparam{tags}{List of tags (in same format as GetSupportedTags's return value). The parser
171will redirect these tags to {\it handler} (until call to \helpref{PopTagHandler}{wxhtmlparserpoptaghandler}). }
172
173\wxheading{Example}
174
175Imagine you want to parse following pseudo-html structure:
176
177\begin{verbatim}
178<myitems>
179 <param name="one" value="1">
180 <param name="two" value="2">
181</myitems>
182
183<execute>
184 <param program="text.exe">
185</execute>
186\end{verbatim}
187
188It is obvious that you cannot use only one tag handler for <param> tag.
189Instead you must use context-sensitive handlers for <param> inside <myitems>
190and <param> inside <execute>.
191
192This is the prefered solution:
193
194\begin{verbatim}
195TAG_HANDLER_BEGIN(MYITEM, "MYITEMS")
196 TAG_HANDLER_PROC(tag)
197 {
198 // ...something...
199
200 m_Parser -> PushTagHandler(this, "PARAM");
201 ParseInner(tag);
202 m_Parser -> PopTagHandler();
203
204 // ...something...
205 }
206TAG_HANDLER_END(MYITEM)
207\end{verbatim}
208
209
210\membersection{wxHtmlParser::PopTagHandler}\label{wxhtmlparserpoptaghandler}
211
212\func{void}{PopTagHandler}{\void}
213
214Restores parser's state before last call to
215\helpref{PushTagHandler}{wxhtmlparserpushtaghandler}.
216
217
559fe022
VS
218\membersection{wxHtmlParser::SetFS}\label{wxhtmlparsersetfs}
219
220\func{void}{SetFS}{\param{wxFileSystem }{*fs}}
221
222Sets the virtual file system that will be used to request additional
223files. (For example {\tt <IMG>} tag handler requests wxFSFile with the
224image data.)
22d6efa8 225