update credits
[LibreOffice.git] / redland / raptor / raptor2.h
blob4d0291bb6dfa4e1aa47553f18f03c064f6a4bb02
1 /* -*- Mode: c; c-basic-offset: 2 -*-
3 * raptor.h - Redland Parser Toolkit for RDF (Raptor) - public API
5 * Copyright (C) 2000-2013, David Beckett http://www.dajobe.org/
6 * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/
8 * This package is Free Software and part of Redland http://librdf.org/
10 * It is licensed under the following three licenses as alternatives:
11 * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
12 * 2. GNU General Public License (GPL) V2 or any newer version
13 * 3. Apache License, V2.0 or any newer version
15 * You may not use this file except in compliance with at least one of
16 * the above three licenses.
18 * See LICENSE.html or LICENSE.txt at the top of this package for the
19 * complete terms and further detail along with the license texts for
20 * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
27 #ifndef RAPTOR_H
28 #define RAPTOR_H
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #include <stdio.h>
37 /* Required for va_list in raptor_vsnprintf */
38 #include <stdarg.h>
41 /**
42 * RAPTOR_V2_AVAILABLE
44 * Flag for marking raptor2 API availability.
46 #define RAPTOR_V2_AVAILABLE 1
49 /**
50 * RAPTOR_VERSION:
52 * Raptor library version number
54 * Format: major * 10000 + minor * 100 + release
56 #define RAPTOR_VERSION 20009
58 /**
59 * RAPTOR_VERSION_STRING:
61 * Raptor library version string
63 #define RAPTOR_VERSION_STRING "2.0.9"
65 /**
66 * RAPTOR_VERSION_MAJOR:
68 * Raptor library major version
70 #define RAPTOR_VERSION_MAJOR 2
72 /**
73 * RAPTOR_VERSION_MINOR:
75 * Raptor library minor version
77 #define RAPTOR_VERSION_MINOR 0
79 /**
80 * RAPTOR_VERSION_RELEASE:
82 * Raptor library release
84 #define RAPTOR_VERSION_RELEASE 9
86 /**
87 * RAPTOR_API:
89 * Macro for wrapping API function call declarations.
92 #ifndef RAPTOR_API
93 # ifdef WIN32
94 # ifdef __GNUC__
95 # undef _declspec
96 # define _declspec(x) __declspec(x)
97 # endif
98 # ifdef RAPTOR_STATIC
99 # define RAPTOR_API
100 # else
101 # ifdef RAPTOR_INTERNAL
102 # define RAPTOR_API _declspec(dllexport)
103 # else
104 # define RAPTOR_API _declspec(dllimport)
105 # endif
106 # endif
107 # else
108 # define RAPTOR_API
109 # endif
110 #endif
112 /* Use gcc 3.1+ feature to allow marking of deprecated API calls.
113 * This gives a warning during compiling.
115 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
116 #define RAPTOR_DEPRECATED __attribute__((deprecated))
117 #define RAPTOR_NORETURN __attribute__((__noreturn__))
118 #else
119 #define RAPTOR_DEPRECATED
120 #define RAPTOR_NORETURN
121 #endif
124 * RAPTOR_PRINTF_FORMAT:
125 * @string_index: ignore me
126 * @first_to_check_index: ignore me
128 * Internal macro
130 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
131 #define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index) \
132 __attribute__((__format__(__printf__, string_index, first_to_check_index)))
133 #else
134 #define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index)
135 #endif
138 * raptor_uri:
140 * Raptor URI Class.
142 typedef struct raptor_uri_s raptor_uri;
145 /* Public statics */
148 * raptor_short_copyright_string:
150 * Short copyright string (one line).
152 RAPTOR_API
153 extern const char * const raptor_short_copyright_string;
156 * raptor_copyright_string:
158 * Copyright string (multiple lines).
160 RAPTOR_API
161 extern const char * const raptor_copyright_string;
164 * raptor_version_string:
166 * Raptor version as a string.
168 RAPTOR_API
169 extern const char * const raptor_version_string;
172 * raptor_version_major:
174 * Raptor major version number.
176 RAPTOR_API
177 extern const unsigned int raptor_version_major;
180 * raptor_version_minor:
182 * Raptor minor version number.
184 RAPTOR_API
185 extern const unsigned int raptor_version_minor;
188 * raptor_version_release:
190 * Raptor release version number.
192 RAPTOR_API
193 extern const unsigned int raptor_version_release;
196 * raptor_version_decimal:
198 * Raptor version as a decimal number.
200 * Format: major * 10000 + minor * 100 + release
202 RAPTOR_API
203 extern const unsigned int raptor_version_decimal;
206 * raptor_license_string:
208 * Raptor license string.
210 RAPTOR_API
211 extern const char * const raptor_license_string;
214 * raptor_home_url_string:
216 * Raptor home page URL.
218 RAPTOR_API
219 extern const char * const raptor_home_url_string;
222 * raptor_xml_namespace_uri:
224 * XML Namespace (xml:) URI string.
226 RAPTOR_API
227 extern const unsigned char * const raptor_xml_namespace_uri;
231 * raptor_rdf_namespace_uri:
233 * RDF Namespace (rdf:) URI string.
235 RAPTOR_API
236 extern const unsigned char * const raptor_rdf_namespace_uri;
239 * raptor_rdf_namespace_uri_len:
241 * Length of #raptor_rdf_namespace_uri string
243 RAPTOR_API
244 extern const unsigned int raptor_rdf_namespace_uri_len;
247 * raptor_rdf_schema_namespace_uri:
249 * RDF Schema (rdfs:) Namespace URI string.
251 RAPTOR_API
252 extern const unsigned char * const raptor_rdf_schema_namespace_uri;
255 * raptor_xmlschema_datatypes_namespace_uri:
257 * XML Schema datatypes (xsd:) namespace URI string.
259 RAPTOR_API
260 extern const unsigned char * const raptor_xmlschema_datatypes_namespace_uri;
263 * raptor_owl_namespace_uri:
265 * OWL (owl:) Namespace URI string.
267 RAPTOR_API
268 extern const unsigned char * const raptor_owl_namespace_uri;
271 * raptor_xml_literal_datatype_uri_string:
273 * XML Literal datatype (rdf:XMLLiteral) URI string.
275 RAPTOR_API
276 extern const unsigned char * const raptor_xml_literal_datatype_uri_string;
279 * raptor_xml_literal_datatype_uri_string_len:
281 * Length of #raptor_xml_literal_datatype_uri_string
283 RAPTOR_API
284 extern const unsigned int raptor_xml_literal_datatype_uri_string_len;
287 /* Public structure */
289 * raptor_world:
291 * Raptor world class.
293 typedef struct raptor_world_s raptor_world;
295 * raptor_parser:
297 * Raptor Parser class
299 typedef struct raptor_parser_s raptor_parser;
301 * raptor_serializer:
303 * Raptor Serializer class
305 typedef struct raptor_serializer_s raptor_serializer;
308 * raptor_www:
310 * Raptor WWW class
312 typedef struct raptor_www_s raptor_www;
314 * raptor_iostream:
316 * Raptor I/O Stream class
318 typedef struct raptor_iostream_s raptor_iostream;
320 * raptor_xml_element:
322 * Raptor XML Element class
324 typedef struct raptor_xml_element_s raptor_xml_element;
326 * raptor_xml_writer:
328 * Raptor XML Writer class
330 typedef struct raptor_xml_writer_s raptor_xml_writer;
332 * raptor_qname:
334 * Raptor XML qname class
336 typedef struct raptor_qname_s raptor_qname;
338 * raptor_namespace:
340 * Raptor XML Namespace class
342 typedef struct raptor_namespace_s raptor_namespace;
344 * raptor_namespace_stack:
346 * Raptor XML Namespace Stack class
348 typedef struct raptor_namespace_stack_s raptor_namespace_stack;
351 * raptor_sax2:
353 * Raptor SAX2 class
355 typedef struct raptor_sax2_s raptor_sax2;
359 * raptor_type_q:
360 * @mime_type: MIME type string
361 * @mime_type_len: length of @mime_type
362 * @q: Q value 0-10 standing for decimal 0.0-1.0
364 * (MIME Type, Q) pair
366 typedef struct {
367 const char* mime_type;
368 size_t mime_type_len;
369 unsigned char q;
370 } raptor_type_q;
374 * raptor_syntax_bitflags:
375 * @RAPTOR_SYNTAX_NEED_BASE_URI: the syntax requires a base URI
377 * Bit flags for #raptor_syntax_description flags field
379 typedef enum {
380 RAPTOR_SYNTAX_NEED_BASE_URI = 1
381 } raptor_syntax_bitflags;
385 * raptor_syntax_description:
386 * @names: array of syntax names - the first one (required) is the public name, the rest are aliases. The array is NULL terminated.
387 * @names_count: size of @names array
388 * @label: long descriptive label for syntax
389 * @mime_types: Array of (MIME type, Q) values associated with the syntax (or NULL). If present the array is NULL terminated.
390 * @mime_types_count: size of @mime_types array
391 * @uri_strings: array of URIs identifying the syntax (or NULL). The first one if present is the main URI, the rest are aliases. The array is NULL terminated.
392 * @uri_strings_count: size of @uri_strings array
393 * @flags: See #raptor_syntax_bitflags for the bits
395 * Description of a syntax or file format.
398 typedef struct {
399 const char* const* names;
400 unsigned int names_count;
402 const char* label;
404 const raptor_type_q* mime_types;
405 unsigned int mime_types_count;
407 const char* const* uri_strings;
408 unsigned int uri_strings_count;
410 unsigned int flags;
411 } raptor_syntax_description;
415 * raptor_term_type:
416 * @RAPTOR_TERM_TYPE_URI: RDF URI
417 * @RAPTOR_TERM_TYPE_LITERAL: RDF literal
418 * @RAPTOR_TERM_TYPE_BLANK: RDF blank node
419 * @RAPTOR_TERM_TYPE_UNKNOWN: Internal
421 * Type of term in a #raptor_statement
423 * Node type 3 is unused but exists to preserve numeric compatibility
424 * with librdf_node_type values.
426 typedef enum {
427 RAPTOR_TERM_TYPE_UNKNOWN = 0,
428 RAPTOR_TERM_TYPE_URI = 1,
429 RAPTOR_TERM_TYPE_LITERAL = 2,
430 /* unused type 3 */
431 RAPTOR_TERM_TYPE_BLANK = 4
432 } raptor_term_type;
436 * raptor_locator:
437 * @uri: URI of location (or NULL)
438 * @file: Filename of location (or NULL)
439 * @line: Line number of location (or <0 for no line)
440 * @column: Column number of location (or <0 for no column)
441 * @byte: Byte number of location (or <0 for no byte)
443 * Location information for an error, warning or information message.
445 typedef struct {
446 raptor_uri *uri;
447 const char *file;
448 int line;
449 int column;
450 int byte;
451 } raptor_locator;
454 * raptor_option:
455 * @RAPTOR_OPTION_SCANNING: If true (default false), the RDF/XML
456 * parser will look for embedded rdf:RDF elements inside the XML
457 * content, and not require that the XML start with an rdf:RDF root
458 * element.
459 * @RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES: If true (default true)
460 * then the RDF/XML parser will allow non-XML namespaced attributes
461 * to be accepted as well as rdf: namespaced ones. For example,
462 * 'about' and 'ID' will be interpreted as if they were rdf:about
463 * and rdf:ID respectively.
464 * @RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES: If true (default true)
465 * then the RDF/XML parser will allow unknown parsetypes to be
466 * present and will pass them on to the user. Unimplemented at
467 * present.
468 * @RAPTOR_OPTION_ALLOW_BAGID: If true (default true) then the
469 * RDF/XML parser will support the rdf:bagID attribute that was
470 * removed from the RDF/XML language when it was revised. This
471 * support may be removed in future.
472 * @RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST: If true (default false)
473 * then the RDF/XML parser will generate the idList rdf:type
474 * rdf:List triple in the handling of rdf:parseType="Collection".
475 * This triple was removed during the revising of RDF/XML after
476 * collections were initially added.
477 * @RAPTOR_OPTION_NORMALIZE_LANGUAGE: If true (default true) then
478 * XML language values such as from xml:lang will be normalized to
479 * lowercase.
480 * @RAPTOR_OPTION_NON_NFC_FATAL: If true (default false) then
481 * illegal Unicode Normal Form C in literals will give a fatal
482 * error, otherwise just a warning.
483 * @RAPTOR_OPTION_WARN_OTHER_PARSETYPES: If true (default true) then
484 * the RDF/XML parser will warn about unknown rdf:parseType values.
485 * @RAPTOR_OPTION_CHECK_RDF_ID: If true (default true) then the
486 * RDF/XML will check rdf:ID attribute values for duplicates and
487 * cause an error if any are found.
488 * @RAPTOR_OPTION_RELATIVE_URIS: If true (default true) then
489 * relative URIs will be used wherever possible when serializing.
490 * @RAPTOR_OPTION_WRITER_AUTO_INDENT: Automatically indent elements when
491 * seriailizing.
492 * @RAPTOR_OPTION_WRITER_AUTO_EMPTY: Automatically detect and
493 * abbreviate empty elements when serializing.
494 * @RAPTOR_OPTION_WRITER_INDENT_WIDTH: Integer number of spaces to use
495 * for each indent level when serializing with auto indent.
496 * @RAPTOR_OPTION_WRITER_XML_VERSION: Integer XML version XML 1.0 (10) or XML 1.1 (11)
497 * @RAPTOR_OPTION_WRITER_XML_DECLARATION: Write XML 1.0 or 1.1 declaration.
498 * @RAPTOR_OPTION_NO_NET: Deny network requests inside other requests.
499 * @RAPTOR_OPTION_RESOURCE_BORDER: Border color of resource
500 * nodes for GraphViz DOT serializer.
501 * @RAPTOR_OPTION_LITERAL_BORDER: Border color of literal nodes
502 * for GraphViz DOT serializer.
503 * @RAPTOR_OPTION_BNODE_BORDER: Border color of blank nodes for
504 * GraphViz DOT serializer.
505 * @RAPTOR_OPTION_RESOURCE_FILL: Fill color of resource nodes
506 * for GraphViz DOT serializer.
507 * @RAPTOR_OPTION_LITERAL_FILL: Fill color of literal nodes for
508 * GraphViz DOT serializer.
509 * @RAPTOR_OPTION_BNODE_FILL: Fill color of blank nodes for
510 * GraphViz DOT serializer.
511 * @RAPTOR_OPTION_HTML_TAG_SOUP: Use a lax HTML parser if an XML parser
512 * fails when read HTML for GRDDL parser.
513 * @RAPTOR_OPTION_MICROFORMATS: Look for microformats for GRDDL parser.
514 * @RAPTOR_OPTION_HTML_LINK: Look for head &lt;link&gt; to type rdf/xml
515 * for GRDDL parser.
516 * @RAPTOR_OPTION_WWW_TIMEOUT: Set timeout for internal WWW URI requests
517 * for GRDDL parser.
518 * @RAPTOR_OPTION_WRITE_BASE_URI: Write @base directive for Turtle/N3.
519 * @RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL: HTTP Cache-Control: header
520 * @RAPTOR_OPTION_WWW_HTTP_USER_AGENT: HTTP User-Agent: header
521 * @RAPTOR_OPTION_JSON_CALLBACK: JSON serializer callback function.
522 * @RAPTOR_OPTION_JSON_EXTRA_DATA: JSON serializer extra top-level data
523 * @RAPTOR_OPTION_RSS_TRIPLES: Atom/RSS serializer writes extra RDF triples it finds (none, rdf-xml, atom-triples)
524 * @RAPTOR_OPTION_ATOM_ENTRY_URI: Atom entry URI. If given, generate an Atom Entry Document with the item having the given URI, otherwise generate an Atom Feed Document with any items found.
525 * @RAPTOR_OPTION_PREFIX_ELEMENTS: Integer. If set, generate Atom/RSS1.0 documents with prefixed elements, otherwise unprefixed.
526 * @RAPTOR_OPTION_STRICT: Boolean. If set, operate in strict conformance mode.
527 * @RAPTOR_OPTION_WWW_CERT_FILENAME: String. SSL client certificate filename
528 * @RAPTOR_OPTION_WWW_CERT_TYPE: String. SSL client certificate type
529 * @RAPTOR_OPTION_WWW_CERT_PASSPHRASE: String. SSL client certificate passphrase
530 * @RAPTOR_OPTION_WWW_SSL_VERIFY_PEER: Integer. SSL verify peer - non-0 to verify peer SSL certificate (default)
531 * @RAPTOR_OPTION_WWW_SSL_VERIFY_HOST: Integer. SSL verify host - 0 none, 1 CN match, 2 host match (default). Other values are ignored.
532 * @RAPTOR_OPTION_NO_FILE: Deny file reading requests inside other requests.
533 * @RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES: When reading XML, load external entities.
534 * @RAPTOR_OPTION_LAST: Internal
536 * Raptor parser, serializer or XML writer options.
538 typedef enum {
539 RAPTOR_OPTION_SCANNING,
540 RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES,
541 RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES,
542 RAPTOR_OPTION_ALLOW_BAGID,
543 RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST,
544 RAPTOR_OPTION_NORMALIZE_LANGUAGE,
545 RAPTOR_OPTION_NON_NFC_FATAL,
546 RAPTOR_OPTION_WARN_OTHER_PARSETYPES,
547 RAPTOR_OPTION_CHECK_RDF_ID,
548 RAPTOR_OPTION_RELATIVE_URIS,
549 RAPTOR_OPTION_WRITER_AUTO_INDENT,
550 RAPTOR_OPTION_WRITER_AUTO_EMPTY,
551 RAPTOR_OPTION_WRITER_INDENT_WIDTH,
552 RAPTOR_OPTION_WRITER_XML_VERSION,
553 RAPTOR_OPTION_WRITER_XML_DECLARATION,
554 RAPTOR_OPTION_NO_NET,
555 RAPTOR_OPTION_RESOURCE_BORDER,
556 RAPTOR_OPTION_LITERAL_BORDER,
557 RAPTOR_OPTION_BNODE_BORDER,
558 RAPTOR_OPTION_RESOURCE_FILL,
559 RAPTOR_OPTION_LITERAL_FILL,
560 RAPTOR_OPTION_BNODE_FILL,
561 RAPTOR_OPTION_HTML_TAG_SOUP,
562 RAPTOR_OPTION_MICROFORMATS,
563 RAPTOR_OPTION_HTML_LINK,
564 RAPTOR_OPTION_WWW_TIMEOUT,
565 RAPTOR_OPTION_WRITE_BASE_URI,
566 RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL,
567 RAPTOR_OPTION_WWW_HTTP_USER_AGENT,
568 RAPTOR_OPTION_JSON_CALLBACK,
569 RAPTOR_OPTION_JSON_EXTRA_DATA,
570 RAPTOR_OPTION_RSS_TRIPLES,
571 RAPTOR_OPTION_ATOM_ENTRY_URI,
572 RAPTOR_OPTION_PREFIX_ELEMENTS,
573 RAPTOR_OPTION_STRICT,
574 RAPTOR_OPTION_WWW_CERT_FILENAME,
575 RAPTOR_OPTION_WWW_CERT_TYPE,
576 RAPTOR_OPTION_WWW_CERT_PASSPHRASE,
577 RAPTOR_OPTION_NO_FILE,
578 RAPTOR_OPTION_WWW_SSL_VERIFY_PEER,
579 RAPTOR_OPTION_WWW_SSL_VERIFY_HOST,
580 RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES,
581 RAPTOR_OPTION_LAST = RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES
582 } raptor_option;
586 * raptor_term_literal_value:
587 * @string: literal string
588 * @string_len: length of string
589 * @datatype: datatype URI (or NULL)
590 * @language: literal language (or NULL)
591 * @language_len: length of language
593 * Literal term value - this typedef exists solely for use in #raptor_term
595 * Either @datatype or @language may be non-NULL but not both.
597 typedef struct {
598 unsigned char *string;
599 unsigned int string_len;
601 raptor_uri *datatype;
603 unsigned char *language;
604 unsigned char language_len;
605 } raptor_term_literal_value;
609 * raptor_term_blank_value:
610 * @string: literal string
611 * @string_len: length of string
613 * Blank term value - this typedef exists solely for use in #raptor_term
616 typedef struct {
617 unsigned char *string;
618 unsigned int string_len;
619 } raptor_term_blank_value;
623 * raptor_term_value:
624 * @uri: uri value when term type is #RAPTOR_TERM_TYPE_URI
625 * @literal: literal value when term type is #RAPTOR_TERM_TYPE_LITERAL
626 * @blank: blank value when term type is #RAPTOR_TERM_TYPE_BLANK
628 * Term value - this typedef exists solely for use in #raptor_term
631 typedef union {
632 raptor_uri *uri;
634 raptor_term_literal_value literal;
636 raptor_term_blank_value blank;
637 } raptor_term_value;
641 * raptor_term:
642 * @world: world
643 * @usage: usage reference count (if >0)
644 * @type: term type
645 * @value: term values per type
647 * An RDF statement term
650 typedef struct {
651 raptor_world* world;
653 int usage;
655 raptor_term_type type;
657 raptor_term_value value;
659 } raptor_term;
663 * raptor_statement:
664 * @world: world pointer
665 * @usage: usage count
666 * @subject: statement subject
667 * @predicate: statement predicate
668 * @object: statement object
669 * @graph: statement graph name (or NULL if not present)
671 * An RDF triple with optional graph name (quad)
673 * See #raptor_term for a description of how the fields may be used.
674 * As returned by a parser statement_handler.
676 typedef struct {
677 raptor_world* world;
678 int usage;
679 raptor_term* subject;
680 raptor_term* predicate;
681 raptor_term* object;
682 raptor_term* graph;
683 } raptor_statement;
687 * raptor_log_level:
688 * @RAPTOR_LOG_LEVEL_NONE: Internal
689 * @RAPTOR_LOG_LEVEL_TRACE: very fine-grained tracing messages information
690 * @RAPTOR_LOG_LEVEL_DEBUG: fine-grained tracing messages suitable for debugging
691 * @RAPTOR_LOG_LEVEL_INFO: coarse-grained information messages
692 * @RAPTOR_LOG_LEVEL_WARN: warning messages of potentially harmful problems
693 * @RAPTOR_LOG_LEVEL_ERROR: error messages where the application can continue
694 * @RAPTOR_LOG_LEVEL_FATAL: fatal error message where the application will likely abort
695 * @RAPTOR_LOG_LEVEL_LAST: Internal
697 * Log levels
699 typedef enum {
700 RAPTOR_LOG_LEVEL_NONE,
701 RAPTOR_LOG_LEVEL_TRACE,
702 RAPTOR_LOG_LEVEL_DEBUG,
703 RAPTOR_LOG_LEVEL_INFO,
704 RAPTOR_LOG_LEVEL_WARN,
705 RAPTOR_LOG_LEVEL_ERROR,
706 RAPTOR_LOG_LEVEL_FATAL,
707 RAPTOR_LOG_LEVEL_LAST = RAPTOR_LOG_LEVEL_FATAL
708 } raptor_log_level;
712 * raptor_domain:
713 * @RAPTOR_DOMAIN_IOSTREAM: I/O stream
714 * @RAPTOR_DOMAIN_NAMESPACE: XML Namespace / namespace stack
715 * @RAPTOR_DOMAIN_PARSER: RDF Parser
716 * @RAPTOR_DOMAIN_QNAME: XML QName
717 * @RAPTOR_DOMAIN_SAX2: XML SAX2
718 * @RAPTOR_DOMAIN_SERIALIZER: RDF Serializer
719 * @RAPTOR_DOMAIN_TERM: RDF Term
720 * @RAPTOR_DOMAIN_TURTLE_WRITER: Turtle Writer
721 * @RAPTOR_DOMAIN_URI: RDF Uri
722 * @RAPTOR_DOMAIN_WORLD: RDF world
723 * @RAPTOR_DOMAIN_WWW: WWW
724 * @RAPTOR_DOMAIN_XML_WRITER: XML Writer
725 * @RAPTOR_DOMAIN_NONE: Internal
726 * @RAPTOR_DOMAIN_LAST: Internal
728 * Log domain
730 typedef enum {
731 RAPTOR_DOMAIN_NONE,
732 RAPTOR_DOMAIN_IOSTREAM,
733 RAPTOR_DOMAIN_NAMESPACE,
734 RAPTOR_DOMAIN_PARSER,
735 RAPTOR_DOMAIN_QNAME,
736 RAPTOR_DOMAIN_SAX2,
737 RAPTOR_DOMAIN_SERIALIZER,
738 RAPTOR_DOMAIN_TERM,
739 RAPTOR_DOMAIN_TURTLE_WRITER,
740 RAPTOR_DOMAIN_URI,
741 RAPTOR_DOMAIN_WORLD,
742 RAPTOR_DOMAIN_WWW,
743 RAPTOR_DOMAIN_XML_WRITER,
744 RAPTOR_DOMAIN_LAST = RAPTOR_DOMAIN_XML_WRITER
745 } raptor_domain;
749 * raptor_log_message:
750 * @code: error code or < 0 if not used or known
751 * @domain: message domain or #RAPTOR_DOMAIN_NONE if not used or known
752 * @level: log message level
753 * @locator: location associated with message or NULL if not known
754 * @text: message string
756 * Log message.
758 typedef struct {
759 int code;
760 raptor_domain domain;
761 raptor_log_level level;
762 raptor_locator *locator;
763 const char *text;
764 } raptor_log_message;
768 * raptor_log_handler:
769 * @user_data: user data
770 * @message: log message
772 * Handler function for log messages with location
774 * Used during parsing and serializing for errors and warnings that
775 * may include location information. Handlers may be set
776 * by raptor_world_set_log_handler().
779 typedef void (*raptor_log_handler)(void *user_data, raptor_log_message *message);
783 * raptor_statement_handler:
784 * @user_data: user data
785 * @statement: statement to report
787 * Statement (triple) reporting handler function.
789 * This handler function set with
790 * raptor_parser_set_statement_handler() on a parser receives
791 * statements as the parsing proceeds. The @statement argument to the
792 * handler is shared and must be copied by the caller with
793 * raptor_statement_copy().
795 typedef void (*raptor_statement_handler)(void *user_data, raptor_statement *statement);
798 * raptor_graph_mark_flags:
799 * @RAPTOR_GRAPH_MARK_START: mark is start of graph (otherwise is end)
800 * @RAPTOR_GRAPH_MARK_DECLARED: mark was declared in syntax rather than implict
802 * Graph mark handler bitmask flags
804 typedef enum {
805 RAPTOR_GRAPH_MARK_START = 1,
806 RAPTOR_GRAPH_MARK_DECLARED = 2
807 } raptor_graph_mark_flags;
811 * raptor_graph_mark_handler:
812 * @user_data: user data
813 * @graph: graph to report, NULL for the default graph
814 * @flags: bitmask of #raptor_graph_mark_flags flags
816 * Graph start/end mark handler function.
818 * Records start and end of graphs happening in a stream of generated
819 * #raptor_statement via the statement handler. The callback starts a
820 * graph when @flags has #RAPTOR_GRAPH_MARK_START bit set.
822 * The start and ends may be either declared in the syntax via some
823 * keyword or mechanism such as TRiG {} syntax when @flags has bit
824 * #RAPTOR_GRAPH_MARK_DECLARED set, or be implied by the start/end of
825 * the data in other syntaxes, and the bit will be unset.
827 typedef void (*raptor_graph_mark_handler)(void *user_data, raptor_uri *graph, int flags);
830 * raptor_generate_bnodeid_handler:
831 * @user_data: user data
832 * @user_bnodeid: a user-specified ID or NULL if none available.
834 * Generate a blank node identifier handler function.
836 * Return value: new blank node ID to use
838 typedef unsigned char* (*raptor_generate_bnodeid_handler)(void *user_data, unsigned char* user_bnodeid);
841 * raptor_namespace_handler:
842 * @user_data: user data
843 * @nspace: #raptor_namespace declared
845 * XML Namespace declaration reporting handler set by
846 * raptor_parser_set_namespace_handler().
848 typedef void (*raptor_namespace_handler)(void* user_data, raptor_namespace *nspace);
852 * raptor_www_write_bytes_handler:
853 * @www: WWW object
854 * @userdata: user data
855 * @ptr: data pointer
856 * @size: size of individual item
857 * @nmemb: number of items
859 * Receiving bytes of data from WWW retrieval handler.
861 * Set by raptor_www_set_write_bytes_handler().
863 typedef void (*raptor_www_write_bytes_handler)(raptor_www* www, void *userdata, const void *ptr, size_t size, size_t nmemb);
866 * raptor_www_content_type_handler:
867 * @www: WWW object
868 * @userdata: user data
869 * @content_type: content type seen
871 * Receiving Content-Type: header from WWW retrieval handler.
873 * Set by raptor_www_set_content_type_handler().
875 typedef void (*raptor_www_content_type_handler)(raptor_www* www, void *userdata, const char *content_type);
878 * raptor_www_final_uri_handler:
879 * @www: WWW object
880 * @userdata: user data
881 * @final_uri: final URI seen
883 * Receiving the final resolved URI from a WWW retrieval
885 * Set by raptor_www_set_final_uri_handler().
887 typedef void (*raptor_www_final_uri_handler)(raptor_www* www, void *userdata, raptor_uri *final_uri);
890 * raptor_uri_filter_func:
891 * @user_data: user data
892 * @uri: #raptor_uri URI to check
894 * Callback function for #raptor_www_set_uri_filter
896 * Return value: non-0 to filter the URI
898 typedef int (*raptor_uri_filter_func)(void *user_data, raptor_uri* uri);
902 * raptor_world_flag:
903 * @RAPTOR_WORLD_FLAG_LIBXML_GENERIC_ERROR_SAVE: if set (non-0 value) - save/restore the libxml generic error handler when raptor library initializes (default set)
904 * @RAPTOR_WORLD_FLAG_LIBXML_STRUCTURED_ERROR_SAVE: if set (non-0 value) - save/restore the libxml structured error handler when raptor library terminates (default set)
905 * @RAPTOR_WORLD_FLAG_URI_INTERNING: if set (non-0 value) - each URI is saved interned in-memory and reused (default set)
906 * @RAPTOR_WORLD_FLAG_WWW_SKIP_INIT_FINISH: if set (non-0 value) the raptor will neither initialise or terminate the lower level WWW library. Usually in raptor initialising either curl_global_init (for libcurl) are called and in raptor cleanup, curl_global_cleanup is called. This flag allows the application finer control over these libraries such as setting other global options or potentially calling and terminating raptor several times. It does mean that applications which use this call must do their own extra work in order to allocate and free all resources to the system.
908 * Raptor world flags
910 * These are used by raptor_world_set_flags() to control raptor-wide
911 * options across classes. These must be set before
912 * raptor_world_open() is called explicitly or implicitly (by
913 * creating a raptor object). There is no enumeration function for
914 * these flags because they are not user options and must be set
915 * before the library is initialised. For similar reasons, there is
916 * no get function.
918 * If any libxml handler saving/restoring is enabled, any existing
919 * handler and context is saved before parsing and restored
920 * afterwards. Otherwise, no saving/restoring is performed.
923 typedef enum {
924 RAPTOR_WORLD_FLAG_LIBXML_GENERIC_ERROR_SAVE = 1,
925 RAPTOR_WORLD_FLAG_LIBXML_STRUCTURED_ERROR_SAVE = 2,
926 RAPTOR_WORLD_FLAG_URI_INTERNING = 3,
927 RAPTOR_WORLD_FLAG_WWW_SKIP_INIT_FINISH = 4
928 } raptor_world_flag;
932 * raptor_data_compare_handler:
933 * @data1: first data object
934 * @data2: second data object
936 * Function to compare two data objects - signature like strcmp() and function pssed to qsort()
938 * Designed to be passed into generic data structure constructors
939 * like raptor_new_avltree().
941 * Return value: compare value <0 if @data1 is before @data2, =0 if equal, >0 if @data1 is after @data2
943 typedef int (*raptor_data_compare_handler)(const void* data1, const void* data2);
947 * raptor_data_malloc_handler:
948 * @size: data size
950 * Typedef for a function to allocate memory - signature like malloc()
952 * Designed to be passed into constructors
953 * like raptor_www_fetch_to_string
955 * Return value: pointer to newly allocated memory or NULL on failure
957 typedef void* (*raptor_data_malloc_handler)(size_t size);
961 * raptor_data_free_handler:
962 * @data: data object or NULL
964 * Typedef for function to free a data object - signature like free()
966 * Designed to be passed into generic data structure constructors
967 * like raptor_new_avltree(). If @data is NULL, nothing should be done.
969 typedef void (*raptor_data_free_handler)(void* data);
973 * raptor_data_context_free_handler:
974 * @context: context data for the free function
975 * @object: object to free
977 * Handler function for freeing a sequence item with a contextual pointer.
979 * Set by raptor_new_sequence_with_context().
981 typedef void (*raptor_data_context_free_handler)(void* context, void* object);
984 * raptor_data_print_handler:
985 * @object: object to print
986 * @fh: FILE* to print to
988 * Handler function for printing an object to a stream.
990 * Set by raptor_new_sequence()
992 * Return value: non-0 on failure
994 typedef int (*raptor_data_print_handler)(void *object, FILE *fh);
997 * raptor_data_context_print_handler:
998 * @context: context data for the print function
999 * @object: object to print
1000 * @fh: FILE* to print to
1002 * Function function for printing an object with data context to a stream.
1004 * Set by raptor_new_sequence_with_context()
1006 * Return value: non-0 on failure
1008 typedef int (*raptor_data_context_print_handler)(void *context, void *object, FILE *fh);
1011 * raptor_stringbuffer:
1013 * Raptor string buffer class
1015 typedef struct raptor_stringbuffer_s raptor_stringbuffer;
1018 /* Public functions */
1020 #define raptor_new_world() raptor_new_world_internal(RAPTOR_VERSION)
1021 /* The real target of the raptor_new_world() macro */
1022 RAPTOR_API
1023 raptor_world *raptor_new_world_internal(unsigned int version_decimal);
1024 RAPTOR_API
1025 int raptor_world_open(raptor_world* world);
1026 RAPTOR_API
1027 void raptor_free_world(raptor_world* world);
1028 RAPTOR_API
1029 int raptor_world_set_libxslt_security_preferences(raptor_world *world, void *security_preferences);
1030 RAPTOR_API
1031 int raptor_world_set_flag(raptor_world *world, raptor_world_flag flag, int value);
1032 RAPTOR_API
1033 int raptor_world_set_log_handler(raptor_world *world, void *user_data, raptor_log_handler handler);
1034 RAPTOR_API
1035 void raptor_world_set_generate_bnodeid_handler(raptor_world* world, void *user_data, raptor_generate_bnodeid_handler handler);
1036 RAPTOR_API
1037 unsigned char* raptor_world_generate_bnodeid(raptor_world *world);
1038 RAPTOR_API
1039 void raptor_world_set_generate_bnodeid_parameters(raptor_world* world, char *prefix, int base);
1040 RAPTOR_API
1041 const char* raptor_log_level_get_label(raptor_log_level level);
1042 RAPTOR_API
1043 const char* raptor_domain_get_label(raptor_domain domain);
1045 /* Names */
1046 RAPTOR_API
1047 int raptor_world_is_parser_name(raptor_world* world, const char *name);
1048 RAPTOR_API
1049 const char* raptor_world_guess_parser_name(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
1050 RAPTOR_API
1051 int raptor_world_is_serializer_name(raptor_world* world, const char *name);
1053 /* Syntax descriptions */
1054 RAPTOR_API
1055 const raptor_syntax_description* raptor_world_get_parser_description(raptor_world* world, unsigned int counter);
1056 RAPTOR_API
1057 const raptor_syntax_description* raptor_world_get_serializer_description(raptor_world* world, unsigned int counter);
1058 RAPTOR_API
1059 int raptor_syntax_description_validate(raptor_syntax_description* desc);
1061 RAPTOR_API
1062 raptor_option raptor_world_get_option_from_uri(raptor_world* world, raptor_uri *uri);
1065 /* Term Class */
1066 RAPTOR_API
1067 raptor_term* raptor_new_term_from_uri(raptor_world* world, raptor_uri* uri);
1068 RAPTOR_API
1069 raptor_term* raptor_new_term_from_counted_uri_string(raptor_world* world, const unsigned char *uri_string, size_t length);
1070 RAPTOR_API
1071 raptor_term* raptor_new_term_from_uri_string(raptor_world* world, const unsigned char *uri_string);
1072 RAPTOR_API
1073 raptor_term* raptor_new_term_from_literal(raptor_world* world, const unsigned char* literal, raptor_uri* datatype, const unsigned char* language);
1074 RAPTOR_API
1075 raptor_term* raptor_new_term_from_counted_literal(raptor_world* world, const unsigned char* literal, size_t literal_len, raptor_uri* datatype, const unsigned char* language, unsigned char language_len);
1076 RAPTOR_API
1077 raptor_term* raptor_new_term_from_blank(raptor_world* world, const unsigned char* blank);
1078 RAPTOR_API
1079 raptor_term* raptor_new_term_from_counted_blank(raptor_world* world, const unsigned char* blank, size_t length);
1080 RAPTOR_API
1081 raptor_term* raptor_term_copy(raptor_term* term);
1082 RAPTOR_API
1083 int raptor_term_compare(const raptor_term *t1, const raptor_term *t2);
1084 RAPTOR_API
1085 int raptor_term_equals(raptor_term* t1, raptor_term* t2);
1086 RAPTOR_API
1087 void raptor_free_term(raptor_term *term);
1089 RAPTOR_API
1090 unsigned char* raptor_term_to_counted_string(raptor_term *term, size_t* len_p);
1091 RAPTOR_API
1092 unsigned char* raptor_term_to_string(raptor_term *term);
1093 RAPTOR_API
1094 int raptor_term_ntriples_write(const raptor_term *term, raptor_iostream* iostr);
1095 RAPTOR_API
1096 int raptor_uri_turtle_write(raptor_world *world, raptor_iostream* iostr, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri);
1097 RAPTOR_API
1098 int raptor_term_turtle_write(raptor_iostream* iostr, raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri);
1099 RAPTOR_API
1100 unsigned char* raptor_uri_to_turtle_counted_string(raptor_world *world, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri, size_t *len_p);
1101 RAPTOR_API
1102 unsigned char* raptor_uri_to_turtle_string(raptor_world *world, raptor_uri* uri, raptor_namespace_stack *nstack, raptor_uri *base_uri);
1103 RAPTOR_API
1104 unsigned char* raptor_term_to_turtle_counted_string(raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri, size_t *len_p);
1105 RAPTOR_API
1106 unsigned char* raptor_term_to_turtle_string(raptor_term* term, raptor_namespace_stack *nstack, raptor_uri *base_uri);
1109 /* Statement Class */
1110 RAPTOR_API
1111 void raptor_statement_init(raptor_statement *statement, raptor_world *world);
1112 RAPTOR_API
1113 void raptor_statement_clear(raptor_statement *statement);
1114 RAPTOR_API
1115 raptor_statement* raptor_new_statement(raptor_world *world);
1116 RAPTOR_API
1117 raptor_statement* raptor_new_statement_from_nodes(raptor_world* world, raptor_term *subject, raptor_term *predicate, raptor_term *object, raptor_term *graph);
1118 RAPTOR_API
1119 raptor_statement* raptor_statement_copy(raptor_statement *statement);
1120 RAPTOR_API
1121 void raptor_free_statement(raptor_statement *statement);
1123 RAPTOR_API
1124 int raptor_statement_print(const raptor_statement * statement, FILE *stream);
1125 RAPTOR_API
1126 int raptor_statement_print_as_ntriples(const raptor_statement * statement, FILE *stream);
1127 RAPTOR_API
1128 int raptor_statement_compare(const raptor_statement *s1, const raptor_statement *s2);
1129 RAPTOR_API
1130 int raptor_statement_equals(const raptor_statement* s1, const raptor_statement* s2);
1133 /* Parser Class */
1134 RAPTOR_API
1135 raptor_parser* raptor_new_parser(raptor_world* world, const char *name);
1136 RAPTOR_API
1137 raptor_parser* raptor_new_parser_for_content(raptor_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
1138 RAPTOR_API
1139 void raptor_free_parser(raptor_parser* parser);
1141 /* methods */
1143 /* Handlers */
1144 RAPTOR_API
1145 void raptor_parser_set_statement_handler(raptor_parser* parser, void *user_data, raptor_statement_handler handler);
1146 RAPTOR_API
1147 void raptor_parser_set_graph_mark_handler(raptor_parser* parser, void *user_data, raptor_graph_mark_handler handler);
1148 RAPTOR_API
1149 void raptor_parser_set_namespace_handler(raptor_parser* parser, void *user_data, raptor_namespace_handler handler);
1150 RAPTOR_API
1151 void raptor_parser_set_uri_filter(raptor_parser* parser, raptor_uri_filter_func filter, void* user_data);
1152 RAPTOR_API
1153 raptor_locator* raptor_parser_get_locator(raptor_parser* rdf_parser);
1156 /* Parsing functions */
1157 RAPTOR_API
1158 int raptor_parser_parse_start(raptor_parser *rdf_parser, raptor_uri *uri);
1159 RAPTOR_API
1160 int raptor_parser_parse_chunk(raptor_parser* rdf_parser, const unsigned char *buffer, size_t len, int is_end);
1161 RAPTOR_API
1162 int raptor_parser_parse_file_stream(raptor_parser* rdf_parser, FILE *stream, const char *filename, raptor_uri *base_uri);
1163 RAPTOR_API
1164 int raptor_parser_parse_file(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri);
1165 RAPTOR_API
1166 int raptor_parser_parse_uri(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri);
1167 RAPTOR_API
1168 int raptor_parser_parse_uri_with_connection(raptor_parser* rdf_parser, raptor_uri *uri, raptor_uri *base_uri, void *connection);
1169 RAPTOR_API
1170 int raptor_parser_parse_iostream(raptor_parser* rdf_parser, raptor_iostream *iostr, raptor_uri *base_uri);
1171 RAPTOR_API
1172 void raptor_parser_parse_abort(raptor_parser* rdf_parser);
1173 RAPTOR_API
1174 const char* raptor_parser_get_name(raptor_parser *rdf_parser);
1175 RAPTOR_API
1176 const raptor_syntax_description* raptor_parser_get_description(raptor_parser *rdf_parser);
1178 /* parser option methods */
1179 RAPTOR_API
1180 int raptor_parser_set_option(raptor_parser *parser, raptor_option option, const char* string, int integer);
1181 RAPTOR_API
1182 int raptor_parser_get_option(raptor_parser *parser, raptor_option option, char** string_p, int* integer_p);
1184 /* parser utility methods */
1185 RAPTOR_API
1186 const char* raptor_parser_get_accept_header(raptor_parser* rdf_parser);
1187 RAPTOR_API
1188 raptor_world* raptor_parser_get_world(raptor_parser* rdf_parser);
1189 RAPTOR_API
1190 raptor_uri* raptor_parser_get_graph(raptor_parser* rdf_parser);
1193 /* Locator Class */
1194 /* methods */
1195 RAPTOR_API
1196 int raptor_locator_print(raptor_locator* locator, FILE *stream);
1197 RAPTOR_API
1198 int raptor_locator_format(char *buffer, size_t length, raptor_locator* locator);
1199 RAPTOR_API
1200 int raptor_locator_line(raptor_locator *locator);
1201 RAPTOR_API
1202 int raptor_locator_column(raptor_locator *locator);
1203 RAPTOR_API
1204 int raptor_locator_byte(raptor_locator *locator);
1205 RAPTOR_API
1206 const char* raptor_locator_file(raptor_locator *locator);
1207 RAPTOR_API
1208 const char* raptor_locator_uri(raptor_locator *locator);
1211 /* Serializer Class */
1212 RAPTOR_API
1213 raptor_serializer* raptor_new_serializer(raptor_world* world, const char *name);
1214 RAPTOR_API
1215 void raptor_free_serializer(raptor_serializer* rdf_serializer);
1217 /* methods */
1218 RAPTOR_API
1219 int raptor_serializer_start_to_iostream(raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream);
1220 RAPTOR_API
1221 int raptor_serializer_start_to_filename(raptor_serializer *rdf_serializer, const char *filename);
1222 RAPTOR_API
1223 int raptor_serializer_start_to_string(raptor_serializer *rdf_serializer, raptor_uri *uri, void **string_p, size_t *length_p);
1224 RAPTOR_API
1225 int raptor_serializer_start_to_file_handle(raptor_serializer *rdf_serializer, raptor_uri *uri, FILE *fh);
1226 RAPTOR_API
1227 int raptor_serializer_set_namespace(raptor_serializer* rdf_serializer, raptor_uri *uri, const unsigned char *prefix);
1228 RAPTOR_API
1229 int raptor_serializer_set_namespace_from_namespace(raptor_serializer* rdf_serializer, raptor_namespace *nspace);
1230 RAPTOR_API
1231 int raptor_serializer_serialize_statement(raptor_serializer* rdf_serializer, raptor_statement *statement);
1232 RAPTOR_API
1233 int raptor_serializer_serialize_end(raptor_serializer *rdf_serializer);
1234 RAPTOR_API
1235 raptor_iostream* raptor_serializer_get_iostream(raptor_serializer *serializer);
1236 RAPTOR_API
1237 raptor_locator* raptor_serializer_get_locator(raptor_serializer *rdf_serializer);
1238 RAPTOR_API
1239 int raptor_serializer_flush(raptor_serializer *rdf_serializer);
1240 RAPTOR_API
1241 const raptor_syntax_description* raptor_serializer_get_description(raptor_serializer *rdf_serializer);
1243 /* serializer option methods */
1244 RAPTOR_API
1245 int raptor_serializer_set_option(raptor_serializer *serializer, raptor_option option, const char* string, int integer);
1246 RAPTOR_API
1247 int raptor_serializer_get_option(raptor_serializer *serializer, raptor_option option, char** string_p, int* integer_p);
1249 /* utility methods */
1250 RAPTOR_API
1251 raptor_world* raptor_serializer_get_world(raptor_serializer* rdf_serializer);
1254 /* memory functions */
1255 RAPTOR_API
1256 void raptor_free_memory(void *ptr);
1257 RAPTOR_API
1258 void* raptor_alloc_memory(size_t size);
1259 RAPTOR_API
1260 void* raptor_calloc_memory(size_t nmemb, size_t size);
1263 /* URI Class */
1264 RAPTOR_API
1265 raptor_uri* raptor_new_uri_from_counted_string(raptor_world* world, const unsigned char *uri_string, size_t length);
1266 RAPTOR_API
1267 raptor_uri* raptor_new_uri(raptor_world* world, const unsigned char *uri_string);
1268 RAPTOR_API
1269 raptor_uri* raptor_new_uri_from_uri_local_name(raptor_world* world, raptor_uri *uri, const unsigned char *local_name);
1270 RAPTOR_API
1271 raptor_uri* raptor_new_uri_relative_to_base(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string);
1272 RAPTOR_API
1273 raptor_uri* raptor_new_uri_relative_to_base_counted(raptor_world* world, raptor_uri *base_uri, const unsigned char *uri_string, size_t uri_len);
1274 RAPTOR_API
1275 raptor_uri* raptor_new_uri_from_id(raptor_world* world, raptor_uri *base_uri, const unsigned char *id);
1276 RAPTOR_API
1277 raptor_uri* raptor_new_uri_from_uri_or_file_string(raptor_world* world, raptor_uri* base_uri, const unsigned char* uri_or_file_string);
1278 RAPTOR_API
1279 raptor_uri* raptor_new_uri_for_rdf_concept(raptor_world* world, const unsigned char *name);
1280 RAPTOR_API
1281 raptor_uri* raptor_new_uri_for_xmlbase(raptor_uri* old_uri);
1282 RAPTOR_API
1283 raptor_uri* raptor_new_uri_for_retrieval(raptor_uri* old_uri);
1284 RAPTOR_API
1285 void raptor_free_uri(raptor_uri *uri);
1287 /* methods */
1288 RAPTOR_API
1289 int raptor_uri_equals(raptor_uri* uri1, raptor_uri* uri2);
1290 RAPTOR_API
1291 int raptor_uri_compare(raptor_uri* uri1, raptor_uri* uri2);
1292 RAPTOR_API
1293 raptor_uri* raptor_uri_copy(raptor_uri *uri);
1294 RAPTOR_API
1295 unsigned char* raptor_uri_as_string(raptor_uri *uri);
1296 RAPTOR_API
1297 unsigned char* raptor_uri_as_counted_string(raptor_uri *uri, size_t* len_p);
1298 RAPTOR_API
1299 unsigned char* raptor_uri_to_relative_counted_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri, size_t *length_p);
1300 RAPTOR_API
1301 unsigned char* raptor_uri_to_relative_uri_string(raptor_uri *base_uri, raptor_uri *reference_uri);
1302 RAPTOR_API
1303 int raptor_uri_print(const raptor_uri* uri, FILE *stream);
1304 RAPTOR_API
1305 unsigned char* raptor_uri_to_counted_string(raptor_uri *uri, size_t *len_p);
1306 RAPTOR_API
1307 unsigned char* raptor_uri_to_string(raptor_uri *uri);
1308 RAPTOR_API
1309 raptor_world* raptor_uri_get_world(raptor_uri *uri);
1310 RAPTOR_API
1311 int raptor_uri_file_exists(raptor_uri* uri);
1313 /* XML utility functions */
1314 RAPTOR_API
1315 int raptor_xml_escape_string_any(raptor_world* world, const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote, int xml_version);
1316 RAPTOR_API
1317 int raptor_xml_escape_string_any_write(const unsigned char *string, size_t len, char quote, int xml_version, raptor_iostream* iostr);
1318 RAPTOR_API
1319 int raptor_xml_escape_string(raptor_world *world, const unsigned char *string, size_t len, unsigned char *buffer, size_t length, char quote);
1320 RAPTOR_API
1321 int raptor_xml_escape_string_write(const unsigned char *string, size_t len, char quote, raptor_iostream* iostr);
1322 RAPTOR_API
1323 int raptor_xml_name_check(const unsigned char *string, size_t length, int xml_version);
1326 /* portable vsnprintf utility function */
1327 RAPTOR_API RAPTOR_DEPRECATED
1328 char* raptor_vsnprintf(const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(1, 0);
1329 RAPTOR_API
1330 int raptor_vsnprintf2(char *buffer, size_t size, const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(3, 0);
1331 RAPTOR_API
1332 int raptor_snprintf(char *buffer, size_t size, const char *format, ...) RAPTOR_PRINTF_FORMAT(3, 4);
1333 RAPTOR_API
1334 int raptor_vasprintf(char **ret, const char *format, va_list arguments) RAPTOR_PRINTF_FORMAT(2, 0);
1336 /* RFC2396 URI resolving functions */
1337 RAPTOR_API
1338 size_t raptor_uri_resolve_uri_reference(const unsigned char *base_uri, const unsigned char *reference_uri, unsigned char* buffer, size_t length);
1340 /* URI String utility functions */
1341 RAPTOR_API
1342 unsigned char* raptor_uri_filename_to_uri_string(const char *filename);
1343 RAPTOR_API
1344 int raptor_uri_filename_exists(const unsigned char* path);
1345 RAPTOR_API
1346 char* raptor_uri_uri_string_to_filename(const unsigned char *uri_string);
1347 RAPTOR_API
1348 char* raptor_uri_uri_string_to_filename_fragment(const unsigned char *uri_string, unsigned char **fragment_p);
1349 RAPTOR_API
1350 int raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string);
1351 RAPTOR_API
1352 int raptor_stringbuffer_append_uri_escaped_counted_string(raptor_stringbuffer* sb, const char* string, size_t length, int space_is_plus);
1353 RAPTOR_API
1354 char* raptor_uri_uri_string_to_counted_filename_fragment(const unsigned char *uri_string, size_t* len_p, unsigned char **fragment_p, size_t* fragment_len_p);
1358 * RAPTOR_RDF_MS_URI:
1360 * RDF Namespace URI (rdf:).
1362 * Copy with raptor_uri_copy() to use.
1364 #define RAPTOR_RDF_MS_URI raptor_rdf_namespace_uri
1367 * RAPTOR_RDF_SCHEMA_URI:
1369 * RDF Schema Namespace URI (rdfs:).
1371 * Copy with raptor_uri_copy() to use.
1373 #define RAPTOR_RDF_SCHEMA_URI raptor_rdf_schema_namespace_uri
1376 * RAPTOR_XMLSCHEMA_DATATYPES_URI:
1378 * XML Schema Datatypes URI (xsd:).
1380 * Copy with raptor_uri_copy() to use.
1382 #define RAPTOR_XMLSCHEMA_DATATYPES_URI raptor_xmlschema_datatypes_namespace_uri
1385 * RAPTOR_OWL_URI:
1387 * OWL Namespace URI (owl:).
1389 * Copy with raptor_uri_copy() to use.
1391 #define RAPTOR_OWL_URI raptor_owl_namespace_uri
1394 /* raptor_www */
1395 RAPTOR_API
1396 raptor_www* raptor_new_www(raptor_world* world);
1397 RAPTOR_API
1398 raptor_www* raptor_new_www_with_connection(raptor_world* world, void* connection);
1399 RAPTOR_API
1400 void raptor_free_www(raptor_www *www);
1401 RAPTOR_API
1402 int raptor_www_set_ssl_cert_options(raptor_www* www, const char* cert_filename, const char* cert_type, const char* cert_passphrase);
1403 RAPTOR_API
1404 int raptor_www_set_ssl_verify_options(raptor_www* www, int verify_peer, int verify_host);
1405 RAPTOR_API
1406 void raptor_www_set_user_agent(raptor_www *www, const char *user_agent);
1407 RAPTOR_API
1408 void raptor_www_set_proxy(raptor_www *www, const char *proxy);
1409 RAPTOR_API
1410 void raptor_www_set_http_accept(raptor_www *www, const char *value);
1411 RAPTOR_API
1412 void raptor_www_set_write_bytes_handler(raptor_www *www, raptor_www_write_bytes_handler handler, void *user_data);
1413 RAPTOR_API
1414 void raptor_www_set_content_type_handler(raptor_www *www, raptor_www_content_type_handler handler, void *user_data);
1415 RAPTOR_API
1416 void raptor_www_set_final_uri_handler(raptor_www* www, raptor_www_final_uri_handler handler, void *user_data);
1417 RAPTOR_API
1418 void raptor_www_set_uri_filter(raptor_www* www, raptor_uri_filter_func filter, void* user_data);
1419 RAPTOR_API
1420 void raptor_www_set_connection_timeout(raptor_www* www, int timeout);
1421 RAPTOR_API
1422 int raptor_www_set_http_cache_control(raptor_www* www, const char* cache_control);
1423 RAPTOR_API
1424 int raptor_www_fetch(raptor_www *www, raptor_uri *uri);
1425 RAPTOR_API
1426 int raptor_www_fetch_to_string(raptor_www *www, raptor_uri *uri, void **string_p, size_t *length_p, raptor_data_malloc_handler const malloc_handler);
1427 RAPTOR_API
1428 void* raptor_www_get_connection(raptor_www *www);
1429 RAPTOR_API
1430 void raptor_www_abort(raptor_www *www, const char *reason);
1431 RAPTOR_API
1432 raptor_uri* raptor_www_get_final_uri(raptor_www* www);
1435 /* XML QNames Class */
1436 RAPTOR_API
1437 raptor_qname* raptor_new_qname(raptor_namespace_stack *nstack, const unsigned char *name, const unsigned char *value);
1438 RAPTOR_API
1439 raptor_qname* raptor_new_qname_from_namespace_local_name(raptor_world* world, raptor_namespace *ns, const unsigned char *local_name, const unsigned char *value);
1441 /* methods */
1442 RAPTOR_API
1443 raptor_qname* raptor_qname_copy(raptor_qname *qname);
1444 RAPTOR_API
1445 void raptor_free_qname(raptor_qname* name);
1446 RAPTOR_API
1447 int raptor_qname_equal(raptor_qname *name1, raptor_qname *name2);
1448 RAPTOR_API
1449 unsigned char* raptor_qname_to_counted_name(raptor_qname *qname, size_t* length_p);
1450 RAPTOR_API
1451 const raptor_namespace* raptor_qname_get_namespace(raptor_qname* name);
1452 RAPTOR_API
1453 const unsigned char* raptor_qname_get_local_name(raptor_qname* name);
1454 RAPTOR_API
1455 const unsigned char* raptor_qname_get_value(raptor_qname* name);
1456 RAPTOR_API
1457 const unsigned char* raptor_qname_get_counted_value(raptor_qname* name, size_t* length_p);
1458 RAPTOR_API
1459 int raptor_qname_write(raptor_qname *qname, raptor_iostream* iostr);
1461 /* QName String utility functions */
1462 RAPTOR_API
1463 raptor_uri* raptor_qname_string_to_uri(raptor_namespace_stack *nstack, const unsigned char *name, size_t name_len);
1465 /* XML Namespaces Stack class */
1466 RAPTOR_API
1467 raptor_namespace* raptor_new_namespace_from_uri(raptor_namespace_stack *nstack, const unsigned char *prefix, raptor_uri* ns_uri, int depth);
1468 RAPTOR_API
1469 raptor_namespace_stack* raptor_new_namespaces(raptor_world* world, int defaults);
1470 RAPTOR_API
1471 int raptor_namespaces_init(raptor_world* world, raptor_namespace_stack *nstack, int defaults);
1472 RAPTOR_API
1473 void raptor_namespaces_clear(raptor_namespace_stack *nstack);
1474 RAPTOR_API
1475 void raptor_free_namespaces(raptor_namespace_stack *nstack);
1477 /* methods */
1478 RAPTOR_API
1479 void raptor_namespaces_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *nspace);
1480 RAPTOR_API
1481 int raptor_namespaces_start_namespace_full(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth);
1482 RAPTOR_API
1483 void raptor_namespaces_end_for_depth(raptor_namespace_stack *nstack, int depth);
1484 RAPTOR_API
1485 raptor_namespace* raptor_namespaces_get_default_namespace(raptor_namespace_stack *nstack);
1486 RAPTOR_API
1487 raptor_namespace* raptor_namespaces_find_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, int prefix_length);
1488 RAPTOR_API
1489 raptor_namespace* raptor_namespaces_find_namespace_by_uri(raptor_namespace_stack *nstack, raptor_uri *ns_uri);
1490 RAPTOR_API
1491 int raptor_namespaces_namespace_in_scope(raptor_namespace_stack *nstack, const raptor_namespace *nspace);
1492 RAPTOR_API
1493 raptor_qname* raptor_new_qname_from_namespace_uri(raptor_namespace_stack *nstack, raptor_uri *uri, int xml_version);
1496 /* XML Namespace Class */
1497 RAPTOR_API
1498 raptor_namespace* raptor_new_namespace(raptor_namespace_stack *nstack, const unsigned char *prefix, const unsigned char *ns_uri_string, int depth);
1499 RAPTOR_API
1500 void raptor_free_namespace(raptor_namespace *ns);
1501 RAPTOR_API
1502 int raptor_namespace_stack_start_namespace(raptor_namespace_stack *nstack, raptor_namespace *ns, int new_depth);
1503 RAPTOR_API
1504 raptor_uri* raptor_namespace_get_uri(const raptor_namespace *ns);
1505 RAPTOR_API
1506 const unsigned char* raptor_namespace_get_prefix(const raptor_namespace *ns);
1507 RAPTOR_API
1508 const unsigned char* raptor_namespace_get_counted_prefix(const raptor_namespace *ns, size_t *length_p);
1509 RAPTOR_API
1510 unsigned char* raptor_namespace_format_as_xml(const raptor_namespace *ns, size_t *length_p);
1511 RAPTOR_API
1512 int raptor_namespace_write(raptor_namespace *ns, raptor_iostream* iostr);
1514 /* namespace string utility function */
1515 RAPTOR_API
1516 int raptor_xml_namespace_string_parse(const unsigned char *string, unsigned char **prefix, unsigned char **uri_string);
1518 /* Sequence class */
1520 * raptor_sequence:
1522 * Raptor sequence class
1524 typedef struct raptor_sequence_s raptor_sequence;
1526 /* Sequence Class */
1527 RAPTOR_API
1528 raptor_sequence* raptor_new_sequence(raptor_data_free_handler free_handler, raptor_data_print_handler print_handler);
1529 RAPTOR_API
1530 raptor_sequence* raptor_new_sequence_with_context(raptor_data_context_free_handler free_handler, raptor_data_context_print_handler print_handler, void* handler_context);
1531 RAPTOR_API
1532 void raptor_free_sequence(raptor_sequence* seq);
1534 /* methods */
1535 RAPTOR_API
1536 int raptor_sequence_size(raptor_sequence* seq);
1537 RAPTOR_API
1538 int raptor_sequence_set_at(raptor_sequence* seq, int idx, void *data);
1539 RAPTOR_API
1540 int raptor_sequence_push(raptor_sequence* seq, void *data);
1541 RAPTOR_API
1542 int raptor_sequence_shift(raptor_sequence* seq, void *data);
1543 RAPTOR_API
1544 void* raptor_sequence_get_at(raptor_sequence* seq, int idx);
1545 RAPTOR_API
1546 void* raptor_sequence_pop(raptor_sequence* seq);
1547 RAPTOR_API
1548 void* raptor_sequence_unshift(raptor_sequence* seq);
1549 RAPTOR_API
1550 void* raptor_sequence_delete_at(raptor_sequence* seq, int idx);
1552 RAPTOR_API
1553 void raptor_sequence_sort(raptor_sequence* seq, raptor_data_compare_handler compare);
1554 RAPTOR_API
1555 int raptor_sequence_swap(raptor_sequence* seq, int i, int j);
1556 RAPTOR_API
1557 int raptor_sequence_reverse(raptor_sequence* seq, int start_index, int length);
1558 RAPTOR_API
1559 int raptor_sequence_next_permutation(raptor_sequence *seq, raptor_data_compare_handler compare);
1561 /* helper for printing sequences of strings */
1562 RAPTOR_API
1563 int raptor_sequence_print(raptor_sequence* seq, FILE* fh);
1564 RAPTOR_API
1565 int raptor_sequence_join(raptor_sequence* dest, raptor_sequence *src);
1568 /* Unicode and UTF8 */
1571 * raptor_unichar:
1573 * raptor Unicode codepoint
1575 typedef unsigned long raptor_unichar;
1576 RAPTOR_API
1577 int raptor_unicode_utf8_string_put_char(raptor_unichar c, unsigned char *output, size_t length);
1578 RAPTOR_API
1579 int raptor_unicode_utf8_string_get_char(const unsigned char *input, size_t length, raptor_unichar *output);
1580 RAPTOR_API
1581 int raptor_unicode_is_xml11_namestartchar(raptor_unichar c);
1582 RAPTOR_API
1583 int raptor_unicode_is_xml10_namestartchar(raptor_unichar c);
1584 RAPTOR_API
1585 int raptor_unicode_is_xml11_namechar(raptor_unichar c);
1586 RAPTOR_API
1587 int raptor_unicode_is_xml10_namechar(raptor_unichar c);
1588 RAPTOR_API
1589 int raptor_unicode_check_utf8_string(const unsigned char *string, size_t length);
1590 RAPTOR_API
1591 int raptor_unicode_utf8_strlen(const unsigned char *string, size_t length);
1592 RAPTOR_API
1593 size_t raptor_unicode_utf8_substr(unsigned char* dest, size_t* dest_length_p, const unsigned char* src, size_t src_length, int startingLoc, int length);
1595 /* Stringbuffer Class */
1596 RAPTOR_API
1597 raptor_stringbuffer* raptor_new_stringbuffer(void);
1598 RAPTOR_API
1599 void raptor_free_stringbuffer(raptor_stringbuffer *stringbuffer);
1601 /* methods */
1602 RAPTOR_API
1603 int raptor_stringbuffer_append_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy);
1604 RAPTOR_API
1605 int raptor_stringbuffer_append_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy);
1606 RAPTOR_API
1607 int raptor_stringbuffer_append_decimal(raptor_stringbuffer* stringbuffer, int integer);
1608 RAPTOR_API
1609 int raptor_stringbuffer_append_hexadecimal(raptor_stringbuffer* stringbuffer, int hex);
1610 RAPTOR_API
1611 int raptor_stringbuffer_append_stringbuffer(raptor_stringbuffer* stringbuffer, raptor_stringbuffer* append);
1612 RAPTOR_API
1613 int raptor_stringbuffer_prepend_counted_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, size_t length, int do_copy);
1614 RAPTOR_API
1615 int raptor_stringbuffer_prepend_string(raptor_stringbuffer* stringbuffer, const unsigned char *string, int do_copy);
1616 RAPTOR_API
1617 unsigned char* raptor_stringbuffer_as_string(raptor_stringbuffer* stringbuffer);
1618 RAPTOR_API
1619 size_t raptor_stringbuffer_length(raptor_stringbuffer* stringbuffer);
1620 RAPTOR_API
1621 int raptor_stringbuffer_copy_to_string(raptor_stringbuffer* stringbuffer, unsigned char *string, size_t length);
1624 * raptor_iostream_init_func:
1625 * @context: stream context data
1627 * Handler function for #raptor_iostream initialising.
1629 * Return value: non-0 on failure.
1631 typedef int (*raptor_iostream_init_func) (void *context);
1634 * raptor_iostream_finish_func:
1635 * @context: stream context data
1637 * Handler function for #raptor_iostream terminating.
1640 typedef void (*raptor_iostream_finish_func) (void *context);
1643 * raptor_iostream_write_byte_func
1644 * @context: stream context data
1645 * @byte: byte to write
1647 * Handler function for implementing raptor_iostream_write_byte().
1649 * Return value: non-0 on failure.
1651 typedef int (*raptor_iostream_write_byte_func) (void *context, const int byte);
1654 * raptor_iostream_write_bytes_func:
1655 * @context: stream context data
1656 * @ptr: pointer to bytes to write
1657 * @size: size of item
1658 * @nmemb: number of items
1660 * Handler function for implementing raptor_iostream_write_bytes().
1662 * Return value: non-0 on failure.
1664 typedef int (*raptor_iostream_write_bytes_func) (void *context, const void *ptr, size_t size, size_t nmemb);
1667 * raptor_iostream_write_end_func:
1668 * @context: stream context data
1670 * Handler function for implementing raptor_iostream_write_end().
1672 * Return value: non-0 on failure.
1674 typedef int (*raptor_iostream_write_end_func) (void *context);
1677 * raptor_iostream_read_bytes_func:
1678 * @context: stream context data
1679 * @ptr: pointer to buffer to read into
1680 * @size: size of buffer
1681 * @nmemb: number of items
1683 * Handler function for implementing raptor_iostream_read_bytes().
1685 * Return value: number of items read, 0 or < @size on EOF, <0 on failure
1687 typedef int (*raptor_iostream_read_bytes_func) (void *context, void *ptr, size_t size, size_t nmemb);
1690 * raptor_iostream_read_eof_func:
1691 * @context: stream context data
1693 * Handler function for implementing raptor_iostream_read_eof().
1695 * Return value: non-0 if EOF
1697 typedef int (*raptor_iostream_read_eof_func) (void *context);
1700 * raptor_iostream_handler:
1701 * @version: interface version. Presently 1 or 2.
1702 * @init: initialisation handler - optional, called at most once (V1)
1703 * @finish: finishing handler - optional, called at most once (V1)
1704 * @write_byte: write byte handler - required (for writing) (V1)
1705 * @write_bytes: write bytes handler - required (for writing) (V1)
1706 * @write_end: write end handler - optional (for writing), called at most once (V1)
1707 * @read_bytes: read bytes handler - required (for reading) (V2)
1708 * @read_eof: read EOF handler - required (for reading) (V2)
1710 * I/O stream implementation handler structure.
1713 typedef struct {
1714 int version;
1716 /* V1 functions */
1717 raptor_iostream_init_func init;
1718 raptor_iostream_finish_func finish;
1719 raptor_iostream_write_byte_func write_byte;
1720 raptor_iostream_write_bytes_func write_bytes;
1721 raptor_iostream_write_end_func write_end;
1723 /* V2 functions */
1724 raptor_iostream_read_bytes_func read_bytes;
1725 raptor_iostream_read_eof_func read_eof;
1726 } raptor_iostream_handler;
1729 /* I/O Stream Class */
1730 RAPTOR_API
1731 raptor_iostream* raptor_new_iostream_from_handler(raptor_world* world, void *user_data, const raptor_iostream_handler* const handler);
1732 RAPTOR_API
1733 raptor_iostream* raptor_new_iostream_to_sink(raptor_world* world);
1734 RAPTOR_API
1735 raptor_iostream* raptor_new_iostream_to_filename(raptor_world* world, const char *filename);
1736 RAPTOR_API
1737 raptor_iostream* raptor_new_iostream_to_file_handle(raptor_world* world, FILE *handle);
1738 RAPTOR_API
1739 raptor_iostream* raptor_new_iostream_to_string(raptor_world* world, void **string_p, size_t *length_p, raptor_data_malloc_handler const malloc_handler);
1740 RAPTOR_API
1741 raptor_iostream* raptor_new_iostream_from_sink(raptor_world* world);
1742 RAPTOR_API
1743 raptor_iostream* raptor_new_iostream_from_filename(raptor_world* world, const char *filename);
1744 RAPTOR_API
1745 raptor_iostream* raptor_new_iostream_from_file_handle(raptor_world* world, FILE *handle);
1746 RAPTOR_API
1747 raptor_iostream* raptor_new_iostream_from_string(raptor_world* world, void *string, size_t length);
1748 RAPTOR_API
1749 void raptor_free_iostream(raptor_iostream *iostr);
1751 RAPTOR_API
1752 int raptor_iostream_write_bytes(const void *ptr, size_t size, size_t nmemb, raptor_iostream *iostr);
1753 RAPTOR_API
1754 int raptor_iostream_write_byte(const int byte, raptor_iostream *iostr);
1755 RAPTOR_API
1756 int raptor_iostream_write_end(raptor_iostream *iostr);
1757 RAPTOR_API
1758 int raptor_iostream_string_write(const void *string, raptor_iostream *iostr);
1759 RAPTOR_API
1760 int raptor_iostream_counted_string_write(const void *string, size_t len, raptor_iostream *iostr);
1761 RAPTOR_API
1762 unsigned long raptor_iostream_tell(raptor_iostream *iostr);
1763 RAPTOR_API
1764 int raptor_iostream_decimal_write(int integer, raptor_iostream* iostr);
1765 RAPTOR_API
1766 int raptor_iostream_hexadecimal_write(unsigned int integer, int width, raptor_iostream* iostr);
1767 RAPTOR_API
1768 int raptor_stringbuffer_write(raptor_stringbuffer *sb, raptor_iostream* iostr);
1769 RAPTOR_API
1770 int raptor_uri_write(raptor_uri *uri, raptor_iostream *iostr);
1771 RAPTOR_API
1772 int raptor_iostream_read_bytes(void *ptr, size_t size, size_t nmemb, raptor_iostream* iostr);
1773 RAPTOR_API
1774 int raptor_iostream_read_eof(raptor_iostream *iostr);
1776 /* I/O Stream utility functions */
1777 RAPTOR_API
1778 int raptor_string_ntriples_write(const unsigned char *string, size_t len, const char delim, raptor_iostream *iostr);
1779 RAPTOR_API
1780 int raptor_bnodeid_ntriples_write(const unsigned char *bnodeid, size_t len, raptor_iostream *iostr);
1781 RAPTOR_API
1782 int raptor_string_python_write(const unsigned char *string, size_t len, const char delim, int flags, raptor_iostream *iostr);
1783 RAPTOR_API
1784 int raptor_statement_ntriples_write(const raptor_statement *statement, raptor_iostream* iostr, int write_graph_term);
1788 /* Parser and Serializer options */
1791 * raptor_option_value_type:
1792 * @RAPTOR_OPTION_VALUE_TYPE_BOOL: Boolean integer value. Non-0 is true
1793 * @RAPTOR_OPTION_VALUE_TYPE_INT: Decimal integer value
1794 * @RAPTOR_OPTION_VALUE_TYPE_STRING: String value
1795 * @RAPTOR_OPTION_VALUE_TYPE_URI: URI String value.
1796 * @RAPTOR_OPTION_VALUE_TYPE_LAST: internal
1798 * Option value types.
1800 typedef enum {
1801 RAPTOR_OPTION_VALUE_TYPE_BOOL,
1802 RAPTOR_OPTION_VALUE_TYPE_INT,
1803 RAPTOR_OPTION_VALUE_TYPE_STRING,
1804 RAPTOR_OPTION_VALUE_TYPE_URI,
1805 RAPTOR_OPTION_VALUE_TYPE_LAST = RAPTOR_OPTION_VALUE_TYPE_URI
1806 } raptor_option_value_type;
1810 * raptor_option_description:
1811 * @domain: domain ID
1812 * @option: option ID
1813 * @value_type: data type of option value
1814 * @name: short name for option
1815 * @name_len: length of @name
1816 * @label: description of option
1817 * @uri: URI identifying option
1819 * Description of an option for a domain.
1821 typedef struct {
1822 raptor_domain domain;
1823 raptor_option option;
1824 raptor_option_value_type value_type;
1825 const char* name;
1826 size_t name_len;
1827 const char* label;
1828 raptor_uri* uri;
1829 } raptor_option_description;
1832 RAPTOR_API
1833 unsigned int raptor_option_get_count(void);
1834 RAPTOR_API
1835 const char* raptor_option_get_value_type_label(const raptor_option_value_type type);
1836 RAPTOR_API
1837 void raptor_free_option_description(raptor_option_description* option_description);
1838 RAPTOR_API
1839 raptor_option_description* raptor_world_get_option_description(raptor_world* world, const raptor_domain domain, const raptor_option option);
1842 /* SAX2 element Class (raptor_xml_element) */
1843 RAPTOR_API
1844 raptor_xml_element* raptor_new_xml_element(raptor_qname* name, const unsigned char* xml_language, raptor_uri* xml_base);
1845 RAPTOR_API
1846 raptor_xml_element* raptor_new_xml_element_from_namespace_local_name(raptor_namespace *ns, const unsigned char *name, const unsigned char *xml_language, raptor_uri *xml_base);
1847 RAPTOR_API
1848 void raptor_free_xml_element(raptor_xml_element *element);
1850 /* methods */
1851 RAPTOR_API
1852 raptor_qname* raptor_xml_element_get_name(raptor_xml_element *xml_element);
1853 RAPTOR_API
1854 void raptor_xml_element_set_attributes(raptor_xml_element* xml_element, raptor_qname **attributes, int count);
1855 RAPTOR_API
1856 raptor_qname** raptor_xml_element_get_attributes(raptor_xml_element* xml_element);
1857 RAPTOR_API
1858 int raptor_xml_element_get_attributes_count(raptor_xml_element* xml_element);
1859 RAPTOR_API
1860 int raptor_xml_element_declare_namespace(raptor_xml_element* xml_element, raptor_namespace *nspace);
1861 RAPTOR_API
1862 int raptor_xml_element_write(raptor_xml_element *element, raptor_namespace_stack *nstack, int is_empty, int is_end, int depth, raptor_iostream *iostr);
1863 RAPTOR_API
1864 int raptor_xml_element_is_empty(raptor_xml_element* xml_element);
1865 RAPTOR_API
1866 const unsigned char* raptor_xml_element_get_language(raptor_xml_element* xml_element);
1869 /* XML Writer Class (raptor_xml_writer) */
1870 RAPTOR_API
1871 raptor_xml_writer* raptor_new_xml_writer(raptor_world* world, raptor_namespace_stack *nstack, raptor_iostream* iostr);
1872 RAPTOR_API
1873 void raptor_free_xml_writer(raptor_xml_writer* xml_writer);
1875 /* methods */
1876 RAPTOR_API
1877 void raptor_xml_writer_empty_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
1878 RAPTOR_API
1879 void raptor_xml_writer_start_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
1880 RAPTOR_API
1881 void raptor_xml_writer_end_element(raptor_xml_writer* xml_writer, raptor_xml_element *element);
1882 RAPTOR_API
1883 void raptor_xml_writer_newline(raptor_xml_writer* xml_writer);
1884 RAPTOR_API
1885 void raptor_xml_writer_cdata(raptor_xml_writer* xml_writer, const unsigned char *s);
1886 RAPTOR_API
1887 void raptor_xml_writer_cdata_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
1888 RAPTOR_API
1889 void raptor_xml_writer_raw(raptor_xml_writer* xml_writer, const unsigned char *s);
1890 RAPTOR_API
1891 void raptor_xml_writer_raw_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
1892 RAPTOR_API
1893 void raptor_xml_writer_comment(raptor_xml_writer* xml_writer, const unsigned char *s);
1894 RAPTOR_API
1895 void raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len);
1896 RAPTOR_API
1897 void raptor_xml_writer_flush(raptor_xml_writer* xml_writer);
1898 RAPTOR_API
1899 int raptor_xml_writer_set_option(raptor_xml_writer *xml_writer, raptor_option option, char* string, int integer);
1900 RAPTOR_API
1901 int raptor_xml_writer_get_option(raptor_xml_writer *xml_writer, raptor_option option, char** string_p, int* integer_p);
1902 RAPTOR_API
1903 int raptor_xml_writer_get_depth(raptor_xml_writer *xml_writer);
1906 * raptor_sax2_start_element_handler:
1907 * @user_data: user data
1908 * @xml_element: XML element
1910 * SAX2 start element handler
1912 typedef void (*raptor_sax2_start_element_handler)(void *user_data, raptor_xml_element *xml_element);
1915 * raptor_sax2_end_element_handler:
1916 * @user_data: user data
1917 * @xml_element: XML element
1919 * SAX2 end element handler
1921 typedef void (*raptor_sax2_end_element_handler)(void *user_data, raptor_xml_element* xml_element);
1924 * raptor_sax2_characters_handler:
1925 * @user_data: user data
1926 * @xml_element: XML element
1927 * @s: string
1928 * @len: string len
1930 * SAX2 characters handler
1932 typedef void (*raptor_sax2_characters_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len);
1935 * raptor_sax2_cdata_handler:
1936 * @user_data: user data
1937 * @xml_element: XML element
1938 * @s: string
1939 * @len: string len
1941 * SAX2 CDATA section handler
1943 typedef void (*raptor_sax2_cdata_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s, int len);
1946 * raptor_sax2_comment_handler:
1947 * @user_data: user data
1948 * @xml_element: XML element
1949 * @s: string
1951 * SAX2 XML comment handler
1953 typedef void (*raptor_sax2_comment_handler)(void *user_data, raptor_xml_element* xml_element, const unsigned char *s);
1956 * raptor_sax2_unparsed_entity_decl_handler:
1957 * @user_data: user data
1958 * @entityName: entity name
1959 * @base: base URI
1960 * @systemId: system ID
1961 * @publicId: public ID
1962 * @notationName: notation name
1964 * SAX2 unparsed entity (NDATA) handler
1966 typedef void (*raptor_sax2_unparsed_entity_decl_handler)(void *user_data, const unsigned char* entityName, const unsigned char* base, const unsigned char* systemId, const unsigned char* publicId, const unsigned char* notationName);
1969 * raptor_sax2_external_entity_ref_handler:
1970 * @user_data: user data
1971 * @context: context
1972 * @base: base URI
1973 * @systemId: system ID
1974 * @publicId: public ID
1976 * SAX2 external entity reference handler
1978 * Return value: 0 if processing should not continue because of a
1979 * fatal error in the handling of the external entity.
1981 typedef int (*raptor_sax2_external_entity_ref_handler)(void *user_data, const unsigned char* context, const unsigned char* base, const unsigned char* systemId, const unsigned char* publicId);
1984 /* SAX2 API */
1985 RAPTOR_API
1986 raptor_sax2* raptor_new_sax2(raptor_world *world, raptor_locator *locator, void* user_data);
1987 RAPTOR_API
1988 void raptor_free_sax2(raptor_sax2 *sax2);
1990 /* methods */
1991 RAPTOR_API
1992 void raptor_sax2_set_start_element_handler(raptor_sax2* sax2, raptor_sax2_start_element_handler handler);
1993 RAPTOR_API
1994 void raptor_sax2_set_end_element_handler(raptor_sax2* sax2, raptor_sax2_end_element_handler handler);
1995 RAPTOR_API
1996 void raptor_sax2_set_characters_handler(raptor_sax2* sax2, raptor_sax2_characters_handler handler);
1997 RAPTOR_API
1998 void raptor_sax2_set_cdata_handler(raptor_sax2* sax2, raptor_sax2_cdata_handler handler);
1999 RAPTOR_API
2000 void raptor_sax2_set_comment_handler(raptor_sax2* sax2, raptor_sax2_comment_handler handler);
2001 RAPTOR_API
2002 void raptor_sax2_set_unparsed_entity_decl_handler(raptor_sax2* sax2, raptor_sax2_unparsed_entity_decl_handler handler);
2003 RAPTOR_API
2004 void raptor_sax2_set_external_entity_ref_handler(raptor_sax2* sax2, raptor_sax2_external_entity_ref_handler handler);
2005 RAPTOR_API
2006 void raptor_sax2_set_namespace_handler(raptor_sax2* sax2, raptor_namespace_handler handler);
2007 RAPTOR_API
2008 void raptor_sax2_set_uri_filter(raptor_sax2* sax2, raptor_uri_filter_func filter, void *user_data);
2009 RAPTOR_API
2010 void raptor_sax2_parse_start(raptor_sax2 *sax2, raptor_uri *base_uri);
2011 RAPTOR_API
2012 int raptor_sax2_parse_chunk(raptor_sax2* sax2, const unsigned char *buffer, size_t len, int is_end);
2013 RAPTOR_API
2014 const unsigned char* raptor_sax2_inscope_xml_language(raptor_sax2* sax2);
2015 RAPTOR_API
2016 raptor_uri* raptor_sax2_inscope_base_uri(raptor_sax2* sax2);
2020 /* AVL Trees */
2023 * raptor_avltree:
2025 * AVL Tree
2027 typedef struct raptor_avltree_s raptor_avltree;
2030 * raptor_avltree_iterator:
2032 * AVL Tree Iterator as created by raptor_new_avltree_iterator()
2034 typedef struct raptor_avltree_iterator_s raptor_avltree_iterator;
2037 * raptor_avltree_visit_handler:
2038 * @depth: depth of object in tree
2039 * @data: data object being visited
2040 * @user_data: user data arg to raptor_avltree_visit()
2042 * AVL Tree visitor function as given to raptor_avltree_visit()
2044 * Return value: non-0 to terminate visit early.
2046 typedef int (*raptor_avltree_visit_handler)(int depth, void* data, void *user_data);
2050 * raptor_avltree_bitflags:
2051 * @RAPTOR_AVLTREE_FLAG_REPLACE_DUPLICATES: If set raptor_avltree_add() will replace any duplicate items. If not set, raptor_avltree_add() will not replace them and will return status >0 when adding a duplicate. (Default is not set)
2053 * Bit flags for AVL Tree class constructor raptor_new_avltree()
2055 typedef enum {
2056 RAPTOR_AVLTREE_FLAG_REPLACE_DUPLICATES = 1
2057 } raptor_avltree_bitflags;
2060 RAPTOR_API
2061 raptor_avltree* raptor_new_avltree(raptor_data_compare_handler compare_handler, raptor_data_free_handler free_handler, unsigned int flags);
2062 RAPTOR_API
2063 void raptor_free_avltree(raptor_avltree* tree);
2065 /* methods */
2066 RAPTOR_API
2067 int raptor_avltree_add(raptor_avltree* tree, void* p_data);
2068 RAPTOR_API
2069 void* raptor_avltree_remove(raptor_avltree* tree, void* p_data);
2070 RAPTOR_API
2071 int raptor_avltree_delete(raptor_avltree* tree, void* p_data);
2072 RAPTOR_API
2073 void* raptor_avltree_search(raptor_avltree* tree, const void* p_data);
2074 RAPTOR_API
2075 int raptor_avltree_visit(raptor_avltree* tree, raptor_avltree_visit_handler visit_handler, void* user_data);
2076 RAPTOR_API
2077 int raptor_avltree_size(raptor_avltree* tree);
2078 RAPTOR_API
2079 void raptor_avltree_set_print_handler(raptor_avltree* tree, raptor_data_print_handler print_handler);
2080 RAPTOR_API
2081 int raptor_avltree_print(raptor_avltree* tree, FILE* stream);
2083 RAPTOR_API
2084 raptor_avltree_iterator* raptor_new_avltree_iterator(raptor_avltree* tree, void* range, raptor_data_free_handler range_free_handler, int direction);
2085 RAPTOR_API
2086 void raptor_free_avltree_iterator(raptor_avltree_iterator* iterator);
2088 RAPTOR_API
2089 int raptor_avltree_iterator_is_end(raptor_avltree_iterator* iterator);
2090 RAPTOR_API
2091 int raptor_avltree_iterator_next(raptor_avltree_iterator* iterator);
2092 RAPTOR_API
2093 void* raptor_avltree_iterator_get(raptor_avltree_iterator* iterator);
2096 #ifdef __cplusplus
2098 #endif
2100 #endif