Loading...
Searching...
No Matches
stdex::html::parser< _Elem, _Traits, _Alloc > Class Template Reference

HTML parser. More...

## Public Member Functions

| parser (const document< _Elem, _Traits, _Alloc > &document, _In_reads_or_z_opt_(num_chars) const stdex::schar_t *url=nullptr, size_t num_chars=0, bool parse_frames=false, stdex::progress< size_t > *progress=nullptr)
text_token< _Elem, _Traits, _Alloc > * | parse ()
| Parses HTML document.
token_list::const_iterator | end_tokens (std::basic_string< _Elem, _Traits, _Alloc > &source, token_list &active_tokens, const token_list &new_tokens)
| Pops ending tokens from the active token list and append their tags to the source code string.
void | append_inserted_tokens (std::basic_string< _Elem, _Traits, _Alloc > &source, inserted_token_list &inserted_tokens, size_t word_index, bool after_word, token_list &active_tokens)
| Adds matching inserted tokens before/after the given word in source code.
void | make_absolute_url (std::basic_string< _Elem, _Traits, _Alloc > &rel)
| Converts URL to absolute.
const token_vector & | tokens () const
| Returns collection of tokens.

## Static Public Member Functions

static void | link (std::basic_string< _Elem, _Traits, _Alloc > &source, const text_token< _Elem, _Traits, _Alloc > *t)
| Rebuilds HTML source code from the token tree.
static void | start_tokens (std::basic_string< _Elem, _Traits, _Alloc > &source, token_list &active_tokens, const token_list &new_tokens, token_list::const_iterator from)
| Pushes tokens to the active token list and appends their tags to the source code string.
static void | merge (token_list &a, const token_list &b)
| Adds tokens from list `b` to list `a` creating an union.

## Protected Member Functions

template<class T >
T * | append_token (std::unique_ptr< T > &&token)
| Adds token to the collection.
template<class T >
size_t | append_token (std::unique_ptr< T > &&token, std::basic_string< _Elem, _Traits, _Alloc > &source)
| Adds token to the collection and appends its tag to the source code string.
text_token< _Elem, _Traits, _Alloc > * | parse (const sequence_store::const_iterator &end, uint32_t text_type=0)
| Recursively parses HTML document.
text_token< _Elem, _Traits, _Alloc > * | parse_css (size_t start, size_t end)
| Parses CSS.

## Protected Attributes

const document< _Elem, _Traits, _Alloc > & | m_document
| Document being analyzed.
const stdex::sys_string | m_url
| Absolute document URL.
const bool | m_parse_frames
| Parse frames.
stdex::progress< size_t > * | m_progress
| Progress indicator.
const _Elem * | m_source
| HTML source code.
token_vector | m_tokens
| HTML token storage.
sequence_store::const_iterator | m_offset
| Index of active section.
stdex::parser::basic_css_cdo< _Elem > | m_css_cdo
stdex::parser::basic_css_cdc< _Elem > | m_css_cdc
stdex::parser::basic_css_comment< _Elem > | m_css_comment
stdex::parser::basic_css_string< _Elem > | m_css_string
stdex::parser::basic_css_uri< _Elem > | m_css_uri
stdex::parser::basic_css_import< _Elem > | m_css_import
stdex::parser::basic_any_cu< _Elem > | m_any_char

## Detailed Description

template<class _Elem, class _Traits, class _Alloc>
class stdex::html::parser< _Elem, _Traits, _Alloc >

HTML parser.

## Member Function Documentation

## append_inserted_tokens()

template<class _Elem , class _Traits , class _Alloc >

void stdex::html::parser< _Elem, _Traits, _Alloc >::append_inserted_tokens | ( | std::basic_string< _Elem, _Traits, _Alloc > & | source,
|  | inserted_token_list & | inserted_tokens,
|  | size_t | word_index,
|  | bool | after_word,
|  | token_list & | active_tokens
| ) |  |

inline

Adds matching inserted tokens before/after the given word in source code.

