XML Helper Functions

XML Helper Functions — Functions to help format and parse glabels XML properties

Synopsis


#include <libglabels/xml.h>


gdouble     gl_xml_get_prop_double          (xmlNodePtr node,
                                             const gchar *property,
                                             gdouble default_val);
gboolean    gl_xml_get_prop_boolean         (xmlNodePtr node,
                                             const gchar *property,
                                             gboolean default_val);
gint        gl_xml_get_prop_int             (xmlNodePtr node,
                                             const gchar *property,
                                             gint default_val);
guint       gl_xml_get_prop_uint            (xmlNodePtr node,
                                             const gchar *property,
                                             guint default_val);
gdouble     gl_xml_get_prop_length          (xmlNodePtr node,
                                             const gchar *property,
                                             gdouble default_val);
void        gl_xml_set_prop_double          (xmlNodePtr node,
                                             const gchar *property,
                                             gdouble val);
void        gl_xml_set_prop_boolean         (xmlNodePtr node,
                                             const gchar *property,
                                             gboolean val);
void        gl_xml_set_prop_int             (xmlNodePtr node,
                                             const gchar *property,
                                             gint val);
void        gl_xml_set_prop_uint_hex        (xmlNodePtr node,
                                             const gchar *property,
                                             guint val);
void        gl_xml_set_prop_length          (xmlNodePtr node,
                                             const gchar *property,
                                             gdouble val);
void        gl_xml_set_default_units        (glUnitsType units);

Description

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.

Details

gl_xml_get_prop_double ()

gdouble     gl_xml_get_prop_double          (xmlNodePtr node,
                                             const gchar *property,
                                             gdouble default_val);

Return value of property as a double.

node : the libxml2 xmlNodePtr of the node
property : the property name
default_val : a default value to return if property not found
Returns : the property as a double.

gl_xml_get_prop_boolean ()

gboolean    gl_xml_get_prop_boolean         (xmlNodePtr node,
                                             const gchar *property,
                                             gboolean default_val);

Return value of property as a boolean.

node : the libxml2 xmlNodePtr of the node
property : the property name
default_val : a default value to return if property not found
Returns : the property as a boolean.

gl_xml_get_prop_int ()

gint        gl_xml_get_prop_int             (xmlNodePtr node,
                                             const gchar *property,
                                             gint default_val);

Return value of property as an integer.

node : the libxml2 xmlNodePtr of the node
property : the property name
default_val : a default value to return if property not found
Returns : the property as an integer.

gl_xml_get_prop_uint ()

guint       gl_xml_get_prop_uint            (xmlNodePtr node,
                                             const gchar *property,
                                             guint default_val);

Return value of property (usually formatted in hex) as an unsigned integer.

node : the libxml2 xmlNodePtr of the node
property : the property name
default_val : a default value to return if property not found
Returns : the property as an unsigned integer.

gl_xml_get_prop_length ()

gdouble     gl_xml_get_prop_length          (xmlNodePtr node,
                                             const gchar *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.

node : the libxml2 xmlNodePtr of the node
property : the property name
default_val : a default value to return if property not found
Returns : the length in points.

gl_xml_set_prop_double ()

void        gl_xml_set_prop_double          (xmlNodePtr node,
                                             const gchar *property,
                                             gdouble val);

Set a property from a double.

node : the libxml2 xmlNodePtr of the node
property : the property name
val : the value to set

gl_xml_set_prop_boolean ()

void        gl_xml_set_prop_boolean         (xmlNodePtr node,
                                             const gchar *property,
                                             gboolean val);

Set a property from a boolean.

node : the libxml2 xmlNodePtr of the node
property : the property name
val : the value to set

gl_xml_set_prop_int ()

void        gl_xml_set_prop_int             (xmlNodePtr node,
                                             const gchar *property,
                                             gint val);

Set a property from an integer.

node : the libxml2 xmlNodePtr of the node
property : the property name
val : the value to set

gl_xml_set_prop_uint_hex ()

void        gl_xml_set_prop_uint_hex        (xmlNodePtr node,
                                             const gchar *property,
                                             guint val);

Set a property from an unsigned integer and format in hex.

node : the libxml2 xmlNodePtr of the node
property : the property name
val : the value to set

gl_xml_set_prop_length ()

void        gl_xml_set_prop_length          (xmlNodePtr node,
                                             const gchar *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 gl_xml_set_default_units().

node : the libxml2 xmlNodePtr of the node
property : the property name
val : the length to set in internal units (points)

gl_xml_set_default_units ()

void        gl_xml_set_default_units        (glUnitsType units);

Set the default units when formatting lengths. See gl_xml_set_prop_length().

units : default units selection (glUnitsType)