| Version: 3.3.1

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
wxHtmlTag Class Reference
Class List by Category » HTML

`#include <wx/html/htmltag.h>`

## Detailed Description

This class represents a single HTML tag.

It is used by tag handlers.

##

Library: wxHTML
Category: HTML

## Public Member Functions
wxString | GetAllParams () const
| Returns a string containing all parameters. More...
int | GetBeginPos () const
| Returns beginning position of the text between this tag and paired ending tag. More...
int | GetEndPos1 () const
| Returns ending position of the text between this tag and paired ending tag. More...
int | GetEndPos2 () const
| Returns ending position 2 of the text between this tag and paired ending tag. More...
wxString | GetName () const
| Returns tag's name. More...
wxString | GetParam (const wxString &par, bool with_quotes=false) const
| Returns the value of the parameter. More...
bool | GetParamAsColour (const wxString &par, wxColour *clr) const
| Interprets tag parameter par as colour specification and saves its value into wxColour variable pointed by clr. More...
bool | GetParamAsInt (const wxString &par, int *value) const
| Interprets tag parameter par as an integer and saves its value into int variable pointed by value. More...
bool | GetParamAsString (const wxString &par, wxString *value) const
| Get the value of the parameter. More...
bool | HasEnding () const
| Returns true if this tag is paired with ending tag, false otherwise. More...
bool | HasParam (const wxString &par) const
| Returns true if the tag has a parameter of the given name. More...
int | ScanParam (const wxString &par, const wchar_t *format, void *value) const
| This method scans the given parameter. More...
int | ScanParam (const wxString &par, const char *format, void *value) const

## Static Public Member Functions
static bool | ParseAsColour (const wxString &str, wxColour *clr)
| Parses the given string as an HTML colour. More...

## Protected Member Functions
| wxHtmlTag (wxHtmlTag *parent, const wxString *source, const const_iterator &pos, const const_iterator &end_pos, wxHtmlTagsCache *cache, wxHtmlEntitiesParser *entParser)
| Constructor. More...

## Constructor & Destructor Documentation

## ◆ wxHtmlTag()

wxHtmlTag::wxHtmlTag | ( | wxHtmlTag * | parent,
|  | const wxString * | source,
|  | const const_iterator & | pos,
|  | const const_iterator & | end_pos,
|  | wxHtmlTagsCache * | cache,
|  | wxHtmlEntitiesParser * | entParser
| ) |  |
| protected

Constructor.

You will probably never have to construct a wxHtmlTag object yourself. Feel free to ignore the constructor parameters. Have a look at `src/html/htmlpars.cpp` if you're interested in creating it.

## Member Function Documentation

## ◆ GetAllParams()

wxString wxHtmlTag::GetAllParams | ( |  | ) | const

Returns a string containing all parameters.

Example: tag contains <FONT SIZE=+2 COLOR="#000000">. Call to tag.GetAllParams() would return `'SIZE=+2` COLOR="#000000"'.

## ◆ GetBeginPos()

int wxHtmlTag::GetBeginPos | ( |  | ) | const

Returns beginning position of the text between this tag and paired ending tag.

See explanation (returned position is marked with '|'):

bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|

Deprecated:

Todo:
  provide deprecation description

## ◆ GetEndPos1()

int wxHtmlTag::GetEndPos1 | ( |  | ) | const

Returns ending position of the text between this tag and paired ending tag.

See explanation (returned position is marked with '|'):

bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|

Deprecated:

Todo:
  provide deprecation description

## ◆ GetEndPos2()

int wxHtmlTag::GetEndPos2 | ( |  | ) | const

Returns ending position 2 of the text between this tag and paired ending tag.

See explanation (returned position is marked with '|'):

bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|

Deprecated:

Todo:
  provide deprecation description

## ◆ GetName()

wxString wxHtmlTag::GetName | ( |  | ) | const

Returns tag's name.

