World

## World World — Initialisation and termination of library |

## Synopsis

    typedef             librdf_world;
    librdf_world *      librdf_new_world                    (void);
    void                librdf_free_world                   (librdf_world *world);
    void                librdf_world_open                   (librdf_world *world);
    void                librdf_world_set_rasqal             (librdf_world *world,
                                                             rasqal_world *rasqal_world_ptr);
    rasqal_world *      librdf_world_get_rasqal             (librdf_world *world);
    raptor_world *      librdf_world_get_raptor             (librdf_world *world);
    void                librdf_world_set_raptor             (librdf_world *world,
                                                             raptor_world *raptor_world_ptr);
    void                librdf_world_init_mutex             (librdf_world *world);
    void                librdf_world_set_error              (librdf_world *world,
                                                             void *user_data,
                                                             librdf_log_level_func error_handler);
    void                librdf_world_set_warning            (librdf_world *world,
                                                             void *user_data,
                                                             librdf_log_level_func warning_handler);
    void                librdf_world_set_logger             (librdf_world *world,
                                                             void *user_data,
                                                             librdf_log_func log_handler);
    void                librdf_world_set_digest             (librdf_world *world,
                                                             const char *name);
    void                (*librdf_raptor_init_handler)       (void *user_data,
                                                             raptor_world *raptor_world_ptr);
    void                librdf_world_set_raptor_init_handler
                                                            (librdf_world *world,
                                                             void *user_data,
                                                             librdf_raptor_init_handler handler);
    void                (*librdf_rasqal_init_handler)       (void *user_data,
                                                             rasqal_world *rasqal_world_ptr);
    void                librdf_world_set_rasqal_init_handler
                                                            (librdf_world *world,
                                                             void *user_data,
                                                             librdf_rasqal_init_handler handler);
    #define             LIBRDF_WORLD_FEATURE_GENID_BASE
    #define             LIBRDF_WORLD_FEATURE_GENID_COUNTER
    librdf_node *       librdf_world_get_feature            (librdf_world *world,
                                                             librdf_uri *feature);
    int                 librdf_world_set_feature            (librdf_world *world,
                                                             librdf_uri *feature,
                                                             librdf_node *value);
    void                librdf_init_world                   (char *digest_factory_name,
                                                             void *not_used2);
    void                librdf_destroy_world                (void);

## Description

The Redland librdf_world class handles startup and termination of the library and cleanup of all allocated resources.

## Details

### librdf_world

    typedef struct librdf_world_s librdf_world;

Redland world class.

### librdf_new_world ()

    librdf_world *      librdf_new_world                    (void);

Create a new Redland execution environment.

Once this constructor is called to build a librdf_world object several functions may be called to set some parameters such as `librdf_world_set_error()`, `librdf_world_set_warning()`, `librdf_world_set_logger()`, `librdf_world_set_digest()`, `librdf_world_set_feature()`.

The world object needs initializing using `librdf_world_open()` whether or not the above functions are called. It will be automatically called by all object constructors in Redland 1.0.6 or later, but for earlier versions it MUST be called before using any other part of Redland.

Returns : | a new librdf_world or NULL on failure

### librdf_free_world ()

    void                librdf_free_world                   (librdf_world *world);

Terminate the library and frees all allocated resources.

`world` : | redland world object

### librdf_world_open ()

    void                librdf_world_open                   (librdf_world *world);

Open a created redland world environment.

`world` : | redland world object

### librdf_world_set_rasqal ()

    void                librdf_world_set_rasqal             (librdf_world *world,
                                                             rasqal_world *rasqal_world_ptr);

Set the rasqal_world instance to be used with this librdf_world.

If no rasqal_world instance is set with this function, `librdf_world_open()` creates a new instance.

Ownership of the rasqal_world is not taken. If the rasqal library instance is set with this function, `librdf_free_world()` will not free it.

`world` : | librdf_world object
`rasqal_world_ptr` : | rasqal_world object

### librdf_world_get_rasqal ()

    rasqal_world *      librdf_world_get_rasqal             (librdf_world *world);

Get the rasqal_world instance used by this librdf_world.

`world` : | librdf_world object
Returns : | rasqal_world object or NULL on failure (e.g. not initialized)

### librdf_world_get_raptor ()

    raptor_world *      librdf_world_get_raptor             (librdf_world *world);

Get the raptor_world instance used by this librdf_world.

`world` : | librdf_world object
Returns : | raptor_world object or NULL on failure (e.g. not initialized)

### librdf_world_set_raptor ()

    void                librdf_world_set_raptor             (librdf_world *world,
                                                             raptor_world *raptor_world_ptr);

Set the raptor_world instance to be used with this librdf_world.

If no raptor_world instance is set with this function, `librdf_world_open()` creates a new instance.

