Type implementation functions
[Type functions]


Functions

int RDB_implement_type (const char *name, RDB_type *arep, RDB_int areplen, RDB_exec_context *ecp, RDB_transaction *txp)
void * RDB_obj_irep (RDB_object *valp, size_t *lenp)
int RDB_irep_to_obj (RDB_object *valp, RDB_type *typ, const void *datap, size_t len, RDB_exec_context *ecp)

Detailed Description

#include <rel/typeimpl.h>

Function Documentation

int RDB_implement_type ( const char *  name,
RDB_type *  arep,
RDB_int  areplen,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_implement_type implements the user-defined type with name name. The type must have been defined previously using RDB_define_type(). After RDB_implement_type was inkoved successfully, this type may be used for local variables and table attributes.

If arep is not NULL, it must point to a type which is used as the physical representation. The getter, setter, and selector operators must be provided by the caller.

If arep is NULL and areplen is not -1, areplen specifies the length, in bytes, of the physical representation, which then is a fixed-length array of bytes. The getter, setter, and selector operators must be provided by the caller.

If arep is NULL and areplen is -1, the getter and setter operators and the selector operator are provided by Duro. In this case, the type must have exactly one possible representation, and this representation becomes the physical representation.

For user-provided setters, getters, and selectors, the following conventions apply:

Selectors
A selector is a read-only operator whose name is is the name of a possible representation. It takes one argument for each component.
Getters
A getter is a read-only operator whose name consists of the type and a component name, separated by "_get_". It takes one argument. The argument must be of the user-defined type in question. The return type must be the component type.
Setters
A setter is an update operator whose name consists of the type and a component name, separated by "_set_". It takes two arguments. The first argument is an update argument and must be of the user-defined type in question. The second argument is read-only and must be of the type of the component.

A user-defined comparison operator CMP returning an INTEGER may be supplied. CMP must have two arguments, both of the user-defined type for which the comparison is to be defined.

CMP must return -1, 0, or 1 if the first argument is lower than equal to, or greater than the secons argument, respectively.

If CMP has been defined, it will be called by the built-in comparison operators =, <>, <= etc.

Returns:
On success, RDB_OK is returned. Any other return value indicates an error.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NOT_FOUND_ERROR
The type has not been previously defined.
RDB_INVALID_ARGUMENT_ERROR
arep is NULL and areplen is -1, and the type was defined with more than one possible representation.

The call may also fail for a system error, in which case the transaction may be implicitly rolled back.

int RDB_irep_to_obj ( RDB_object valp,
RDB_type *  typ,
const void *  datap,
size_t  len,
RDB_exec_context *  ecp 
)

Initialize the value pointed to by valp with the internal representation given by datap and len.

Returns:
RDB_OK on success, RDB_ERROR on failure.

void* RDB_obj_irep ( RDB_object valp,
size_t *  lenp 
)

RDB_obj_irep returns a pointer to the binary internal representation of the variable specified by valp. If lenp is not NULL, the size of the internal representation is stored at the location pointed to by lenp.

RDB_obj_irep only works types with a binary internal representation. These are built-in types and user-defined types which use a built-in type or a byte array as physical representation.

Returns:
A pointer to the internal representation.


Generated on Tue Mar 11 23:48:15 2008 for Duro by  doxygen 1.5.1