| Top |
XML Helper FunctionsXML Helper Functions — Functions to help format and parse glabels XML properties |
#include <libglabels/xml.h> #define LGL_XML_NAME_SPACEgchar * lgl_xml_get_prop_string (xmlNodePtr node, constgchar *property, constgchar *default_val);gchar * lgl_xml_get_prop_i18n_string (xmlNodePtr node, constgchar *property, constgchar *default_val);gdouble lgl_xml_get_prop_double (xmlNodePtr node, constgchar *property,gdouble default_val);gboolean lgl_xml_get_prop_boolean (xmlNodePtr node, constgchar *property,gboolean default_val);gint lgl_xml_get_prop_int (xmlNodePtr node, constgchar *property,gint default_val);guint lgl_xml_get_prop_uint (xmlNodePtr node, constgchar *property,guint default_val);gdouble lgl_xml_get_prop_length (xmlNodePtr node, constgchar *property,gdouble default_val);void lgl_xml_set_prop_string (xmlNodePtr node, constgchar *property, constgchar *val);void lgl_xml_set_prop_double (xmlNodePtr node, constgchar *property,gdouble val);void lgl_xml_set_prop_boolean (xmlNodePtr node, constgchar *property,gboolean val);void lgl_xml_set_prop_int (xmlNodePtr node, constgchar *property,gint val);void lgl_xml_set_prop_uint_hex (xmlNodePtr node, constgchar *property,guint val);void lgl_xml_set_prop_length (xmlNodePtr node, constgchar *property,gdouble val);gboolean lgl_xml_is_node (xmlNodePtr node, constgchar *name);gchar * lgl_xml_get_node_content (xmlNodePtr node);void lgl_xml_set_default_units (lglUnitsType units);
This section describes a number of "helper" functions for formatting and parsing various types of properties for tags in glabels XML file formats.
These functions are basically wrappers to functions from libxml2.
gchar * lgl_xml_get_prop_string (xmlNodePtr node, constgchar *property, constgchar *default_val);
Return value of property as a string.
|
the libxml2 |
|
the property name |
|
a default value to return if property not found |
Returns : |
the property as a pointer to a gchar string. This string should
be freed with g_free() |
gchar * lgl_xml_get_prop_i18n_string (xmlNodePtr node, constgchar *property, constgchar *default_val);
Return value of a translatable property as a string.
|
the libxml2 |
|
the property name |
|
a default value to return if property not found |
Returns : |
the property as a pointer to a gchar string. This string should
be freed with g_free() |
gdouble lgl_xml_get_prop_double (xmlNodePtr node, constgchar *property,gdouble default_val);
Return value of property as a double.
|
the libxml2 |
|
the property name |
|
a default value to return if property not found |
Returns : |
the property as a double. |
gboolean lgl_xml_get_prop_boolean (xmlNodePtr node, constgchar *property,gboolean default_val);
Return value of property as a boolean.
|
the libxml2 |
|
the property name |
|
a default value to return if property not found |
Returns : |
the property as a boolean. |
gint lgl_xml_get_prop_int (xmlNodePtr node, constgchar *property,gint default_val);
Return value of property as an integer.
|
the libxml2 |
|
the property name |
|
a default value to return if property not found |
Returns : |
the property as an integer. |
guint lgl_xml_get_prop_uint (xmlNodePtr node, constgchar *property,guint default_val);
Return value of property (usually formatted in hex) as an unsigned integer.
|
the libxml2 |
|
the property name |
|
a default value to return if property not found |
Returns : |
the property as an unsigned integer. |
gdouble lgl_xml_get_prop_length (xmlNodePtr node, constgchar *property,gdouble default_val);
Return value of a length property as a double, converting to internal units (points). The property is expected to be formatted as a number followed by a units string. If there is no units string, the length is assumed to be in points. Valid units strings are "pt" for points, "in" for inches, "mm" for millimeters, "cm" for centimeters, and "pc" for picas.
|
the libxml2 |
|
the property name |
|
a default value to return if property not found |
Returns : |
the length in points. |
void lgl_xml_set_prop_string (xmlNodePtr node, constgchar *property, constgchar *val);
Set a property from a string.
|
the libxml2 |
|
the property name |
|
the value to set |
void lgl_xml_set_prop_double (xmlNodePtr node, constgchar *property,gdouble val);
Set a property from a double.
|
the libxml2 |
|
the property name |
|
the value to set |
void lgl_xml_set_prop_boolean (xmlNodePtr node, constgchar *property,gboolean val);
Set a property from a boolean.
|
the libxml2 |
|
the property name |
|
the value to set |
void lgl_xml_set_prop_int (xmlNodePtr node, constgchar *property,gint val);
Set a property from an integer.
|
the libxml2 |
|
the property name |
|
the value to set |
void lgl_xml_set_prop_uint_hex (xmlNodePtr node, constgchar *property,guint val);
Set a property from an unsigned integer and format in hex.
|
the libxml2 |
|
the property name |
|
the value to set |
void lgl_xml_set_prop_length (xmlNodePtr node, constgchar *property,gdouble val);
Set a property from a length, performing any necessary conversion.
Length properties are formatted as a number followed by a units string.
The units of the formatted property is determined by the most recent call to
lgl_xml_set_default_units().
|
the libxml2 |
|
the property name |
|
the length to set in internal units (points) |
gboolean lgl_xml_is_node (xmlNodePtr node, constgchar *name);
Test if a node name matches given name.
|
the libxml2 |
|
the node name |
Returns : |
TRUE if the name of the node matches. Otherwise FALSE. |
gchar * lgl_xml_get_node_content (xmlNodePtr node);
Get the content of a node.
|
the libxml2 |
Returns : |
the property as a pointer to a gchar string. This string should
be freed with g_free() |
void lgl_xml_set_default_units (lglUnitsType units);
Set the default units when formatting lengths. See
lgl_xml_set_prop_length().
|
default units selection (lglUnitsType) |