The moniker utility functions provide two sets of functions:
Helper functions for constructing and resolving monikers,
and a simple get_object method that constructs and resolves
against an interface in a single pass. Also, asynchronous
versions of these methods are provided using the BonoboAsync
code.
Helper functions for the implementation of new custom
monikers are also provided here, along with a lot of the
grunt code neccessary for moniker implementation, particularly
constructing the chained list of sub-monikers that comprises
a complex moniker.
The most useful function to get a feel for what monikers can do
is the bonobo_get_object method. This is
used to create a moniker and resolve it against a given interface
like this:
Example 1. GetObject example
GtkWidget *
moniker_resolve_demo (void)
{
Bonobo_Control control;
CORBA_Environment ev;
CORBA_exception_init (&ev);
control = bonobo_get_object ("file:/demo/a.jpeg",
"Bonobo/Control", NULL);
if (control == CORBA_OBJECT_NIL)
g_error ("Failed to get object file:/demo/a.jpeg");
return bonobo_widget_new_control (control);
}
This also makes a control out of the widget.
It is worth noting that when resolving monikers a contracted
version of the interface name may be used, ommitting the 'IDL:'
prefix and / or the ':0' suffix.
This encapsulates both the parse stage and resolve process of using
a moniker, providing a simple VisualBasic like mechanism for using the
object name space.
name :
the display name of a moniker
interface_name :
the name of the interface we want returned as the result
This routine is used to continue building up the chain
that forms a multi-part moniker. The parent is referenced
as the parent and passed onto the next stage of parsing
the 'name'. We eventually return a moniker handle which
represents the end of a linked list of monikers each
pointing to their parent:
file:/tmp/a.tar.gz <-- gzip: <-- tar: <-- [ this is returned ]
parent :
A parent moniker to chain to or CORBA_OBJECT_NIL
name :
the display name
ev :
corba environment
Returns :
The end node of a list of monikers representing name
A helper function to share code from the end of a resolve
implementation; this ensures that the returned object is of
the correct interface by doing a queryInterface on the object.
object :
the unknown to query
requested_interface :
the desired interface
ev :
a corba exception environment
Returns :
an handle to the requested interface
bonobo_moniker_util_seek_std_separator ()
int bonobo_moniker_util_seek_std_separator
(const CORBA_char *str,
int min_idx);
This looks for a standard separator in a moniker's
display name string. Most monikers will want to use
standard separators.
See also bonobo_moniker_util_escape
str :
the string to scan
min_idx :
the minimum offset at which a separator can be found.
Returns :
the position of the standard separator, or a
pointer to the end of the string.