|
typedef struct _tag_sax_parser | GF_SAXParser |
|
typedef void(* | gf_xml_sax_node_start) (void *sax_cbck, const char *node_name, const char *name_space, const GF_XMLAttribute *attributes, u32 nb_attributes) |
|
typedef void(* | gf_xml_sax_node_end) (void *sax_cbck, const char *node_name, const char *name_space) |
|
typedef void(* | gf_xml_sax_text_content) (void *sax_cbck, const char *content, Bool is_cdata) |
|
typedef void(* | gf_xml_sax_progress) (void *cbck, u64 done, u64 total) |
|
|
GF_SAXParser * | gf_xml_sax_new (gf_xml_sax_node_start on_node_start, gf_xml_sax_node_end on_node_end, gf_xml_sax_text_content on_text_content, void *cbck) |
|
void | gf_xml_sax_del (GF_SAXParser *parser) |
|
GF_Err | gf_xml_sax_init (GF_SAXParser *parser, unsigned char *BOM) |
|
GF_Err | gf_xml_sax_parse (GF_SAXParser *parser, const void *string_bytes) |
|
GF_Err | gf_xml_sax_suspend (GF_SAXParser *parser, Bool do_suspend) |
|
GF_Err | gf_xml_sax_parse_file (GF_SAXParser *parser, const char *fileName, gf_xml_sax_progress OnProgress) |
|
u32 | gf_xml_sax_get_line (GF_SAXParser *parser) |
|
char * | gf_xml_sax_peek_node (GF_SAXParser *parser, char *att_name, char *att_value, char *substitute, char *get_attr, char *end_pattern, Bool *is_substitute) |
|
Bool | gf_xml_sax_binary_file (GF_SAXParser *parser) |
|
const char * | gf_xml_sax_get_error (GF_SAXParser *parser) |
|
char * | gf_xml_get_root_type (const char *file, GF_Err *ret_code) |
|
u32 | gf_xml_sax_get_node_start_pos (GF_SAXParser *parser) |
|
u32 | gf_xml_sax_get_node_end_pos (GF_SAXParser *parser) |
|
! SAX XML Parser API
GPAC can do progressive loading of XML document using this SAX api.
◆ GF_SAXParser
◆ gf_xml_sax_node_start
typedef void(* gf_xml_sax_node_start) (void *sax_cbck, const char *node_name, const char *name_space, const GF_XMLAttribute *attributes, u32 nb_attributes) |
SAX XML node start callback
- Parameters
-
sax_cbck | user data passed durinc creation of SAX parser |
node_name | name of the XML node starting |
name_space | namespace of the XML node starting |
attributes | array of attributes declared for that XML node |
nb_attributes | number of items in array |
◆ gf_xml_sax_node_end
typedef void(* gf_xml_sax_node_end) (void *sax_cbck, const char *node_name, const char *name_space) |
SAX XML node end callback
- Parameters
-
sax_cbck | user data passed durinc creation of SAX parser |
node_name | name of the XML node starting |
name_space | namespace of the XML node starting |
◆ gf_xml_sax_text_content
typedef void(* gf_xml_sax_text_content) (void *sax_cbck, const char *content, Bool is_cdata) |
SAX text content callback
- Parameters
-
sax_cbck | user data passed durinc creation of SAX parser |
content | text content of the node |
is_cdata | if TRUE the content was ancapsulated in CDATA; otherwise this isthe content of a text node |
◆ gf_xml_sax_progress
typedef void(* gf_xml_sax_progress) (void *cbck, u64 done, u64 total) |
SAX progress callback
- Parameters
-
cbck | user data passed durinc creation of SAX parser |
done | amount of bytes parsed from the file |
total | total number of bytes in the file |
◆ gf_xml_sax_new()
creates new sax parser - all callbacks are optionals
- Parameters
-
on_node_start | callback for XML node start |
on_node_end | callback for XML node end |
on_text_content | callback for text content |
cbck | user data passed to callback functions |
- Returns
- a SAX parser object
◆ gf_xml_sax_del()
destroys sax parser
- Parameters
-
parser | the SAX parser to destroy |
◆ gf_xml_sax_init()
Inits the parser with string containing BOM, if any. BOM must be 4 char string with 0 terminaison. If BOM is NULL, parsing will assume UTF-8 compatible coding
- Parameters
-
parser | the SAX parser to init |
BOM | the 4 character with 0 terminaison BOM or NULL |
- Returns
- error code if any
◆ gf_xml_sax_parse()
Parses input string data. string data MUST be terminated by the 0 character (eg 2 0s for UTF-16)
- Parameters
-
parser | the SAX parser to use |
string_bytes | the string to parse |
- Returns
- error code if any
◆ gf_xml_sax_suspend()
Suspends or resumes SAX parsing. When resuming on file, the function will run until suspended/end of file/error When resuming on steram, the function will simply return
- Parameters
-
parser | the SAX parser to use |
do_suspend | if GF_TRUE, SAX parsing is suspended, otherwise SAX parsing is resumed |
- Returns
- error code if any
◆ gf_xml_sax_parse_file()
parses file (potentially gzipped). OnProgress is optional, used to get progress callback
- Parameters
-
parser | the SAX parser to use |
fileName | the file to parse |
OnProgress | the progress function to use. The callback for the progress function is the one assigned at SAX parser creation gf_xml_sax_new |
- Returns
- error code if any
◆ gf_xml_sax_get_line()
Gets current line number, useful for inspecting errors
- Parameters
-
parser | the SAX parser to use |
- Returns
- current line number of SAX parser
◆ gf_xml_sax_peek_node()
char* gf_xml_sax_peek_node |
( |
GF_SAXParser * |
parser, |
|
|
char * |
att_name, |
|
|
char * |
att_value, |
|
|
char * |
substitute, |
|
|
char * |
get_attr, |
|
|
char * |
end_pattern, |
|
|
Bool * |
is_substitute |
|
) |
| |
Peeks a node forward in the file. This may be used to pick the attribute of the first node found matching a given (attributeName, attributeValue) couple
- Parameters
-
parser | SAX parser to use |
att_name | attribute name to look for |
att_value | value for this attribute |
substitute | gives the name of an additional XML node type to inspect to match the node. May be NULL. |
get_attr | gives the name of the attribute in the substitute node that matches the condition. If substitue node with name atribute is found, the content of the name attribute is returned. May be NULL. |
end_pattern | gives a string indicating where to stop looking in the document. May be NULL. |
is_substitute | is set to GF_TRUE if the return value corresponds to the content of the name attribute of the substitute element |
- Returns
- name of the XML node found, or NULL if no match. This string has to be freed by the caller using gf_free
◆ gf_xml_sax_binary_file()
For file mode only, indicates if a file is compressed or not
- Parameters
-
- Returns
- 1 if file is compressed, 0 otherwise
◆ gf_xml_sax_get_error()
Returns the last error found during parsing
- Parameters
-
- Returns
- the last SAX error encountered
◆ gf_xml_get_root_type()
char* gf_xml_get_root_type |
( |
const char * |
file, |
|
|
GF_Err * |
ret_code |
|
) |
| |
Returns the name of the root XML element
- Parameters
-
file | the XML file to inspect |
ret_code | return error code if any |
- Returns
- the name of the root XML element. This string has to be freed by the caller using gf_free
◆ gf_xml_sax_get_node_start_pos()
Returns the position in bytes of the start of the current node being parsed. The byte offset points to the first < character in the opening tag.
- Parameters
-
- Returns
- the 0-based position of the current XML node
◆ gf_xml_sax_get_node_end_pos()
Returns the position in bytes of the end of the current node being parsed. The byte offset points to the last > character in the closing tag.
- Parameters
-
- Returns
- the 0-based position of the current XML node