Parameters

  [in,out] | source | Source code
  [in,out] | inserted_tokens | List of tokens to insert. The tokens are removed from the list once inserted.
  [in] | word_index | Word index
  [in] | after_word | `false` if source code is before the word; `true` if after the word
  [in,out] | active_tokens | Stack of active tokens

## append_token() [1/2]

template<class _Elem , class _Traits , class _Alloc >
template<class T >

T * stdex::html::parser< _Elem, _Traits, _Alloc >::append_token | ( | std::unique_ptr< T > && | token | ) |

inlineprotected

Adds token to the collection.

Parameters

  [in] | token | Token

Returns
  Pointer to the token for non-owning references

## append_token() [2/2]

template<class _Elem , class _Traits , class _Alloc >
template<class T >

size_t stdex::html::parser< _Elem, _Traits, _Alloc >::append_token | ( | std::unique_ptr< T > && | token,
|  | std::basic_string< _Elem, _Traits, _Alloc > & | source
| ) |  |

inlineprotected

Adds token to the collection and appends its tag to the source code string.

Parameters

  [in] | token | Token
  [in,out] | source | Source code

Returns
  Number of code units appended to the source code

## end_tokens()

template<class _Elem , class _Traits , class _Alloc >

token_list::const_iterator stdex::html::parser< _Elem, _Traits, _Alloc >::end_tokens | ( | std::basic_string< _Elem, _Traits, _Alloc > & | source,
|  | token_list & | active_tokens,
|  | const token_list & | new_tokens
| ) |  |

inline

Pops ending tokens from the active token list and append their tags to the source code string.

Parameters

  [in,out] | source | Source code
  [in,out] | active_tokens | Stack of active tokens
  [in] | new_tokens | Desired stack of active tokens

Returns
  Position in `new_tokens` specifying where the cut was made

## link()

template<class _Elem , class _Traits , class _Alloc >

static void stdex::html::parser< _Elem, _Traits, _Alloc >::link | ( | std::basic_string< _Elem, _Traits, _Alloc > & | source,
|  | const text_token< _Elem, _Traits, _Alloc > * | t
| ) |  |

inlinestatic

Rebuilds HTML source code from the token tree.

Parameters

  [in,out] | source | String to append source code to
  [in] | t | Document root token

## merge()

template<class _Elem , class _Traits , class _Alloc >

static void stdex::html::parser< _Elem, _Traits, _Alloc >::merge | ( | token_list & | a,
|  | const token_list & | b
| ) |  |

inlinestatic

Adds tokens from list `b` to list `a` creating an union.

Parameters

  [in,out] | a | Token list to merge `b` into
  [in] | b | Token list to merge to `a`

## parse()

template<class _Elem , class _Traits , class _Alloc >

text_token< _Elem, _Traits, _Alloc > * stdex::html::parser< _Elem, _Traits, _Alloc >::parse | ( | const sequence_store::const_iterator & | end,
|  | uint32_t | text_type = `0`
| ) |  |

inlineprotected

Recursively parses HTML document.

Parameters

  [in] | end | Parse sequences on [`m_offset`, `end`) interval
  [in] | text_type | Text flags of the sequences being parsed

Returns
  Token represening sequences parsed

## start_tokens()

template<class _Elem , class _Traits , class _Alloc >

static void stdex::html::parser< _Elem, _Traits, _Alloc >::start_tokens | ( | std::basic_string< _Elem, _Traits, _Alloc > & | source,
|  | token_list & | active_tokens,
|  | const token_list & | new_tokens,
|  | token_list::const_iterator | from
| ) |  |

inlinestatic

Pushes tokens to the active token list and appends their tags to the source code string.

Parameters

  [in,out] | source | Source code
  [in,out] | active_tokens | Stack of active tokens
  [in] | new_tokens | New tokens to add
  [in] | from | Token from `new_tokens` to start adding at

The documentation for this class was generated from the following file:

- include/stdex/html.hpp