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 //-----------------------------------------------------------------------------
23 // - internal wxHTML class, do not use!
24 //-----------------------------------------------------------------------------
26 struct wxHtmlCacheItem
;
28 class WXDLLEXPORT wxHtmlTagsCache
: public wxObject
30 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache
)
33 wxHtmlCacheItem
*m_Cache
;
38 wxHtmlTagsCache() : wxObject() {m_CacheSize
= 0; m_Cache
= NULL
;}
39 wxHtmlTagsCache(const wxString
& source
);
40 ~wxHtmlTagsCache() {free(m_Cache
);}
42 // Finds parameters for tag starting at at and fills the variables
43 void QueryTag(int at
, int* end1
, int* end2
);
47 //--------------------------------------------------------------------------------
49 // This represents single tag. It is used as internal structure
51 //--------------------------------------------------------------------------------
53 class WXDLLEXPORT wxHtmlTag
: public wxObject
55 DECLARE_CLASS(wxHtmlTag
)
58 // constructs wxHtmlTag object based on HTML tag.
59 // The tag begins (with '<' character) at position pos in source
60 // end_pos is position where parsing ends (usually end of document)
61 wxHtmlTag(const wxString
& source
, int pos
, int end_pos
, wxHtmlTagsCache
* cache
);
63 // Returns tag's name in uppercase.
64 inline wxString
GetName() const {return m_Name
;}
66 // Returns TRUE if the tag has given parameter. Parameter
67 // should always be in uppercase.
68 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
69 bool HasParam(const wxString
& par
) const;
71 // Returns value of the param. Value is in uppercase unless it is
73 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
74 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
75 // (or ("WhaT.jpg") if with_commas == TRUE)
76 wxString
GetParam(const wxString
& par
, bool with_commas
= FALSE
) const;
78 // Scans param like scanf() functions family do.
79 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
80 // This is always with with_commas=FALSE
81 // Returns number of scanned values
82 // (like sscanf() does)
83 // NOTE: unlike scanf family, this function only accepts
85 int ScanParam(const wxString
& par
, wxChar
*format
, void *param
) const;
87 // Returns string containing all params.
88 inline const wxString
& GetAllParams() const {return m_Params
;}
90 // return TRUE if this is ending tag (</something>) or FALSE
91 // if it isn't (<something>)
92 inline bool IsEnding() const {return m_Ending
;}
94 // return TRUE if this is ending tag (</something>) or FALSE
95 // if it isn't (<something>)
96 inline bool HasEnding() const {return m_End1
>= 0;}
98 // returns beginning position of _internal_ block of text
99 // See explanation (returned value is marked with *):
100 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
101 inline int GetBeginPos() const {return m_Begin
;}
102 // returns ending position of _internal_ block of text.
103 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
104 inline int GetEndPos1() const {return m_End1
;}
105 // returns end position 2 :
106 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
107 inline int GetEndPos2() const {return m_End2
;}
110 wxString m_Name
, m_Params
;
111 int m_Begin
, m_End1
, m_End2
;
121 #endif // _WX_HTMLTAG_H_