]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/htmltag.h
virtual functionsignature corrected
[wxWidgets.git] / include / wx / html / htmltag.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: htmltag.h
3 // Purpose: wxHtmlTag class (represents single tag)
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 #ifndef __HTMLTAG_H__
11 #define __HTMLTAG_H__
12
13 #ifdef __GNUG__
14 #pragma interface
15 #endif
16
17 #include "wx/defs.h"
18 #if wxUSE_HTML
19
20
21 //--------------------------------------------------------------------------------
22 // wxHtmlTagsCache
23 // !! INTERNAL STRUCTURE !! Do not use in your program!
24 // This structure contains information on positions of tags
25 // in the string being parsed
26 //--------------------------------------------------------------------------------
27
28 typedef struct {
29 int Key;
30 // this is "pos" value passed to wxHtmlTag's constructor.
31 // it is position of '<' character of the tag
32 int End1, End2;
33 // end positions for the tag:
34 // end1 is '<' of ending tag,
35 // end2 is '>' or both are
36 // -1 if there is no ending tag for this one...
37 // or -2 if this is ending tag </...>
38 char *Name;
39 // name of this tag
40 } sCacheItem;
41
42
43
44 class wxHtmlTagsCache : public wxObject
45 {
46 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
47
48 private:
49 sCacheItem *m_Cache;
50 int m_CacheSize;
51 int m_CachePos;
52
53 public:
54 wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;}
55 wxHtmlTagsCache(const wxString& source);
56 ~wxHtmlTagsCache() {free(m_Cache);}
57
58 void QueryTag(int at, int* end1, int* end2);
59 // Finds parameters for tag starting at at and fills the variables
60 };
61
62
63
64 //--------------------------------------------------------------------------------
65 // wxHtmlTag
66 // This represents single tag. It is used as internal structure
67 // by wxHtmlParser.
68 //--------------------------------------------------------------------------------
69
70 class WXDLLEXPORT wxHtmlTag : public wxObject
71 {
72 DECLARE_CLASS(wxHtmlTag)
73
74 private:
75 wxString m_Name, m_Params;
76 int m_Begin, m_End1, m_End2;
77 bool m_Ending;
78
79 public:
80 wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
81 // constructs wxHtmlTag object based on HTML tag.
82 // The tag begins (with '<' character) at position pos in source
83 // end_pos is position where parsing ends (usually end of document)
84
85 inline wxString GetName() const {return m_Name;};
86 // Returns tag's name in uppercase.
87
88 bool HasParam(const wxString& par) const;
89 // Returns TRUE if the tag has given parameter. Parameter
90 // should always be in uppercase.
91 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
92
93 wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
94 // Returns value of the param. Value is in uppercase unless it is
95 // enclosed with "
96 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
97 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
98 // (or ("WhaT.jpg") if with_commas == TRUE)
99
100 int ScanParam(const wxString& par, char *format, void *param) const;
101 // Scans param like scanf() functions family do.
102 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
103 // This is always with with_commas=FALSE
104 // Returns number of scanned values
105 // (like sscanf() does)
106 // NOTE: unlike scanf family, this function only accepts
107 // *one* parameter !
108
109 inline const wxString& GetAllParams() const {return m_Params;};
110 // Returns string containing all params.
111
112 inline bool IsEnding() const {return m_Ending;};
113 // return TRUE if this is ending tag (</something>) or FALSE
114 // if it isn't (<something>)
115
116 inline bool HasEnding() const {return m_End1 >= 0;};
117 // return TRUE if this is ending tag (</something>) or FALSE
118 // if it isn't (<something>)
119
120 inline int GetBeginPos() const {return m_Begin;};
121 // returns beginning position of _internal_ block of text
122 // See explanation (returned value is marked with *):
123 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
124 inline int GetEndPos1() const {return m_End1;};
125 // returns ending position of _internal_ block of text.
126 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
127 inline int GetEndPos2() const {return m_End2;};
128 // returns end position 2 :
129 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
130 };
131
132
133
134
135
136
137 #endif // __HTMLTAG_H__
138
139 #endif