glibrdf

GLib wrapper for the Redland RDF library
git clone https://code.djc.id.au/git/glibrdf/

glibrdf.vapi (34026B) - raw

      1 /*  glibrdf.vapi
      2  *
      3  *  Copyright 2012 Dan Callaghan <djc@djc.id.au>
      4  *
      5  *  Derived from:
      6  *    redland.vapi
      7  *      Copyright 2011 Sam Thursfield <ssssam@gmail.com>
      8  *    raptor.vapi
      9  *      Copyright (C) 2008  Nokia
     10  *      Author: Jürg Billeter <j@bitron.ch>
     11  *      Updated by Sam Thursfield 2011
     12  *
     13  *  This program is free software: you can redistribute it and/or modify
     14  *  it under the terms of the GNU General Public License as published by
     15  *  the Free Software Foundation, either version 3 of the License, or
     16  *  (at your option) any later version.
     17  *
     18  *  This program is distributed in the hope that it will be useful,
     19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     21  *  GNU General Public License for more details.
     22  *
     23  *  You should have received a copy of the GNU General Public License
     24  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     25  */
     26 
     27 using GLib;
     28 
     29 [CCode (cheader_filename = "glibrdf.h")]
     30 namespace Rdf {
     31 	/***************************************************************************
     32 	 * World
     33 	 */
     34 
     35 	[Compact]
     36 	[CCode (cname = "librdf_world", free_function = "librdf_free_world")]
     37 	public class World {
     38 		static const string FEATURE_GENID_BASE;
     39 		static const string FEATURE_GENID_COUNTER;
     40 
     41 		[CCode (cname = "librdf_new_world")]
     42 		public World();
     43 		[CCode (cname = "librdf_world_open")]
     44 		public void open();
     45 
     46 		/* Missing: set_rasqal, get_rasqal */
     47 
     48 		/* Missing: init_mutex (internal) */
     49 
     50 		[CCode (cname = "librdf_world_set_error")]
     51 		public void set_error ([CCode (delegate_target_pos = 0.9)] LogLevelFunc error_handler);
     52 		[CCode (cname = "librdf_world_set_warning")]
     53 		public void set_warning ([CCode (delegate_target_pos = 0.9)] LogLevelFunc warning_handler);
     54 		[CCode (cname = "librdf_world_set_logger")]
     55 		public void set_logger ([CCode (delegate_target_pos = 0.9)] LogFunc log_handler);
     56 		[CCode (cname = "librdf_world_set_digest")]
     57 		public void set_digest (string name);
     58 
     59 		[CCode (cname = "librdf_world_get_feature")]
     60 		public unowned Rdf.Node get_feature (Uri feature);
     61 		[CCode (cname = "librdf_world_set_feature")]
     62 		public unowned Rdf.Node set_feature (Uri feature, Node feature_value);
     63 
     64 		/* These have shorter names because we can't provide convenience
     65 		 * macros, unlike the C api
     66 		 */
     67 		[CCode (cname = "librdf_get_concept_resource_by_index")]
     68 		public unowned Node concept (Concept idx);
     69 		[CCode (cname = "librdf_get_concept_uri_by_index")]
     70 		public unowned Uri concept_uri (Concept idx);
     71 
     72 		[CCode (cname = "librdf_get_concept_ms_namespace")]
     73 		public unowned Uri ms_namespace ();
     74 		[CCode (cname = "librdf_get_concept_schema_namespace")]
     75 		public unowned Uri schema_namespace ();
     76 
     77 		/* Parser API, but in Vala's object model they make more sense here */
     78 		/*[CCode (cname = "librdf_parser_register_factory")]
     79 		public void register_parser_factory (string name, string label, string mime_type, string uri_string, ParserFactory factory);*/
     80 		[CCode (cname = "librdf_parser_enumerate")]
     81 		public bool enumerate_parser (uint counter, out unowned string name, out unowned string label);
     82 		[CCode (cname = "librdf_parser_check_name")]
     83 		public bool check_parser_name (string name);
     84 	}
     85 
     86 	/***************************************************************************
     87 	 * Concepts
     88 	 */
     89 
     90 	[CCode (cprefix="LIBRDF_CONCEPT_")]
     91 	public enum Concept {
     92 		MS_Alt,
     93 		MS_Bag,
     94 		MS_Property,
     95 		MS_Seq,
     96 		MS_Statement,
     97 		MS_object,
     98 		MS_predicate,
     99 		MS_subject,
    100 		MS_type,
    101 		MS_value,
    102 		MS_li,
    103 
    104 		MS_RDF,
    105 		MS_Description,
    106 
    107 		MS_aboutEach,
    108 		MS_aboutEachPrefix,
    109 
    110 		RS_nodeID,
    111 		RS_List,
    112 		RS_first,
    113 		RS_rest,
    114 		RS_nil,
    115 		RS_XMLLiteral,
    116 
    117 		/* RDF Schema concepts defined in prose at
    118 		*   http://www.w3.org/TR/2000/CR-rdf-schema-20000327/
    119 		* and in RDF Schema form at 
    120 		*   http://www.w3.org/2000/01/rdf-schema
    121 		*/
    122 		S_Class,
    123 		S_ConstraintProperty,
    124 		S_ConstraintResource,
    125 		S_Container,
    126 		S_ContainerMembershipProperty,
    127 		S_Literal,
    128 		S_Resource,
    129 		S_comment,
    130 		S_domain,
    131 		S_isDefinedBy,
    132 		S_label,
    133 		S_range,
    134 		S_seeAlso,
    135 		S_subClassOf,
    136 		S_subPropertyOf,
    137 
    138 		FIRST_S_ID,
    139 		LAST
    140 	}
    141 
    142 
    143 	/***************************************************************************
    144 	 * Iterator
    145 	 */
    146 
    147 	[Compact]
    148 	[CCode (cname = "librdf_iterator",
    149 	        free_function = "librdf_free_iterator")]
    150 	public class Iterator {
    151 		[Flags]
    152 		public enum GetMethod {
    153 			GET_OBJECT,
    154 			GET_CONTEXT,
    155 			GET_KEY,
    156 			GET_VALUE
    157 		}
    158 
    159 		[CCode (cname = "librdf_new_empty_iterator")]
    160 		public Iterator.empty (World world);
    161 
    162 		/*[CCode (cname = "librdf_iterator_map_handler")]
    163 		public Delegate void *MapHandler ([CCode delegate_target_pos = 1.9], Iterator iterator, void *item);*/
    164 		/* typedef void (*librdf_iterator_map_free_context_handler)(void *map_context); */
    165 
    166 		/* void librdf_new_iterator ((librdf_world *world, void *context, int (*is_end_method)(void*), int (*next_method)(void*), void* (*get_method)(void*, int), void (*finished_method)(void*)); */
    167 
    168 		[CCode (cname = "librdf_iterator_end")]
    169 		public bool end ();
    170 		[CCode (cname = "librdf_iterator_next")]
    171 		public int next ();
    172 		[CCode (cname = "librdf_iterator_get_object")]
    173 		public unowned Node get_object ();
    174 		[CCode (cname = "librdf_iterator_get_context")]
    175 		public unowned Node get_context ();
    176 		[CCode (cname = "librdf_iterator_get_key")]
    177 		public unowned void *get_key ();
    178 		[CCode (cname = "librdf_iterator_get_value")]
    179 		public unowned void *get_value ();
    180 
    181 		/*REDLAND_API
    182 		int librdf_iterator_add_map(librdf_iterator* iterator, librdf_iterator_map_handler map_function, librdf_iterator_map_free_context_handler free_context, void *map_context);*/
    183 	}
    184 
    185 
    186 	/***************************************************************************
    187 	 * Log
    188 	 */
    189 
    190 	[CCode (cprefix = "LIBRDF_LOG_", cname = "librdf_log_level")]
    191 	public enum LogLevel {
    192 		NONE,
    193 		DEBUG,
    194 		INFO,
    195 		WARN,
    196 		ERROR,
    197 		FATAL,
    198 		LAST
    199 	}
    200 
    201 	[CCode (cname = "LIBRDF_FROM_")]
    202 	public enum LogFacility {
    203 		CONCEPTS,
    204 		DIGEST,
    205 		FILES,
    206 		HASH,
    207 		INIT,
    208 		ITERATOR,
    209 		LIST,
    210 		MODEL,
    211 		NODE,
    212 		PARSER,
    213 		QUERY,
    214 		SERIALIZER,
    215 		STATEMENT,
    216 		STORAGE,
    217 		STREAM,
    218 		URI,
    219 		UTF8,
    220 		MEMORY,
    221 		NONE,
    222 		LAST
    223 	}
    224 
    225 	[Compact]
    226 	[CCode (cname = "librdf_log_message")]
    227 	public class LogMessage {
    228 		public int code;
    229 		public LogLevel level;
    230 		public LogFacility facility;
    231 		public string message;
    232 		public Raptor.Locator? locator;
    233 
    234 		[CCode (cname = "librdf_log_message_code")]
    235 		public int get_code ();
    236 		[CCode (cname = "librdf_log_message_level")]
    237 		public LogLevel get_level ();
    238 		[CCode (cname = "librdf_log_message_facility")]
    239 		public LogFacility get_facility ();
    240 		[CCode (cname = "librdf_log_message_message")]
    241 		public string get_message ();
    242 		[CCode (cname = "librdf_log_message_locator")]
    243 		public Raptor.Locator? get_locator ();
    244 	}
    245 
    246 	[CCode (cname = "librdf_log_level_func", instance_pos = 0)]
    247 	public delegate int LogLevelFunc (string message, va_list arguments);
    248 	[CCode (cname = "librdf_log_func", instance_pos = 0)]
    249 	public delegate int LogFunc (LogMessage message);
    250 
    251 	/***************************************************************************
    252 	 * Model (graph)
    253 	 */
    254 
    255 	/*REDLAND_API
    256 	int librdf_model_enumerate(librdf_world* world, const unsigned int counter, const char **name, const char **label);*/
    257 
    258 	[Compact]
    259 	[CCode (cname = "librdf_model",
    260 	        copy_function = "librdf_new_model_from_model",
    261 	        free_function = "librdf_free_model")]
    262 	public class Model {
    263 		[CCode (cname = "librdf_new_model")]
    264 		public Model (World world, Storage storage, string? options_string);
    265 		/*[CCode (cname = "librdf_new_model_with_options")]
    266 		public Model.with_options (World world, Storage storage, Hash options);*/
    267 
    268 		[CCode (cname = "librdf_model_size")]
    269 		public int size ();
    270 
    271 		[CCode (cname = "librdf_model_add")]
    272 		public int add (Node subject, Node predicate, Node object);
    273 		[CCode (cname = "librdf_model_add_string_literal_statement")]
    274 		public int add_string_literal_statement (Node subject, Node predicate, string literal, string? xml_language, bool is_wf_xml);
    275 		[CCode (cname = "librdf_model_add_typed_literal_statement")]
    276 		public int add_typed_literal_statement (Node subject, Node predicate, string literal, string? xml_language, Uri datatype_uri);
    277 		[CCode (cname = "librdf_model_add_statement")]
    278 		public int add_statement (Statement statement);
    279 		[CCode (cname = "librdf_model_add_statements")]
    280 		public int add_statements (Stream statement_stream);
    281 
    282 		[CCode (cname = "librdf_model_remove_statement")]
    283 		public int remove_statement (Statement statement);
    284 
    285 		[CCode (cname = "librdf_model_contains_statement")]
    286 		public bool contains_statement (Statement statement);
    287 		[CCode (cname = "librdf_model_has_arc_in")]
    288 		public bool has_arc_in (Node node, Node property);
    289 		[Ccode (cname = "librdf_model_has_arc_out")]
    290 		public bool has_arc_out (Node node, Node property);
    291 
    292 		[CCode (cname = "librdf_model_as_stream")]
    293 		public Stream as_stream ();
    294 
    295 		[CCode (cname = "librdf_model_find_statements")]
    296 		public Stream? find_statements (Statement statement);
    297 
    298 		[CCode (cname = "LIBRDF_MODEL_FIND_OPTION_MATCH_SUBSTRING_LITERAL")]
    299 		public static const string FIND_OPTION_MATCH_SUBSTRICT_LITERAL;
    300 
    301 		/* [CCode (cname = "librdf_model_find_statements_with_options")]
    302 		public Stream? find_statements_with_options (Statement statement, Node context_node, Hash options); */
    303 
    304 		[CCode (cname = "librdf_model_get_sources")]
    305 		public Iterator? get_sources (Node arc, Node target);
    306 		[CCode (cname = "librdf_model_get_arcs")]
    307 		public Iterator? get_arcs (Node source, Node target);
    308 		[CCode (cname = "librdf_model_get_targets")]
    309 		public Iterator? get_targets (Node source, Node arc);
    310 		[CCode (cname = "librdf_model_get_source")]
    311                 public Node? get_source (Node arc, Node target);
    312 		[CCode (cname = "librdf_model_get_arc")]
    313                 public Node? get_arc (Node source, Node target);
    314 		[CCode (cname = "librdf_model_get_target")]
    315                 public Node? get_target (Node source, Node arc);
    316 
    317 		[CCode (cname = "librdf_model_get_arcs_in")]
    318 		public Iterator? get_arcs_in (Node node);
    319 		[CCode (cname = "librdf_model_get_arcs_out")]
    320 		public Iterator? get_arcs_out (Node node);
    321 
    322 		/* From the manual: "FIXME: not tested"
    323 		[CCode (cname = "librdf_model_add_submodel")]
    324 		public int add_submodel (Model submodel);
    325 		[CCode (cname = "librdf_model_remove_submodel")]
    326 		public int remove_submodel (Model submodel);
    327 		*/
    328 
    329 		[CCode (cname = "librdf_model_print")]
    330 		public void print (FileStream file_stream);
    331 
    332 		[CCode (cname = "librdf_model_context_add_statement")]
    333 		public int context_add_statement (Node? context, Statement statement);
    334 		[CCode (cname = "librdf_model_context_add_statements")]
    335 		public int context_add_statements (Node? context, Stream stream);
    336 		[CCode (cname = "librdf_model_context_remove_statement")]
    337 		public int context_remove_statement (Node? context, Statement statement);
    338 		[CCode (cname = "librdf_model_context_remove_statements")]
    339 		public int context_remove_statements (Node context);
    340 
    341 		[CCode (cname = "librdf_model_context_as_stream")]
    342 		public Stream? context_as_stream (Node context);
    343 		[CCode (cname = "librdf_model_contains_context")]
    344 		public bool contains_context (Node context);
    345 
    346 		/* query language */
    347 		/*REDLAND_API
    348 		librdf_query_results* librdf_model_query_execute(librdf_model* model, librdf_query* query);*/
    349 
    350 		[CCode (cname = "librdf_model_sync")]
    351 		public int sync ();
    352 		[CCode (cname = "librdf_model_get_storage")]
    353 		public unowned Storage get_storage ();
    354 		[CCode (cname = "librdf_model_load")]
    355 		public int load (Uri uri, string? name, string? mime_type, Uri? type_uri);
    356 		/*[CCode (cname = "librdf_model_to_counted_string")]
    357 		public string 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);*/
    358 		[CCode (cname = "librdf_model_to_string")]
    359 		public string? to_string (Uri? uri, string? name, string? mime_type, Uri? type_uri);
    360 
    361 		[CCode (cname = "librdf_model_find_statements_in_context")]
    362 		public Stream? find_statements_in_context (Statement statement, Node context_node);
    363 
    364 		[CCode (cname = "librdf_model_get_contexts")]
    365 		public Iterator? get_contexts ();
    366 
    367 		[CCode (cname = "librdf_model_transaction_start")]
    368 		public int transaction_start ();
    369 		[CCode (cname = "librdf_model_transaction_start_with_handle")]
    370 		public int transaction_start_with_handle (void *handle);
    371 		[CCode (cname = "librdf_model_transaction_commit")]
    372 		public int transaction_commit ();
    373 		[CCode (cname = "librdf_model_transaction_rollback")]
    374 		public int transaction_rollback ();
    375 		[CCode (cname = "librdf_model_transaction_get_handle")]
    376 		public void *transaction_get_handle ();
    377 
    378 		[CCode (cname = "LIBRDF_MODEL_FEATURE_CONTEXTS")]
    379 		public static const string FEATURE_CONTEXTS;
    380 
    381 		[CCode (cname = "librdf_model_get_feature")]
    382 		public unowned Node? get_feature (Uri feature);
    383 		[CCode (cname = "librdf_model_set_feature")]
    384 		public int set_feature (Uri feature, Node feature_value);
    385 	}
    386 
    387 	/***************************************************************************
    388 	 * Node
    389 	 */
    390 
    391 	[CCode (cname = "librdf_node_type", cprefix = "LIBRDF_NODE_TYPE_")]
    392 	public enum NodeType {
    393 		UNKNOWN,
    394 		RESOURCE,
    395 		LITERAL,
    396 		BLANK,
    397 		LAST
    398 	}
    399 
    400         [CCode (cname = "librdf_gvalue_adaptor_func", has_target = false)]
    401         public delegate GLib.Value GValueAdaptor(string lv);
    402         [CCode (cname = "librdf_gvalue_adaptor_map_func", has_target = false)]
    403         public delegate GValueAdaptor GValueAdaptorMap(Uri datatype_uri);
    404         [CCode (cname = "librdf_default_gvalue_adaptor_map")]
    405         public GValueAdaptor default_gvalue_adaptor_map(Uri datatype_uri);
    406 
    407 	[Compact]
    408         [Immutable]
    409 	[CCode (cname = "librdf_node",
    410                 const_cname = "librdf_node",
    411 	        copy_function = "librdf_new_node_from_node",
    412                 free_function = "librdf_free_node",
    413                 type_id = "G_TYPE_RDF_NODE")]
    414 	public class Node {
    415 		[CCode (cname = "librdf_new_node")]
    416 		public Node (World world);
    417 		[CCode (cname = "librdf_new_node_from_node")]
    418 		public Node.from_node (Node node);
    419 		[CCode (cname = "librdf_new_node_from_blank_identifier")]
    420 		public Node.from_blank_identifier (World world, string? identifier);
    421 		[CCode (cname = "librdf_new_node_from_uri_string")]
    422 		public Node.from_uri_string (World world, string uri_string);
    423 		[CCode (cname = "librdf_new_node_from_uri")]
    424 		public Node.from_uri (World world, Uri uri);
    425 		[CCode (cname = "librdf_new_node_from_uri_local_name")]
    426 		public Node.from_uri_local_name (World world, Uri uri, string local_name);
    427 		[CCode (cname = "librdf_new_node_from_normalised_uri_string")]
    428 		public Node.from_normalised_uri_string (World world, string uri_string, Uri source_uri,
    429 		                                        Uri base_uri);
    430 		[CCode (cname = "librdf_new_node_from_literal")]
    431 		public Node.from_literal (World world, string literal_string, string? xml_language,
    432 		                          bool is_wf_xml);
    433 		[CCode (cname = "librdf_new_node_from_typed_literal")]
    434 		public Node.from_typed_literal (World world, string literal_value, string? xml_language,
    435 		                                Uri? datatype_uri);
    436 		/* Missing: (because all other 'counted' variants are)
    437 		[CCode (cname = "librdf_new_node_from_typed_counted_literal")]
    438 		public Node.from_typed_counted_literal (World world, string literal_value,
    439 		                                        size_t value_len, string xml_language,
    440 		                                        size_t xml_language_len, Uri datatype_uri); */
    441 
    442 		[CCode (cname = "librdf_node_get_uri")]
    443 		public unowned Uri? get_uri ();
    444 		[CCode (cname = "librdf_node_get_type")]
    445 		public NodeType get_type ();
    446 		[CCode (cname = "librdf_node_get_literal_value")]
    447 		public unowned string? get_literal_value ();  /* (as UTF8) */
    448 		/* Missing (as all 'counted' variants):
    449 		[CCode (cname = "librdf_node_get_literal_value_as_counted_string")]
    450 		public string get_literal_value_as_counted_string (out size_t len_p); */
    451 		[CCode (cname = "librdf_node_get_literal_value_as_latin1")]
    452 		public uint8[]? get_literal_value_as_latin1 ();
    453 		[CCode (cname = "librdf_node_get_literal_value_language")]
    454                 public unowned string? get_literal_value_language ();
    455 		[CCode (cname = "librdf_node_get_literal_value_is_wf_xml")]
    456 		public bool get_literal_value_is_wf_xml ();
    457 		[CCode (cname = "librdf_node_get_literal_value_datatype_uri")]
    458 		public unowned Uri? get_literal_value_datatype_uri ();
    459                 [CCode (cname = "librdf_node_get_literal_gvalue")]
    460                 public GLib.Value get_literal_gvalue(GValueAdaptorMap? adaptor_map = null);
    461 
    462 		[CCode (cname = "librdf_node_get_li_ordinal")]
    463 		public int get_li_ordinal ();
    464 		[CCode (cname = "librdf_node_get_blank_identifier")]
    465 		public unowned string get_blank_indentifier ();
    466 
    467 		[CCode (cname = "librdf_node_is_resource")]
    468 		public bool is_resource ();
    469 		[CCode (cname = "librdf_node_is_literal")]
    470 		public bool is_literal ();
    471 		[CCode (cname = "librdf_node_is_blank")]
    472 		public bool is_blank ();
    473 
    474 		/* Missing:
    475 		REDLAND_API
    476 		size_t librdf_node_encode(librdf_node* node, unsigned char *buffer, size_t length);
    477 		REDLAND_API
    478 		librdf_node* librdf_node_decode(librdf_world *world, size_t* size_p, unsigned char *buffer, size_t length);
    479 		*/
    480 
    481 		[CCode (cname = "librdf_node_to_string")]
    482 		public string? to_string ();
    483 
    484 		/* Missing:
    485 		REDLAND_API
    486 		unsigned char* librdf_node_to_counted_string(librdf_node* node, size_t* len_p);
    487 		*/
    488 
    489 		[CCode (cname = "librdf_node_print")]
    490 		public void print (FileStream file_stream);
    491 
    492 		[CCode (cname = "librdf_node_equals")]
    493 		public bool equals (Node other);
    494 	}
    495 
    496 	/***************************************************************************
    497 	 * Parser
    498 	 */
    499 
    500 	[Compact]
    501 	[CCode (cname = "librdf_parser_factory")]
    502 	public class ParserFactory {
    503 	}
    504 
    505 	[Compact]
    506 	[CCode (cname = "librdf_parser", free_function="librdf_free_parser")]
    507 	public class Parser {
    508 		[CCode (cname = "LIBRDF_PARSER_FEATURE_ERROR_COUNT")]
    509 		public static const string FEATURE_ERROR_COUNT;
    510 		[CCode (cname = "LIBRDF_PARSER_FEATURE_WARNING_COUNT")]
    511 		public static const string FEATURE_WARNING_COUNT;
    512 
    513 		[CCode (cname = "librdf_parser_guess_name2")]
    514 		// FIXME: correct param types?
    515 		public static unowned string guess_name (World world, string? mime_type, uint8 *content, uint8 *identifier);
    516 
    517 		[CCode (cname = "librdf_new_parser")]
    518 		public Parser (World world, string? name, string? mime_type, Uri? type_uri);
    519 		[CCode (cname = "librdf_new_parser_from_factory")]
    520 		public Parser.from_factory (World world, ParserFactory factory);
    521 
    522 		[CCode (cname = "librdf_parser_parse_as_stream")]
    523 		public Stream parse_as_stream (Uri uri, Uri? base_uri);
    524 		[CCode (cname = "librdf_parser_parse_into_model")]
    525 		public int parse_into_model (Uri uri, Uri? base_uri, Model model);
    526 		[CCode (cname = "librdf_parser_parse_string_as_stream")]
    527 		public Stream parse_string_as_string (string data, Uri? base_uri);
    528 		[CCode (cname = "librdf_parser_parse_string_into_model")]
    529 		public int parse_string_into_model (string data, Uri? base_uri, Model model);
    530 		[CCode (cname = "librdf_parser_parse_file_handle_as_stream")]
    531 		public Stream parse_file_as_stream (FileStream file_stream, int close_fh, Uri? base_uri);
    532 		[CCode (cname = "librdf_parser_parse_file_handle_into_model")]
    533 		public int parse_file_stream_into_model (FileStream file_stream, int close_fh,
    534 		                                         Uri? base_uri, Model model);
    535 
    536 		/*REDLAND_API
    537 		librdf_stream* librdf_parser_parse_counted_string_as_stream(librdf_parser* parser, const unsigned char *string, size_t length, librdf_uri* base_uri);
    538 		*/
    539 		/*REDLAND_API
    540 		int librdf_parser_parse_counted_string_into_model(librdf_parser* parser, const unsigned char *string, size_t length, librdf_uri* base_uri, librdf_model* model);
    541 		*/
    542 
    543 		[CCode (cname = "librdf_parser_set_uri_filter")]
    544 		public void set_uri_filter ([CCode (delegate_target_pos = 1.1)] UriFilterFunc filter);
    545 		/*REDLAND_API
    546 		librdf_uri_filter_func librdf_parser_get_uri_filter(librdf_parser* parser, void** user_data_p);
    547 		*/
    548 
    549 		[CCode (cname = "librdf_parser_get_feature")]
    550 		public unowned Node? get_feature (Uri feature);
    551 		[CCode (cname = "librdf_parser_set_feature")]
    552 		public int set_feature (Uri feature, Node feature_value);
    553 		[CCode (cname = "librdf_parser_get_accept_header")]
    554 		public unowned string? get_accept_header ();
    555 
    556 		[CCode (cname = "librdf_parser_get_namespaces_seen_prefix")]
    557 		public unowned string? get_namespaces_seen_prefix (int namespace_index);
    558 		[CCode (cname = "librdf_parser_get_namespaces_seen_uri")]
    559 		public unowned Uri? get_namespaces_seen_uri (int namespace_index);
    560 		[CCode (cname = "librdf_parser_get_namespaces_seen_count")]
    561 		public int get_namespaces_seen_count ();
    562 	}
    563 
    564 	/***************************************************************************
    565 	 * Statement (triple)
    566 	 */
    567 
    568 	[Compact]
    569 	[CCode (cname = "librdf_statement",
    570 	        copy_function = "librdf_new_statement_from_statement",
    571 	        free_function = "librdf_free_statement")]
    572 	public class Statement {
    573 		public enum Part {
    574 			SUBJECT,
    575 			PREDICATE,
    576 			OBJECT,
    577 			ALL
    578 		}
    579 
    580 		[CCode (cname = "librdf_new_statement")]
    581 		public Statement (World world);
    582 		[CCode (cname = "librdf_new_statement_from_nodes")]
    583 		public Statement.from_nodes (World world, owned Node? subject, owned Node? predicate, owned Node? object);
    584 
    585 		/* Static allocation stuff .. 
    586 		REDLAND_API
    587 		void librdf_statement_init(librdf_world *world, librdf_statement *statement);
    588 		REDLAND_API
    589 		void librdf_statement_clear(librdf_statement *statement);*/
    590 
    591 		[CCode (cname = "librdf_statement_get_subject")]
    592 		public unowned Node get_subject ();
    593 		[CCode (cname = "librdf_statement_set_subject")]
    594 		public void set_subject (Node node);
    595 
    596 		[CCode (cname = "librdf_statement_get_predicate")]
    597 		public unowned Node get_predicate ();
    598 		[CCode (cname = "librdf_statement_set_predicate")]
    599 		public void set_predicate (Node node);
    600 
    601 		[CCode (cname = "librdf_statement_get_object")]
    602 		public unowned Node get_object ();
    603 		[CCode (cname = "librdf_statement_set_object")]
    604 		public void set_object (Node node);
    605 
    606 		[CCode (cname = "librdf_statement_is_complete")]
    607 		public bool is_complete ();
    608 
    609 		/*REDLAND_API
    610 		unsigned char *librdf_statement_to_string(librdf_statement *statement);*/
    611 		[CCode (cname = "librdf_statement_print")]
    612 		public void print (FileStream file_stream);
    613 
    614 		[CCode (cname = "librdf_statement_equals")]
    615 		public int equals (Statement other);
    616 		[CCode (cname = "librdf_statement_match")]
    617 		public int match (Statement other);
    618 
    619 		/*REDLAND_API
    620 		size_t librdf_statement_encode(librdf_statement* statement, unsigned char *buffer, size_t length);
    621 		REDLAND_API
    622 		size_t librdf_statement_encode_parts(librdf_statement* statement, librdf_node* context_node, unsigned char *buffer, size_t length, librdf_statement_part fields);
    623 		REDLAND_API
    624 		size_t librdf_statement_decode(librdf_statement* statement, unsigned char *buffer, size_t length);
    625 		REDLAND_API
    626 		size_t librdf_statement_decode_parts(librdf_statement* statement, librdf_node** context_node, unsigned char *buffer, size_t length);*/
    627 	}
    628 
    629 	/***************************************************************************
    630 	 * Storage
    631 	 */
    632 
    633 	/*REDLAND_API
    634 	int librdf_storage_register_factory(librdf_world *world, const char *name, const char *label, void (*factory) (librdf_storage_factory*));*/
    635 
    636 	/*REDLAND_API
    637 	int librdf_storage_enumerate(librdf_world* world, const unsigned int counter, const char **name, const char **label);*/
    638 
    639 	[Compact]
    640 	[CCode (cname = "librdf_storage",
    641 	        copy_function = "librdf_new_storage_from_storage",
    642 	        free_function = "librdf_free_storage")]
    643 	public class Storage {
    644 		[CCode (cname = "librdf_new_storage")]
    645 		public Storage (World world, string? storage_name, string? name, string? options_string);
    646 		/*[CCode (cname = "librdf_new_storage_with_options")]
    647 		public Storage (World world, string storage_name, string name, Hash options);*/
    648 		/*REDLAND_API
    649 		librdf_storage* librdf_new_storage_from_factory(librdf_world *world, librdf_storage_factory* factory, const char *name, librdf_hash* options);*/
    650 
    651 		/* "Indended to be internal to librdf storage modules"
    652 		REDLAND_API
    653 		void librdf_storage_add_reference(librdf_storage *storage);
    654 		REDLAND_API
    655 		void librdf_storage_remove_reference(librdf_storage *storage); 
    656 
    657 		REDLAND_API
    658 		void librdf_storage_set_instance(librdf_storage *storage, librdf_storage_instance instance);
    659 		REDLAND_API
    660 		librdf_storage_instance librdf_storage_get_instance(librdf_storage *storage);*/
    661 
    662 		[CCode (cname = "librdf_storage_get_world")]
    663 		public unowned World get_world ();
    664 
    665 		[CCode (cname = "librdf_storage_open")]
    666 		public int open (Model model);
    667 		[CCode (cname = "librdf_storage_close")]
    668 		public int close ();
    669 
    670 		[CCode (cname = "librdf_storage_size")]
    671 		public int size ();
    672 
    673 		[CCode (cname = "librdf_storage_add_statement")]
    674 		public int add_statement (Statement statement);
    675 		/*[CCode (cname = "librdf_storage_add_statements")]
    676 		public int add_statements (Stream statement_stream);*/
    677 		[CCode (cname = "librdf_storage_remove_statement")]
    678 		public int remove_statement (Statement statement);
    679 		[CCode (cname = "librdf_storage_contains_statement")]
    680 		public bool contains_statement (Statement statement);
    681 
    682 		/*REDLAND_API
    683 		librdf_stream* librdf_storage_serialise(librdf_storage* storage);
    684 		REDLAND_API
    685 		librdf_stream* librdf_storage_find_statements(librdf_storage* storage, librdf_statement* statement);
    686 		REDLAND_API
    687 		librdf_stream* librdf_storage_find_statements_with_options(librdf_storage* storage, librdf_statement* statement, librdf_node* context_node, librdf_hash* options);
    688 		REDLAND_API
    689 		librdf_iterator* librdf_storage_get_sources(librdf_storage *storage, librdf_node *arc, librdf_node *target);
    690 		REDLAND_API
    691 		librdf_iterator* librdf_storage_get_arcs(librdf_storage *storage, librdf_node *source, librdf_node *target);
    692 		REDLAND_API
    693 		librdf_iterator* librdf_storage_get_targets(librdf_storage *storage, librdf_node *source, librdf_node *arc);*/
    694 
    695 		/*REDLAND_API
    696 		librdf_iterator* librdf_storage_get_arcs_in(librdf_storage *storage, librdf_node *node);
    697 		REDLAND_API
    698 		librdf_iterator* librdf_storage_get_arcs_out(librdf_storage *storage, librdf_node *node);*/
    699 
    700 		[CCode (cname = "librdf_storage_has_arc_in")]
    701 		public int has_arc_in (Node node, Node property);
    702 		[CCode (cname = "librdf_storage_has_arc_out")]
    703 		public int has_arc_out (Node node, Node property);
    704 
    705 		[CCode (cname = "librdf_storage_context_add_statement")]
    706 		public int context_add_statement (Node context, Statement statement);
    707 		/*[CCode (cname = "librdf_storage_context_add_statements")]
    708 		public int context_add_statements (Node context, Stream stream);*/
    709 		[CCode (cname = "librdf_storage_context_remove_statement")]
    710 		public int context_remove_statement (Node context, Statement statement);
    711 		[CCode (cname = "librdf_storage_context_remove_statements")]
    712 		public int context_remove_statements (Node context);
    713 		/*REDLAND_API
    714 		librdf_stream* librdf_storage_context_as_stream(librdf_storage* storage, librdf_node* context);
    715 		REDLAND_API REDLAND_DEPRECATED
    716 		librdf_stream* librdf_storage_context_serialise(librdf_storage* storage, librdf_node* context);*/
    717   
    718 		/*REDLAND_API
    719 		int librdf_storage_supports_query(librdf_storage* storage, librdf_query *query);
    720 		REDLAND_API
    721 		librdf_query_results* librdf_storage_query_execute(librdf_storage* storage, librdf_query *query);*/
    722 
    723 		[CCode (cname = "librdf_storage_sync")]
    724 		public int sync ();
    725 
    726 		/*REDLAND_API
    727 		librdf_stream* librdf_storage_find_statements_in_context(librdf_storage* storage, librdf_statement* statement, librdf_node* context_node);
    728 
    729 		REDLAND_API
    730 		librdf_iterator* librdf_storage_get_contexts(librdf_storage* storage);*/
    731 
    732 		[CCode (cname = "librdf_storage_get_feature")]
    733 		public unowned Node? get_feature (Uri feature);
    734 		[CCode (cname = "librdf_storage_set_feature")]
    735 		public int set_feature (Uri feature, Node feature_value);
    736 
    737 		[CCode (cname = "librdf_storage_transaction_start")]
    738 		public int transaction_start ();
    739 		[CCode (cname = "librdf_storage_transaction_start_with_handle")]
    740 		public int transaction_start_with_handle (void *handle);
    741 		[CCode (cname = "librdf_storage_transaction_commit")]
    742 		public int transaction_commit ();
    743 		[CCode (cname = "librdf_storage_transaction_rollback")]
    744 		public int transaction_rollback ();
    745 		[CCode (cname = "librdf_storage_transaction_get_handle")]
    746 		public void *transaction_get_handle ();
    747 	}
    748 
    749 	/***************************************************************************
    750 	 * Stream
    751 	 */
    752 
    753 	/* typedef librdf_statement* (*librdf_stream_map_handler)(librdf_stream *stream, void *map_context, librdf_statement *item); */
    754 	/* typedef void (*librdf_stream_map_free_context_handler)(void *map_context); */
    755 
    756 	[Compact]
    757 	[CCode (cname = "librdf_stream",
    758 	        free_function = "librdf_free_stream")]
    759 	public class Stream {
    760 		[Flags]
    761 		[CCode (cprefix="LIBRDF_STREAM_GET_METHOD")]
    762 		public enum GetMethod {
    763 			GET_OBJECT,
    764 			GET_CONTEXT
    765 		}
    766 
    767 		/* REDLAND_API
    768 		librdf_stream* librdf_new_stream(librdf_world *world, void* context, int (*is_end_method)(void*), int (*next_method)(void*), void* (*get_method)(void*, int), void (*finished_method)(void*)); */
    769 		[CCode (cname = "librdf_new_empty_stream")]
    770 		public Stream.empty (World world);
    771 		[CCode (cname = "librdf_new_stream_from_node_iterator")]
    772 		public Stream.from_node_iterator (Iterator iterator, Statement statement, Statement.Part field);
    773 
    774 		[CCode (cname = "librdf_stream_end")]
    775 		public bool end ();
    776 		[CCode (cname = "librdf_stream_next")]
    777 		public int next ();
    778 		[CCode (cname = "librdf_stream_get_object")]
    779 		public unowned Statement get_object ();
    780 		[CCode (cname = "librdf_stream_get_context")]
    781 		public void *get_context ();
    782 
    783 		/*REDLAND_API
    784 		int librdf_stream_add_map(librdf_stream* stream, librdf_stream_map_handler map_function, librdf_stream_map_free_context_handler free_context, void *map_context);*/
    785 
    786 		[CCode (cname = "librdf_stream_print")]
    787 		public void print (FileStream file_stream);
    788 	}
    789 
    790 	/***************************************************************************
    791 	 * Uri
    792 	 */
    793 
    794 	[CCode (cname = "librdf_uri_filter_func", instance_pos = 0)]
    795 	public delegate int UriFilterFunc (Uri uri);
    796 
    797 	[Compact]
    798 	[CCode (cname = "librdf_uri",
    799 	        copy_function = "librdf_new_uri_from_uri",
    800 	        free_function = "librdf_free_uri")]
    801 	public class Uri {
    802 		[CCode (cname = "librdf_new_uri")]
    803 		public Uri (World world, string uri_string);
    804 		[CCode (cname = "librdf_new_uri_from_uri")]
    805 		public Uri.from_uri (Uri old_uri);
    806 		[CCode (cname = "librdf_new_uri_from_uri_local_name")]
    807 		public Uri.from_uri_local_name (Uri old_uri, string local_name);
    808 		[CCode (cname = "librdf_new_uri_normalised_to_base")]
    809 		public Uri.normalised_to_base (string uri_string, Uri source_uri, Uri base_uri);
    810 		[CCode (cname = "librdf_new_uri_relative_to_base")]
    811 		public Uri.relative_to_base (Uri base_uri, string uri_string);
    812 		[CCode (cname = "librdf_new_uri_from_filename")]
    813 		public Uri.from_filename (World world, string filename);
    814 
    815 		/* FIXME: only present due to vala not using the free_function correctly */
    816 		[CCode (cname = "librdf_free_uri")]
    817 		public void free ();
    818 
    819 		[CCode (cname = "librdf_uri_as_string")]
    820 		public unowned string as_string();
    821 		/*[CCode (cname = "librdf_uri_as_counted_string")] (librdf_uri *uri, size_t *len_p); */
    822 		[CCode (cname = "librdf_uri_print")]
    823 		public void print (FileStream file_stream);
    824 		[CCode (cname = "librdf_uri_to_string")]
    825 		public string to_string ();
    826 		/*REDLAND_API
    827 		unsigned char* librdf_uri_to_counted_string (librdf_uri* uri, size_t* len_p);*/
    828 
    829 		[CCode (cname = "librdf_uri_equals")]
    830 		public bool equals (Uri other);
    831 		[CCode (cname = "librdf_uri_compare")]
    832 		public int compare (Uri other);
    833 		[CCode (cname = "librdf_uri_is_file_uri")]
    834 		public bool is_file_uri ();
    835 		[CCode (cname = "librdf_uri_to_filename")]
    836 		public string to_filename ();
    837 	}
    838 }
    839 
    840 [CCode (cheader_filename = "raptor.h")]
    841 namespace Raptor {
    842 	public enum IdentifierType {
    843 		RESOURCE,
    844 		ANONYMOUS,
    845 		PREDICATE,
    846 		ORDINAL,
    847 		LITERAL,
    848 		XML_LITERAL
    849 	}
    850 
    851 	[CCode (cname = "raptor_locator")]
    852 	public struct Locator {
    853 		public Raptor.Uri uri;
    854 		public string file;
    855 		public int line;
    856 		public int column;
    857 		public int byte;
    858 	}
    859 
    860 	extern void init ();
    861 
    862 	[Compact]
    863 	[CCode (cname = "raptor_parser", free_function = "raptor_free_parser")]
    864 	public class Parser {
    865 		[CCode (cname = "raptor_new_parser")]
    866 		public Parser (string name);
    867 		[CCode (cname = "raptor_set_statement_handler")]
    868 		public void set_statement_handler ([CCode (delegate_target_pos = 0.9)] StatementHandler handler);
    869 		[CCode (cname = "raptor_parse_file")]
    870 		public void parse_file (Uri? uri, Uri? base_uri);
    871 		[CCode (cname = "raptor_start_parse")]
    872 		public void start_parse (Uri uri);
    873 	}
    874 
    875 	[Compact]
    876 	[CCode (cname = "void")]
    877 	public class Term {
    878 		[CCode (cname = "raptor_statement_part_as_string")]
    879 		public string part_as_string (IdentifierType type, Uri? literal_datatype,
    880 		                              string? literal_language);
    881 	}
    882 
    883 	[Compact]
    884 	[CCode (cname = "raptor_statement")]
    885 	public class Statement {
    886 		public Term subject;
    887 		public IdentifierType subject_type;
    888 		public Term predicate;
    889 		public IdentifierType predicate_type;
    890 		public Term object;
    891 		public IdentifierType object_type;
    892 		public Uri? object_literal_datatype;
    893 		public string? object_literal_language;
    894 
    895 		[CCode (cname = "raptor_statement_compare")]
    896 		public int compare (Statement other);
    897 
    898 		[CCode (cname = "raptor_print_statement")]
    899 		public void print (FileStream stream);
    900 		[CCode (cname = "raptor_print_statement_as_ntriples")]
    901 		public void print_as_ntriples (FileStream stream);
    902 	}
    903 
    904 	[CCode (cname = "raptor_statement_handler", instance_pos = 0)]
    905 	public delegate void StatementHandler (Statement statement);
    906 
    907 	[Compact]
    908 	[CCode (cname = "raptor_uri", free_function = "raptor_free_uri")]
    909 	public class Uri {
    910 		[CCode (cname = "raptor_new_uri")]
    911 		public Uri (string uri_string);
    912 		public static string filename_to_uri_string (string filename);
    913 		public unowned string as_string ();
    914 	}
    915 }