1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlTag class (represents single tag)
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_HTMLTAG_H_
12 #define _WX_HTMLTAG_H_
15 #pragma interface "htmltag.h"
21 class WXDLLEXPORT wxHtmlEntitiesParser
;
23 //-----------------------------------------------------------------------------
25 // - internal wxHTML class, do not use!
26 //-----------------------------------------------------------------------------
28 struct wxHtmlCacheItem
;
30 class WXDLLEXPORT wxHtmlTagsCache
: public wxObject
32 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache
)
35 wxHtmlCacheItem
*m_Cache
;
40 wxHtmlTagsCache() : wxObject() {m_CacheSize
= 0; m_Cache
= NULL
;}
41 wxHtmlTagsCache(const wxString
& source
);
42 ~wxHtmlTagsCache() {free(m_Cache
);}
44 // Finds parameters for tag starting at at and fills the variables
45 void QueryTag(int at
, int* end1
, int* end2
);
49 //--------------------------------------------------------------------------------
51 // This represents single tag. It is used as internal structure
53 //--------------------------------------------------------------------------------
55 class WXDLLEXPORT wxHtmlTag
: public wxObject
57 DECLARE_CLASS(wxHtmlTag
)
60 // constructs wxHtmlTag object based on HTML tag.
61 // The tag begins (with '<' character) at position pos in source
62 // end_pos is position where parsing ends (usually end of document)
63 wxHtmlTag(const wxString
& source
, int pos
, int end_pos
,
64 wxHtmlTagsCache
*cache
,
65 wxHtmlEntitiesParser
*entParser
= NULL
);
67 // Returns tag's name in uppercase.
68 inline wxString
GetName() const {return m_Name
;}
70 // Returns TRUE if the tag has given parameter. Parameter
71 // should always be in uppercase.
72 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
73 bool HasParam(const wxString
& par
) const;
75 // Returns value of the param. Value is in uppercase unless it is
77 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
78 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
79 // (or ("WhaT.jpg") if with_commas == TRUE)
80 wxString
GetParam(const wxString
& par
, bool with_commas
= FALSE
) const;
82 // Convenience functions:
83 bool GetParamAsColour(const wxString
& par
, wxColour
*clr
) const;
84 bool GetParamAsInt(const wxString
& par
, int *clr
) const;
86 // Scans param like scanf() functions family does.
87 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
88 // This is always with with_commas=FALSE
89 // Returns number of scanned values
90 // (like sscanf() does)
91 // NOTE: unlike scanf family, this function only accepts
93 int ScanParam(const wxString
& par
, wxChar
*format
, void *param
) const;
95 // Returns string containing all params.
96 wxString
GetAllParams() const;
98 // return TRUE if this is ending tag (</something>) or FALSE
99 // if it isn't (<something>)
100 inline bool IsEnding() const {return m_Ending
;}
102 // return TRUE if this is ending tag (</something>) or FALSE
103 // if it isn't (<something>)
104 inline bool HasEnding() const {return m_End1
>= 0;}
106 // returns beginning position of _internal_ block of text
107 // See explanation (returned value is marked with *):
108 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
109 inline int GetBeginPos() const {return m_Begin
;}
110 // returns ending position of _internal_ block of text.
111 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
112 inline int GetEndPos1() const {return m_End1
;}
113 // returns end position 2 :
114 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
115 inline int GetEndPos2() const {return m_End2
;}
119 int m_Begin
, m_End1
, m_End2
;
121 wxArrayString m_ParamNames
, m_ParamValues
;
130 #endif // _WX_HTMLTAG_H_