| GSF Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Properties | ||||
GsfXMLIn; GsfXMLInDoc; gboolean (*GsfXMLInUnknownFunc) (GsfXMLIn *xin,xmlChar const *elem,xmlChar const **attrs); GsfXMLInNS; GsfXMLInNode; void (*GsfXMLInExtDtor) (GsfXMLIn *xin,gpointer old_state); enum GsfXMLContent; GsfXMLBlob; GsfInputHTTP; gboolean (*GsfXMLProbeFunc) (const xmlChar *name,const xmlChar *prefix,const xmlChar *URI,int nb_namespaces,const xmlChar **namespaces,int nb_attributes,int nb_defaulted,const xmlChar **attributes); #define GSF_XML_IN_NODE_FULL (parent_id, id, ns, name, has_content, share_children_with_parent, check_ns, start, end, user) #define GSF_XML_IN_NODE (parent_id, id, ns, name, has_content, start, end) #define GSF_XML_IN_NODE_END #define GSF_XML_IN_NS (id, uri) #define GSF_XML_IN_NS_END GsfXMLInDoc * gsf_xml_in_doc_new (GsfXMLInNode const *nodes,GsfXMLInNS const *ns); void gsf_xml_in_doc_free (GsfXMLInDoc *doc); void gsf_xml_in_doc_add_nodes (GsfXMLInDoc *doc,GsfXMLInNode const *nodes); gboolean gsf_xml_in_doc_parse (GsfXMLInDoc *doc,GsfInput *input,gpointer user_state); void gsf_xml_in_doc_set_unknown_handler (GsfXMLInDoc *doc,GsfXMLInUnknownFunc handler); void gsf_xml_in_push_state (GsfXMLIn *xin,GsfXMLInDoc const *doc,gpointer new_state,GsfXMLInExtDtor dtor,xmlChar const **attrs); gboolean gsf_xml_in_namecmp (GsfXMLIn const *xin,char const *str,unsigned int ns_id,char const *name); char const * gsf_xml_in_check_ns (GsfXMLIn const *xin,char const *str,unsigned int ns_id); GsfInput * gsf_xml_in_get_input (GsfXMLIn const *xin); gboolean gsf_xml_probe (GsfInput *input,GsfXMLProbeFunc func); GsfXMLOut; GsfXMLOut * gsf_xml_out_new (GsfOutput *output); void gsf_xml_out_set_doc_type (GsfXMLOut *xout,char const *type); GsfOutput * gsf_xml_out_get_output (GsfXMLOut const *xout); void gsf_xml_out_start_element (GsfXMLOut *xout,char const *id); char const * gsf_xml_out_end_element (GsfXMLOut *xout); void gsf_xml_out_add_cstr (GsfXMLOut *xout,char const *id,char const *val_utf8); void gsf_xml_out_add_cstr_unchecked (GsfXMLOut *xout,char const *id,char const *val_utf8); void gsf_xml_out_add_bool (GsfXMLOut *xout,char const *id,gboolean val); void gsf_xml_out_add_int (GsfXMLOut *xout,char const *id,int val); void gsf_xml_out_add_uint (GsfXMLOut *xout,char const *id,unsigned int val); void gsf_xml_out_add_float (GsfXMLOut *xout,char const *id,double val,int precision); void gsf_xml_out_add_enum (GsfXMLOut *xout,char const *id,GType etype,gint val); void gsf_xml_out_add_color (GsfXMLOut *xout,char const *id,unsigned int r,unsigned int g,unsigned int b); void gsf_xml_out_add_base64 (GsfXMLOut *xout,char const *id,guint8 const *data,unsigned int len); void gsf_xml_out_add_gvalue (GsfXMLOut *xout,char const *id,GValue const *val); void gsf_xml_out_simple_element (GsfXMLOut *xout,char const *id,char const *content); void gsf_xml_out_simple_float_element (GsfXMLOut *xout,char const *id,double val,int precision); void gsf_xml_out_simple_int_element (GsfXMLOut *xout,char const *id,int val); gchar * gsf_input_http_get_content_type (GsfInputHTTP *input); GType gsf_input_http_get_type (void); gchar * gsf_input_http_get_url (GsfInputHTTP *input); xmlParserCtxt * gsf_xml_parser_context (GsfInput *input); gboolean gsf_xml_gvalue_from_str (GValue *res,GType t,char const *str); int gsf_xmlDocFormatDump (GsfOutput *output,xmlDoc *cur,char const *encoding,gboolean format);
typedef struct {
/* public state : read only */
gpointer user_state;
GString *content;
GsfXMLInDoc const *doc;
GsfXMLInNode const *node; /* current node (not on the stack) */
} GsfXMLIn;
| user data | |
| the current node content | |
GsfXMLInDoc const * |
GsfXMLInDoc |
GsfXMLInNode const * |
current node (not on the stack) |
gboolean (*GsfXMLInUnknownFunc) (GsfXMLIn *xin,xmlChar const *elem,xmlChar const **attrs);
typedef struct {
char const *id; /* unique in the entire tree */
int ns_id;
char const *name;
char const *parent_id;
void (*start) (GsfXMLIn *xin, xmlChar const **attrs);
void (*end) (GsfXMLIn *xin, GsfXMLBlob *unknown);
union {
int v_int;
gboolean v_bool;
gpointer v_blob;
char const *v_str;
} user_data;
GsfXMLContent has_content;
unsigned int check_children_for_ns : 1;
unsigned int share_children_with_parent : 1;
} GsfXMLInNode;
| identifier unique in the entire tree | |
| namespace identifier | |
| node name | |
| parent node identifier | |
| callback for the node opening | |
| callback for node end | |
GsfXMLContent |
whether the node has content |
| whetehr to check namespace for children | |
| whether to share children with parent. |
typedef enum {
GSF_XML_NO_CONTENT = FALSE,
GSF_XML_CONTENT,
GSF_XML_SHARED_CONTENT
} GsfXMLContent;
Controls the handling of character data within a parser node.
gboolean (*GsfXMLProbeFunc) (const xmlChar *name,const xmlChar *prefix,const xmlChar *URI,int nb_namespaces,const xmlChar **namespaces,int nb_attributes,int nb_defaulted,const xmlChar **attributes);
#define GSF_XML_IN_NODE_FULL(parent_id, id, ns, name, has_content, \
share_children_with_parent, check_ns, start, end, user)
GsfXMLInDoc * gsf_xml_in_doc_new (GsfXMLInNode const *nodes,GsfXMLInNS const *ns);
Combine the nodes in the NULL terminated array starting at nodes with the
name spaces in the NULL terminated array starting at ns. Prepare the
data structures necessary to validate a doument based on that description.
|
an array of node descriptors |
|
an array of namespace identifiers |
Returns : |
NULL on error |
void gsf_xml_in_doc_free (GsfXMLInDoc *doc);
Free up resources
|
GsfXMLInDoc |
void gsf_xml_in_doc_add_nodes (GsfXMLInDoc *doc,GsfXMLInNode const *nodes);
Adds additional nodes to the structure of doc
|
GsfXMLInDoc |
|
NULL terminated array of GsfXMLInNode
|
gboolean gsf_xml_in_doc_parse (GsfXMLInDoc *doc,GsfInput *input,gpointer user_state);
Read an xml document from input and parse based on the the descriptor in
doc
|
GsfXMLInDoc |
|
GsfInput |
|
arbitrary content stored in the parser |
Returns : |
FALSE on error |
void gsf_xml_in_doc_set_unknown_handler (GsfXMLInDoc *doc,GsfXMLInUnknownFunc handler);
Call the function handler when an unexpected child node is found
|
GsfXMLInDoc |
|
The function to call. [scope call] |
void gsf_xml_in_push_state (GsfXMLIn *xin,GsfXMLInDoc const *doc,gpointer new_state,GsfXMLInExtDtor dtor,xmlChar const **attrs);
Take the first node from doc as the current node and call its start handler.
|
GsfXMLIn |
|
GsfXMLInDoc |
|
arbitrary content for the parser |
|
GsfXMLInExtDtor. [scope call] |
|
array of xmlChar const * |
gboolean gsf_xml_in_namecmp (GsfXMLIn const *xin,char const *str,unsigned int ns_id,char const *name);
Checks to see if str is the same as ns_id::name with either an explicit
namespace or the current default namespace.
|
The GsfXMLIn we are reading from. |
|
The potentially namespace qualified node name. |
|
The name space id to check |
|
The target node name |
Returns : |
TRUE if str == ns_id:name according to state. |
char const * gsf_xml_in_check_ns (GsfXMLIn const *xin,char const *str,unsigned int ns_id);
According to state is str in the namespace ns_id ?
|
GsfXMLIn |
|
string to check |
|
the namespace id |
Returns : |
a pointer to str after the namespace if
successful, otherwise NULL. [transfer none]
|
GsfInput * gsf_xml_in_get_input (GsfXMLIn const *xin);
(New in 1.14.2)
|
GsfXMLIn |
Returns : |
(but does not reference) the stream being parsed. [transfer none] |
gboolean gsf_xml_probe (GsfInput *input,GsfXMLProbeFunc func);
|
GsfInput |
|
GsfXMLProbeFunc. [scope call] |
Returns : |
TRUE on success. |
void gsf_xml_out_set_doc_type (GsfXMLOut *xout,char const *type);
Store some optional some <!DOCTYPE .. > content
|
GsfXMLOut |
|
the document type declaration |
GsfOutput * gsf_xml_out_get_output (GsfXMLOut const *xout);
Get the GsfInput we are parsing from.
void gsf_xml_out_start_element (GsfXMLOut *xout,char const *id);
Output a start element id, if necessary preceeded by an XML declaration.
|
GsfXMLOut |
|
Element name |
char const * gsf_xml_out_end_element (GsfXMLOut *xout);
Closes/ends an XML element.
|
GsfXMLOut |
Returns : |
the element that has been closed. [transfer none] |
void gsf_xml_out_add_cstr (GsfXMLOut *xout,char const *id,char const *val_utf8);
dump val_utf8 to an attribute named id or as the nodes content escaping
characters as necessary. If val_utf8 is NULL do nothing (no warning, no
output)
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
a utf8 encoded string. [allow-none] |
void gsf_xml_out_add_cstr_unchecked (GsfXMLOut *xout,char const *id,char const *val_utf8);
dump val_utf8 to an attribute named id without checking to see if
the content needs escaping. A useful performance enhancement when
the application knows that structure of the content well. If
val_utf8 is NULL do nothing (no warning, no output)
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
a utf8 encoded string to export. [allow-none] |
void gsf_xml_out_add_bool (GsfXMLOut *xout,char const *id,gboolean val);
dump boolean value val to an attribute named id or as the nodes content
Use '1' or '0' to simplify import
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
a boolean |
void gsf_xml_out_add_int (GsfXMLOut *xout,char const *id,int val);
dump integer value val to an attribute named id or as the nodes content
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
the value |
void gsf_xml_out_add_uint (GsfXMLOut *xout,char const *id,unsigned int val);
dump unsigned integer value val to an attribute named id or as the nodes
content
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
the value |
void gsf_xml_out_add_float (GsfXMLOut *xout,char const *id,double val,int precision);
dump float value val to an attribute named id or as the nodes
content with precision precision. The number will be formattted
according to the "C" locale.
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
the value |
|
the number of significant digits to use, -1 meaning "enough". |
void gsf_xml_out_add_enum (GsfXMLOut *xout,char const *id,GType etype,gint val);
Output the name of value val of enumeration type etype.
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
GType |
|
enum element number |
void gsf_xml_out_add_color (GsfXMLOut *xout,char const *id,unsigned int r,unsigned int g,unsigned int b);
dump Color r.g.b to an attribute named id or as the nodes content
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
Red value |
|
Green value |
|
Blue value |
void gsf_xml_out_add_base64 (GsfXMLOut *xout,char const *id,guint8 const *data,unsigned int len);
Dump len bytes in data into the content of node id using base64
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
Data to be written |
|
Length of data |
void gsf_xml_out_add_gvalue (GsfXMLOut *xout,char const *id,GValue const *val);
Output the value of val as a string. Does NOT store any type information
with the string, just thevalue.
|
GsfXMLOut |
|
tag id or NULL for content. [allow-none]
|
|
GValue |
void gsf_xml_out_simple_element (GsfXMLOut *xout,char const *id,char const *content);
Convenience routine to output a simple id element with content content.
|
GsfXMLOut |
|
Element name |
|
Content of the element |
void gsf_xml_out_simple_float_element (GsfXMLOut *xout,char const *id,double val,int precision);
Convenience routine to output an element id with float value val using
precision significant digits.
|
GsfXMLOut |
|
Element name |
|
Element value |
|
the number of significant digits to use, -1 meaning "enough". |
void gsf_xml_out_simple_int_element (GsfXMLOut *xout,char const *id,int val);
Convenience routine to output an element id with integer value val.
|
GsfXMLOut |
|
Element name |
|
Element value |
gchar * gsf_input_http_get_content_type (GsfInputHTTP *input);
|
GsfInputHTTP |
Returns : |
an allocated string containing the Content-Type field of the HTTP response. |
gchar * gsf_input_http_get_url (GsfInputHTTP *input);
|
GsfInputHTTP |
Returns : |
an allocated string containing the URL used for input. |
xmlParserCtxt * gsf_xml_parser_context (GsfInput *input);
Create a libxml2 pull style parser context wrapper around gsf input input.
This signature will probably change to supply a SAX structure.
input.
NOTE: skipped since xmlParserCtxt is not exported to introspection.
|
GsfInput |
Returns : |
A parser context or NULL
|
gboolean gsf_xml_gvalue_from_str (GValue *res,GType t,char const *str);
Try to parse str as a value of type t into res.
|
Result value |
|
Type of data |
|
Value string |
Returns : |
True when parsing of str as a value of type t was succesfull;
false otherwise. |
int gsf_xmlDocFormatDump (GsfOutput *output,xmlDoc *cur,char const *encoding,gboolean format);
Dumps the document cur into output.
|
GsfOutput |
|
xmlDocPtr |
|
The encoding to use. [allow-none] |
|
TRUE to reformat the output. |
Returns : |
status from xmlSaveFormatFileTo. |