Tizen Native API
|
Functions | |
Eina_Bool | eina_simple_xml_parse (const char *buf, unsigned buflen, Eina_Bool strip, Eina_Simple_XML_Cb func, const void *data) |
Parses a section of the XML string text. | |
const char * | eina_simple_xml_tag_attributes_find (const char *buf, unsigned buflen) |
Finds where the attributes start from given the contents of a tag are provided. | |
Eina_Bool | eina_simple_xml_attributes_parse (const char *buf, unsigned buflen, Eina_Simple_XML_Attribute_Cb func, const void *data) |
Parses a buffer with XML attributes to key=value pairs. | |
Eina_Simple_XML_Attribute * | eina_simple_xml_attribute_new (Eina_Simple_XML_Node_Tag *parent, const char *key, const char *value) |
Creates (and appends) a new attribute to the tag. | |
void | eina_simple_xml_attribute_free (Eina_Simple_XML_Attribute *attr) |
Removes an attribute from the parent and deletes it. | |
Eina_Simple_XML_Node_Tag * | eina_simple_xml_node_tag_new (Eina_Simple_XML_Node_Tag *parent, const char *name) |
Creates a new tag. If parent is provided, it is automatically appended. | |
void | eina_simple_xml_node_tag_free (Eina_Simple_XML_Node_Tag *tag) |
Removes a tag from the parent and deletes it. | |
Eina_Simple_XML_Node_Data * | eina_simple_xml_node_data_new (Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length) |
Creates new data. If parent is provided, it is automatically appended. | |
void | eina_simple_xml_node_data_free (Eina_Simple_XML_Node_Data *node) |
Removes data from the parent and deletes it. | |
Eina_Simple_XML_Node_CData * | eina_simple_xml_node_cdata_new (Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length) |
Creates new cdata. If parent is provided, it is automatically appended. | |
void | eina_simple_xml_node_cdata_free (Eina_Simple_XML_Node_Data *node) |
Removes cdata from the parent and deletes it. | |
Eina_Simple_XML_Node_Doctype_Child * | eina_simple_xml_node_doctype_child_new (Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length) |
Creates a new doctype child. If parent is provided, it is automatically appended. | |
void | eina_simple_xml_node_doctype_child_free (Eina_Simple_XML_Node_Data *node) |
Removes the doctype child from the parent and deletes it. | |
Eina_Simple_XML_Node_Processing * | eina_simple_xml_node_processing_new (Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length) |
Creates new processing. If parent is provided, it is automatically appended. | |
void | eina_simple_xml_node_processing_free (Eina_Simple_XML_Node_Data *node) |
Removes processing from the parent and deletes it. | |
Eina_Simple_XML_Node_Doctype * | eina_simple_xml_node_doctype_new (Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length) |
Creates a new doctype. If parent is provided, it is automatically appended. | |
void | eina_simple_xml_node_doctype_free (Eina_Simple_XML_Node_Data *node) |
Removes the doctype from the parent and deletes it. | |
Eina_Simple_XML_Node_Comment * | eina_simple_xml_node_comment_new (Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length) |
Creates a new comment. If parent is provided, it is automatically appended. | |
void | eina_simple_xml_node_comment_free (Eina_Simple_XML_Node_Data *node) |
Removes a comment from the parent and deletes it. | |
Eina_Simple_XML_Node_Root * | eina_simple_xml_node_load (const char *buf, unsigned buflen, Eina_Bool strip) |
Loads an XML node tree based on the given string. | |
void | eina_simple_xml_node_root_free (Eina_Simple_XML_Node_Root *root) |
Frees the node tree built with eina_simple_xml_node_load(). | |
char * | eina_simple_xml_node_dump (Eina_Simple_XML_Node *node, const char *indent) |
Converts the node tree under the given element to an XML string. | |
Typedefs | |
typedef struct _Eina_Simple_XML_Node_Data | Eina_Simple_XML_Node_Doctype_Child |
This is a simplistic relaxed SAX-like XML parser.
This parser is far from being compliant with XML standards, but works for most XMLs out there. If you know that your format is simple and won't vary in the future with strange corner cases, then you can use it safely.
The parser is SAX like, that is, it tokenizes content and calls you back so that you can take some action. No content is allocated during this parser work and it's not recursive, so you can use it with a very large document without any issues.
It does not validate the document anyhow, neither does it create a tree hierarchy. That's up to you.
Accordingly to XML, open tags may contain attributes. This parser does not tokenize this. If you want you can use eina_simple_xml_tag_attributes_find() and then eina_simple_xml_attributes_parse().
typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Doctype_Child |
Enumeration for a simple XML type.
void eina_simple_xml_attribute_free | ( | Eina_Simple_XML_Attribute * | attr | ) |
Removes an attribute from the parent and deletes it.
[in] | attr | The attribute to release memory of |
Eina_Simple_XML_Attribute* eina_simple_xml_attribute_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | key, | ||
const char * | value | ||
) |
Creates (and appends) a new attribute to the tag.
[in] | parent | If provided, this is set in the resulting structure and the attribute is appended to the attributes list |
[in] | key | The null-terminated string Must not be NULL . |
[in] | value | The null-terminated string If NULL , the empty string is used. |
NULL
on error Eina_Bool eina_simple_xml_attributes_parse | ( | const char * | buf, |
unsigned | buflen, | ||
Eina_Simple_XML_Attribute_Cb | func, | ||
const void * | data | ||
) |
Parses a buffer with XML attributes to key=value pairs.
[in] | buf | The input string May not contain \0 terminator. |
[in] | buflen | The input string size |
[in] | func | The function to call back while parse does some action The first parameter is the given user data, the second is the key (null-terminated) and the last is the value (null terminated) These strings should not be modified and the reference is just valid till the function returns |
[in] | data | The data to pass to the callback function |
EINA_TRUE
on success, otherwise EINA_FALSE
if it is aborted by the user or a parsing error occurs void eina_simple_xml_node_cdata_free | ( | Eina_Simple_XML_Node_Data * | node | ) |
Removes cdata from the parent and deletes it.
[in] | node | The cdata to release memory of |
Eina_Simple_XML_Node_CData* eina_simple_xml_node_cdata_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | contents, | ||
size_t | length | ||
) |
Creates new cdata. If parent is provided, it is automatically appended.
[in] | parent | If provided, this is set in the resulting structure and the cdata is appended to the children list |
[in] | contents | The string to be used Must not be NULL . |
[in] | length | size in bytes of contents |
NULL
on error void eina_simple_xml_node_comment_free | ( | Eina_Simple_XML_Node_Data * | node | ) |
Removes a comment from the parent and deletes it.
[in] | node | The comment to release memory of |
Eina_Simple_XML_Node_Comment* eina_simple_xml_node_comment_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | contents, | ||
size_t | length | ||
) |
Creates a new comment. If parent is provided, it is automatically appended.
[in] | parent | If provided, this is set in the resulting structure and the comment is appended to the children list |
[in] | contents | The string to be used Must not be NULL . |
[in] | length | size in bytes of contents |
NULL
on error void eina_simple_xml_node_data_free | ( | Eina_Simple_XML_Node_Data * | node | ) |
Removes data from the parent and deletes it.
[in] | node | The data to release memory of |
Eina_Simple_XML_Node_Data* eina_simple_xml_node_data_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | contents, | ||
size_t | length | ||
) |
Creates new data. If parent is provided, it is automatically appended.
[in] | parent | If provided, this is set in the resulting structure and the data is appended to the children list |
[in] | contents | The string to be used Must not be NULL . |
[in] | length | size in bytes of contents |
NULL
on error void eina_simple_xml_node_doctype_child_free | ( | Eina_Simple_XML_Node_Data * | node | ) |
Removes the doctype child from the parent and deletes it.
[in] | node | The doctype child to release memory of |
Eina_Simple_XML_Node_Doctype_Child* eina_simple_xml_node_doctype_child_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | contents, | ||
size_t | length | ||
) |
Creates a new doctype child. If parent is provided, it is automatically appended.
[in] | parent | If provided, this is set in the resulting structure and the doctype child is appended to the children list |
[in] | contents | The string to be used Must not be NULL . |
[in] | length | size in bytes of contents |
NULL
on error void eina_simple_xml_node_doctype_free | ( | Eina_Simple_XML_Node_Data * | node | ) |
Removes the doctype from the parent and deletes it.
[in] | node | The doctype to release memory of |
Eina_Simple_XML_Node_Doctype* eina_simple_xml_node_doctype_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | contents, | ||
size_t | length | ||
) |
Creates a new doctype. If parent is provided, it is automatically appended.
[in] | parent | If provided, this is set in the resulting structure and the doctype is appended to the children list |
[in] | contents | The string to be used Must not be NULL . |
[in] | length | size in bytes of contents |
NULL
on error char* eina_simple_xml_node_dump | ( | Eina_Simple_XML_Node * | node, |
const char * | indent | ||
) |
Converts the node tree under the given element to an XML string.
[in] | node | The base node to convert |
[in] | indent | The indentation string, otherwise NULL to disable it |
NULL
on errors, otherwise a newly allocated string on success Eina_Simple_XML_Node_Root* eina_simple_xml_node_load | ( | const char * | buf, |
unsigned | buflen, | ||
Eina_Bool | strip | ||
) |
Loads an XML node tree based on the given string.
[in] | buf | The input string May not contain \0 terminator. |
[in] | buflen | The input string size |
[in] | strip | The boolean value that indicates when this parser should do strip leading and whitespace trailing |
NULL
on errors NULL
, we are going to do our best to avoid returning nothing. void eina_simple_xml_node_processing_free | ( | Eina_Simple_XML_Node_Data * | node | ) |
Removes processing from the parent and deletes it.
[in] | node | The processing to release memory of |
Eina_Simple_XML_Node_Processing* eina_simple_xml_node_processing_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | contents, | ||
size_t | length | ||
) |
Creates new processing. If parent is provided, it is automatically appended.
[in] | parent | If provided, this is set in the resulting structure and the processing is appended to the children list |
[in] | contents | The string to be used Must not be NULL . |
[in] | length | size in bytes of contents |
NULL
on error void eina_simple_xml_node_root_free | ( | Eina_Simple_XML_Node_Root * | root | ) |
Frees the node tree built with eina_simple_xml_node_load().
[in] | root | The memory returned by eina_simple_xml_node_load() |
void eina_simple_xml_node_tag_free | ( | Eina_Simple_XML_Node_Tag * | tag | ) |
Removes a tag from the parent and deletes it.
[in] | tag | The tag to release memory of |
Eina_Simple_XML_Node_Tag* eina_simple_xml_node_tag_new | ( | Eina_Simple_XML_Node_Tag * | parent, |
const char * | name | ||
) |
Creates a new tag. If parent is provided, it is automatically appended.
[in] | parent | If provided, this is set in the resulting structure and the tag is appended to the children list |
[in] | name | The null-terminated string Must not be NULL . |
NULL
on error Eina_Bool eina_simple_xml_parse | ( | const char * | buf, |
unsigned | buflen, | ||
Eina_Bool | strip, | ||
Eina_Simple_XML_Cb | func, | ||
const void * | data | ||
) |
Parses a section of the XML string text.
[in] | buf | The input string May not contain the \0 terminator. |
[in] | buflen | The input string size |
[in] | strip | The boolean value that indicates when this parser should do strip leading and whitespace trailing This whitespace is still issued, but as type EINA_SIMPLE_XML_IGNORED. |
[in] | func | The function to call back while parse does some action The first parameter is the given user data, the second is the token type, the third is the pointer to the content's start (it's not a NULL terminated string), the fourth is where this content is located, that is buf (does not include tag start, for instance "<!DOCTYPE value>" the offset points at "value"), the fifth is the size of the content Whenever this function returns EINA_FALSE the parser aborts. |
[in] | data | The data to give as context to func |
EINA_TRUE
on success, otherwise EINA_FALSE
if it is aborted by the user or a parsing error occurs const char* eina_simple_xml_tag_attributes_find | ( | const char * | buf, |
unsigned | buflen | ||
) |
Finds where the attributes start from given the contents of a tag are provided.
[in] | buf | The input string May not contain \0 terminator. |
[in] | buflen | The input string size |
NULL
is returned if no attributes are found.