Top | ![]() |
![]() |
![]() |
![]() |
typedef | librdf_model |
typedef | librdf_model_factory |
#define | LIBRDF_MODEL_FIND_OPTION_MATCH_SUBSTRING_LITERAL |
#define | LIBRDF_MODEL_FEATURE_CONTEXTS |
The main user API class for Redland, providing access to the RDF graph and the triples in it (librdf_statement), storage, parsing, serializing and querying.
int librdf_model_enumerate (librdf_world *world
,const unsigned int counter
,const char **name
,const char **label
);
Get information on models.
librdf_model * librdf_new_model (librdf_world *world
,librdf_storage *storage
,const char *options_string
);
Constructor - create a new storage librdf_model object.
The options are encoded as described in librdf_hash_from_string()
and can be NULL if none are required.
world |
redland world object |
|
storage |
librdf_storage to use |
|
options_string |
options to initialise model |
librdf_model * librdf_new_model_with_options (librdf_world *world
,librdf_storage *storage
,librdf_hash *options
);
Constructor - Create a new librdf_model with storage.
Options are presently not used.
world |
redland world object |
|
storage |
librdf_storage storage to use |
|
options |
librdf_hash of options to use |
librdf_model *
librdf_new_model_from_model (librdf_model *model
);
Copy constructor - create a new librdf_model from an existing one.
Creates a new model as a copy of the existing model in the same storage context.
void
librdf_free_model (librdf_model *model
);
Destructor - Destroy a librdf_model object.
int
librdf_model_size (librdf_model *model
);
Get the number of statements in the model.
WARNING: Not all underlying stores can return the size of the graph In which case the return value will be negative.
int librdf_model_add (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,librdf_node *object
);
Create and add a new statement about a resource to the model.
After this method, the librdf_node objects become owned by the model. All of subject, predicate and object must be non-NULL.
model |
model object |
|
subject |
librdf_node of subject |
|
predicate |
librdf_node of predicate |
|
object |
librdf_node of object (literal or resource) |
int librdf_model_add_string_literal_statement (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,const unsigned char *literal
,const char *xml_language
,int is_wf_xml
);
Create and add a new statement about a literal to the model.
The language can be set to NULL if not used. All of subject, predicate and literal must be non-NULL.
0.9.12: xml_space argument deleted
model |
model object |
|
subject |
librdf_node of subject |
|
predicate |
librdf_node of predicate |
|
literal |
string literal conten |
|
xml_language |
language of literal |
|
is_wf_xml |
literal is XML |
int librdf_model_add_typed_literal_statement (librdf_model *model
,librdf_node *subject
,librdf_node *predicate
,const unsigned char *literal
,const char *xml_language
,librdf_uri *datatype_uri
);
Create and add a new statement about a typed literal to the model.
After this method, the librdf_node subject and predicate become owned by the model.
The language can be set to NULL if not used. All of subject, predicate and literal must be non-NULL.
model |
model object |
|
subject |
librdf_node of subject |
|
predicate |
librdf_node of predicate |
|
literal |
string literal content |
|
xml_language |
language of literal |
|
datatype_uri |
datatype librdf_uri |
int librdf_model_add_statement (librdf_model *model
,librdf_statement *statement
);
Add a statement to the model.
The passed-in statement is copied when added to the model, not shared with the model. It must be a complete statement - all of subject, predicate, object parts must be present.
Only statements that are legal RDF can be added: URI or blank subject, URI predicate and URI or blank or literal object (i.e. anything).
If the statement already exists in the model, it is not added. Duplicate statements can be added when used with Redland Contexts such as with librdf_model_context_add_statement
int librdf_model_add_statements (librdf_model *model
,librdf_stream *statement_stream
);
Add a stream of statements to the model.
If any of the statements are illegal RDF statements they will be skipped and not added. See librdf_model_add_statement for the detail.
If any of the statements already exists in the store, they are not added unless Redland contexts are being used. See also librdf_model_context_add_statements
int librdf_model_remove_statement (librdf_model *model
,librdf_statement *statement
);
Remove a known statement from the model.
It must be a complete statement - all of subject, predicate, object parts must be present and a legal RDF triple.
int librdf_model_contains_statement (librdf_model *model
,librdf_statement *statement
);
Check for a statement in the model.
It must be a complete statement - all of subject, predicate, object parts must be present and a legal RDF triple. Use librdf_model_find_statements to search for partial statement matches.
WARNING: librdf_model_contains_statement may not work correctly with stores using contexts. In this case, a search using librdf_model_find_statements for a non-empty list will return the correct result.
int librdf_model_has_arc_in (librdf_model *model
,librdf_node *node
,librdf_node *property
);
Check if a node has a given property pointing to it.
model |
librdf_model object |
|
node |
librdf_node resource node |
|
property |
librdf_node property node |
int librdf_model_has_arc_out (librdf_model *model
,librdf_node *node
,librdf_node *property
);
Check if a node has a given property pointing from it.
model |
librdf_model object |
|
node |
librdf_node resource node |
|
property |
librdf_node property node |
librdf_stream *
librdf_model_as_stream (librdf_model *model
);
List the model contents as a stream of statements.
librdf_stream *
librdf_model_serialise (librdf_model *model
);
librdf_model_serialise
is deprecated and should not be used in newly-written code.
Serialise the entire model as a stream (DEPRECATED).
DEPRECATED to reduce confusion with the librdf_serializer class. Please use librdf_model_as_stream.
librdf_stream * librdf_model_find_statements (librdf_model *model
,librdf_statement *statement
);
Find matching statements in the model.
The partial statement is a statement where the subject, predicate and/or object can take the value NULL which indicates a match with any value in the model
librdf_stream * librdf_model_find_statements_with_options (librdf_model *model
,librdf_statement *statement
,librdf_node *context_node
,librdf_hash *options
);
Search the model for matching statements with match options.
Searches the model for a (partial) statement as described in
librdf_statement_match()
and returns a librdf_stream of
matching librdf_statement objects.
If options is given then the match is made according to the given options. If options is NULL, this is equivalent to librdf_model_find_statements_in_context.
model |
librdf_model object |
|
statement |
librdf_statement partial statement to find |
|
context_node |
librdf_node context node or NULL. |
|
options |
librdf_hash of matching options or NULL |
librdf_iterator * librdf_model_get_sources (librdf_model *model
,librdf_node *arc
,librdf_node *target
);
Return the sources (subjects) of arc in an RDF graph given arc (predicate) and target (object).
Searches the model for arcs matching the given arc and target and returns a list of the source librdf_node objects as an iterator
librdf_iterator * librdf_model_get_arcs (librdf_model *model
,librdf_node *source
,librdf_node *target
);
Return the arcs (predicates) of an arc in an RDF graph given source (subject) and target (object).
Searches the model for arcs matching the given source and target and returns a list of the arc librdf_node objects as an iterator
librdf_iterator * librdf_model_get_targets (librdf_model *model
,librdf_node *source
,librdf_node *arc
);
Return the targets (objects) of an arc in an RDF graph given source (subject) and arc (predicate).
Searches the model for targets matching the given source and arc and returns a list of the source librdf_node objects as an iterator
librdf_node * librdf_model_get_source (librdf_model *model
,librdf_node *arc
,librdf_node *target
);
Return one source (subject) of arc in an RDF graph given arc (predicate) and target (object).
Searches the model for arcs matching the given arc and target and returns one librdf_node object
librdf_node * librdf_model_get_arc (librdf_model *model
,librdf_node *source
,librdf_node *target
);
Return one arc (predicate) of an arc in an RDF graph given source (subject) and target (object).
Searches the model for arcs matching the given source and target and returns one librdf_node object
librdf_node * librdf_model_get_target (librdf_model *model
,librdf_node *source
,librdf_node *arc
);
Return one target (object) of an arc in an RDF graph given source (subject) and arc (predicate).
Searches the model for targets matching the given source and arc and returns one librdf_node object
librdf_iterator * librdf_model_get_arcs_in (librdf_model *model
,librdf_node *node
);
Return the properties pointing to the given resource.
librdf_iterator * librdf_model_get_arcs_out (librdf_model *model
,librdf_node *node
);
Return the properties pointing from the given resource.
int librdf_model_add_submodel (librdf_model *model
,librdf_model *sub_model
);
Add a sub-model to the model.
FIXME: Not tested
int librdf_model_remove_submodel (librdf_model *model
,librdf_model *sub_model
);
Remove a sub-model from the model.
FIXME: Not tested
void librdf_model_print (librdf_model *model
,FILE *fh
);
librdf_model_print
is deprecated and should not be used in newly-written code.
Print the model.
This method is for debugging and the format of the output should not be relied on.
Deprecated
: Use librdf_model_write()
to write to raptor_iostream
which can be made to write to a string. Use a librdf_serializer
to write proper syntax formats.
int librdf_model_context_add_statement (librdf_model *model
,librdf_node *context
,librdf_statement *statement
);
Add a statement to a model with a context.
It must be a complete statement - all of subject, predicate, object parts must be present.
If context
is NULL, this is equivalent to librdf_model_add_statement
model |
librdf_model object |
|
context |
librdf_node context |
|
statement |
librdf_statement statement object |
int librdf_model_context_add_statements (librdf_model *model
,librdf_node *context
,librdf_stream *stream
);
Add statements to a model with a context.
If context
is NULL, this is equivalent to librdf_model_add_statements
int librdf_model_context_remove_statement (librdf_model *model
,librdf_node *context
,librdf_statement *statement
);
Remove a statement from a model in a context.
It must be a complete statement - all of subject, predicate, object parts must be present.
If context
is NULL, this is equivalent to librdf_model_remove_statement
model |
librdf_model object |
|
context |
librdf_node context |
|
statement |
librdf_statement statement |
int librdf_model_context_remove_statements (librdf_model *model
,librdf_node *context
);
Remove statements from a model with the given context.
librdf_stream * librdf_model_context_as_stream (librdf_model *model
,librdf_node *context
);
List all statements in a model context.
librdf_stream * librdf_model_context_serialize (librdf_model *model
,librdf_node *context
);
librdf_model_context_serialize
is deprecated and should not be used in newly-written code.
List all statements in a model context.
DEPRECATED to reduce confusion with the librdf_serializer class. Please use librdf_model_context_as_stream.
int librdf_model_contains_context (librdf_model *model
,librdf_node *context
);
Check for a context in the model.
int
librdf_model_supports_contexts (librdf_model *model
);
Check if this model supports contexts
librdf_query_results * librdf_model_query_execute (librdf_model *model
,librdf_query *query
);
Execute a query against the model.
Run the given query against the model and return a librdf_stream of matching librdf_statement objects
int
librdf_model_sync (librdf_model *model
);
Synchronise the model to the model implementation.
librdf_storage *
librdf_model_get_storage (librdf_model *model
);
Return the storage of this model.
Note: this can only return one storage, so model implementations that have multiple librdf_storage internally may chose not to implement this.
int librdf_model_load (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
);
Load content from a URI into the model.
If the name field is NULL, the library will try to guess the parser to use from the uri, mime_type and type_uri fields. This is done via the raptor_guess_parser_name function.
model |
librdf_model object |
|
uri |
the URI to read the content |
|
name |
the name of the parser (or NULL) |
|
mime_type |
the MIME type of the syntax (NULL if not used) |
|
type_uri |
URI identifying the syntax (NULL if not used) |
unsigned char * librdf_model_to_counted_string (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
,size_t *string_length_p
);
Write serialized model to a string.
If the name field is NULL, the default serializer will be used.
Note: the returned string must be freed by the caller using librdf_free_memory()
.
model |
librdf_model object |
|
uri |
base URI to use in serializing (or NULL if not used) |
|
name |
the name of the serializer (or NULL for default) |
|
mime_type |
the MIME type of the syntax (NULL if not used) |
|
type_uri |
URI identifying the syntax (NULL if not used) |
|
string_length_p |
pointer to location to store string length (or NULL) |
unsigned char * librdf_model_to_string (librdf_model *model
,librdf_uri *uri
,const char *name
,const char *mime_type
,librdf_uri *type_uri
);
Write serialized model to a string.
If the name field is NULL, the default serializer will be used.
Note: the returned string must be freed by the caller.
model |
librdf_model object |
|
uri |
base URI to use in serializing (or NULL if not used) |
|
name |
the name of the serializer (or NULL for default) |
|
mime_type |
the MIME type of the syntax (NULL if not used) |
|
type_uri |
URI identifying the syntax (NULL if not used) |
librdf_stream * librdf_model_find_statements_in_context (librdf_model *model
,librdf_statement *statement
,librdf_node *context_node
);
Search the model for matching statements in a given context.
Searches the model for a (partial) statement as described in
librdf_statement_match()
in the given context and returns a
librdf_stream of matching librdf_statement objects. If
context is NULL, this is equivalent to librdf_model_find_statements.
model |
librdf_model object |
|
statement |
librdf_statement partial statement to find |
|
context_node |
context librdf_node (or NULL) |
librdf_iterator *
librdf_model_get_contexts (librdf_model *model
);
Return the list of contexts in the graph.
Returns an iterator of librdf_node context nodes for each context in the graph.
librdf_node * librdf_model_get_feature (librdf_model *model
,librdf_uri *feature
);
Get the value of a graph feature .
int librdf_model_set_feature (librdf_model *model
,librdf_uri *feature
,librdf_node *value
);
Set the value of a graph feature.
model |
librdf_model object |
|
feature |
librdf_uri feature property |
|
value |
librdf_node feature property value |
int
librdf_model_transaction_commit (librdf_model *model
);
Commit a transaction.
void *
librdf_model_transaction_get_handle (librdf_model *model
);
Get the current transaction handle.
int
librdf_model_transaction_rollback (librdf_model *model
);
Rollback a transaction.
int
librdf_model_transaction_start (librdf_model *model
);
Start a transaction
int librdf_model_transaction_start_with_handle (librdf_model *model
,void *handle
);
Start a transaction using an existing external transaction object.
int librdf_model_write (librdf_model *model
,raptor_iostream *iostr
);
Write a model to an iostream in a debug format.
This method is for debugging and the format of the output should not be relied on. In particular, when contexts are used the result may be 4 nodes.
typedef struct librdf_model_factory_s librdf_model_factory;
Redland model factory class.
#define LIBRDF_MODEL_FIND_OPTION_MATCH_SUBSTRING_LITERAL "http://feature.librdf.org/model-find-match-substring-literal"
Model find statement option.
If set, the find statement uses substring matching.