bonobo-property-bag-xml

Name

bonobo-property-bag-xml -- BonoboArg XML persistance logic

Synopsis



BonoboUINode* bonobo_property_bag_xml_encode_any
                                            (BonoboUINode *opt_parent,
                                             const CORBA_any *any,
                                             CORBA_Environment *ev);
CORBA_any*  bonobo_property_bag_xml_decode_any
                                            (BonoboUINode *node,
                                             CORBA_Environment *ev);

Description

This API is really super simple. It is designed in conjuction with the BonoboUINode API to allow you to serialize a BonoboArg ( in fact a CORBA_any ) to an XML format, and obviously the converse.

Here is a code sample to produce an XML string from a CORBA_any or BonoboArg:

Example 1. Converting Any to XML

char *
convert_arg_to_xml (BonoboArg *bonobo_arg)
{
	CORBA_Environment ev;
	BonoboUINode     *node;
	char             *value;

	CORBA_exception_init (&ev);

	node = bonobo_property_bag_xml_encode_any (NULL, bonobo_arg, &ev);
	if (!node)
		return NULL;

	value = bonobo_property_bag_xml_decode_any (node, &ev);
	bonobo_ui_node_free (node);

	CORBA_exception_free (&ev);

	return value;
}
     

Here is the converse sample to produce a BonoboArg from an XML string:

Example 2. Converting XML to an Any

BonoboArg *
convert_xml_to_arg (const char *xml)
{
	CORBA_Environment ev;
	BonoboUINode     *node;
	BonoboArg        *value;

	CORBA_exception_init (&ev);

	node = bonobo_ui_node_from_string (xml);
	if (!node)
		return NULL;

	value = bonobo_property_bag_xml_decode_any (node, &ev);

	bonobo_ui_node_free (node);
	CORBA_exception_free (&ev);

	return value;
}
     

Details

bonobo_property_bag_xml_encode_any ()

BonoboUINode* bonobo_property_bag_xml_encode_any
                                            (BonoboUINode *opt_parent,
                                             const CORBA_any *any,
                                             CORBA_Environment *ev);

This routine encodes any into an XML tree using the BonoboUINode XML abstraction. ev is used for flagging any non-fatal exceptions during the process. On exception NULL will be returned. opt_parent should be NULL, and is used internally for recursive tree construction.

Both type and content data are dumped in a non-standard, but trivial format.

opt_parent : optional parent, should be NULL
any : the Any to serialize
ev : a corba exception environment
Returns : the XML tree representing the Any


bonobo_property_bag_xml_decode_any ()

CORBA_any*  bonobo_property_bag_xml_decode_any
                                            (BonoboUINode *node,
                                             CORBA_Environment *ev);

This routine is the converse of bonobo_property_bag_xml_encode_any. It hydrates a serialized CORBA_any.

node : the parsed XML representation of an any
ev : a corba exception environment
Returns : the CORBA_any or NULL on error