The name is always in uppercase and it doesn't contain " or '/' characters. (So the name of <FONT SIZE=+2> tag is "FONT" and name of </table> is "TABLE").

## ◆ GetParam()

wxString wxHtmlTag::GetParam | ( | const wxString & | par,
|  | bool | with_quotes = `false`
| ) |  | const

Returns the value of the parameter.

You should check whether the parameter exists or not (use wxHtmlTag::HasParam) first or use GetParamAsString() if you need to distinguish between non-specified and empty parameter values.

Parameters

  par | The parameter's name.
  with_quotes | true if you want to get quotes as well. See example.

Example:

...
// you have wxHtmlTag variable tag which is equal to the
// HTML tag <FONT SIZE=+2 COLOR="#0000FF">
dummy = tag.GetParam("SIZE");
// dummy == "+2"
dummy = tag.GetParam("COLOR");
// dummy == "#0000FF"
dummy = tag.GetParam("COLOR", true);
// dummy == "\"#0000FF\"" -- see the difference!!

## ◆ GetParamAsColour()

bool wxHtmlTag::GetParamAsColour | ( | const wxString & | par,
|  | wxColour * | clr
| ) |  | const

Interprets tag parameter par as colour specification and saves its value into wxColour variable pointed by clr.

Returns true on success and false if par is not colour specification or if the tag has no such parameter.

See also
  ParseAsColour()

## ◆ GetParamAsInt()

bool wxHtmlTag::GetParamAsInt | ( | const wxString & | par,
|  | int * | value
| ) |  | const

Interprets tag parameter par as an integer and saves its value into int variable pointed by value.

Returns true on success and false if par is not an integer or if the tag has no such parameter.

## ◆ GetParamAsString()

bool wxHtmlTag::GetParamAsString | ( | const wxString & | par,
|  | wxString * | value
| ) |  | const

Get the value of the parameter.

If the tag doesn't have such parameter at all, simply returns false. Otherwise, fills value with the parameter value and returns true.

Parameters

  par | The parameter's name.
  value | Pointer to the string to be filled with the parameter value, must be non-null.

Since
  3.0

## ◆ HasEnding()

bool wxHtmlTag::HasEnding | ( |  | ) | const

Returns true if this tag is paired with ending tag, false otherwise.

See the example of HTML document:

<html><body>
Hello<p>
How are you?
<p align=center>This is centered...</p>
Oops<br>Oooops!
</body></html>

In this example tags HTML and BODY have ending tags, first P and BR doesn't have ending tag while the second P has. The third P tag (which is ending itself) of course doesn't have ending tag.

## ◆ HasParam()

bool wxHtmlTag::HasParam | ( | const wxString & | par | ) | const

Returns true if the tag has a parameter of the given name.

Example: <FONT SIZE=+2 COLOR="\#FF00FF"> has two parameters named "SIZE" and "COLOR".

Parameters

  par | the parameter you're looking for.

## ◆ ParseAsColour()

static bool wxHtmlTag::ParseAsColour | ( | const wxString & | str,
|  | wxColour * | clr
| ) |  |
| static

Parses the given string as an HTML colour.

This function recognizes the standard named HTML 4 colours as well as the usual RGB syntax.

Since
  2.9.1

See also
  wxColour::Set()

Returns
  true if the string was successfully parsed and clr was filled with the result or false otherwise.

## ◆ ScanParam() [1/2]

int wxHtmlTag::ScanParam | ( | const wxString & | par,
|  | const char * | format,
|  | void * | value
| ) |  | const

## ◆ ScanParam() [2/2]

int wxHtmlTag::ScanParam | ( | const wxString & | par,
|  | const wchar_t * | format,
|  | void * | value
| ) |  | const

This method scans the given parameter.

Usage is exactly the same as sscanf's usage except that you don't pass a string but a parameter name as the first argument and you can only retrieve one value (i.e. you can use only one "%" element in format).

Parameters

  par | The name of the tag you want to query
  format | scanf()-like format string.
  value | pointer to a variable to store the value in