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.
37 /* Required for va_list in raptor_vsnprintf */
44 * Flag for marking raptor2 API availability.
46 #define RAPTOR_V2_AVAILABLE 1
52 * Raptor library version number
54 * Format: major * 10000 + minor * 100 + release
56 #define RAPTOR_VERSION 20016
59 * RAPTOR_VERSION_STRING:
61 * Raptor library version string
63 #define RAPTOR_VERSION_STRING "2.0.16"
66 * RAPTOR_VERSION_MAJOR:
68 * Raptor library major version
70 #define RAPTOR_VERSION_MAJOR 2
73 * RAPTOR_VERSION_MINOR:
75 * Raptor library minor version
77 #define RAPTOR_VERSION_MINOR 0
80 * RAPTOR_VERSION_RELEASE:
82 * Raptor library release
84 #define RAPTOR_VERSION_RELEASE 16
89 * Macro for wrapping API function call declarations.
96 # define _declspec(x) __declspec(x)
101 # ifdef RAPTOR_INTERNAL
102 # define RAPTOR_API _declspec(dllexport)
104 # define RAPTOR_API _declspec(dllimport)
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__))
119 #define RAPTOR_DEPRECATED
120 #define RAPTOR_NORETURN
124 * RAPTOR_PRINTF_FORMAT:
125 * @string_index: ignore me
126 * @first_to_check_index: ignore me
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)))
134 #define RAPTOR_PRINTF_FORMAT(string_index, first_to_check_index)
142 typedef struct raptor_uri_s raptor_uri
;
148 * raptor_short_copyright_string:
150 * Short copyright string (one line).
153 extern const char * const raptor_short_copyright_string
;
156 * raptor_copyright_string:
158 * Copyright string (multiple lines).
161 extern const char * const raptor_copyright_string
;
164 * raptor_version_string:
166 * Raptor version as a string.
169 extern const char * const raptor_version_string
;
172 * raptor_version_major:
174 * Raptor major version number.
177 extern const unsigned int raptor_version_major
;
180 * raptor_version_minor:
182 * Raptor minor version number.
185 extern const unsigned int raptor_version_minor
;
188 * raptor_version_release:
190 * Raptor release version number.
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
203 extern const unsigned int raptor_version_decimal
;
206 * raptor_license_string:
208 * Raptor license string.
211 extern const char * const raptor_license_string
;
214 * raptor_home_url_string:
216 * Raptor home page URL.
219 extern const char * const raptor_home_url_string
;
222 * raptor_xml_namespace_uri:
224 * XML Namespace (xml:) URI string.
227 extern const unsigned char * const raptor_xml_namespace_uri
;
231 * raptor_rdf_namespace_uri:
233 * RDF Namespace (rdf:) URI string.
236 extern const unsigned char * const raptor_rdf_namespace_uri
;
239 * raptor_rdf_namespace_uri_len:
241 * Length of #raptor_rdf_namespace_uri string
244 extern const unsigned int raptor_rdf_namespace_uri_len
;
247 * raptor_rdf_schema_namespace_uri:
249 * RDF Schema (rdfs:) Namespace URI string.
252 extern const unsigned char * const raptor_rdf_schema_namespace_uri
;
255 * raptor_rdf_schenma_namespace_uri_len:
257 * Length of #raptor_rdf_schenma_namespace_uri string
260 extern const unsigned int raptor_rdf_schema_namespace_uri_len
;
263 * raptor_xmlschema_datatypes_namespace_uri:
265 * XML Schema datatypes (xsd:) namespace URI string.
268 extern const unsigned char * const raptor_xmlschema_datatypes_namespace_uri
;
271 * raptor_owl_namespace_uri:
273 * OWL (owl:) Namespace URI string.
276 extern const unsigned char * const raptor_owl_namespace_uri
;
279 * raptor_xml_literal_datatype_uri_string:
281 * XML Literal datatype (rdf:XMLLiteral) URI string.
284 extern const unsigned char * const raptor_xml_literal_datatype_uri_string
;
287 * raptor_xml_literal_datatype_uri_string_len:
289 * Length of #raptor_xml_literal_datatype_uri_string
292 extern const unsigned int raptor_xml_literal_datatype_uri_string_len
;
295 /* Public structure */
299 * Raptor world class.
301 typedef struct raptor_world_s raptor_world
;
305 * Raptor Parser class
307 typedef struct raptor_parser_s raptor_parser
;
311 * Raptor Serializer class
313 typedef struct raptor_serializer_s raptor_serializer
;
320 typedef struct raptor_www_s raptor_www
;
324 * Raptor I/O Stream class
326 typedef struct raptor_iostream_s raptor_iostream
;
328 * raptor_xml_element:
330 * Raptor XML Element class
332 typedef struct raptor_xml_element_s raptor_xml_element
;
336 * Raptor XML Writer class
338 typedef struct raptor_xml_writer_s raptor_xml_writer
;
342 * Raptor XML qname class
344 typedef struct raptor_qname_s raptor_qname
;
348 * Raptor XML Namespace class
350 typedef struct raptor_namespace_s raptor_namespace
;
352 * raptor_namespace_stack:
354 * Raptor XML Namespace Stack class
356 typedef struct raptor_namespace_stack_s raptor_namespace_stack
;
363 typedef struct raptor_sax2_s raptor_sax2
;
368 * @mime_type: MIME type string
369 * @mime_type_len: length of @mime_type
370 * @q: Q value 0-10 standing for decimal 0.0-1.0
372 * (MIME Type, Q) pair
375 const char* mime_type
;
376 size_t mime_type_len
;
382 * raptor_syntax_bitflags:
383 * @RAPTOR_SYNTAX_NEED_BASE_URI: the syntax requires a base URI
385 * Bit flags for #raptor_syntax_description flags field
388 RAPTOR_SYNTAX_NEED_BASE_URI
= 1
389 } raptor_syntax_bitflags
;
393 * raptor_syntax_description:
394 * @names: array of syntax names - the first one (required) is the public name, the rest are aliases. The array is NULL terminated.
395 * @names_count: size of @names array
396 * @label: long descriptive label for syntax
397 * @mime_types: Array of (MIME type, Q) values associated with the syntax (or NULL). If present the array is NULL terminated.
398 * @mime_types_count: size of @mime_types array
399 * @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.
400 * @uri_strings_count: size of @uri_strings array
401 * @flags: See #raptor_syntax_bitflags for the bits
403 * Description of a syntax or file format.
407 const char* const* names
;
408 unsigned int names_count
;
412 const raptor_type_q
* mime_types
;
413 unsigned int mime_types_count
;
415 const char* const* uri_strings
;
416 unsigned int uri_strings_count
;
419 } raptor_syntax_description
;
424 * @RAPTOR_TERM_TYPE_URI: RDF URI
425 * @RAPTOR_TERM_TYPE_LITERAL: RDF literal
426 * @RAPTOR_TERM_TYPE_BLANK: RDF blank node
427 * @RAPTOR_TERM_TYPE_UNKNOWN: Internal
429 * Type of term in a #raptor_statement
431 * Node type 3 is unused but exists to preserve numeric compatibility
432 * with librdf_node_type values.
435 RAPTOR_TERM_TYPE_UNKNOWN
= 0,
436 RAPTOR_TERM_TYPE_URI
= 1,
437 RAPTOR_TERM_TYPE_LITERAL
= 2,
439 RAPTOR_TERM_TYPE_BLANK
= 4
445 * @uri: URI of location (or NULL)
446 * @file: Filename of location (or NULL)
447 * @line: Line number of location (or <0 for no line)
448 * @column: Column number of location (or <0 for no column)
449 * @byte: Byte number of location (or <0 for no byte)
451 * Location information for an error, warning or information message.
463 * @RAPTOR_OPTION_SCANNING: If true (default false), the RDF/XML
464 * parser will look for embedded rdf:RDF elements inside the XML
465 * content, and not require that the XML start with an rdf:RDF root
467 * @RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES: If true (default true)
468 * then the RDF/XML parser will allow non-XML namespaced attributes
469 * to be accepted as well as rdf: namespaced ones. For example,
470 * 'about' and 'ID' will be interpreted as if they were rdf:about
471 * and rdf:ID respectively.
472 * @RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES: If true (default true)
473 * then the RDF/XML parser will allow unknown parsetypes to be
474 * present and will pass them on to the user. Unimplemented at
476 * @RAPTOR_OPTION_ALLOW_BAGID: If true (default true) then the
477 * RDF/XML parser will support the rdf:bagID attribute that was
478 * removed from the RDF/XML language when it was revised. This
479 * support may be removed in future.
480 * @RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST: If true (default false)
481 * then the RDF/XML parser will generate the idList rdf:type
482 * rdf:List triple in the handling of rdf:parseType="Collection".
483 * This triple was removed during the revising of RDF/XML after
484 * collections were initially added.
485 * @RAPTOR_OPTION_NORMALIZE_LANGUAGE: If true (default true) then
486 * XML language values such as from xml:lang will be normalized to
488 * @RAPTOR_OPTION_NON_NFC_FATAL: If true (default false) then
489 * illegal Unicode Normal Form C in literals will give a fatal
490 * error, otherwise just a warning.
491 * @RAPTOR_OPTION_WARN_OTHER_PARSETYPES: If true (default true) then
492 * the RDF/XML parser will warn about unknown rdf:parseType values.
493 * @RAPTOR_OPTION_CHECK_RDF_ID: If true (default true) then the
494 * RDF/XML will check rdf:ID attribute values for duplicates and
495 * cause an error if any are found.
496 * @RAPTOR_OPTION_RELATIVE_URIS: If true (default true) then
497 * relative URIs will be used wherever possible when serializing.
498 * @RAPTOR_OPTION_WRITER_AUTO_INDENT: Automatically indent elements when
500 * @RAPTOR_OPTION_WRITER_AUTO_EMPTY: Automatically detect and
501 * abbreviate empty elements when serializing.
502 * @RAPTOR_OPTION_WRITER_INDENT_WIDTH: Integer number of spaces to use
503 * for each indent level when serializing with auto indent.
504 * @RAPTOR_OPTION_WRITER_XML_VERSION: Integer XML version XML 1.0 (10) or XML 1.1 (11)
505 * @RAPTOR_OPTION_WRITER_XML_DECLARATION: Write XML 1.0 or 1.1 declaration.
506 * @RAPTOR_OPTION_NO_NET: Deny network requests inside other requests.
507 * @RAPTOR_OPTION_RESOURCE_BORDER: Border color of resource
508 * nodes for GraphViz DOT serializer.
509 * @RAPTOR_OPTION_LITERAL_BORDER: Border color of literal nodes
510 * for GraphViz DOT serializer.
511 * @RAPTOR_OPTION_BNODE_BORDER: Border color of blank nodes for
512 * GraphViz DOT serializer.
513 * @RAPTOR_OPTION_RESOURCE_FILL: Fill color of resource nodes
514 * for GraphViz DOT serializer.
515 * @RAPTOR_OPTION_LITERAL_FILL: Fill color of literal nodes for
516 * GraphViz DOT serializer.
517 * @RAPTOR_OPTION_BNODE_FILL: Fill color of blank nodes for
518 * GraphViz DOT serializer.
519 * @RAPTOR_OPTION_HTML_TAG_SOUP: Use a lax HTML parser if an XML parser
520 * fails when read HTML for GRDDL parser.
521 * @RAPTOR_OPTION_MICROFORMATS: Look for microformats for GRDDL parser.
522 * @RAPTOR_OPTION_HTML_LINK: Look for head <link> to type rdf/xml
524 * @RAPTOR_OPTION_WWW_TIMEOUT: Set timeout for internal WWW URI requests
526 * @RAPTOR_OPTION_WRITE_BASE_URI: Write @base directive for Turtle/N3.
527 * @RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL: HTTP Cache-Control: header
528 * @RAPTOR_OPTION_WWW_HTTP_USER_AGENT: HTTP User-Agent: header
529 * @RAPTOR_OPTION_JSON_CALLBACK: JSON serializer callback function.
530 * @RAPTOR_OPTION_JSON_EXTRA_DATA: JSON serializer extra top-level data
531 * @RAPTOR_OPTION_RSS_TRIPLES: Atom/RSS serializer writes extra RDF triples it finds (none, rdf-xml, atom-triples)
532 * @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.
533 * @RAPTOR_OPTION_PREFIX_ELEMENTS: Integer. If set, generate Atom/RSS1.0 documents with prefixed elements, otherwise unprefixed.
534 * @RAPTOR_OPTION_STRICT: Boolean. If set, operate in strict conformance mode.
535 * @RAPTOR_OPTION_WWW_CERT_FILENAME: String. SSL client certificate filename
536 * @RAPTOR_OPTION_WWW_CERT_TYPE: String. SSL client certificate type
537 * @RAPTOR_OPTION_WWW_CERT_PASSPHRASE: String. SSL client certificate passphrase
538 * @RAPTOR_OPTION_WWW_SSL_VERIFY_PEER: Integer. SSL verify peer - non-0 to verify peer SSL certificate (default)
539 * @RAPTOR_OPTION_WWW_SSL_VERIFY_HOST: Integer. SSL verify host - 0 none, 1 CN match, 2 host match (default). Other values are ignored.
540 * @RAPTOR_OPTION_NO_FILE: Deny file reading requests inside other requests.
541 * @RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES: When reading XML, load external entities.
542 * @RAPTOR_OPTION_LAST: Internal
544 * Raptor parser, serializer or XML writer options.
547 RAPTOR_OPTION_SCANNING
,
548 RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES
,
549 RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES
,
550 RAPTOR_OPTION_ALLOW_BAGID
,
551 RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST
,
552 RAPTOR_OPTION_NORMALIZE_LANGUAGE
,
553 RAPTOR_OPTION_NON_NFC_FATAL
,
554 RAPTOR_OPTION_WARN_OTHER_PARSETYPES
,
555 RAPTOR_OPTION_CHECK_RDF_ID
,
556 RAPTOR_OPTION_RELATIVE_URIS
,
557 RAPTOR_OPTION_WRITER_AUTO_INDENT
,
558 RAPTOR_OPTION_WRITER_AUTO_EMPTY
,
559 RAPTOR_OPTION_WRITER_INDENT_WIDTH
,
560 RAPTOR_OPTION_WRITER_XML_VERSION
,
561 RAPTOR_OPTION_WRITER_XML_DECLARATION
,
562 RAPTOR_OPTION_NO_NET
,
563 RAPTOR_OPTION_RESOURCE_BORDER
,
564 RAPTOR_OPTION_LITERAL_BORDER
,
565 RAPTOR_OPTION_BNODE_BORDER
,
566 RAPTOR_OPTION_RESOURCE_FILL
,
567 RAPTOR_OPTION_LITERAL_FILL
,
568 RAPTOR_OPTION_BNODE_FILL
,
569 RAPTOR_OPTION_HTML_TAG_SOUP
,
570 RAPTOR_OPTION_MICROFORMATS
,
571 RAPTOR_OPTION_HTML_LINK
,
572 RAPTOR_OPTION_WWW_TIMEOUT
,
573 RAPTOR_OPTION_WRITE_BASE_URI
,
574 RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL
,
575 RAPTOR_OPTION_WWW_HTTP_USER_AGENT
,
576 RAPTOR_OPTION_JSON_CALLBACK
,
577 RAPTOR_OPTION_JSON_EXTRA_DATA
,
578 RAPTOR_OPTION_RSS_TRIPLES
,
579 RAPTOR_OPTION_ATOM_ENTRY_URI
,
580 RAPTOR_OPTION_PREFIX_ELEMENTS
,
581 RAPTOR_OPTION_STRICT
,
582 RAPTOR_OPTION_WWW_CERT_FILENAME
,
583 RAPTOR_OPTION_WWW_CERT_TYPE
,
584 RAPTOR_OPTION_WWW_CERT_PASSPHRASE
,
585 RAPTOR_OPTION_NO_FILE
,
586 RAPTOR_OPTION_WWW_SSL_VERIFY_PEER
,
587 RAPTOR_OPTION_WWW_SSL_VERIFY_HOST
,
588 RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES
,
589 RAPTOR_OPTION_LAST
= RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES
594 * raptor_term_literal_value:
595 * @string: literal string
596 * @string_len: length of string
597 * @datatype: datatype URI (or NULL)
598 * @language: literal language (or NULL)
599 * @language_len: length of language
601 * Literal term value - this typedef exists solely for use in #raptor_term
603 * Either @datatype or @language may be non-NULL but not both.
606 unsigned char *string
;
607 unsigned int string_len
;
609 raptor_uri
*datatype
;
611 unsigned char *language
;
612 unsigned char language_len
;
613 } raptor_term_literal_value
;
617 * raptor_term_blank_value:
618 * @string: literal string
619 * @string_len: length of string
621 * Blank term value - this typedef exists solely for use in #raptor_term
625 unsigned char *string
;
626 unsigned int string_len
;
627 } raptor_term_blank_value
;
632 * @uri: uri value when term type is #RAPTOR_TERM_TYPE_URI
633 * @literal: literal value when term type is #RAPTOR_TERM_TYPE_LITERAL
634 * @blank: blank value when term type is #RAPTOR_TERM_TYPE_BLANK
636 * Term value - this typedef exists solely for use in #raptor_term
642 raptor_term_literal_value literal
;
644 raptor_term_blank_value blank
;
651 * @usage: usage reference count (if >0)
653 * @value: term values per type
655 * An RDF statement term
663 raptor_term_type type
;
665 raptor_term_value value
;
672 * @world: world pointer
673 * @usage: usage count
674 * @subject: statement subject
675 * @predicate: statement predicate
676 * @object: statement object
677 * @graph: statement graph name (or NULL if not present)
679 * An RDF triple with optional graph name (quad)
681 * See #raptor_term for a description of how the fields may be used.
682 * As returned by a parser statement_handler.
687 raptor_term
* subject
;
688 raptor_term
* predicate
;
696 * @RAPTOR_LOG_LEVEL_NONE: Internal
697 * @RAPTOR_LOG_LEVEL_TRACE: very fine-grained tracing messages information
698 * @RAPTOR_LOG_LEVEL_DEBUG: fine-grained tracing messages suitable for debugging
699 * @RAPTOR_LOG_LEVEL_INFO: coarse-grained information messages
700 * @RAPTOR_LOG_LEVEL_WARN: warning messages of potentially harmful problems
701 * @RAPTOR_LOG_LEVEL_ERROR: error messages where the application can continue
702 * @RAPTOR_LOG_LEVEL_FATAL: fatal error message where the application will likely abort
703 * @RAPTOR_LOG_LEVEL_LAST: Internal
708 RAPTOR_LOG_LEVEL_NONE
,
709 RAPTOR_LOG_LEVEL_TRACE
,
710 RAPTOR_LOG_LEVEL_DEBUG
,
711 RAPTOR_LOG_LEVEL_INFO
,
712 RAPTOR_LOG_LEVEL_WARN
,
713 RAPTOR_LOG_LEVEL_ERROR
,
714 RAPTOR_LOG_LEVEL_FATAL
,
715 RAPTOR_LOG_LEVEL_LAST
= RAPTOR_LOG_LEVEL_FATAL
721 * @RAPTOR_DOMAIN_IOSTREAM: I/O stream
722 * @RAPTOR_DOMAIN_NAMESPACE: XML Namespace / namespace stack
723 * @RAPTOR_DOMAIN_PARSER: RDF Parser
724 * @RAPTOR_DOMAIN_QNAME: XML QName
725 * @RAPTOR_DOMAIN_SAX2: XML SAX2
726 * @RAPTOR_DOMAIN_SERIALIZER: RDF Serializer
727 * @RAPTOR_DOMAIN_TERM: RDF Term
728 * @RAPTOR_DOMAIN_TURTLE_WRITER: Turtle Writer
729 * @RAPTOR_DOMAIN_URI: RDF Uri
730 * @RAPTOR_DOMAIN_WORLD: RDF world
731 * @RAPTOR_DOMAIN_WWW: WWW
732 * @RAPTOR_DOMAIN_XML_WRITER: XML Writer
733 * @RAPTOR_DOMAIN_NONE: Internal
734 * @RAPTOR_DOMAIN_LAST: Internal
740 RAPTOR_DOMAIN_IOSTREAM
,
741 RAPTOR_DOMAIN_NAMESPACE
,
742 RAPTOR_DOMAIN_PARSER
,
745 RAPTOR_DOMAIN_SERIALIZER
,
747 RAPTOR_DOMAIN_TURTLE_WRITER
,
751 RAPTOR_DOMAIN_XML_WRITER
,
752 RAPTOR_DOMAIN_LAST
= RAPTOR_DOMAIN_XML_WRITER
757 * raptor_log_message:
758 * @code: error code or < 0 if not used or known
759 * @domain: message domain or #RAPTOR_DOMAIN_NONE if not used or known
760 * @level: log message level
761 * @locator: location associated with message or NULL if not known
762 * @text: message string
768 raptor_domain domain
;
769 raptor_log_level level
;
770 raptor_locator
*locator
;
772 } raptor_log_message
;
776 * raptor_log_handler:
777 * @user_data: user data
778 * @message: log message
780 * Handler function for log messages with location
782 * Used during parsing and serializing for errors and warnings that
783 * may include location information. Handlers may be set
784 * by raptor_world_set_log_handler().
787 typedef void (*raptor_log_handler
)(void *user_data
, raptor_log_message
*message
);
791 * raptor_statement_handler:
792 * @user_data: user data
793 * @statement: statement to report
795 * Statement (triple) reporting handler function.
797 * This handler function set with
798 * raptor_parser_set_statement_handler() on a parser receives
799 * statements as the parsing proceeds. The @statement argument to the
800 * handler is shared and must be copied by the caller with
801 * raptor_statement_copy().
803 typedef void (*raptor_statement_handler
)(void *user_data
, raptor_statement
*statement
);
806 * raptor_graph_mark_flags:
807 * @RAPTOR_GRAPH_MARK_START: mark is start of graph (otherwise is end)
808 * @RAPTOR_GRAPH_MARK_DECLARED: mark was declared in syntax rather than implict
810 * Graph mark handler bitmask flags
813 RAPTOR_GRAPH_MARK_START
= 1,
814 RAPTOR_GRAPH_MARK_DECLARED
= 2
815 } raptor_graph_mark_flags
;
819 * raptor_graph_mark_handler:
820 * @user_data: user data
821 * @graph: graph to report, NULL for the default graph
822 * @flags: bitmask of #raptor_graph_mark_flags flags
824 * Graph start/end mark handler function.
826 * Records start and end of graphs happening in a stream of generated
827 * #raptor_statement via the statement handler. The callback starts a
828 * graph when @flags has #RAPTOR_GRAPH_MARK_START bit set.
830 * The start and ends may be either declared in the syntax via some
831 * keyword or mechanism such as TRiG {} syntax when @flags has bit
832 * #RAPTOR_GRAPH_MARK_DECLARED set, or be implied by the start/end of
833 * the data in other syntaxes, and the bit will be unset.
835 typedef void (*raptor_graph_mark_handler
)(void *user_data
, raptor_uri
*graph
, int flags
);
838 * raptor_generate_bnodeid_handler:
839 * @user_data: user data
840 * @user_bnodeid: a user-specified ID or NULL if none available.
842 * Generate a blank node identifier handler function.
844 * Return value: new blank node ID to use
846 typedef unsigned char* (*raptor_generate_bnodeid_handler
)(void *user_data
, unsigned char* user_bnodeid
);
849 * raptor_namespace_handler:
850 * @user_data: user data
851 * @nspace: #raptor_namespace declared
853 * XML Namespace declaration reporting handler set by
854 * raptor_parser_set_namespace_handler().
856 typedef void (*raptor_namespace_handler
)(void* user_data
, raptor_namespace
*nspace
);
860 * raptor_www_write_bytes_handler:
862 * @userdata: user data
864 * @size: size of individual item
865 * @nmemb: number of items
867 * Receiving bytes of data from WWW retrieval handler.
869 * Set by raptor_www_set_write_bytes_handler().
871 typedef void (*raptor_www_write_bytes_handler
)(raptor_www
* www
, void *userdata
, const void *ptr
, size_t size
, size_t nmemb
);
874 * raptor_www_content_type_handler:
876 * @userdata: user data
877 * @content_type: content type seen
879 * Receiving Content-Type: header from WWW retrieval handler.
881 * Set by raptor_www_set_content_type_handler().
883 typedef void (*raptor_www_content_type_handler
)(raptor_www
* www
, void *userdata
, const char *content_type
);
886 * raptor_www_final_uri_handler:
888 * @userdata: user data
889 * @final_uri: final URI seen
891 * Receiving the final resolved URI from a WWW retrieval
893 * Set by raptor_www_set_final_uri_handler().
895 typedef void (*raptor_www_final_uri_handler
)(raptor_www
* www
, void *userdata
, raptor_uri
*final_uri
);
898 * raptor_uri_filter_func:
899 * @user_data: user data
900 * @uri: #raptor_uri URI to check
902 * Callback function for #raptor_www_set_uri_filter
904 * Return value: non-0 to filter the URI
906 typedef int (*raptor_uri_filter_func
)(void *user_data
, raptor_uri
* uri
);
911 * @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)
912 * @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)
913 * @RAPTOR_WORLD_FLAG_URI_INTERNING: if set (non-0 value) - each URI is saved interned in-memory and reused (default set)
914 * @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.
918 * These are used by raptor_world_set_flags() to control raptor-wide
919 * options across classes. These must be set before
920 * raptor_world_open() is called explicitly or implicitly (by
921 * creating a raptor object). There is no enumeration function for
922 * these flags because they are not user options and must be set
923 * before the library is initialised. For similar reasons, there is
926 * If any libxml handler saving/restoring is enabled, any existing
927 * handler and context is saved before parsing and restored
928 * afterwards. Otherwise, no saving/restoring is performed.
932 RAPTOR_WORLD_FLAG_LIBXML_GENERIC_ERROR_SAVE
= 1,
933 RAPTOR_WORLD_FLAG_LIBXML_STRUCTURED_ERROR_SAVE
= 2,
934 RAPTOR_WORLD_FLAG_URI_INTERNING
= 3,
935 RAPTOR_WORLD_FLAG_WWW_SKIP_INIT_FINISH
= 4
940 * raptor_data_compare_arg_handler:
941 * @data1: first object
942 * @data2: second object
943 * @user_data: user data argument
945 * Function to compare two data objects with a user data argument
947 * Designed to be used with raptor_sort_r() and compatible functions
948 * such as raptor_sequence_sort_r() which uses it.
950 * Return value: compare value <0 if @data1 is before @data2, =0 if equal, >0 if @data1 is after @data2
952 typedef int (*raptor_data_compare_arg_handler
)(const void *data1
, const void *data2
, void *user_data
);
956 * raptor_data_compare_handler:
957 * @data1: first data object
958 * @data2: second data object
960 * Function to compare two data objects - signature like strcmp() and function pssed to qsort()
962 * Designed to be passed into generic data structure constructors
963 * like raptor_new_avltree().
965 * Return value: compare value <0 if @data1 is before @data2, =0 if equal, >0 if @data1 is after @data2
967 typedef int (*raptor_data_compare_handler
)(const void* data1
, const void* data2
);
971 * raptor_data_malloc_handler:
974 * Typedef for a function to allocate memory - signature like malloc()
976 * Designed to be passed into constructors
977 * like raptor_www_fetch_to_string
979 * Return value: pointer to newly allocated memory or NULL on failure
981 typedef void* (*raptor_data_malloc_handler
)(size_t size
);
985 * raptor_data_free_handler:
986 * @data: data object or NULL
988 * Typedef for function to free a data object - signature like free()
990 * Designed to be passed into generic data structure constructors
991 * like raptor_new_avltree(). If @data is NULL, nothing should be done.
993 typedef void (*raptor_data_free_handler
)(void* data
);
997 * raptor_data_context_free_handler:
998 * @context: context data for the free function
999 * @object: object to free
1001 * Handler function for freeing a sequence item with a contextual pointer.
1003 * Set by raptor_new_sequence_with_context().
1005 typedef void (*raptor_data_context_free_handler
)(void* context
, void* object
);
1008 * raptor_data_print_handler:
1009 * @object: object to print
1010 * @fh: FILE* to print to
1012 * Handler function for printing an object to a stream.
1014 * Set by raptor_new_sequence()
1016 * Return value: non-0 on failure
1018 typedef int (*raptor_data_print_handler
)(void *object
, FILE *fh
);
1021 * raptor_data_context_print_handler:
1022 * @context: context data for the print function
1023 * @object: object to print
1024 * @fh: FILE* to print to
1026 * Function function for printing an object with data context to a stream.
1028 * Set by raptor_new_sequence_with_context()
1030 * Return value: non-0 on failure
1032 typedef int (*raptor_data_context_print_handler
)(void *context
, void *object
, FILE *fh
);
1035 * raptor_stringbuffer:
1037 * Raptor string buffer class
1039 typedef struct raptor_stringbuffer_s raptor_stringbuffer
;
1042 /* Public functions */
1044 #define raptor_new_world() raptor_new_world_internal(RAPTOR_VERSION)
1045 /* The real target of the raptor_new_world() macro */
1047 raptor_world
*raptor_new_world_internal(unsigned int version_decimal
);
1049 int raptor_world_open(raptor_world
* world
);
1051 void raptor_free_world(raptor_world
* world
);
1053 int raptor_world_set_libxslt_security_preferences(raptor_world
*world
, void *security_preferences
);
1055 int raptor_world_set_flag(raptor_world
*world
, raptor_world_flag flag
, int value
);
1057 int raptor_world_set_log_handler(raptor_world
*world
, void *user_data
, raptor_log_handler handler
);
1059 void raptor_world_set_generate_bnodeid_handler(raptor_world
* world
, void *user_data
, raptor_generate_bnodeid_handler handler
);
1061 unsigned char* raptor_world_generate_bnodeid(raptor_world
*world
);
1063 void raptor_world_set_generate_bnodeid_parameters(raptor_world
* world
, char *prefix
, int base
);
1065 const char* raptor_log_level_get_label(raptor_log_level level
);
1067 const char* raptor_domain_get_label(raptor_domain domain
);
1071 int raptor_world_is_parser_name(raptor_world
* world
, const char *name
);
1073 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
);
1075 int raptor_world_is_serializer_name(raptor_world
* world
, const char *name
);
1077 /* Syntax descriptions */
1079 int raptor_world_get_parsers_count(raptor_world
* world
);
1081 int raptor_world_get_serializers_count(raptor_world
* world
);
1083 const raptor_syntax_description
* raptor_world_get_parser_description(raptor_world
* world
, unsigned int counter
);
1085 const raptor_syntax_description
* raptor_world_get_serializer_description(raptor_world
* world
, unsigned int counter
);
1087 int raptor_syntax_description_validate(raptor_syntax_description
* desc
);
1090 raptor_option
raptor_world_get_option_from_uri(raptor_world
* world
, raptor_uri
*uri
);
1095 raptor_term
* raptor_new_term_from_uri(raptor_world
* world
, raptor_uri
* uri
);
1097 raptor_term
* raptor_new_term_from_counted_uri_string(raptor_world
* world
, const unsigned char *uri_string
, size_t length
);
1099 raptor_term
* raptor_new_term_from_uri_string(raptor_world
* world
, const unsigned char *uri_string
);
1101 raptor_term
* raptor_new_term_from_literal(raptor_world
* world
, const unsigned char* literal
, raptor_uri
* datatype
, const unsigned char* language
);
1103 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
);
1105 raptor_term
* raptor_new_term_from_blank(raptor_world
* world
, const unsigned char* blank
);
1107 raptor_term
* raptor_new_term_from_counted_blank(raptor_world
* world
, const unsigned char* blank
, size_t length
);
1109 raptor_term
* raptor_new_term_from_counted_string(raptor_world
* world
, unsigned char* string
, size_t length
);
1111 raptor_term
* raptor_term_copy(raptor_term
* term
);
1113 int raptor_term_compare(const raptor_term
*t1
, const raptor_term
*t2
);
1115 int raptor_term_equals(raptor_term
* t1
, raptor_term
* t2
);
1117 void raptor_free_term(raptor_term
*term
);
1120 unsigned char* raptor_term_to_counted_string(raptor_term
*term
, size_t* len_p
);
1122 unsigned char* raptor_term_to_string(raptor_term
*term
);
1124 int raptor_term_escaped_write(const raptor_term
*term
, unsigned int flags
, raptor_iostream
* iostr
);
1125 RAPTOR_API RAPTOR_DEPRECATED
1126 int raptor_term_ntriples_write(const raptor_term
*term
, raptor_iostream
* iostr
);
1128 int raptor_uri_turtle_write(raptor_world
*world
, raptor_iostream
* iostr
, raptor_uri
* uri
, raptor_namespace_stack
*nstack
, raptor_uri
*base_uri
);
1130 int raptor_term_turtle_write(raptor_iostream
* iostr
, raptor_term
* term
, raptor_namespace_stack
*nstack
, raptor_uri
*base_uri
);
1132 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
);
1134 unsigned char* raptor_uri_to_turtle_string(raptor_world
*world
, raptor_uri
* uri
, raptor_namespace_stack
*nstack
, raptor_uri
*base_uri
);
1136 unsigned char* raptor_term_to_turtle_counted_string(raptor_term
* term
, raptor_namespace_stack
*nstack
, raptor_uri
*base_uri
, size_t *len_p
);
1138 unsigned char* raptor_term_to_turtle_string(raptor_term
* term
, raptor_namespace_stack
*nstack
, raptor_uri
*base_uri
);
1141 /* Statement Class */
1143 void raptor_statement_init(raptor_statement
*statement
, raptor_world
*world
);
1145 void raptor_statement_clear(raptor_statement
*statement
);
1147 raptor_statement
* raptor_new_statement(raptor_world
*world
);
1149 raptor_statement
* raptor_new_statement_from_nodes(raptor_world
* world
, raptor_term
*subject
, raptor_term
*predicate
, raptor_term
*object
, raptor_term
*graph
);
1151 raptor_statement
* raptor_statement_copy(raptor_statement
*statement
);
1153 void raptor_free_statement(raptor_statement
*statement
);
1156 int raptor_statement_print(const raptor_statement
* statement
, FILE *stream
);
1158 int raptor_statement_print_as_ntriples(const raptor_statement
* statement
, FILE *stream
);
1160 int raptor_statement_compare(const raptor_statement
*s1
, const raptor_statement
*s2
);
1162 int raptor_statement_equals(const raptor_statement
* s1
, const raptor_statement
* s2
);
1167 raptor_parser
* raptor_new_parser(raptor_world
* world
, const char *name
);
1169 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
);
1171 void raptor_free_parser(raptor_parser
* parser
);
1177 void raptor_parser_set_statement_handler(raptor_parser
* parser
, void *user_data
, raptor_statement_handler handler
);
1179 void raptor_parser_set_graph_mark_handler(raptor_parser
* parser
, void *user_data
, raptor_graph_mark_handler handler
);
1181 void raptor_parser_set_namespace_handler(raptor_parser
* parser
, void *user_data
, raptor_namespace_handler handler
);
1183 void raptor_parser_set_uri_filter(raptor_parser
* parser
, raptor_uri_filter_func filter
, void* user_data
);
1185 raptor_locator
* raptor_parser_get_locator(raptor_parser
* rdf_parser
);
1188 /* Parsing functions */
1190 int raptor_parser_parse_start(raptor_parser
*rdf_parser
, raptor_uri
*uri
);
1192 int raptor_parser_parse_chunk(raptor_parser
* rdf_parser
, const unsigned char *buffer
, size_t len
, int is_end
);
1194 int raptor_parser_parse_file_stream(raptor_parser
* rdf_parser
, FILE *stream
, const char *filename
, raptor_uri
*base_uri
);
1196 int raptor_parser_parse_file(raptor_parser
* rdf_parser
, raptor_uri
*uri
, raptor_uri
*base_uri
);
1198 int raptor_parser_parse_uri(raptor_parser
* rdf_parser
, raptor_uri
*uri
, raptor_uri
*base_uri
);
1200 int raptor_parser_parse_uri_with_connection(raptor_parser
* rdf_parser
, raptor_uri
*uri
, raptor_uri
*base_uri
, void *connection
);
1202 int raptor_parser_parse_iostream(raptor_parser
* rdf_parser
, raptor_iostream
*iostr
, raptor_uri
*base_uri
);
1204 void raptor_parser_parse_abort(raptor_parser
* rdf_parser
);
1206 const char* raptor_parser_get_name(raptor_parser
*rdf_parser
);
1208 const raptor_syntax_description
* raptor_parser_get_description(raptor_parser
*rdf_parser
);
1210 /* parser option methods */
1212 int raptor_parser_set_option(raptor_parser
*parser
, raptor_option option
, const char* string
, int integer
);
1214 int raptor_parser_get_option(raptor_parser
*parser
, raptor_option option
, char** string_p
, int* integer_p
);
1216 /* parser utility methods */
1218 const char* raptor_parser_get_accept_header(raptor_parser
* rdf_parser
);
1220 raptor_world
* raptor_parser_get_world(raptor_parser
* rdf_parser
);
1222 raptor_uri
* raptor_parser_get_graph(raptor_parser
* rdf_parser
);
1228 int raptor_locator_print(raptor_locator
* locator
, FILE *stream
);
1230 int raptor_locator_format(char *buffer
, size_t length
, raptor_locator
* locator
);
1232 int raptor_locator_line(raptor_locator
*locator
);
1234 int raptor_locator_column(raptor_locator
*locator
);
1236 int raptor_locator_byte(raptor_locator
*locator
);
1238 const char* raptor_locator_file(raptor_locator
*locator
);
1240 const char* raptor_locator_uri(raptor_locator
*locator
);
1243 /* Serializer Class */
1245 raptor_serializer
* raptor_new_serializer(raptor_world
* world
, const char *name
);
1247 void raptor_free_serializer(raptor_serializer
* rdf_serializer
);
1251 int raptor_serializer_start_to_iostream(raptor_serializer
*rdf_serializer
, raptor_uri
*uri
, raptor_iostream
*iostream
);
1253 int raptor_serializer_start_to_filename(raptor_serializer
*rdf_serializer
, const char *filename
);
1255 int raptor_serializer_start_to_string(raptor_serializer
*rdf_serializer
, raptor_uri
*uri
, void **string_p
, size_t *length_p
);
1257 int raptor_serializer_start_to_file_handle(raptor_serializer
*rdf_serializer
, raptor_uri
*uri
, FILE *fh
);
1259 int raptor_serializer_set_namespace(raptor_serializer
* rdf_serializer
, raptor_uri
*uri
, const unsigned char *prefix
);
1261 int raptor_serializer_set_namespace_from_namespace(raptor_serializer
* rdf_serializer
, raptor_namespace
*nspace
);
1263 int raptor_serializer_serialize_statement(raptor_serializer
* rdf_serializer
, raptor_statement
*statement
);
1265 int raptor_serializer_serialize_end(raptor_serializer
*rdf_serializer
);
1267 raptor_iostream
* raptor_serializer_get_iostream(raptor_serializer
*serializer
);
1269 raptor_locator
* raptor_serializer_get_locator(raptor_serializer
*rdf_serializer
);
1271 int raptor_serializer_flush(raptor_serializer
*rdf_serializer
);
1273 const raptor_syntax_description
* raptor_serializer_get_description(raptor_serializer
*rdf_serializer
);
1275 /* serializer option methods */
1277 int raptor_serializer_set_option(raptor_serializer
*serializer
, raptor_option option
, const char* string
, int integer
);
1279 int raptor_serializer_get_option(raptor_serializer
*serializer
, raptor_option option
, char** string_p
, int* integer_p
);
1281 /* utility methods */
1283 raptor_world
* raptor_serializer_get_world(raptor_serializer
* rdf_serializer
);
1286 /* memory functions */
1288 void raptor_free_memory(void *ptr
);
1290 void* raptor_alloc_memory(size_t size
);
1292 void* raptor_calloc_memory(size_t nmemb
, size_t size
);
1297 raptor_uri
* raptor_new_uri_from_counted_string(raptor_world
* world
, const unsigned char *uri_string
, size_t length
);
1299 raptor_uri
* raptor_new_uri(raptor_world
* world
, const unsigned char *uri_string
);
1301 raptor_uri
* raptor_new_uri_from_uri_local_name(raptor_world
* world
, raptor_uri
*uri
, const unsigned char *local_name
);
1303 raptor_uri
* raptor_new_uri_relative_to_base(raptor_world
* world
, raptor_uri
*base_uri
, const unsigned char *uri_string
);
1305 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
);
1307 raptor_uri
* raptor_new_uri_from_id(raptor_world
* world
, raptor_uri
*base_uri
, const unsigned char *id
);
1309 raptor_uri
* raptor_new_uri_from_uri_or_file_string(raptor_world
* world
, raptor_uri
* base_uri
, const unsigned char* uri_or_file_string
);
1311 raptor_uri
* raptor_new_uri_for_rdf_concept(raptor_world
* world
, const unsigned char *name
);
1313 raptor_uri
* raptor_new_uri_for_xmlbase(raptor_uri
* old_uri
);
1315 raptor_uri
* raptor_new_uri_for_retrieval(raptor_uri
* old_uri
);
1317 void raptor_free_uri(raptor_uri
*uri
);
1321 int raptor_uri_equals(raptor_uri
* uri1
, raptor_uri
* uri2
);
1323 int raptor_uri_compare(raptor_uri
* uri1
, raptor_uri
* uri2
);
1325 raptor_uri
* raptor_uri_copy(raptor_uri
*uri
);
1327 unsigned char* raptor_uri_as_string(raptor_uri
*uri
);
1329 unsigned char* raptor_uri_as_counted_string(raptor_uri
*uri
, size_t* len_p
);
1331 unsigned char* raptor_uri_to_relative_counted_uri_string(raptor_uri
*base_uri
, raptor_uri
*reference_uri
, size_t *length_p
);
1333 unsigned char* raptor_uri_to_relative_uri_string(raptor_uri
*base_uri
, raptor_uri
*reference_uri
);
1335 int raptor_uri_print(const raptor_uri
* uri
, FILE *stream
);
1337 unsigned char* raptor_uri_to_counted_string(raptor_uri
*uri
, size_t *len_p
);
1339 unsigned char* raptor_uri_to_string(raptor_uri
*uri
);
1341 raptor_world
* raptor_uri_get_world(raptor_uri
*uri
);
1343 int raptor_uri_file_exists(raptor_uri
* uri
);
1345 int raptor_uri_escaped_write(raptor_uri
* uri
, raptor_uri
* base_uri
, unsigned int flags
, raptor_iostream
*iostr
);
1347 /* XML utility functions */
1349 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
);
1351 int raptor_xml_escape_string_any_write(const unsigned char *string
, size_t len
, char quote
, int xml_version
, raptor_iostream
* iostr
);
1353 int raptor_xml_escape_string(raptor_world
*world
, const unsigned char *string
, size_t len
, unsigned char *buffer
, size_t length
, char quote
);
1355 int raptor_xml_escape_string_write(const unsigned char *string
, size_t len
, char quote
, raptor_iostream
* iostr
);
1357 int raptor_xml_name_check(const unsigned char *string
, size_t length
, int xml_version
);
1360 /* portable vsnprintf utility function */
1361 RAPTOR_API RAPTOR_DEPRECATED
1362 char* raptor_vsnprintf(const char *format
, va_list arguments
) RAPTOR_PRINTF_FORMAT(1, 0);
1364 int raptor_vsnprintf2(char *buffer
, size_t size
, const char *format
, va_list arguments
) RAPTOR_PRINTF_FORMAT(3, 0);
1366 int raptor_snprintf(char *buffer
, size_t size
, const char *format
, ...) RAPTOR_PRINTF_FORMAT(3, 4);
1368 int raptor_vasprintf(char **ret
, const char *format
, va_list arguments
) RAPTOR_PRINTF_FORMAT(2, 0);
1370 /* RFC2396 URI resolving functions */
1372 size_t raptor_uri_resolve_uri_reference(const unsigned char *base_uri
, const unsigned char *reference_uri
, unsigned char* buffer
, size_t length
);
1374 /* URI String utility functions */
1376 unsigned char* raptor_uri_counted_filename_to_uri_string(const char *filename
, size_t filename_len
);
1378 unsigned char* raptor_uri_filename_to_uri_string(const char *filename
);
1380 int raptor_uri_filename_exists(const unsigned char* path
);
1382 char* raptor_uri_uri_string_to_filename(const unsigned char *uri_string
);
1384 char* raptor_uri_uri_string_to_filename_fragment(const unsigned char *uri_string
, unsigned char **fragment_p
);
1386 int raptor_uri_uri_string_is_file_uri(const unsigned char* uri_string
);
1388 int raptor_stringbuffer_append_uri_escaped_counted_string(raptor_stringbuffer
* sb
, const char* string
, size_t length
, int space_is_plus
);
1390 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
);
1392 int raptor_uri_uri_string_is_absolute(const unsigned char* uri_string
);
1396 * RAPTOR_RDF_MS_URI:
1398 * RDF Namespace URI (rdf:).
1400 * Copy with raptor_uri_copy() to use.
1402 #define RAPTOR_RDF_MS_URI raptor_rdf_namespace_uri
1405 * RAPTOR_RDF_SCHEMA_URI:
1407 * RDF Schema Namespace URI (rdfs:).
1409 * Copy with raptor_uri_copy() to use.
1411 #define RAPTOR_RDF_SCHEMA_URI raptor_rdf_schema_namespace_uri
1414 * RAPTOR_XMLSCHEMA_DATATYPES_URI:
1416 * XML Schema Datatypes URI (xsd:).
1418 * Copy with raptor_uri_copy() to use.
1420 #define RAPTOR_XMLSCHEMA_DATATYPES_URI raptor_xmlschema_datatypes_namespace_uri
1425 * OWL Namespace URI (owl:).
1427 * Copy with raptor_uri_copy() to use.
1429 #define RAPTOR_OWL_URI raptor_owl_namespace_uri
1434 raptor_www
* raptor_new_www(raptor_world
* world
);
1436 raptor_www
* raptor_new_www_with_connection(raptor_world
* world
, void* connection
);
1438 void raptor_free_www(raptor_www
*www
);
1440 int raptor_www_set_ssl_cert_options(raptor_www
* www
, const char* cert_filename
, const char* cert_type
, const char* cert_passphrase
);
1442 int raptor_www_set_ssl_verify_options(raptor_www
* www
, int verify_peer
, int verify_host
);
1444 int raptor_www_set_user_agent2(raptor_www
*www
, const char *user_agent
, size_t user_agent_len
);
1445 RAPTOR_API RAPTOR_DEPRECATED
1446 void raptor_www_set_user_agent(raptor_www
*www
, const char *user_agent
);
1448 int raptor_www_set_proxy2(raptor_www
*www
, const char *proxy
, size_t proxy_len
);
1449 RAPTOR_API RAPTOR_DEPRECATED
1450 void raptor_www_set_proxy(raptor_www
*www
, const char *proxy
);
1452 int raptor_www_set_http_accept2(raptor_www
*www
, const char *value
, size_t value_len
);
1453 RAPTOR_API RAPTOR_DEPRECATED
1454 void raptor_www_set_http_accept(raptor_www
*www
, const char *value
);
1456 void raptor_www_set_write_bytes_handler(raptor_www
*www
, raptor_www_write_bytes_handler handler
, void *user_data
);
1458 void raptor_www_set_content_type_handler(raptor_www
*www
, raptor_www_content_type_handler handler
, void *user_data
);
1460 void raptor_www_set_final_uri_handler(raptor_www
* www
, raptor_www_final_uri_handler handler
, void *user_data
);
1462 void raptor_www_set_uri_filter(raptor_www
* www
, raptor_uri_filter_func filter
, void* user_data
);
1464 void raptor_www_set_connection_timeout(raptor_www
* www
, int timeout
);
1466 int raptor_www_set_http_cache_control(raptor_www
* www
, const char* cache_control
);
1468 int raptor_www_fetch(raptor_www
*www
, raptor_uri
*uri
);
1470 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
);
1472 void* raptor_www_get_connection(raptor_www
*www
);
1474 void raptor_www_abort(raptor_www
*www
, const char *reason
);
1476 raptor_uri
* raptor_www_get_final_uri(raptor_www
* www
);
1479 /* XML QNames Class */
1481 raptor_qname
* raptor_new_qname(raptor_namespace_stack
*nstack
, const unsigned char *name
, const unsigned char *value
);
1483 raptor_qname
* raptor_new_qname_from_namespace_local_name(raptor_world
* world
, raptor_namespace
*ns
, const unsigned char *local_name
, const unsigned char *value
);
1487 raptor_qname
* raptor_qname_copy(raptor_qname
*qname
);
1489 void raptor_free_qname(raptor_qname
* name
);
1491 int raptor_qname_equal(raptor_qname
*name1
, raptor_qname
*name2
);
1493 unsigned char* raptor_qname_to_counted_name(raptor_qname
*qname
, size_t* length_p
);
1495 const raptor_namespace
* raptor_qname_get_namespace(raptor_qname
* name
);
1497 const unsigned char* raptor_qname_get_local_name(raptor_qname
* name
);
1499 const unsigned char* raptor_qname_get_value(raptor_qname
* name
);
1501 const unsigned char* raptor_qname_get_counted_value(raptor_qname
* name
, size_t* length_p
);
1503 int raptor_qname_write(raptor_qname
*qname
, raptor_iostream
* iostr
);
1505 /* QName String utility functions */
1507 raptor_uri
* raptor_qname_string_to_uri(raptor_namespace_stack
*nstack
, const unsigned char *name
, size_t name_len
);
1509 unsigned char* raptor_qname_format_as_xml(const raptor_qname
*qname
, size_t *length_p
);
1511 /* XML Namespaces Stack class */
1513 raptor_namespace
* raptor_new_namespace_from_uri(raptor_namespace_stack
*nstack
, const unsigned char *prefix
, raptor_uri
* ns_uri
, int depth
);
1515 raptor_namespace_stack
* raptor_new_namespaces(raptor_world
* world
, int defaults
);
1517 int raptor_namespaces_init(raptor_world
* world
, raptor_namespace_stack
*nstack
, int defaults
);
1519 void raptor_namespaces_clear(raptor_namespace_stack
*nstack
);
1521 void raptor_free_namespaces(raptor_namespace_stack
*nstack
);
1525 void raptor_namespaces_start_namespace(raptor_namespace_stack
*nstack
, raptor_namespace
*nspace
);
1527 int raptor_namespaces_start_namespace_full(raptor_namespace_stack
*nstack
, const unsigned char *prefix
, const unsigned char *ns_uri_string
, int depth
);
1529 void raptor_namespaces_end_for_depth(raptor_namespace_stack
*nstack
, int depth
);
1531 raptor_namespace
* raptor_namespaces_get_default_namespace(raptor_namespace_stack
*nstack
);
1533 raptor_namespace
* raptor_namespaces_find_namespace(raptor_namespace_stack
*nstack
, const unsigned char *prefix
, int prefix_length
);
1535 raptor_namespace
* raptor_namespaces_find_namespace_by_uri(raptor_namespace_stack
*nstack
, raptor_uri
*ns_uri
);
1537 int raptor_namespaces_namespace_in_scope(raptor_namespace_stack
*nstack
, const raptor_namespace
*nspace
);
1539 raptor_qname
* raptor_new_qname_from_namespace_uri(raptor_namespace_stack
*nstack
, raptor_uri
*uri
, int xml_version
);
1542 /* XML Namespace Class */
1544 raptor_namespace
* raptor_new_namespace(raptor_namespace_stack
*nstack
, const unsigned char *prefix
, const unsigned char *ns_uri_string
, int depth
);
1546 void raptor_free_namespace(raptor_namespace
*ns
);
1548 int raptor_namespace_stack_start_namespace(raptor_namespace_stack
*nstack
, raptor_namespace
*ns
, int new_depth
);
1550 raptor_uri
* raptor_namespace_get_uri(const raptor_namespace
*ns
);
1552 const unsigned char* raptor_namespace_get_prefix(const raptor_namespace
*ns
);
1554 const unsigned char* raptor_namespace_get_counted_prefix(const raptor_namespace
*ns
, size_t *length_p
);
1556 unsigned char* raptor_namespace_format_as_xml(const raptor_namespace
*ns
, size_t *length_p
);
1558 int raptor_namespace_write(raptor_namespace
*ns
, raptor_iostream
* iostr
);
1560 /* namespace string utility function */
1562 int raptor_xml_namespace_string_parse(const unsigned char *string
, unsigned char **prefix
, unsigned char **uri_string
);
1564 /* Sequence class */
1568 * Raptor sequence class
1570 typedef struct raptor_sequence_s raptor_sequence
;
1572 /* Sequence Class */
1574 raptor_sequence
* raptor_new_sequence(raptor_data_free_handler free_handler
, raptor_data_print_handler print_handler
);
1576 raptor_sequence
* raptor_new_sequence_with_context(raptor_data_context_free_handler free_handler
, raptor_data_context_print_handler print_handler
, void* handler_context
);
1578 void raptor_free_sequence(raptor_sequence
* seq
);
1582 int raptor_sequence_size(raptor_sequence
* seq
);
1584 int raptor_sequence_set_at(raptor_sequence
* seq
, int idx
, void *data
);
1586 int raptor_sequence_push(raptor_sequence
* seq
, void *data
);
1588 int raptor_sequence_shift(raptor_sequence
* seq
, void *data
);
1590 void* raptor_sequence_get_at(raptor_sequence
* seq
, int idx
);
1592 void* raptor_sequence_pop(raptor_sequence
* seq
);
1594 void* raptor_sequence_unshift(raptor_sequence
* seq
);
1596 void* raptor_sequence_delete_at(raptor_sequence
* seq
, int idx
);
1599 void raptor_sequence_sort(raptor_sequence
* seq
, raptor_data_compare_handler compare
);
1601 void raptor_sequence_sort_r(raptor_sequence
* seq
, raptor_data_compare_arg_handler compare
, void* user_data
);
1603 int raptor_sequence_swap(raptor_sequence
* seq
, int i
, int j
);
1605 int raptor_sequence_reverse(raptor_sequence
* seq
, int start_index
, int length
);
1607 int raptor_sequence_next_permutation(raptor_sequence
*seq
, raptor_data_compare_handler compare
);
1609 /* helper for printing sequences of strings */
1611 int raptor_sequence_print(raptor_sequence
* seq
, FILE* fh
);
1613 int raptor_sequence_join(raptor_sequence
* dest
, raptor_sequence
*src
);
1616 /* Unicode and UTF8 */
1621 * raptor Unicode codepoint
1623 typedef unsigned long raptor_unichar
;
1625 int raptor_unicode_utf8_string_put_char(raptor_unichar c
, unsigned char *output
, size_t length
);
1627 int raptor_unicode_utf8_string_get_char(const unsigned char *input
, size_t length
, raptor_unichar
*output
);
1629 int raptor_unicode_is_xml11_namestartchar(raptor_unichar c
);
1631 int raptor_unicode_is_xml10_namestartchar(raptor_unichar c
);
1633 int raptor_unicode_is_xml11_namechar(raptor_unichar c
);
1635 int raptor_unicode_is_xml10_namechar(raptor_unichar c
);
1637 int raptor_unicode_check_utf8_string(const unsigned char *string
, size_t length
);
1639 int raptor_unicode_utf8_strlen(const unsigned char *string
, size_t length
);
1641 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
);
1643 /* Stringbuffer Class */
1645 raptor_stringbuffer
* raptor_new_stringbuffer(void);
1647 void raptor_free_stringbuffer(raptor_stringbuffer
*stringbuffer
);
1651 int raptor_stringbuffer_append_counted_string(raptor_stringbuffer
* stringbuffer
, const unsigned char *string
, size_t length
, int do_copy
);
1653 int raptor_stringbuffer_append_string(raptor_stringbuffer
* stringbuffer
, const unsigned char *string
, int do_copy
);
1655 int raptor_stringbuffer_append_decimal(raptor_stringbuffer
* stringbuffer
, int integer
);
1657 int raptor_stringbuffer_append_hexadecimal(raptor_stringbuffer
* stringbuffer
, int hex
);
1659 int raptor_stringbuffer_append_stringbuffer(raptor_stringbuffer
* stringbuffer
, raptor_stringbuffer
* append
);
1661 int raptor_stringbuffer_prepend_counted_string(raptor_stringbuffer
* stringbuffer
, const unsigned char *string
, size_t length
, int do_copy
);
1663 int raptor_stringbuffer_prepend_string(raptor_stringbuffer
* stringbuffer
, const unsigned char *string
, int do_copy
);
1665 unsigned char* raptor_stringbuffer_as_string(raptor_stringbuffer
* stringbuffer
);
1667 size_t raptor_stringbuffer_length(raptor_stringbuffer
* stringbuffer
);
1669 int raptor_stringbuffer_copy_to_string(raptor_stringbuffer
* stringbuffer
, unsigned char *string
, size_t length
);
1672 * raptor_iostream_init_func:
1673 * @context: stream context data
1675 * Handler function for #raptor_iostream initialising.
1677 * Return value: non-0 on failure.
1679 typedef int (*raptor_iostream_init_func
) (void *context
);
1682 * raptor_iostream_finish_func:
1683 * @context: stream context data
1685 * Handler function for #raptor_iostream terminating.
1688 typedef void (*raptor_iostream_finish_func
) (void *context
);
1691 * raptor_iostream_write_byte_func
1692 * @context: stream context data
1693 * @byte: byte to write
1695 * Handler function for implementing raptor_iostream_write_byte().
1697 * Return value: non-0 on failure.
1699 typedef int (*raptor_iostream_write_byte_func
) (void *context
, const int byte
);
1702 * raptor_iostream_write_bytes_func:
1703 * @context: stream context data
1704 * @ptr: pointer to bytes to write
1705 * @size: size of item
1706 * @nmemb: number of items
1708 * Handler function for implementing raptor_iostream_write_bytes().
1710 * Return value: non-0 on failure.
1712 typedef int (*raptor_iostream_write_bytes_func
) (void *context
, const void *ptr
, size_t size
, size_t nmemb
);
1715 * raptor_iostream_write_end_func:
1716 * @context: stream context data
1718 * Handler function for implementing raptor_iostream_write_end().
1720 * Return value: non-0 on failure.
1722 typedef int (*raptor_iostream_write_end_func
) (void *context
);
1725 * raptor_iostream_read_bytes_func:
1726 * @context: stream context data
1727 * @ptr: pointer to buffer to read into
1728 * @size: size of buffer
1729 * @nmemb: number of items
1731 * Handler function for implementing raptor_iostream_read_bytes().
1733 * Return value: number of items read, 0 or < @size on EOF, <0 on failure
1735 typedef int (*raptor_iostream_read_bytes_func
) (void *context
, void *ptr
, size_t size
, size_t nmemb
);
1738 * raptor_iostream_read_eof_func:
1739 * @context: stream context data
1741 * Handler function for implementing raptor_iostream_read_eof().
1743 * Return value: non-0 if EOF
1745 typedef int (*raptor_iostream_read_eof_func
) (void *context
);
1748 * raptor_iostream_handler:
1749 * @version: interface version. Presently 1 or 2.
1750 * @init: initialisation handler - optional, called at most once (V1)
1751 * @finish: finishing handler - optional, called at most once (V1)
1752 * @write_byte: write byte handler - required (for writing) (V1)
1753 * @write_bytes: write bytes handler - required (for writing) (V1)
1754 * @write_end: write end handler - optional (for writing), called at most once (V1)
1755 * @read_bytes: read bytes handler - required (for reading) (V2)
1756 * @read_eof: read EOF handler - required (for reading) (V2)
1758 * I/O stream implementation handler structure.
1765 raptor_iostream_init_func init
;
1766 raptor_iostream_finish_func finish
;
1767 raptor_iostream_write_byte_func write_byte
;
1768 raptor_iostream_write_bytes_func write_bytes
;
1769 raptor_iostream_write_end_func write_end
;
1772 raptor_iostream_read_bytes_func read_bytes
;
1773 raptor_iostream_read_eof_func read_eof
;
1774 } raptor_iostream_handler
;
1777 /* I/O Stream Class */
1779 raptor_iostream
* raptor_new_iostream_from_handler(raptor_world
* world
, void *user_data
, const raptor_iostream_handler
* const handler
);
1781 raptor_iostream
* raptor_new_iostream_to_sink(raptor_world
* world
);
1783 raptor_iostream
* raptor_new_iostream_to_filename(raptor_world
* world
, const char *filename
);
1785 raptor_iostream
* raptor_new_iostream_to_file_handle(raptor_world
* world
, FILE *handle
);
1787 raptor_iostream
* raptor_new_iostream_to_string(raptor_world
* world
, void **string_p
, size_t *length_p
, raptor_data_malloc_handler
const malloc_handler
);
1789 raptor_iostream
* raptor_new_iostream_from_sink(raptor_world
* world
);
1791 raptor_iostream
* raptor_new_iostream_from_filename(raptor_world
* world
, const char *filename
);
1793 raptor_iostream
* raptor_new_iostream_from_file_handle(raptor_world
* world
, FILE *handle
);
1795 raptor_iostream
* raptor_new_iostream_from_string(raptor_world
* world
, void *string
, size_t length
);
1797 void raptor_free_iostream(raptor_iostream
*iostr
);
1800 int raptor_iostream_write_bytes(const void *ptr
, size_t size
, size_t nmemb
, raptor_iostream
*iostr
);
1802 int raptor_iostream_write_byte(const int byte
, raptor_iostream
*iostr
);
1804 int raptor_iostream_write_end(raptor_iostream
*iostr
);
1806 int raptor_iostream_string_write(const void *string
, raptor_iostream
*iostr
);
1808 int raptor_iostream_counted_string_write(const void *string
, size_t len
, raptor_iostream
*iostr
);
1810 unsigned long raptor_iostream_tell(raptor_iostream
*iostr
);
1812 int raptor_iostream_decimal_write(int integer
, raptor_iostream
* iostr
);
1814 int raptor_iostream_hexadecimal_write(unsigned int integer
, int width
, raptor_iostream
* iostr
);
1816 int raptor_stringbuffer_write(raptor_stringbuffer
*sb
, raptor_iostream
* iostr
);
1818 int raptor_uri_write(raptor_uri
*uri
, raptor_iostream
*iostr
);
1820 int raptor_iostream_read_bytes(void *ptr
, size_t size
, size_t nmemb
, raptor_iostream
* iostr
);
1822 int raptor_iostream_read_eof(raptor_iostream
*iostr
);
1824 /* I/O Stream utility functions */
1827 * raptor_escaped_write_bitflags:
1828 * @RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF : Allow \b \f,
1829 * @RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU : Allow \t \n \r \u \U
1830 * @RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8 : Use UTF-8 instead of \u \U for U+0080 or larger (will always use \u for U+0000..U+001F and U+007F)
1831 * @RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES: Must escape #x00-#x20<>\"{}|^` in URIs
1832 * @RAPTOR_ESCAPED_WRITE_NTRIPLES_LITERAL: N-Triples literal
1833 * @RAPTOR_ESCAPED_WRITE_NTRIPLES_URI: N-Triples URI
1834 * @RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL: SPARQL literal: allows raw UTF8 for printable literals
1835 * @RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL: SPARQL long literal: no BS-escapes allowed
1836 * @RAPTOR_ESCAPED_WRITE_SPARQL_URI: SPARQL uri: have to escape certain characters
1837 * @RAPTOR_ESCAPED_WRITE_TURTLE_URI: Turtle 2013 URIs (like SPARQL)
1838 * @RAPTOR_ESCAPED_WRITE_TURTLE_LITERAL: Turtle 2013 literals (like SPARQL)
1839 * @RAPTOR_ESCAPED_WRITE_TURTLE_LONG_LITERAL: Turtle 2013 long literals (like SPARQL)
1840 * @RAPTOR_ESCAPED_WRITE_JSON_LITERAL: JSON literals: UTF-8 plus \b \f \t \r \n, \uXXXX only, no \U
1842 * Bit flags for raptor_string_escaped_write() and friends.
1845 RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF
= 1,
1846 RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU
= 2,
1847 RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8
= 4,
1848 RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES
= 8,
1850 /* N-Triples - favour writing \u, \U over UTF8 */
1851 RAPTOR_ESCAPED_WRITE_NTRIPLES_LITERAL
= RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU
| RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF
,
1852 RAPTOR_ESCAPED_WRITE_NTRIPLES_URI
= RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES
,
1854 /* SPARQL literal: allows raw UTF8 for printable literals */
1855 RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL
= RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8
,
1857 /* SPARQL long literal: no BS-escapes allowed */
1858 RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL
= RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8
,
1860 /* SPARQL uri: have to escape certain characters */
1861 RAPTOR_ESCAPED_WRITE_SPARQL_URI
= RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8
| RAPTOR_ESCAPED_WRITE_BITFLAG_SPARQL_URI_ESCAPES
,
1863 /* Turtle (2013) escapes are like SPARQL */
1864 RAPTOR_ESCAPED_WRITE_TURTLE_URI
= RAPTOR_ESCAPED_WRITE_SPARQL_URI
,
1865 RAPTOR_ESCAPED_WRITE_TURTLE_LITERAL
= RAPTOR_ESCAPED_WRITE_SPARQL_LITERAL
,
1866 RAPTOR_ESCAPED_WRITE_TURTLE_LONG_LITERAL
= RAPTOR_ESCAPED_WRITE_SPARQL_LONG_LITERAL
,
1868 /* JSON literals: UTF-8 plus \b \f \t \r \n \uXXXX */
1869 RAPTOR_ESCAPED_WRITE_JSON_LITERAL
= RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_TNRU
| RAPTOR_ESCAPED_WRITE_BITFLAG_BS_ESCAPES_BF
| RAPTOR_ESCAPED_WRITE_BITFLAG_UTF8
1870 } raptor_escaped_write_bitflags
;
1874 int raptor_string_ntriples_write(const unsigned char *string
, size_t len
, const char delim
, raptor_iostream
*iostr
);
1876 int raptor_bnodeid_ntriples_write(const unsigned char *bnodeid
, size_t len
, raptor_iostream
*iostr
);
1877 RAPTOR_API RAPTOR_DEPRECATED
1878 int raptor_string_python_write(const unsigned char *string
, size_t len
, const char delim
, unsigned int mode
, raptor_iostream
*iostr
);
1880 int raptor_statement_ntriples_write(const raptor_statement
*statement
, raptor_iostream
* iostr
, int write_graph_term
);
1882 int raptor_string_escaped_write(const unsigned char *string
, size_t len
, const char delim
, unsigned int flags
, raptor_iostream
*iostr
);
1885 /* Parser and Serializer options */
1888 * raptor_option_value_type:
1889 * @RAPTOR_OPTION_VALUE_TYPE_BOOL: Boolean integer value. Non-0 is true
1890 * @RAPTOR_OPTION_VALUE_TYPE_INT: Decimal integer value
1891 * @RAPTOR_OPTION_VALUE_TYPE_STRING: String value
1892 * @RAPTOR_OPTION_VALUE_TYPE_URI: URI String value.
1893 * @RAPTOR_OPTION_VALUE_TYPE_LAST: internal
1895 * Option value types.
1898 RAPTOR_OPTION_VALUE_TYPE_BOOL
,
1899 RAPTOR_OPTION_VALUE_TYPE_INT
,
1900 RAPTOR_OPTION_VALUE_TYPE_STRING
,
1901 RAPTOR_OPTION_VALUE_TYPE_URI
,
1902 RAPTOR_OPTION_VALUE_TYPE_LAST
= RAPTOR_OPTION_VALUE_TYPE_URI
1903 } raptor_option_value_type
;
1907 * raptor_option_description:
1908 * @domain: domain ID
1909 * @option: option ID
1910 * @value_type: data type of option value
1911 * @name: short name for option
1912 * @name_len: length of @name
1913 * @label: description of option
1914 * @uri: URI identifying option
1916 * Description of an option for a domain.
1919 raptor_domain domain
;
1920 raptor_option option
;
1921 raptor_option_value_type value_type
;
1926 } raptor_option_description
;
1930 unsigned int raptor_option_get_count(void);
1932 const char* raptor_option_get_value_type_label(const raptor_option_value_type type
);
1934 void raptor_free_option_description(raptor_option_description
* option_description
);
1936 raptor_option_description
* raptor_world_get_option_description(raptor_world
* world
, const raptor_domain domain
, const raptor_option option
);
1939 /* SAX2 element Class (raptor_xml_element) */
1941 raptor_xml_element
* raptor_new_xml_element(raptor_qname
* name
, const unsigned char* xml_language
, raptor_uri
* xml_base
);
1943 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
);
1945 void raptor_free_xml_element(raptor_xml_element
*element
);
1949 raptor_qname
* raptor_xml_element_get_name(raptor_xml_element
*xml_element
);
1951 void raptor_xml_element_set_attributes(raptor_xml_element
* xml_element
, raptor_qname
**attributes
, int count
);
1953 raptor_qname
** raptor_xml_element_get_attributes(raptor_xml_element
* xml_element
);
1955 int raptor_xml_element_get_attributes_count(raptor_xml_element
* xml_element
);
1957 int raptor_xml_element_declare_namespace(raptor_xml_element
* xml_element
, raptor_namespace
*nspace
);
1959 int raptor_xml_element_write(raptor_xml_element
*element
, raptor_namespace_stack
*nstack
, int is_empty
, int is_end
, int depth
, raptor_iostream
*iostr
);
1961 int raptor_xml_element_is_empty(raptor_xml_element
* xml_element
);
1963 const unsigned char* raptor_xml_element_get_language(raptor_xml_element
* xml_element
);
1966 /* XML Writer Class (raptor_xml_writer) */
1968 raptor_xml_writer
* raptor_new_xml_writer(raptor_world
* world
, raptor_namespace_stack
*nstack
, raptor_iostream
* iostr
);
1970 void raptor_free_xml_writer(raptor_xml_writer
* xml_writer
);
1974 void raptor_xml_writer_empty_element(raptor_xml_writer
* xml_writer
, raptor_xml_element
*element
);
1976 void raptor_xml_writer_start_element(raptor_xml_writer
* xml_writer
, raptor_xml_element
*element
);
1978 void raptor_xml_writer_end_element(raptor_xml_writer
* xml_writer
, raptor_xml_element
*element
);
1980 void raptor_xml_writer_newline(raptor_xml_writer
* xml_writer
);
1982 void raptor_xml_writer_cdata(raptor_xml_writer
* xml_writer
, const unsigned char *s
);
1984 void raptor_xml_writer_cdata_counted(raptor_xml_writer
* xml_writer
, const unsigned char *s
, unsigned int len
);
1986 void raptor_xml_writer_raw(raptor_xml_writer
* xml_writer
, const unsigned char *s
);
1988 void raptor_xml_writer_raw_counted(raptor_xml_writer
* xml_writer
, const unsigned char *s
, unsigned int len
);
1990 void raptor_xml_writer_comment(raptor_xml_writer
* xml_writer
, const unsigned char *s
);
1992 void raptor_xml_writer_comment_counted(raptor_xml_writer
* xml_writer
, const unsigned char *s
, unsigned int len
);
1994 void raptor_xml_writer_flush(raptor_xml_writer
* xml_writer
);
1996 int raptor_xml_writer_set_option(raptor_xml_writer
*xml_writer
, raptor_option option
, char* string
, int integer
);
1998 int raptor_xml_writer_get_option(raptor_xml_writer
*xml_writer
, raptor_option option
, char** string_p
, int* integer_p
);
2000 int raptor_xml_writer_get_depth(raptor_xml_writer
*xml_writer
);
2003 * raptor_sax2_start_element_handler:
2004 * @user_data: user data
2005 * @xml_element: XML element
2007 * SAX2 start element handler
2009 typedef void (*raptor_sax2_start_element_handler
)(void *user_data
, raptor_xml_element
*xml_element
);
2012 * raptor_sax2_end_element_handler:
2013 * @user_data: user data
2014 * @xml_element: XML element
2016 * SAX2 end element handler
2018 typedef void (*raptor_sax2_end_element_handler
)(void *user_data
, raptor_xml_element
* xml_element
);
2021 * raptor_sax2_characters_handler:
2022 * @user_data: user data
2023 * @xml_element: XML element
2027 * SAX2 characters handler
2029 typedef void (*raptor_sax2_characters_handler
)(void *user_data
, raptor_xml_element
* xml_element
, const unsigned char *s
, int len
);
2032 * raptor_sax2_cdata_handler:
2033 * @user_data: user data
2034 * @xml_element: XML element
2038 * SAX2 CDATA section handler
2040 typedef void (*raptor_sax2_cdata_handler
)(void *user_data
, raptor_xml_element
* xml_element
, const unsigned char *s
, int len
);
2043 * raptor_sax2_comment_handler:
2044 * @user_data: user data
2045 * @xml_element: XML element
2048 * SAX2 XML comment handler
2050 typedef void (*raptor_sax2_comment_handler
)(void *user_data
, raptor_xml_element
* xml_element
, const unsigned char *s
);
2053 * raptor_sax2_unparsed_entity_decl_handler:
2054 * @user_data: user data
2055 * @entityName: entity name
2057 * @systemId: system ID
2058 * @publicId: public ID
2059 * @notationName: notation name
2061 * SAX2 unparsed entity (NDATA) handler
2063 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
);
2066 * raptor_sax2_external_entity_ref_handler:
2067 * @user_data: user data
2070 * @systemId: system ID
2071 * @publicId: public ID
2073 * SAX2 external entity reference handler
2075 * Return value: 0 if processing should not continue because of a
2076 * fatal error in the handling of the external entity.
2078 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
);
2083 raptor_sax2
* raptor_new_sax2(raptor_world
*world
, raptor_locator
*locator
, void* user_data
);
2085 void raptor_free_sax2(raptor_sax2
*sax2
);
2089 void raptor_sax2_set_start_element_handler(raptor_sax2
* sax2
, raptor_sax2_start_element_handler handler
);
2091 void raptor_sax2_set_end_element_handler(raptor_sax2
* sax2
, raptor_sax2_end_element_handler handler
);
2093 void raptor_sax2_set_characters_handler(raptor_sax2
* sax2
, raptor_sax2_characters_handler handler
);
2095 void raptor_sax2_set_cdata_handler(raptor_sax2
* sax2
, raptor_sax2_cdata_handler handler
);
2097 void raptor_sax2_set_comment_handler(raptor_sax2
* sax2
, raptor_sax2_comment_handler handler
);
2099 void raptor_sax2_set_unparsed_entity_decl_handler(raptor_sax2
* sax2
, raptor_sax2_unparsed_entity_decl_handler handler
);
2101 void raptor_sax2_set_external_entity_ref_handler(raptor_sax2
* sax2
, raptor_sax2_external_entity_ref_handler handler
);
2103 void raptor_sax2_set_namespace_handler(raptor_sax2
* sax2
, raptor_namespace_handler handler
);
2105 void raptor_sax2_set_uri_filter(raptor_sax2
* sax2
, raptor_uri_filter_func filter
, void *user_data
);
2107 void raptor_sax2_parse_start(raptor_sax2
*sax2
, raptor_uri
*base_uri
);
2109 int raptor_sax2_parse_chunk(raptor_sax2
* sax2
, const unsigned char *buffer
, size_t len
, int is_end
);
2111 const unsigned char* raptor_sax2_inscope_xml_language(raptor_sax2
* sax2
);
2113 raptor_uri
* raptor_sax2_inscope_base_uri(raptor_sax2
* sax2
);
2124 typedef struct raptor_avltree_s raptor_avltree
;
2127 * raptor_avltree_iterator:
2129 * AVL Tree Iterator as created by raptor_new_avltree_iterator()
2131 typedef struct raptor_avltree_iterator_s raptor_avltree_iterator
;
2134 * raptor_avltree_visit_handler:
2135 * @depth: depth of object in tree
2136 * @data: data object being visited
2137 * @user_data: user data arg to raptor_avltree_visit()
2139 * AVL Tree visitor function as given to raptor_avltree_visit()
2141 * Return value: non-0 to terminate visit early.
2143 typedef int (*raptor_avltree_visit_handler
)(int depth
, void* data
, void *user_data
);
2147 * raptor_avltree_bitflags:
2148 * @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)
2150 * Bit flags for AVL Tree class constructor raptor_new_avltree()
2153 RAPTOR_AVLTREE_FLAG_REPLACE_DUPLICATES
= 1
2154 } raptor_avltree_bitflags
;
2158 raptor_avltree
* raptor_new_avltree(raptor_data_compare_handler compare_handler
, raptor_data_free_handler free_handler
, unsigned int flags
);
2160 void raptor_free_avltree(raptor_avltree
* tree
);
2164 int raptor_avltree_add(raptor_avltree
* tree
, void* p_data
);
2166 void* raptor_avltree_remove(raptor_avltree
* tree
, void* p_data
);
2168 int raptor_avltree_delete(raptor_avltree
* tree
, void* p_data
);
2170 void raptor_avltree_trim(raptor_avltree
* tree
);
2172 void* raptor_avltree_search(raptor_avltree
* tree
, const void* p_data
);
2174 int raptor_avltree_visit(raptor_avltree
* tree
, raptor_avltree_visit_handler visit_handler
, void* user_data
);
2176 int raptor_avltree_size(raptor_avltree
* tree
);
2178 void raptor_avltree_set_print_handler(raptor_avltree
* tree
, raptor_data_print_handler print_handler
);
2180 int raptor_avltree_print(raptor_avltree
* tree
, FILE* stream
);
2183 raptor_avltree_iterator
* raptor_new_avltree_iterator(raptor_avltree
* tree
, void* range
, raptor_data_free_handler range_free_handler
, int direction
);
2185 void raptor_free_avltree_iterator(raptor_avltree_iterator
* iterator
);
2188 int raptor_avltree_iterator_is_end(raptor_avltree_iterator
* iterator
);
2190 int raptor_avltree_iterator_next(raptor_avltree_iterator
* iterator
);
2192 void* raptor_avltree_iterator_get(raptor_avltree_iterator
* iterator
);
2194 /* utility methods */
2196 void raptor_sort_r(void *base
, size_t nel
, size_t width
, raptor_data_compare_arg_handler compar
, void *user_data
);