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