Top | ![]() |
![]() |
![]() |
![]() |
GObject ╰── GDataParsable ├── GDataEntry ├── GDataAPPCategories ├── GDataAuthor ├── GDataFeed ├── GDataCategory ├── GDataGContactCalendar ├── GDataGContactEvent ├── GDataGContactExternalID ├── GDataGContactJot ├── GDataGContactLanguage ├── GDataGContactRelation ├── GDataGContactWebsite ├── GDataGDEmailAddress ├── GDataGDIMAddress ├── GDataGDName ├── GDataGDOrganization ├── GDataGDPhoneNumber ├── GDataGDPostalAddress ├── GDataGDReminder ├── GDataGDWhen ├── GDataGDWhere ├── GDataGDWho ├── GDataGenerator ├── GDataLink ├── GDataMediaCategory ├── GDataMediaContent ├── GDataMediaCredit ├── GDataMediaThumbnail ╰── GDataYouTubeState
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.
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
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
typedef struct _GDataParsable GDataParsable;
All the fields in the GDataParsable structure are private and should never be accessed directly.
Since 0.3.0
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); const gchar *element_name; const gchar *element_namespace; } GDataParsableClass;
The class structure for the GDataParsable class.
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 |
||
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
“constructed-from-xml”
property“constructed-from-xml” gboolean
Specifies whether the object was constructed by parsing XML or manually.
Flags: Read / Write / Construct Only
Default value: FALSE
Since 0.7.0