]>
git.saurik.com Git - wxWidgets.git/blob - interface/html/htmlpars.h
355e8fcc3377d0c248f81be19d94a8a0baa3b2a0
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: html/htmlpars.h
3 // Purpose: documentation for wxHtmlTagHandler class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxHtmlTagHandler
11 @headerfile htmlpars.h wx/html/htmlpars.h
20 class wxHtmlTagHandler
: public wxObject
29 Returns list of supported tags. The list is in uppercase and tags
30 are delimited by ','. Example : @c "I,B,FONT,P"
32 virtual wxString
GetSupportedTags();
35 This is the core method of each handler. It is called each time
36 one of supported tags is detected. @a tag contains all necessary
37 info (see wxHtmlTag for details).
39 @returns @true if ParseInner was called, @false otherwise.
41 virtual bool HandleTag(const wxHtmlTag
& tag
);
44 This method calls parser's wxHtmlParser::DoParsing method
45 for the string between this tag and the paired ending tag:
47 In this example, a call to ParseInner (with @a tag pointing to A tag)
48 will parse 'Hello, world!'.
50 void ParseInner(const wxHtmlTag
& tag
);
53 Assigns @a parser to this handler. Each @b instance of handler
54 is guaranteed to be called only from the parser.
56 virtual void SetParser(wxHtmlParser parser
);
59 @b wxHtmlParser* m_Parser
60 This attribute is used to access parent parser. It is protected so that
61 it can't be accessed by user but can be accessed from derived classes.
68 @headerfile htmlpars.h wx/html/htmlpars.h
70 Classes derived from this handle the @b generic parsing of HTML documents: it
72 the document and divide it into blocks of tags (where one block
73 consists of beginning and ending tag and of text between these
76 It is independent from wxHtmlWindow and can be used as stand-alone parser
77 (Julian Smart's idea of speech-only HTML viewer or wget-like utility -
78 see InetGet sample for example).
80 It uses system of tag handlers to parse the HTML document. Tag handlers
81 are not statically shared by all instances but are created for each
82 wxHtmlParser instance. The reason is that the handler may contain
83 document-specific temporary data used during parsing (e.g. complicated
84 structures like tables).
86 Typically the user calls only the wxHtmlParser::Parse method.
92 @ref overview_cells "Cells Overview", @ref overview_handlers "Tag Handlers
104 This may (and may not) be overwritten in derived class.
105 This method is called each time new tag is about to be added.
106 @a tag contains information about the tag. (See wxHtmlTag
108 Default (wxHtmlParser) behaviour is this:
109 First it finds a handler capable of handling this tag and then it calls
110 handler's HandleTag method.
112 void AddTag(const wxHtmlTag
& tag
);
115 Adds handler to the internal list ( hash table) of handlers. This
116 method should not be called directly by user but rather by derived class'
118 This adds the handler to this @b instance of wxHtmlParser, not to
119 all objects of this class! (Static front-end to AddTagHandler is provided
121 All handlers are deleted on object deletion.
123 virtual void AddTagHandler(wxHtmlTagHandler handler
);
126 Must be overwritten in derived class.
127 This method is called by DoParsing()
128 each time a part of text is parsed. @a txt is NOT only one word, it is
129 substring of input. It is not formatted or preprocessed (so white spaces are
132 virtual void AddWord(const wxString
& txt
);
136 Parses the m_Source from begin_pos to end_pos-1.
137 (in noparams version it parses whole m_Source)
139 void DoParsing(int begin_pos
, int end_pos
);
144 This must be called after DoParsing().
146 virtual void DoneParser();
149 Returns pointer to the file system. Because each tag handler has
150 reference to it is parent parser it can easily request the file by
153 wxFileSystem
* GetFS();
156 Returns product of parsing. Returned value is result of parsing
157 of the document. The type of this result depends on internal
158 representation in derived parser (but it must be derived from wxObject!).
159 See wxHtmlWinParser for details.
161 virtual wxObject
* GetProduct();
164 Returns pointer to the source being parsed.
166 wxString
* GetSource();
169 Setups the parser for parsing the @a source string. (Should be overridden
172 virtual void InitParser(const wxString
& source
);
175 Opens given URL and returns @c wxFSFile object that can be used to read data
176 from it. This method may return @NULL in one of two cases: either the URL doesn't
177 point to any valid resource or the URL is blocked by overridden implementation
178 of @e OpenURL in derived class.
181 Indicates type of the resource. Is one of:
215 Opening a resource that doesn't fall into
220 virtual wxFSFile
* OpenURL(wxHtmlURLType type
,
221 const wxString
& url
);
224 Proceeds parsing of the document. This is end-user method. You can simply
225 call it when you need to obtain parsed output (which is parser-specific)
226 The method does these things:
227 calls @ref initparser() InitParser(source)
231 returns value returned by GetProduct
232 You shouldn't use InitParser, DoParsing, GetProduct or DoneParser directly.
234 wxObject
* Parse(const wxString
& source
);
237 Restores parser's state before last call to
240 void PopTagHandler();
243 Forces the handler to handle additional tags
244 (not returned by wxHtmlTagHandler::GetSupportedTags).
245 The handler should already be added to this parser.
250 List of tags (in same format as GetSupportedTags's return value). The parser
251 will redirect these tags to handler (until call to PopTagHandler).
253 void PushTagHandler(wxHtmlTagHandler
* handler
,
254 const wxString
& tags
);
257 Sets the virtual file system that will be used to request additional
258 files. (For example @c IMG tag handler requests wxFSFile with the
261 void SetFS(wxFileSystem fs
);
264 Call this function to interrupt parsing from a tag handler. No more tags
265 will be parsed afterward. This function may only be called from
266 Parse() or any function called
267 by it (i.e. from tag handlers).