|Redland RDF Application Framework Manual|
Redland uses objects and is written in C, which has no built in support for object construction, destruction, copying etc. This library thus uses conventions for the names of the routines providing the constructor, destructor and copy constructor functionality for a class as well as conventions for the general methods.
A class FOO is defined as a C typedef
and its a public interface defined in
along with any public or private types, enumerations or constants.
The private definitions are not exposed to library users, only
internally when the library is built. The implementation of the
class is defined in file
rdf_foo.c and may
include private (static) functions either for internal
implementations or to satisfy part of a factory API.
Each class may have a class initialiser / termination pair of functions which must be called before any object in the class is created, and after the last object has been freed. These are defined with signatures like:
void init_librdf_foo (...) void terminate_librdf_foo (void)
The arguments to the initialisation vary since there are sometimes some class wide options that can be set at initialisation time.
The object constructor(s) are defined with signatures like:
which takes no parameters. Additional constructors can be defined with parameters, and are named in a similar way with an extra part appropriate for the name for example:
librdf_foo* librdf_new_foo_with_options(char *options)
A copy constructor may be defined which will have the signature:
librdf_foo* librdf_new_foo_from_foo(librdf_foo* old_foo)
A destructor must be defined and has the signature:
void librdf_free_foo(librdf_foo* foo)
Methods of the class have names starting with
examples could be:
/* accessor functions to object part 'thing' */ int librdf_foo_set_thing(librdf_foo* foo, char *thing) char *librdf_foo_get_thing(librdf_foo* foo)
It is often convienent to get a string representation of an
object for further processing, debugging or serialisation. There are
two conventions for methods that provide this functionality - the
first is when a pointer is returned to a shared
copy of the string and in that case the method ends
_as_string. The second is when a pointer is
returned to a newly allocated string in which
case the method ends