Hubbub
|
#include <stdbool.h>
#include <inttypes.h>
#include <hubbub/errors.h>
#include <hubbub/functypes.h>
#include <hubbub/tree.h>
#include <hubbub/types.h>
Go to the source code of this file.
Data Structures | |
union | hubbub_parser_optparams |
Hubbub parser option parameters. More... | |
Typedefs | |
typedef struct hubbub_parser | hubbub_parser |
typedef enum hubbub_parser_opttype | hubbub_parser_opttype |
Hubbub parser option types. More... | |
typedef union hubbub_parser_optparams | hubbub_parser_optparams |
Hubbub parser option parameters. More... | |
Enumerations | |
enum | hubbub_parser_opttype { HUBBUB_PARSER_TOKEN_HANDLER, HUBBUB_PARSER_ERROR_HANDLER, HUBBUB_PARSER_CONTENT_MODEL, HUBBUB_PARSER_TREE_HANDLER, HUBBUB_PARSER_DOCUMENT_NODE, HUBBUB_PARSER_ENABLE_SCRIPTING, HUBBUB_PARSER_PAUSE } |
Hubbub parser option types. More... | |
Functions | |
hubbub_error | hubbub_parser_create (const char *enc, bool fix_enc, hubbub_parser **parser) |
Create a hubbub parser. More... | |
hubbub_error | hubbub_parser_destroy (hubbub_parser *parser) |
Destroy a hubbub parser. More... | |
hubbub_error | hubbub_parser_setopt (hubbub_parser *parser, hubbub_parser_opttype type, hubbub_parser_optparams *params) |
Configure a hubbub parser. More... | |
hubbub_error | hubbub_parser_parse_chunk (hubbub_parser *parser, const uint8_t *data, size_t len) |
Pass a chunk of data to a hubbub parser for parsing. More... | |
hubbub_error | hubbub_parser_insert_chunk (hubbub_parser *parser, const uint8_t *data, size_t len) |
Insert a chunk of data into a hubbub parser input stream. More... | |
hubbub_error | hubbub_parser_completed (hubbub_parser *parser) |
Inform the parser that the last chunk of data has been parsed. More... | |
const char * | hubbub_parser_read_charset (hubbub_parser *parser, hubbub_charset_source *source) |
Read the document charset. More... | |
typedef struct hubbub_parser hubbub_parser |
typedef union hubbub_parser_optparams hubbub_parser_optparams |
Hubbub parser option parameters.
typedef enum hubbub_parser_opttype hubbub_parser_opttype |
Hubbub parser option types.
hubbub_error hubbub_parser_completed | ( | hubbub_parser * | parser | ) |
Inform the parser that the last chunk of data has been parsed.
parser | Parser to inform |
Definition at line 279 of file parser.c.
References HUBBUB_BADPARM, hubbub_error_from_parserutils_error(), HUBBUB_OK, hubbub_tokeniser_run(), hubbub_parser::stream, and hubbub_parser::tok.
hubbub_error hubbub_parser_create | ( | const char * | enc, |
bool | fix_enc, | ||
hubbub_parser ** | parser | ||
) |
Create a hubbub parser.
enc | Source document encoding, or NULL to autodetect |
fix_enc | Permit fixing up of encoding if it's frequently misused |
parser | Pointer to location to receive parser instance |
Definition at line 41 of file parser.c.
References HUBBUB_BADPARM, HUBBUB_CHARSET_CONFIDENT, hubbub_charset_extract(), hubbub_charset_fix_charset(), HUBBUB_CHARSET_UNKNOWN, hubbub_error_from_parserutils_error(), HUBBUB_NOMEM, HUBBUB_OK, hubbub_tokeniser_create(), hubbub_tokeniser_destroy(), hubbub_treebuilder_create(), hubbub_parser::stream, hubbub_parser::tb, and hubbub_parser::tok.
hubbub_error hubbub_parser_destroy | ( | hubbub_parser * | parser | ) |
Destroy a hubbub parser.
parser | Parser instance to destroy |
Definition at line 102 of file parser.c.
References HUBBUB_BADPARM, HUBBUB_OK, hubbub_tokeniser_destroy(), hubbub_treebuilder_destroy(), hubbub_parser::stream, hubbub_parser::tb, and hubbub_parser::tok.
hubbub_error hubbub_parser_insert_chunk | ( | hubbub_parser * | parser, |
const uint8_t * | data, | ||
size_t | len | ||
) |
Insert a chunk of data into a hubbub parser input stream.
This data is encoded in the input charset
Inserts the given data into the input stream ready for parsing but does not cause any additional processing of the input. This is useful to allow hubbub callbacks to add computed data to the input.
parser | Parser instance to use |
data | Data to parse (encoded in the input charset) |
len | Length, in bytes, of data |
Inserts the given data into the input stream ready for parsing but does not cause any additional processing of the input. This is useful to allow hubbub callbacks to add computed data to the input.
parser | Parser instance to use |
data | Data to parse (encoded in UTF-8) |
len | Length, in bytes, of data |
Definition at line 218 of file parser.c.
References HUBBUB_BADPARM, hubbub_tokeniser_insert_chunk(), and hubbub_parser::tok.
hubbub_error hubbub_parser_parse_chunk | ( | hubbub_parser * | parser, |
const uint8_t * | data, | ||
size_t | len | ||
) |
Pass a chunk of data to a hubbub parser for parsing.
parser | Parser instance to use |
data | Data to parse (encoded in the input charset) |
len | Length, in bytes, of data |
Definition at line 235 of file parser.c.
References HUBBUB_BADENCODING, HUBBUB_BADPARM, HUBBUB_CHARSET_TENTATIVE, hubbub_error_from_parserutils_error(), HUBBUB_OK, hubbub_tokeniser_run(), hubbub_parser::stream, and hubbub_parser::tok.
const char* hubbub_parser_read_charset | ( | hubbub_parser * | parser, |
hubbub_charset_source * | source | ||
) |
Read the document charset.
parser | Parser instance to query |
source | Pointer to location to receive charset source |
Definition at line 305 of file parser.c.
References name, and hubbub_parser::stream.
hubbub_error hubbub_parser_setopt | ( | hubbub_parser * | parser, |
hubbub_parser_opttype | type, | ||
hubbub_parser_optparams * | params | ||
) |
Configure a hubbub parser.
parser | Parser instance to configure |
type | Option to set |
params | Option-specific parameters |
Definition at line 126 of file parser.c.
References HUBBUB_BADPARM, HUBBUB_INVALID, HUBBUB_OK, HUBBUB_PARSER_CONTENT_MODEL, HUBBUB_PARSER_DOCUMENT_NODE, HUBBUB_PARSER_ENABLE_SCRIPTING, HUBBUB_PARSER_ERROR_HANDLER, HUBBUB_PARSER_PAUSE, HUBBUB_PARSER_TOKEN_HANDLER, HUBBUB_PARSER_TREE_HANDLER, HUBBUB_TOKENISER_CONTENT_MODEL, HUBBUB_TOKENISER_ERROR_HANDLER, HUBBUB_TOKENISER_PAUSE, hubbub_tokeniser_setopt(), HUBBUB_TOKENISER_TOKEN_HANDLER, hubbub_treebuilder_destroy(), HUBBUB_TREEBUILDER_DOCUMENT_NODE, HUBBUB_TREEBUILDER_ENABLE_SCRIPTING, HUBBUB_TREEBUILDER_ERROR_HANDLER, hubbub_treebuilder_setopt(), HUBBUB_TREEBUILDER_TREE_HANDLER, hubbub_parser::tb, and hubbub_parser::tok.