Top |
Object Hierarchy
GObject ╰── GDataParsable ├── GDataEntry ├── GDataAPPCategories ├── GDataAuthor ├── GDataFeed ├── GDataCategory ├── GDataDocumentsMetadata ├── GDataGContactCalendar ├── GDataGContactEvent ├── GDataGContactExternalID ├── GDataGContactJot ├── GDataGContactLanguage ├── GDataGContactRelation ├── GDataGContactWebsite ├── GDataGDEmailAddress ├── GDataGDIMAddress ├── GDataGDName ├── GDataGDOrganization ├── GDataGDPhoneNumber ├── GDataGDPostalAddress ├── GDataGDReminder ├── GDataGDWhen ├── GDataGDWhere ├── GDataGDWho ├── GDataGenerator ├── GDataLink ├── GDataMediaCategory ├── GDataMediaContent ├── GDataMediaCredit ├── GDataMediaThumbnail ╰── GDataYouTubeState
Description
GDataParsable is an abstract class allowing easy implementation of an extensible parser. It is primarily extended by GDataFeed and GDataEntry, both of which require XML parsing which can be extended by subclassing.
It allows methods to be defined for handling the root XML node, each of its child nodes, and a method to be called after parsing is complete.
Functions
gdata_parsable_get_content_type ()
const gchar *
gdata_parsable_get_content_type (GDataParsable *self
);
Returns the content type upon which the GDataParsable is built. For example, application/atom+xml
or application/json
.
Since: 0.17.7
gdata_parsable_new_from_xml ()
GDataParsable * gdata_parsable_new_from_xml (GType parsable_type
,const gchar *xml
,gint length
,GError **error
);
Creates a new GDataParsable subclass (of the given parsable_type
) from the given xml
.
An object of the given parsable_type
is created, and its pre_parse_xml
, parse_xml
and
post_parse_xml
class functions called on the XML tree obtained from xml
. pre_parse_xml
and
post_parse_xml
are called once each on the root node of the tree, while parse_xml
is called for
each of the child nodes of the root node.
If length
is -1, xml
will be assumed to be null-terminated.
If an error occurs during parsing, a suitable error from GDataParserError will be returned.
Since: 0.4.0
gdata_parsable_get_xml ()
gchar *
gdata_parsable_get_xml (GDataParsable *self
);
Builds an XML representation of the GDataParsable in its current state, such that it could be inserted on the server. The XML is guaranteed to have all its namespaces declared properly in a self-contained fashion, and is valid for stand-alone use.
Since: 0.4.0
gdata_parsable_new_from_json ()
GDataParsable * gdata_parsable_new_from_json (GType parsable_type
,const gchar *json
,gint length
,GError **error
);
Creates a new GDataParsable subclass (of the given parsable_type
) from the given json
.
An object of the given parsable_type
is created, and its parse_json
and
post_parse_json
class functions called on the JSON node obtained from json
.
post_parse_json
is called once on the root node, while parse_json
is called for
each of the node's members.
If length
is -1, json
will be assumed to be nul-terminated.
If an error occurs during parsing, a suitable error from GDataParserError will be returned.
Since: 0.15.0
gdata_parsable_get_json ()
gchar *
gdata_parsable_get_json (GDataParsable *self
);
Builds a JSON representation of the GDataParsable in its current state, such that it could be inserted on the server. The JSON is valid for stand-alone use.
Since: 0.15.0
Types and Values
GDataParsable
typedef struct _GDataParsable GDataParsable;
All the fields in the GDataParsable structure are private and should never be accessed directly.
Since: 0.3.0
GDataParsableClass
typedef struct { GObjectClass parent; gboolean (*pre_parse_xml) (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error); gboolean (*parse_xml) (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error); gboolean (*post_parse_xml) (GDataParsable *parsable, gpointer user_data, GError **error); void (*pre_get_xml) (GDataParsable *parsable, GString *xml_string); void (*get_xml) (GDataParsable *parsable, GString *xml_string); void (*get_namespaces) (GDataParsable *parsable, GHashTable *namespaces); gboolean (*parse_json) (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error); gboolean (*post_parse_json) (GDataParsable *parsable, gpointer user_data, GError **error); void (*get_json) (GDataParsable *parsable, JsonBuilder *builder); const gchar *(*get_content_type) (void); const gchar *element_name; const gchar *element_namespace; } GDataParsableClass;
The class structure for the GDataParsable class. Note that JSON and XML functions are mutually exclusive: a given implementation of GDataParsable is represented as exactly one of JSON and XML.
Members
GObjectClass |
the parent class |
|
a function called before parsing of an XML tree is started, which allows properties from the root node to be extracted
and used in |
||
a function to parse an XML representation of the GDataParsable to set the properties of the |
||
a function called after parsing an XML tree, to allow the |
||
a function called before building the XML representation of the children of the GDataParsable, which allows attributes of the root
XML node to be added to |
||
a function to build an XML representation of the GDataParsable in its current state, appending it to the provided GString |
||
a function to return a string containing the namespace declarations used by the |
||
a function to parse a JSON representation of the GDataParsable to set the properties of the |
||
a function called after parsing a JSON object, to allow the |
||
a function to build a JSON representation of the GDataParsable in its current state, appending it to the provided JsonBuilder |
||
a function which returns content type upon which is GDataParsable built |
||
const gchar * |
the name of the XML element which represents this parsable |
|
const gchar * |
the prefix of the XML namespace used for the parsable |
Since: 0.3.0