Ownership of the raptor_world is not taken. If the raptor library instance is set with this function, `librdf_free_world()` will not free it.

`world` : | librdf_world object
`raptor_world_ptr` : | raptor_world object

### librdf_world_init_mutex ()

    void                librdf_world_init_mutex             (librdf_world *world);

INTERNAL - Create the world mutex.

`world` : | redland world object

### librdf_world_set_error ()

    void                librdf_world_set_error              (librdf_world *world,
                                                             void *user_data,
                                                             librdf_log_level_func error_handler);

Set the world error handling function.

The function will receive callbacks when the world fails. `librdf_world_set_logger()` provides richer access to all log messages and should be used in preference.

`world` : | redland world object
`user_data` : | user data to pass to function
`error_handler` : | pointer to the function

### librdf_world_set_warning ()

    void                librdf_world_set_warning            (librdf_world *world,
                                                             void *user_data,
                                                             librdf_log_level_func warning_handler);

Set the world warning handling function.

The function will receive callbacks when the world gives a warning. `librdf_world_set_logger()` provides richer access to all log messages and should be used in preference.

`world` : | redland world object
`user_data` : | user data to pass to function
`warning_handler` : | pointer to the function

### librdf_world_set_logger ()

    void                librdf_world_set_logger             (librdf_world *world,
                                                             void *user_data,
                                                             librdf_log_func log_handler);

Set the world log handling function.

The function will receive callbacks when redland generates a log message

`world` : | redland world object
`user_data` : | user data to pass to function
`log_handler` : | pointer to the function

### librdf_world_set_digest ()

    void                librdf_world_set_digest             (librdf_world *world,
                                                             const char *name);

Set the default content digest name.

Sets the digest factory for various modules that need to make digests of their objects.

`world` : | redland world object
`name` : | Digest factory name

### librdf_raptor_init_handler ()

    void                (*librdf_raptor_init_handler)       (void *user_data,
                                                             raptor_world *raptor_world_ptr);

### librdf_world_set_raptor_init_handler ()

    void                librdf_world_set_raptor_init_handler
                                                            (librdf_world *world,
                                                             void *user_data,
                                                             librdf_raptor_init_handler handler);

Set the raptor initialization handler to be called if a new raptor_world is constructed.

`world` : | librdf_world object
`user_data` : | user data
`handler` : | handler to call

### librdf_rasqal_init_handler ()

    void                (*librdf_rasqal_init_handler)       (void *user_data,
                                                             rasqal_world *rasqal_world_ptr);

### librdf_world_set_rasqal_init_handler ()

    void                librdf_world_set_rasqal_init_handler
                                                            (librdf_world *world,
                                                             void *user_data,
                                                             librdf_rasqal_init_handler handler);

Set the rasqal initialization handler to be called if a new rasqal_world is constructed.

`world` : | librdf_world object
`user_data` : | user data
`handler` : | handler to call

### LIBRDF_WORLD_FEATURE_GENID_BASE

    #define LIBRDF_WORLD_FEATURE_GENID_BASE "http://feature.librdf.org/genid-base"

World feature to set the generated ID base.

Must be set before the world is opened with `librdf_world_open()`.

### LIBRDF_WORLD_FEATURE_GENID_COUNTER

    #define LIBRDF_WORLD_FEATURE_GENID_COUNTER "http://feature.librdf.org/genid-counter"

World feature to set the generated ID counter.

Must be set before the world is opened with `librdf_world_open()`.

### librdf_world_get_feature ()

    librdf_node *       librdf_world_get_feature            (librdf_world *world,
                                                             librdf_uri *feature);

Get the value of a world feature.

`world` : | librdf_world object
`feature` : | librdf_uri feature property
Returns : | new librdf_node feature value or NULL if no such feature exists or the value is empty.

### librdf_world_set_feature ()

    int                 librdf_world_set_feature            (librdf_world *world,
                                                             librdf_uri *feature,
                                                             librdf_node *value);

Set the value of a world feature.

`world` : | librdf_world object
`feature` : | librdf_uri feature property
`value` : | librdf_node feature property value
Returns : | non 0 on failure (negative if no such feature)

### librdf_init_world ()

    void                librdf_init_world                   (char *digest_factory_name,
                                                             void *not_used2);

Initialise the library `deprecated`: Do not use.

Use `librdf_new_world()` and `librdf_world_open()` on librdf_world object

See `librdf_world_set_digest()` for documentation on arguments.

`digest_factory_name` : | Name of digest factory to use
`not_used2` : | Not used

### librdf_destroy_world ()

    void                librdf_destroy_world                (void);

Terminate the library `deprecated`: Do not use.

Use `librdf_free_world()` on librdf_world object

Terminates and frees the resources.