Magellan Linux

Contents of /trunk/soprano/patches/soprano-2.6.51-git20110720.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1428 - (show annotations) (download)
Wed Jul 20 20:28:37 2011 UTC (12 years, 10 months ago) by niro
File size: 54492 byte(s)
added git patch
1 diff -Naur soprano/backends/redland/redlandqueryresult.cpp soprano-2.6.51/backends/redland/redlandqueryresult.cpp
2 --- soprano/backends/redland/redlandqueryresult.cpp 2011-07-19 18:49:58.000000000 +0200
3 +++ soprano-2.6.51/backends/redland/redlandqueryresult.cpp 2011-06-05 10:38:25.000000000 +0200
4 @@ -77,10 +77,9 @@
5 d->model = model;
6
7 const char** names = 0;
8 - int number = librdf_query_results_get_bindings_count(d->result);
9 if ( !librdf_query_results_get_bindings( d->result, &names, 0 ) ) {
10 - for ( int i = 0; i < number; i++ ) {
11 - d->names.append( QString::fromUtf8( names[i] ) );
12 + for ( ; *names; names++ ) {
13 + d->names.append( QString::fromUtf8( *names ) );
14 }
15 }
16 }
17 diff -Naur soprano/ChangeLog soprano-2.6.51/ChangeLog
18 --- soprano/ChangeLog 2011-07-19 18:49:58.000000000 +0200
19 +++ soprano-2.6.51/ChangeLog 2011-06-05 10:38:25.000000000 +0200
20 @@ -2,8 +2,6 @@
21 * Use the new Virtuoso parameter XAnyNormalization to use normalized accents for full-text searching by default.
22 * Updated NAO Vocabulary namespace to include changes from SDO 0.7.
23 * Added method LiteralValue::fromVariant which provides some useful type conversions.
24 - * Fixed incorrect binding names counting in redland queries
25 - * Ported Raptor serializer and parser plugins to Raptor2.
26
27 2.6.1
28 * Let onto2vocabularyclass convert dots in entity names to underscores to create valid C++ names.
29 diff -Naur soprano/cmake/modules/FindRaptor.cmake soprano-2.6.51/cmake/modules/FindRaptor.cmake
30 --- soprano/cmake/modules/FindRaptor.cmake 2011-07-19 18:49:58.000000000 +0200
31 +++ soprano-2.6.51/cmake/modules/FindRaptor.cmake 2011-06-05 10:38:25.000000000 +0200
32 @@ -5,13 +5,9 @@
33 # RAPTOR_LIBRARIES - Link these to use Raptor
34 # RAPTOR_INCLUDE_DIR - Include directory for using Raptor
35 # RAPTOR_DEFINITIONS - Compiler switches required for using Raptor
36 -#
37 -# Capabilities
38 -# RAPTOR_HAVE_TRIG - Set if raptor has TRIG
39 +# RAPTOR_VERSION - The Raptor version string
40
41 -# (c) 2007-2011 Sebastian Trueg <trueg@kde.org>
42 -# (c) 2011 Artem Serebriyskiy <v.for.vandal@gmail.com>
43 -# (c) 2011 Michael Jansen <kde@michael-jansen.biz>
44 +# (c) 2007-2009 Sebastian Trueg <trueg@kde.org>
45 #
46 # Based on FindFontconfig Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
47 #
48 @@ -19,83 +15,89 @@
49 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
50
51
52 -MACRO ( FIND_RAPTOR libname libhints includehints )
53 - find_library_with_debug(
54 - RAPTOR_LIBRARIES
55 - WIN32_DEBUG_POSTFIX d
56 - NAMES ${libname}
57 - HINTS ${libhints})
58 - find_path(
59 - RAPTOR_INCLUDE_DIR raptor.h
60 - HINTS ${includehints}
61 - PATH_SUFFIXES ${libname})
62 -ENDMACRO ()
63 -
64 -
65 -
66 -# Check if we have cached results in case the last round was successful.
67 -if ( NOT( RAPTOR_INCLUDE_DIR AND RAPTOR_LIBRARIES ) OR NOT RAPTOR_FOUND )
68 -
69 - include(FindLibraryWithDebug)
70 - include(MacroEnsureVersion)
71 - find_package(PkgConfig)
72 -
73 - # Vy default look for version 2.0
74 - if (NOT Raptor_FIND_VERSION )
75 - set( Raptor_FIND_VERSION "2.0")
76 - set( Raptor_FIND_VERSION_MAJOR "2" )
77 - set( Raptor_FIND_VERSION_MINOR "0" )
78 - endif ()
79 -
80 - if ( Raptor_FIND_VERSION_MAJOR EQUAL "2" )
81 -
82 - if ( NOT WIN32 )
83 - pkg_check_modules(PC_RAPTOR2 QUIET raptor2)
84 - if ( PC_RAPTOR2_FOUND )
85 - set(RAPTOR_DEFINITIONS ${PC_RAPTOR2_CFLAGS_OTHER})
86 - set(RAPTOR_VERSION ${PC_RAPTOR2_VERSION} CACHE STRING "Raptor Version found" )
87 - endif ()
88 - endif ()
89 - find_raptor( raptor2 "${PC_RAPTOR2_LIBDIR};${PC_RAPTOR2_LIBRARY_DIRS}" "${PC_RAPTOR2_INCLUDEDIR};${PC_RAPTOR2_INCLUDE_DIRS}")
90 -
91 - elseif ( Raptor_FIND_VERSION_MAJOR EQUAL "1" )
92 -
93 - if ( NOT WIN32 )
94 - pkg_check_modules(PC_RAPTOR QUIET raptor)
95 - if ( PC_RAPTOR_FOUND )
96 - set(RAPTOR_DEFINITIONS ${PC_RAPTOR_CFLAGS_OTHER})
97 - set(RAPTOR_VERSION ${PC_RAPTOR_VERSION} CACHE STRING "Raptor Version found" )
98 - endif ()
99 - endif ()
100 - find_raptor( raptor "${PC_RAPTOR_LIBDIR};${PC_RAPTOR_LIBRARY_DIRS}" "${PC_RAPTOR_INCLUDEDIR};${PC_RAPTOR_INCLUDE_DIRS}")
101 -
102 - else ()
103 -
104 - message( FATAL_ERROR "No idea how to check for version : ${Raptor_FIND_VERSION}")
105 -
106 - endif()
107 -
108 - if (RAPTOR_VERSION)
109 - MACRO_ENSURE_VERSION("1.4.16" ${RAPTOR_VERSION} RAPTOR_HAVE_TRIG)
110 - endif (RAPTOR_VERSION)
111 -
112 - mark_as_advanced(RAPTOR_INCLUDE_DIR RAPTOR_LIBRARIES)
113 -
114 -endif () # Check for cached values
115 -
116 -include(FindPackageHandleStandardArgs)
117 -
118 -find_package_handle_standard_args(
119 - Raptor
120 - VERSION_VAR RAPTOR_VERSION
121 - REQUIRED_VARS RAPTOR_LIBRARIES RAPTOR_INCLUDE_DIR)
122 -
123 -mark_as_advanced(RAPTOR_VERSION)
124 -
125 -if (NOT RAPTOR_FOUND AND Raptor_FIND_VERSION_MAJOR EQUAL "2" AND NOT Raptor_FIND_QUIET )
126 - pkg_check_modules(PC_RAPTOR QUIET raptor)
127 - if (PC_RAPTOR_FOUND)
128 - message( STATUS "You have raptor1 version ${PC_RAPTOR_VERSION} installed. Please update." )
129 - endif ()
130 -endif ()
131 +INCLUDE(MacroEnsureVersion)
132 +
133
134 +if(WINCE)
135 +FIND_PROGRAM(
136 + RAPTOR_CONFIG
137 + NAMES raptor-config
138 + PATHS ${HOST_BINDIR} NO_DEFAULT_PATH
139 + )
140 +else(WINCE)
141 +FIND_PROGRAM(
142 + RAPTOR_CONFIG
143 + NAMES raptor-config
144 + )
145 +endif(WINCE)
146 +
147 +if(RAPTOR_CONFIG)
148 + EXECUTE_PROCESS(
149 + COMMAND ${RAPTOR_CONFIG} --version
150 + OUTPUT_VARIABLE RAPTOR_VERSION
151 + )
152 + if(RAPTOR_VERSION)
153 + STRING(REPLACE "\n" "" RAPTOR_VERSION ${RAPTOR_VERSION})
154 +
155 + MACRO_ENSURE_VERSION("1.4.16" ${RAPTOR_VERSION} RAPTOR_HAVE_TRIG)
156 +
157 + # extract include paths from raptor-config
158 + EXECUTE_PROCESS(
159 + COMMAND ${RAPTOR_CONFIG} --cflags
160 + OUTPUT_VARIABLE raptor_CFLAGS_ARGS)
161 + STRING( REPLACE " " ";" raptor_CFLAGS_ARGS ${raptor_CFLAGS_ARGS} )
162 + FOREACH( _ARG ${raptor_CFLAGS_ARGS} )
163 + IF(${_ARG} MATCHES "^-I")
164 + STRING(REGEX REPLACE "^-I" "" _ARG ${_ARG})
165 + STRING( REPLACE "\n" "" _ARG ${_ARG} )
166 + LIST(APPEND raptor_INCLUDE_DIRS ${_ARG})
167 + ENDIF(${_ARG} MATCHES "^-I")
168 + ENDFOREACH(_ARG)
169 +
170 + # extract lib paths from raptor-config
171 + EXECUTE_PROCESS(
172 + COMMAND ${RAPTOR_CONFIG} --libs
173 + OUTPUT_VARIABLE raptor_CFLAGS_ARGS)
174 + STRING( REPLACE " " ";" raptor_CFLAGS_ARGS ${raptor_CFLAGS_ARGS} )
175 + FOREACH( _ARG ${raptor_CFLAGS_ARGS} )
176 + IF(${_ARG} MATCHES "^-L")
177 + STRING(REGEX REPLACE "^-L" "" _ARG ${_ARG})
178 + LIST(APPEND raptor_LIBRARY_DIRS ${_ARG})
179 + ENDIF(${_ARG} MATCHES "^-L")
180 + ENDFOREACH(_ARG)
181 + endif(RAPTOR_VERSION)
182 +else(RAPTOR_CONFIG)
183 + SET(RAPTOR_VERSION "1.0.0")
184 +endif(RAPTOR_CONFIG)
185 +
186 +find_path(RAPTOR_INCLUDE_DIR raptor.h
187 + PATHS
188 + ${redland_INCLUDE_DIRS}
189 + ${raptor_INCLUDE_DIRS}
190 + /usr/X11/include
191 + PATH_SUFFIXES redland
192 + )
193 +
194 +find_library(RAPTOR_LIBRARIES NAMES raptor libraptor
195 + PATHS
196 + ${raptor_LIBRARY_DIRS}
197 + )
198 +
199 +if (RAPTOR_INCLUDE_DIR AND RAPTOR_LIBRARIES)
200 + set(RAPTOR_FOUND TRUE)
201 +endif (RAPTOR_INCLUDE_DIR AND RAPTOR_LIBRARIES)
202 +
203 +if (RAPTOR_FOUND)
204 + set(RAPTOR_DEFINITIONS ${raptor_CFLAGS})
205 + if (NOT Raptor_FIND_QUIETLY)
206 + message(STATUS "Found Raptor ${RAPTOR_VERSION}: libs - ${RAPTOR_LIBRARIES}; includes - ${RAPTOR_INCLUDE_DIR}")
207 + endif (NOT Raptor_FIND_QUIETLY)
208 +else (RAPTOR_FOUND)
209 + if (Raptor_FIND_REQUIRED)
210 + message(FATAL_ERROR "Could NOT find Raptor")
211 + endif (Raptor_FIND_REQUIRED)
212 +endif (RAPTOR_FOUND)
213 +
214 +mark_as_advanced(RAPTOR_INCLUDE_DIR_TMP
215 + RAPTOR_INCLUDE_DIR
216 + RAPTOR_LIBRARIES)
217 diff -Naur soprano/CMakeLists.txt soprano-2.6.51/CMakeLists.txt
218 --- soprano/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200
219 +++ soprano-2.6.51/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200
220 @@ -7,7 +7,7 @@
221 ################## Soprano version ################################
222 set(CMAKE_SOPRANO_VERSION_MAJOR 2)
223 set(CMAKE_SOPRANO_VERSION_MINOR 6)
224 -set(CMAKE_SOPRANO_VERSION_RELEASE 52)
225 +set(CMAKE_SOPRANO_VERSION_RELEASE 51)
226 set(CMAKE_SOPRANO_VERSION_STRING "${CMAKE_SOPRANO_VERSION_MAJOR}.${CMAKE_SOPRANO_VERSION_MINOR}.${CMAKE_SOPRANO_VERSION_RELEASE}")
227
228
229 diff -Naur soprano/parsers/raptor/CMakeLists.txt soprano-2.6.51/parsers/raptor/CMakeLists.txt
230 --- soprano/parsers/raptor/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200
231 +++ soprano-2.6.51/parsers/raptor/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200
232 @@ -13,11 +13,13 @@
233 raptorparser.cpp
234 )
235
236 +configure_file(raptor-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/raptor-config.h)
237 +
238 qt4_automoc(${raptor_parser_SRC})
239
240 -add_library(soprano_raptorparser MODULE ${raptor_parser_SRC})
241 +add_library(soprano_raptorparser MODULE ${raptor_parser_SRC})
242
243 -TARGET_LINK_LIBRARIES(soprano_raptorparser soprano raptor2 ${RAPTOR_LIBRARIES})
244 +TARGET_LINK_LIBRARIES(soprano_raptorparser soprano ${RAPTOR_LIBRARIES})
245
246 set_target_properties(soprano_raptorparser PROPERTIES
247 DEFINE_SYMBOL MAKE_RAPTORPARSER_LIB
248 diff -Naur soprano/parsers/raptor/raptor-config.h.cmake soprano-2.6.51/parsers/raptor/raptor-config.h.cmake
249 --- soprano/parsers/raptor/raptor-config.h.cmake 1970-01-01 01:00:00.000000000 +0100
250 +++ soprano-2.6.51/parsers/raptor/raptor-config.h.cmake 2011-06-05 10:38:25.000000000 +0200
251 @@ -0,0 +1 @@
252 +#cmakedefine RAPTOR_HAVE_TRIG
253 diff -Naur soprano/parsers/raptor/raptorparser.cpp soprano-2.6.51/parsers/raptor/raptorparser.cpp
254 --- soprano/parsers/raptor/raptorparser.cpp 2011-07-19 18:49:58.000000000 +0200
255 +++ soprano-2.6.51/parsers/raptor/raptorparser.cpp 2011-06-05 10:38:25.000000000 +0200
256 @@ -3,7 +3,7 @@
257 * This file is part of Soprano Project
258 *
259 * Copyright (C) 2006 Duncan Mac-Vicar <duncan@kde.org>
260 - * Copyright (C) 2007,2011 Sebastian Trueg <trueg@kde.org>
261 + * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
262 *
263 * This library is free software; you can redistribute it and/or
264 * modify it under the terms of the GNU Library General Public
265 @@ -22,13 +22,14 @@
266 */
267
268 #include "raptorparser.h"
269 +#include "raptor-config.h"
270
271 #include "util/simplestatementiterator.h"
272 #include "statement.h"
273 #include "locator.h"
274 #include "error.h"
275
276 -#include <raptor2/raptor.h>
277 +#include <raptor.h>
278
279 #include <QtCore/QUrl>
280 #include <QtCore/QFile>
281 @@ -39,71 +40,88 @@
282 #include <QtCore/QMutexLocker>
283
284
285 +namespace {
286 + class RaptorInitHelper
287 + {
288 + public:
289 + RaptorInitHelper() {
290 + raptor_init();
291 + }
292 + ~RaptorInitHelper() {
293 + raptor_finish();
294 + }
295 + };
296 +}
297 +
298 Q_EXPORT_PLUGIN2(soprano_raptorparser, Soprano::Raptor::Parser)
299
300 namespace {
301 - void raptorLogHandler(void *userData,raptor_log_message *message)
302 + // for some strange reason raptor <= 1.4.15 can only handle application/turtle when parsing
303 + // and application/x-turtle when serializing, but not the other way around
304 + QString mimeTypeString( Soprano::RdfSerialization s, const QString& userSerialization )
305 + {
306 +#ifndef RAPTOR_HAVE_TRIG
307 + if ( s == Soprano::SerializationTurtle ) {
308 + return "application/turtle"; // x-turtle does not work....
309 + }
310 + else
311 +#endif
312 + {
313 + return serializationMimeType( s, userSerialization );
314 + }
315 + }
316 +
317 +
318 + void raptorMessageHandler( void* userData, raptor_locator* locator, const char* message )
319 {
320 Soprano::Raptor::Parser* p = static_cast<Soprano::Raptor::Parser*>( userData );
321 - if ( message->locator ) {
322 - p->setError( Soprano::Error::ParserError( Soprano::Error::Locator( message->locator->line, message->locator->column, message->locator->byte ),
323 - QString::fromUtf8( message->text ),
324 + if ( locator ) {
325 + p->setError( Soprano::Error::ParserError( Soprano::Error::Locator( locator->line, locator->column, locator->byte ),
326 + QString::fromUtf8( message ),
327 Soprano::Error::ErrorParsingFailed ) );
328 }
329 else {
330 - p->setError( Soprano::Error::Error( QString::fromUtf8( message->text ), Soprano::Error::ErrorUnknown ) );
331 + p->setError( Soprano::Error::Error( QString::fromUtf8( message ), Soprano::Error::ErrorUnknown ) );
332 }
333 }
334
335 - Soprano::Node convertNode( raptor_term * term )
336 - {
337 - if(!term) {
338 - return Soprano::Node();
339 - }
340
341 - switch( term->type ) {
342 - case RAPTOR_TERM_TYPE_URI: {
343 - return Soprano::Node::createResourceNode(
344 - QString::fromUtf8( ( char* )raptor_uri_as_string( term->value.uri ) ) );
345 - }
346 -
347 - case RAPTOR_TERM_TYPE_BLANK: {
348 - return Soprano::Node::createBlankNode(
349 - QString::fromUtf8( ( const char* )(term->value.blank.string) ) );
350 - }
351 -
352 - case RAPTOR_TERM_TYPE_LITERAL: {
353 - if ( term->value.literal.datatype ) {
354 - return Soprano::Node::createLiteralNode(
355 - Soprano::LiteralValue::fromString(
356 - QString::fromUtf8( ( const char* )term->value.literal.string ),
357 - QString::fromUtf8(
358 - ( char* )raptor_uri_as_string(term->value.literal.datatype ) )
359 - )
360 - );
361 + Soprano::Node convertNode( const void* data, raptor_identifier_type type,
362 + raptor_uri* objectLiteralDatatype = 0, const unsigned char* objectLiteralLanguage = 0 )
363 + {
364 + switch( type ) {
365 + case RAPTOR_IDENTIFIER_TYPE_RESOURCE:
366 + case RAPTOR_IDENTIFIER_TYPE_PREDICATE:
367 + case RAPTOR_IDENTIFIER_TYPE_ORDINAL:
368 + return Soprano::Node::createResourceNode( QString::fromUtf8( ( char* )raptor_uri_as_string( ( raptor_uri* )data ) ) );
369 +
370 + case RAPTOR_IDENTIFIER_TYPE_ANONYMOUS:
371 + return Soprano::Node::createBlankNode( QString::fromUtf8( ( const char* )data ) );
372 +
373 + case RAPTOR_IDENTIFIER_TYPE_LITERAL:
374 + case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL:
375 + if ( objectLiteralDatatype ) {
376 + return Soprano::Node::createLiteralNode( Soprano::LiteralValue::fromString( QString::fromUtf8( ( const char* )data ),
377 + QString::fromUtf8( ( char* )raptor_uri_as_string( objectLiteralDatatype ) ) ) );
378 }
379 else {
380 - return Soprano::Node::createLiteralNode(
381 - Soprano::LiteralValue::createPlainLiteral(
382 - QString::fromUtf8( ( const char* )term->value.literal.string ),
383 - QString::fromUtf8( ( const char* )term->value.literal.language ) ) );
384 + return Soprano::Node::createLiteralNode( Soprano::LiteralValue::createPlainLiteral( QString::fromUtf8( ( const char* )data ),
385 + QString::fromUtf8( ( const char* )objectLiteralLanguage ) ) );
386 }
387 - }
388
389 default:
390 return Soprano::Node();
391 }
392 -
393 - // make gcc shut up
394 - return Soprano::Node();
395 }
396
397 +
398 Soprano::Statement convertTriple( const raptor_statement* triple )
399 {
400 - return Soprano::Statement( convertNode( triple->subject ),
401 - convertNode( triple->predicate ),
402 - convertNode( triple->object ),
403 - convertNode( triple->graph ) );
404 + return Soprano::Statement( convertNode( triple->subject, triple->subject_type ),
405 + convertNode( triple->predicate, triple->predicate_type ),
406 + convertNode( triple->object, triple->object_type,
407 + triple->object_literal_datatype,
408 + triple->object_literal_language ) );
409 }
410
411
412 @@ -114,48 +132,47 @@
413 };
414
415
416 - void raptorTriplesHandler( void* userData, raptor_statement* triple )
417 + void raptorTriplesHandler( void* userData, const raptor_statement* triple )
418 {
419 - Q_ASSERT(userData);
420 ParserData* pd = static_cast<ParserData*>( userData );
421 - pd->statements.append( convertTriple( triple ) );
422 + Soprano::Statement s = convertTriple( triple );
423 +// qDebug() << "got triple: " << s;
424 + s.setContext( pd->currentContext );
425 + pd->statements.append( s );
426 }
427 -}
428
429
430 -class Soprano::Raptor::Parser::Private
431 -{
432 -public:
433 - raptor_world * world;
434 - mutable QMutex mutex;
435 -};
436 + void raptorGraphHandler( void* userData, raptor_uri* graph )
437 + {
438 + Soprano::Node context = Soprano::Node::createResourceNode( QString::fromUtf8( ( char* )raptor_uri_as_string( graph ) ) );
439 + ParserData* pd = static_cast<ParserData*>( userData );
440 + pd->currentContext = context;
441 +// qDebug() << "got graph: " << context;
442 + }
443 +}
444
445
446 Soprano::Raptor::Parser::Parser()
447 : QObject(),
448 - Soprano::Parser( "raptor" ),
449 - d(new Private())
450 + Soprano::Parser( "raptor" )
451 {
452 - d->world = raptor_new_world();
453 - raptor_world_open(d->world);
454 - Q_ASSERT(d->world);
455 }
456
457
458 Soprano::Raptor::Parser::~Parser()
459 {
460 - raptor_free_world(d->world);
461 - delete d;
462 }
463
464
465 Soprano::RdfSerializations Soprano::Raptor::Parser::supportedSerializations() const
466 {
467 - return( SerializationRdfXml
468 - |SerializationNTriples
469 - |SerializationTurtle
470 - |SerializationTrig
471 - );
472 + return( SerializationRdfXml
473 + |SerializationNTriples
474 + |SerializationTurtle
475 +#ifdef RAPTOR_HAVE_TRIG
476 + |SerializationTrig
477 +#endif
478 + );
479 }
480
481
482 @@ -163,14 +180,13 @@
483 const QString& userSerialization ) const
484 {
485 // create the parser
486 - const QString mimeType = Soprano::serializationMimeType( serialization, userSerialization );
487 + QString mimeType = mimeTypeString( serialization, userSerialization );
488 raptor_parser* parser = 0;
489 if ( serialization == Soprano::SerializationNTriples ) {
490 - parser = raptor_new_parser(d->world,"ntriples"); // mimetype for ntriple is text/plain which is useless for the method below
491 + parser = raptor_new_parser( "ntriples" ); // mimetype for ntriple is text/plain which is useless for the method below
492 }
493 else {
494 - parser = raptor_new_parser_for_content( d->world,
495 - 0,
496 + parser = raptor_new_parser_for_content( 0,
497 mimeType.toLatin1().data(),
498 0,
499 0,
500 @@ -178,14 +194,16 @@
501 }
502
503 if ( !parser ) {
504 - qDebug() << "(Soprano::Raptor::Parser) no parser for serialization " << Soprano::serializationMimeType( serialization, userSerialization );
505 - setError( QString( "Failed to create parser for serialization %1" ).arg( Soprano::serializationMimeType( serialization, userSerialization ) ) );
506 + qDebug() << "(Soprano::Raptor::Parser) no parser for serialization " << mimeTypeString( serialization, userSerialization );
507 + setError( QString( "Failed to create parser for serialization %1" ).arg( mimeTypeString( serialization, userSerialization ) ) );
508 return 0;
509 }
510
511 - // set the error handling method
512 + // set the erro handling method
513 Parser* that = const_cast<Parser*>( this );
514 - raptor_world_set_log_handler(d->world, that, raptorLogHandler);
515 + raptor_set_fatal_error_handler( parser, that, raptorMessageHandler );
516 + raptor_set_error_handler( parser, that, raptorMessageHandler );
517 + raptor_set_warning_handler( parser, that, raptorMessageHandler );
518
519 return parser;
520 }
521 @@ -205,6 +223,48 @@
522 setError( QString( "Could not open file %1 for reading." ).arg( filename ) );
523 return StatementIterator();
524 }
525 +
526 +// clearError();
527 +
528 +// raptor_parser* parser = createParser( serialization, userSerialization );
529 +// if ( !parser ) {
530 +// return StatementIterator();
531 +// }
532 +
533 +// // prepare the container for the parsed data
534 +// QList<Statement> statements;
535 +// raptor_set_statement_handler( parser, &statements, raptorTriplesHandler );
536 +
537 +// // start the atual parsing
538 +// QUrl uri( QUrl::fromLocalFile( filename ) );
539 +// if ( uri.scheme().isEmpty() ) {
540 +// // we need to help the stupid librdf file url handling
541 +// uri.setScheme("file");
542 +// }
543 +// raptor_uri* raptorBaseUri = 0;
544 +// if ( !baseUri.toString().isEmpty() ) {
545 +// raptorBaseUri = raptor_new_uri( (unsigned char *) baseUri.toString().toUtf8().data() );
546 +// }
547 +// raptor_uri* raptorUri = raptor_new_uri( (unsigned char *) uri.toString().toUtf8().data() );
548 +// if ( !raptorUri ) {
549 +// setError( QLatin1String( "Internal: Failed to create raptor_uri instance for '%1'" ).arg( uri ) );
550 +// return StatementIterator();
551 +// }
552 +
553 +// int r = raptor_parse_uri( parser, raptorUri, raptorBaseUri );
554 +
555 +// raptor_free_parser( parser );
556 +// raptor_free_uri( raptorUri );
557 +// if ( raptorBaseUri ) {
558 +// raptor_free_uri( raptorBaseUri );
559 +// }
560 +
561 +// if ( r == 0 ) {
562 +// return SimpleStatementIterator( statements );
563 +// }
564 +// else {
565 +// return StatementIterator();
566 +// }
567 }
568
569
570 @@ -219,12 +279,14 @@
571 }
572
573
574 -Soprano::StatementIterator Soprano::Raptor::Parser::parseStream( QTextStream& stream,
575 - const QUrl& baseUri,
576 - RdfSerialization serialization,
577 - const QString& userSerialization ) const
578 +Soprano::StatementIterator
579 +Soprano::Raptor::Parser::parseStream( QTextStream& stream,
580 + const QUrl& baseUri,
581 + RdfSerialization serialization,
582 + const QString& userSerialization ) const
583 {
584 - QMutexLocker lock( &d->mutex );
585 + QMutexLocker lock( &m_mutex );
586 + RaptorInitHelper raptorInitHelper;
587
588 clearError();
589
590 @@ -235,19 +297,22 @@
591
592 // prepare the container for the parsed data
593 ParserData data;
594 - raptor_parser_set_statement_handler( parser, &data, raptorTriplesHandler );
595 + raptor_set_statement_handler( parser, &data, raptorTriplesHandler );
596 +#ifdef RAPTOR_HAVE_TRIG
597 + raptor_set_graph_handler( parser, &data, raptorGraphHandler );
598 +#endif
599
600 // start the atual parsing
601 raptor_uri* raptorBaseUri = 0;
602 if ( baseUri.isValid() ) {
603 - raptorBaseUri = raptor_new_uri( d->world,(unsigned char *) baseUri.toString().toUtf8().data() );
604 + raptorBaseUri = raptor_new_uri( (unsigned char *) baseUri.toString().toUtf8().data() );
605 }
606 else {
607 - raptorBaseUri = raptor_new_uri( d->world, (unsigned char *) "http://soprano.sourceforge.net/dummyBaseUri" );
608 + raptorBaseUri = raptor_new_uri( (unsigned char *) "http://soprano.sourceforge.net/dummyBaseUri" );
609 }
610
611 clearError();
612 - if ( raptor_parser_parse_start( parser, raptorBaseUri ) != 0 ) {
613 + if ( raptor_start_parse( parser, raptorBaseUri ) ) {
614 if ( !lastError() ) {
615 ErrorCache::setError( QLatin1String( "Failed to start parsing." ) );
616 }
617 @@ -266,10 +331,7 @@
618 while ( !dev->atEnd() ) {
619 qint64 r = dev->read( buf.data(), buf.size() );
620 if ( r <= 0 ||
621 - raptor_parser_parse_chunk( parser, ( const unsigned char* )buf.data(), r, 0 ) ) {
622 - // parse_chunck return failure code.
623 - // Call it with END=true and then free
624 - raptor_parser_parse_chunk(parser,0,0,/*END=*/1);
625 + raptor_parse_chunk( parser, ( const unsigned char* )buf.data(), r, 0 ) ) {
626 raptor_free_parser( parser );
627 if ( raptorBaseUri ) {
628 raptor_free_uri( raptorBaseUri );
629 @@ -282,10 +344,7 @@
630 while ( !stream.atEnd() ) {
631 QString buf = stream.read( bufSize );
632 QByteArray utf8Data = buf.toUtf8();
633 - if ( raptor_parser_parse_chunk( parser, ( const unsigned char* )utf8Data.data(), utf8Data.length(), 0 ) ) {
634 - // parse_chunck return failure code.
635 - // Call it with END=true and then free
636 - raptor_parser_parse_chunk(parser,0,0,/*END=*/1);
637 + if ( raptor_parse_chunk( parser, ( const unsigned char* )utf8Data.data(), utf8Data.length(), 0 ) ) {
638 raptor_free_parser( parser );
639 if ( raptorBaseUri ) {
640 raptor_free_uri( raptorBaseUri );
641 @@ -294,8 +353,7 @@
642 }
643 }
644 }
645 - // Call parse_chunk with END=true
646 - raptor_parser_parse_chunk( parser, 0, 0, 1 );
647 + raptor_parse_chunk( parser, 0, 0, 1 );
648
649 raptor_free_parser( parser );
650 if ( raptorBaseUri ) {
651 diff -Naur soprano/parsers/raptor/raptorparser.h soprano-2.6.51/parsers/raptor/raptorparser.h
652 --- soprano/parsers/raptor/raptorparser.h 2011-07-19 18:49:58.000000000 +0200
653 +++ soprano-2.6.51/parsers/raptor/raptorparser.h 2011-06-05 10:38:25.000000000 +0200
654 @@ -29,11 +29,13 @@
655
656 #include "parser.h"
657
658 -#include<raptor2/raptor.h>
659 +#include <raptor.h>
660 +
661
662 namespace Soprano {
663 namespace Raptor {
664 - class Parser : public QObject, public Soprano::Parser {
665 + class Parser : public QObject, public Soprano::Parser
666 + {
667 Q_OBJECT
668 Q_INTERFACES(Soprano::Parser)
669
670 @@ -41,7 +43,7 @@
671 Parser();
672 ~Parser();
673
674 - RdfSerializations supportedSerializations() const;
675 + RdfSerializations supportedSerializations() const;
676
677 StatementIterator parseFile( const QString& filename,
678 const QUrl& baseUri,
679 @@ -62,10 +64,7 @@
680 raptor_parser* createParser( RdfSerialization serialization,
681 const QString& userSerialization = QString() ) const;
682
683 - class Private;
684 - Private * d;
685 -
686 -
687 + mutable QMutex m_mutex;
688 };
689 }
690 }
691 diff -Naur soprano/serializers/raptor/CMakeLists.txt soprano-2.6.51/serializers/raptor/CMakeLists.txt
692 --- soprano/serializers/raptor/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200
693 +++ soprano-2.6.51/serializers/raptor/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200
694 @@ -9,8 +9,13 @@
695 ${RAPTOR_INCLUDE_DIR}
696 )
697
698 +include(CheckFunctionExists)
699 set(CMAKE_REQUIRED_INCLUDES ${RAPTOR_INCLUDE_DIR})
700 set(CMAKE_REQUIRED_LIBRARIES ${RAPTOR_LIBRARIES})
701 +check_function_exists( raptor_new_iostream_from_handler2 HAVE_IOSTREAM_HANDLER2 )
702 +if(HAVE_IOSTREAM_HANDLER2)
703 + add_definitions(-DHAVE_IOSTREAM_HANDLER2)
704 +endif(HAVE_IOSTREAM_HANDLER2)
705
706 set(raptor_serializer_SRC
707 raptorserializer.cpp
708 diff -Naur soprano/serializers/raptor/raptorserializer.cpp soprano-2.6.51/serializers/raptor/raptorserializer.cpp
709 --- soprano/serializers/raptor/raptorserializer.cpp 2011-07-19 18:49:58.000000000 +0200
710 +++ soprano-2.6.51/serializers/raptor/raptorserializer.cpp 2011-06-05 10:38:25.000000000 +0200
711 @@ -38,135 +38,54 @@
712 class RaptorInitHelper
713 {
714 public:
715 - raptor_world* world;
716 -
717 RaptorInitHelper() {
718 - world = raptor_new_world();
719 - raptor_world_open(world);
720 + raptor_init();
721 }
722 ~RaptorInitHelper() {
723 - raptor_free_world(world);
724 + raptor_finish();
725 }
726 };
727
728 - /* Probably unnecessary for serializer*/
729 - /*
730 - QString mimeTypeString( Soprano::RdfSerialization s, const QString& userSerialization )
731 - {
732 - if ( s == Soprano::SerializationTurtle ) {
733 - return "application/turtle"; // x-turtle does not work....
734 - }
735 - else {
736 - return serializationMimeType( s, userSerialization );
737 - }
738 - }*/
739 -
740 - raptor_term * convertNode( raptor_world * world, const Soprano::Node& node)
741 + bool convertNode( const Soprano::Node& node, const void** data, raptor_identifier_type* type, raptor_uri** dataType = 0, const unsigned char** lang = 0 )
742 {
743 - raptor_term * answer = 0;
744 - /* According to documentation, raptor_new_term family takes copy of
745 - * all given input parameters
746 - */
747 if ( node.isResource() ) {
748 - raptor_uri * uri = raptor_new_uri(world, ( const unsigned char* )node.uri().toEncoded().data() );
749 - answer = raptor_new_term_from_uri(world,uri);
750 -
751 - raptor_free_uri(uri);
752 + *data = raptor_new_uri( ( const unsigned char* )node.uri().toEncoded().data() );
753 + *type = RAPTOR_IDENTIFIER_TYPE_RESOURCE;
754 + return true;
755 }
756 else if ( node.isBlank() ) {
757 - answer = raptor_new_term_from_blank(
758 - world, (const unsigned char*)node.identifier().toUtf8().data() );
759 + *data = qstrdup( node.identifier().toUtf8().data() );
760 + *type = RAPTOR_IDENTIFIER_TYPE_ANONYMOUS;
761 + return true;
762 }
763 else if ( node.isLiteral() ) {
764 - // Because QByteArray.data() is valid as long as QByteArray itself is
765 - // alive, we store langBA ( and others _x_BA untill function exits
766 -
767 - //const unsigned char * literal = 0;
768 - QByteArray langBA;
769 - const unsigned char * lang = 0;
770 - raptor_uri * datatype = 0;
771 -
772 + *data = qstrdup( node.toString().toUtf8().data() );
773 if ( node.literal().isPlain() ) {
774 if ( !node.language().isEmpty() )
775 - langBA = node.language().toUtf8();
776 - lang = ( const unsigned char* )( langBA.constData() );
777 + *lang = ( unsigned char* )qstrdup( ( const char* )node.language().toUtf8().data() );
778 }
779 else {
780 - datatype = raptor_new_uri( world, ( const unsigned char* )node.dataType().toEncoded().data() );
781 + *dataType = raptor_new_uri( ( const unsigned char* )node.dataType().toEncoded().data() );
782 }
783 -
784 - // Now we costructs statement
785 - answer = raptor_new_term_from_literal(world,(const unsigned char*)node.literal().toByteArray().constData(),datatype,lang);
786 -
787 - // And free unnecessary resources
788 - if ( datatype)
789 - raptor_free_uri(datatype);
790 -
791 + *type = RAPTOR_IDENTIFIER_TYPE_LITERAL;
792 + return true;
793 }
794
795 - return answer;
796 + return false;
797 }
798
799
800 - raptor_statement* convertStatement(raptor_world * world, const Soprano::Statement& statement )
801 + raptor_statement* convertStatement( const Soprano::Statement& statement )
802 {
803 - // Get terms
804 - raptor_term * subject_term = 0, *object_term = 0, * predicate_term = 0;
805 - raptor_term * graph_term = 0;
806 -
807 - subject_term = convertNode(world,statement.subject());
808 - if ( !subject_term) {
809 - qDebug() << "Failed to convert subject to raptor_term";
810 - return 0;
811 - }
812 -
813 - predicate_term = convertNode(world,statement.predicate());
814 - if (!predicate_term) {
815 - qDebug() << "Failed to convert predicate to raptor_term";
816 - raptor_free_term(subject_term);
817 - return 0;
818 - }
819 -
820 - object_term = convertNode(world,statement.object());
821 - if (!object_term) {
822 - qDebug() << "Failed to convert object to raptor_term";
823 - raptor_free_term(subject_term);
824 - raptor_free_term(predicate_term);
825 - return 0;
826 - }
827 -
828 - if ( !statement.context().isEmpty() ) {
829 - graph_term = convertNode(world,statement.context());
830 - if(!graph_term) {
831 - qDebug() << "Failed to convert graph/context to raptor_term. Node is" << statement.context();
832 - raptor_free_term(subject_term);
833 - raptor_free_term(predicate_term);
834 - raptor_free_term(object_term);
835 - return 0;
836 - }
837 - }
838 -
839 -
840 - raptor_statement* s = raptor_new_statement_from_nodes(
841 - world,
842 - subject_term,
843 - predicate_term,
844 - object_term,
845 - graph_term);
846 -
847 - if (!s) {
848 - qDebug() << "Failed to build raptor_statement from terms";
849 - raptor_free_term(subject_term);
850 - raptor_free_term(predicate_term);
851 - raptor_free_term(object_term);
852 - raptor_free_term(graph_term);
853 - }
854 -
855 + raptor_statement* s = new raptor_statement;
856 + memset( s, 0, sizeof( raptor_statement ) );
857 + convertNode( statement.subject(), &s->subject, &s->subject_type );
858 + convertNode( statement.predicate(), &s->predicate, &s->predicate_type );
859 + convertNode( statement.object(), &s->object, &s->object_type, &s->object_literal_datatype, &s->object_literal_language );
860 return s;
861 }
862
863
864 - /*
865 void free_node( const void* data, raptor_identifier_type type )
866 {
867 switch( type ) {
868 @@ -190,7 +109,6 @@
869 free( ( char* )s->object_literal_language );
870 delete s;
871 }
872 - */
873
874
875 int raptorIOStreamWriteByte( void* data, const int byte )
876 @@ -203,7 +121,6 @@
877 else {
878 ( *s ) << ( char )byte;
879 }
880 - //qDebug() << "Write char:" << (char)(byte);
881 return 0;
882 }
883
884 @@ -223,7 +140,6 @@
885 raptorIOStreamWriteByte( data, p[i] );
886 }
887 }
888 - //qDebug() << "Write string: " << p;
889 break;
890 }
891 default:
892 @@ -237,36 +153,15 @@
893 Q_EXPORT_PLUGIN2(soprano_raptorserializer, Soprano::Raptor::Serializer)
894
895
896 -
897 -/* We can not rely on RaptorInitHelper anymore because
898 - * we need raptor_world in supportedUserSerializations.
899 - * Instead of constantly creating new raptor_world just to
900 - * detect user supported serializations, it is easier to
901 - * embed raptor_world into class.
902 - * And we can not declare raptor_world as a member of
903 - * Serializer directly, because raptor_world is a typedef,
904 - * not a class. So it can not be forward declarated
905 - */
906 -class Soprano::Raptor::Serializer::Private
907 -{
908 - public:
909 - raptor_world * world;
910 -};
911 -
912 Soprano::Raptor::Serializer::Serializer()
913 : QObject(),
914 Soprano::Serializer( "raptor" )
915 {
916 - this->d = new Private();
917 - this->d->world = raptor_new_world();
918 - raptor_world_open(d->world);
919 }
920
921
922 Soprano::Raptor::Serializer::~Serializer()
923 {
924 - raptor_free_world(d->world);
925 - delete d;
926 }
927
928
929 @@ -279,19 +174,17 @@
930 QStringList Soprano::Raptor::Serializer::supportedUserSerializations() const
931 {
932 QStringList sl;
933 - const raptor_syntax_description * serializer_descr = 0;
934 - for ( int i = 0; 1; ++i ) {
935 - serializer_descr =
936 - raptor_world_get_serializer_description(d->world,i);
937 -
938 - /* raptor_world_get_serializer_description will return
939 - * NULL when conter runs out of bonds and there is no
940 - * more serializers
941 - */
942 - if (!serializer_descr)
943 - break;
944 -
945 - sl << QString::fromUtf8( serializer_descr->names[0] );
946 + int i = 0;
947 + const char* name = 0;
948 + const char* label = 0;
949 + const char* mimeType = 0;
950 + const unsigned char* uri = 0;
951 + while ( !raptor_serializers_enumerate( i,
952 + &name,
953 + &label,
954 + &mimeType,
955 + &uri ) ) {
956 + sl << QString::fromUtf8( name );
957 ++i;
958 }
959 return sl;
960 @@ -305,43 +198,28 @@
961 {
962 clearError();
963
964 - raptor_world * world = this->d->world;
965 + RaptorInitHelper raptorHelper;
966
967 raptor_serializer* serializer = 0;
968 - QString mimeType = serializationMimeType(serialization,userSerialization);
969 -
970 if ( serialization == SerializationRdfXml ) {
971 - serializer = raptor_new_serializer( world, "rdfxml-abbrev" ); // we always want the abbreviated xmlrdf
972 + serializer = raptor_new_serializer( "rdfxml-abbrev" ); // we always want the abbreviated xmlrdf
973 }
974 else {
975 - const raptor_syntax_description * serializer_descr = 0;
976 for ( int i = 0; 1; ++i ) {
977 - serializer_descr =
978 - raptor_world_get_serializer_description(world,i);
979 -
980 - /* raptor_world_get_serializer_description will return
981 - * NULL when conter runs out of bonds and there is no
982 - * more serializers
983 - */
984 - if (!serializer_descr)
985 + const char* syntax_name = 0;
986 + const char* syntax_label = 0;
987 + const char* mime_type = 0;
988 + const unsigned char* uri_string = 0;
989 + if ( raptor_serializers_enumerate( i,
990 + &syntax_name,
991 + &syntax_label,
992 + &mime_type,
993 + &uri_string ) )
994 break;
995 -
996 - /* In serializer_descr->mime_types we have a array of pairs
997 - * (mime_type,Q) of mime_type for this syntax. It looks like
998 - * we can ignore Q value in this case
999 - * Acording to documentation, this array can have zero elements
1000 - */
1001 - for( int mt_number = 0; mt_number < serializer_descr->mime_types_count;
1002 - mt_number++)
1003 - {
1004 - const char * mime_type_N = serializer_descr->mime_types[mt_number].mime_type;
1005 - if ( !qstrcmp( serializationMimeType( serialization, userSerialization ).toLatin1().data(), mime_type_N ) ) {
1006 - serializer = raptor_new_serializer( world, serializer_descr->names[0] );
1007 - break;
1008 - }
1009 - }
1010 - if ( serializer )
1011 + if ( !qstrcmp( serializationMimeType( serialization, userSerialization ).toLatin1().data(), mime_type ) ) {
1012 + serializer = raptor_new_serializer( syntax_name );
1013 break;
1014 + }
1015 }
1016 }
1017
1018 @@ -354,8 +232,8 @@
1019 QHash<QString, QUrl> namespaces = prefixes();
1020 for ( QHash<QString, QUrl>::const_iterator pfit = namespaces.constBegin();
1021 pfit != namespaces.constEnd(); ++pfit ) {
1022 - raptor_uri* ns = raptor_new_uri( world,reinterpret_cast<unsigned char*>( pfit.value().toEncoded().data() ) );
1023 - raptor_serializer_set_namespace( serializer,
1024 + raptor_uri* ns = raptor_new_uri( reinterpret_cast<unsigned char*>( pfit.value().toEncoded().data() ) );
1025 + raptor_serialize_set_namespace( serializer,
1026 ns,
1027 ( unsigned char* )pfit.key().toLatin1().data() );
1028 raptor_free_uri( ns );
1029 @@ -363,53 +241,42 @@
1030
1031 bool success = true;
1032
1033 - raptor_iostream_handler raptorStreamHandler;
1034 - // ATTENTION: Raptor documentation is incorrect! Always set
1035 - // version to 2 and raptor_iostream_calculate_modes internal
1036 - // call will correctly determine operation mode ( read,write,readwrite)
1037 - raptorStreamHandler.version = 2;
1038 - raptorStreamHandler.init = 0;
1039 - raptorStreamHandler.finish = 0;
1040 - raptorStreamHandler.write_byte = raptorIOStreamWriteByte;
1041 - raptorStreamHandler.write_bytes = raptorIOStreamWriteBytes;
1042 - raptorStreamHandler.write_end = 0;
1043 - raptorStreamHandler.read_bytes = 0;
1044 - raptorStreamHandler.read_eof = 0;
1045 -
1046 - raptor_iostream* raptorStream = raptor_new_iostream_from_handler(
1047 - world,
1048 - &stream,
1049 - &raptorStreamHandler
1050 - );
1051 -
1052 - if (!raptorStream) {
1053 - qDebug() << "Can not create raptor iostream";
1054 - raptor_free_serializer(serializer);
1055 - return false;
1056 - }
1057 +#ifdef HAVE_IOSTREAM_HANDLER2
1058 + raptor_iostream_handler2 raptorStreamHandler = {
1059 + 2,
1060 + 0,
1061 + 0,
1062 + raptorIOStreamWriteByte,
1063 + raptorIOStreamWriteBytes,
1064 + 0,
1065 + 0,
1066 + 0
1067 + };
1068 + raptor_iostream* raptorStream = raptor_new_iostream_from_handler2( &stream,
1069 + &raptorStreamHandler );
1070 +#else
1071 + raptor_iostream_handler raptorStreamHandler = {
1072 + 0,
1073 + 0,
1074 + raptorIOStreamWriteByte,
1075 + raptorIOStreamWriteBytes,
1076 + 0
1077 + };
1078 + raptor_iostream* raptorStream = raptor_new_iostream_from_handler( &stream,
1079 + &raptorStreamHandler );
1080 +#endif
1081
1082 // raptor_serialize_start takes ownership of raptorStream
1083 - raptor_serializer_start_to_iostream( serializer,0, raptorStream );
1084 + raptor_serialize_start( serializer, 0, raptorStream );
1085
1086 while ( it.next() ) {
1087 - raptor_statement * rs = convertStatement(world, *it );
1088 - if (rs) {
1089 - //qDebug() << "Serializing statement: " << *it;
1090 - raptor_serializer_serialize_statement(serializer, rs );
1091 - raptor_free_statement( rs );
1092 - }
1093 - else {
1094 - qDebug() << "Fail to convert Soprano::Statement " <<
1095 - *it <<
1096 - " to raptor_statement";
1097 - success = false;
1098 - break;
1099 - }
1100 + raptor_statement* rs = convertStatement( *it );
1101 + raptor_serialize_statement( serializer, rs );
1102 + free_statement( rs );
1103 }
1104
1105 - raptor_serializer_serialize_end( serializer );
1106 + raptor_serialize_end( serializer );
1107 raptor_free_serializer( serializer );
1108 - raptor_free_iostream(raptorStream);
1109
1110 return success;
1111 }
1112 diff -Naur soprano/serializers/raptor/raptorserializer.h soprano-2.6.51/serializers/raptor/raptorserializer.h
1113 --- soprano/serializers/raptor/raptorserializer.h 2011-07-19 18:49:58.000000000 +0200
1114 +++ soprano-2.6.51/serializers/raptor/raptorserializer.h 2011-06-05 10:38:25.000000000 +0200
1115 @@ -28,6 +28,7 @@
1116
1117 #include "serializer.h"
1118
1119 +
1120 namespace Soprano {
1121 namespace Raptor {
1122 class Serializer : public QObject, public Soprano::Serializer
1123 @@ -46,12 +47,6 @@
1124 QTextStream& stream,
1125 RdfSerialization serialization,
1126 const QString& userSerialization = QString() ) const;
1127 - private:
1128 - /* See source file comments, that explain why it is necessary to
1129 - * use Private class and RaptorInitHelper is not succifient anymore
1130 - */
1131 - class Private;
1132 - Private * d;
1133 };
1134 }
1135 }
1136 diff -Naur soprano/soprano/inference/inferenceruleset.cpp soprano-2.6.51/soprano/inference/inferenceruleset.cpp
1137 --- soprano/soprano/inference/inferenceruleset.cpp 2011-07-19 18:49:58.000000000 +0200
1138 +++ soprano-2.6.51/soprano/inference/inferenceruleset.cpp 2011-06-05 10:38:25.000000000 +0200
1139 @@ -27,10 +27,7 @@
1140
1141 #include <QtCore/QHash>
1142 #include <QtCore/QList>
1143 -#ifdef Q_OS_WIN
1144 -#include <QtCore/QCoreApplication>
1145 -#include <QtCore/QDir>
1146 -#endif
1147 +
1148
1149 class Soprano::Inference::RuleSet::Private : public QSharedData
1150 {
1151 @@ -141,22 +138,5 @@
1152
1153 RuleParser parser;
1154 parser.parseFile( path );
1155 -#ifdef Q_OS_WIN
1156 - // Additionally try to look up the rules based on the runtime Path if
1157 - // they can not be found at the install prefix
1158 - if (!parser.rules().count()) {
1159 - path = QDir( QCoreApplication::applicationDirPath() ).absoluteFilePath( ".." );
1160 - path += "/share/soprano/rules/";
1161 -
1162 - switch( set ) {
1163 - case RDFS:
1164 - path += "rdfs.rules";
1165 - break;
1166 - case NRL:
1167 - path += "nrl.rules";
1168 - break;
1169 - }
1170 - }
1171 -#endif
1172 return parser.rules();
1173 }
1174 diff -Naur soprano/soprano/sopranodirs.cpp soprano-2.6.51/soprano/sopranodirs.cpp
1175 --- soprano/soprano/sopranodirs.cpp 2011-07-19 18:49:58.000000000 +0200
1176 +++ soprano-2.6.51/soprano/sopranodirs.cpp 2011-06-05 10:38:25.000000000 +0200
1177 @@ -28,12 +28,8 @@
1178 #include <QtCore/QCoreApplication>
1179 #include <QtCore/QDebug>
1180
1181 -#ifdef Q_OS_WIN
1182 -static inline QString getWinPrefix()
1183 -{
1184 - // returns the parent directory of the application
1185 - return QDir( QCoreApplication::applicationDirPath() ).absoluteFilePath( ".." );
1186 -}
1187 +
1188 +#if defined _WIN32 || defined _WIN64
1189 #define PATH_SEPARATOR ';'
1190 #else
1191 #define PATH_SEPARATOR ':'
1192 @@ -127,8 +123,6 @@
1193 paths << QLatin1String( SOPRANO_PREFIX"/lib"SOPRANO_LIB_SUFFIX );
1194 #ifdef Q_OS_WIN
1195 paths << QLatin1String( SOPRANO_PREFIX"/bin" );
1196 - paths << getWinPrefix() + QLatin1String( "/bin" );
1197 - paths << getWinPrefix() + QLatin1String( "/lib"SOPRANO_LIB_SUFFIX );
1198 #else
1199 paths << QLatin1String( "/usr/lib"SOPRANO_LIB_SUFFIX );
1200 paths << QLatin1String( "/usr/local/lib"SOPRANO_LIB_SUFFIX );
1201 @@ -142,9 +136,6 @@
1202 {
1203 QStringList paths;
1204 paths << QLatin1String( SOPRANO_PREFIX"/share" )
1205 -#ifdef Q_OS_WIN
1206 - << getWinPrefix() + QLatin1String( "/share" )
1207 -#endif
1208 << Soprano::envDirList( "SOPRANO_DIRS" )
1209 << Soprano::envDirList( "XDG_DATA_DIRS" );
1210 return paths;
1211 @@ -155,9 +146,6 @@
1212 {
1213 QStringList paths;
1214 paths << QLatin1String( SOPRANO_PREFIX"/bin" )
1215 -#ifdef Q_OS_WIN
1216 - << getWinPrefix() + QLatin1String( "/bin" )
1217 -#endif
1218 << envDirList( "PATH" );
1219 return paths;
1220 }
1221 diff -Naur soprano/test/CMakeLists.txt soprano-2.6.51/test/CMakeLists.txt
1222 --- soprano/test/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200
1223 +++ soprano-2.6.51/test/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200
1224 @@ -135,12 +135,6 @@
1225 target_link_libraries(parsertest soprano ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
1226 add_test(parsertest ${EXECUTABLE_OUTPUT_PATH}/parsertest)
1227
1228 -# serializer test
1229 -qt4_automoc(serializetest serializetest.cpp)
1230 -add_executable(serializertest serializetest.cpp)
1231 -target_link_libraries(serializertest soprano ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
1232 -add_test(serializertest ${EXECUTABLE_OUTPUT_PATH}/serializertest)
1233 -
1234 # Error test
1235 qt4_automoc(errortest errortest.cpp)
1236 add_executable(errortest errortest.cpp)
1237 diff -Naur soprano/test/serializetest.cpp soprano-2.6.51/test/serializetest.cpp
1238 --- soprano/test/serializetest.cpp 2011-07-19 18:49:58.000000000 +0200
1239 +++ soprano-2.6.51/test/serializetest.cpp 1970-01-01 01:00:00.000000000 +0100
1240 @@ -1,167 +0,0 @@
1241 -/*
1242 - * This file is part of Soprano Project.
1243 - *
1244 - * Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
1245 - *
1246 - * This library is free software; you can redistribute it and/or
1247 - * modify it under the terms of the GNU Library General Public
1248 - * License as published by the Free Software Foundation; either
1249 - * version 2 of the License, or (at your option) any later version.
1250 - *
1251 - * This library is distributed in the hope that it will be useful,
1252 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1253 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1254 - * Library General Public License for more details.
1255 - *
1256 - * You should have received a copy of the GNU Library General Public License
1257 - * along with this library; see the file COPYING.LIB. If not, write to
1258 - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
1259 - * Boston, MA 02110-1301, USA.
1260 - */
1261 -
1262 -#include "serializetest.h"
1263 -#include "config-testdata.h"
1264 -
1265 -#include "serializer.h"
1266 -#include "parser.h"
1267 -#include "pluginmanager.h"
1268 -#include "statementiterator.h"
1269 -#include "simplestatementiterator.h"
1270 -#include "statement.h"
1271 -#include "vocabulary.h"
1272 -
1273 -#include <QtTest/QTest>
1274 -#include <QtCore/QFile>
1275 -#include <QtCore/QDebug>
1276 -
1277 -
1278 -using namespace Soprano;
1279 -
1280 -#include "testdata.h"
1281 -
1282 -
1283 -void SerializerTest::init()
1284 -{
1285 -#if 0
1286 - // Init reference statements list
1287 - const Parser * parser = PluginManager::instance()->discoverParserForSerialization(SerializationTrig);
1288 - QVERIFY(parser);
1289 - StatementIterator refIt = parser->parseFile(
1290 - SOPRANO_TEST_DATA_DIR"/trig-testdata.trig",
1291 - QUrl("http://soprano.sf.net/testdata/"),
1292 - SerializationTrig);
1293 - this->referenceStatements = refIt.allStatements();
1294 -#endif
1295 -}
1296 -
1297 -Q_DECLARE_METATYPE( Soprano::RdfSerialization )
1298 -
1299 -void SerializerTest::testSerializer_data()
1300 -{
1301 -
1302 - QTest::addColumn<Soprano::RdfSerialization>( "serialization" );
1303 - QTest::addColumn<bool>( "withContext" );
1304 -
1305 - QTest::newRow("rdf_xml") << SerializationRdfXml << false;
1306 - QTest::newRow("turtle") << SerializationTurtle << false;
1307 - QTest::newRow("trig") << SerializationTrig << true;
1308 -}
1309 -
1310 -
1311 -
1312 -void SerializerTest::testSerializer()
1313 -{
1314 - QFETCH( RdfSerialization, serialization );
1315 - QFETCH( bool, withContext );
1316 -
1317 - //qDebug() << "Serialization: " << serializationMimeType(serialization);
1318 - QList<const Serializer*> serializers = PluginManager::instance()->allSerializers();
1319 -
1320 -
1321 - /* Step 1 - create reference statements */
1322 - QList<Statement> referenceStatements = testData(withContext);
1323 - //QList<Statement> testStatements = testData( withContext );
1324 -
1325 - Q_FOREACH( const Serializer * serializer, serializers ) {
1326 - if ( serializer->supportsSerialization( serialization ) ) {
1327 - // Find if we have Parser for this serialization, to parse data back.
1328 - // If not, then oops )
1329 - const Parser * back_parser = PluginManager::instance()->discoverParserForSerialization(serialization);
1330 - if ( !back_parser ) {
1331 - qDebug() << "We can not found parser for" <<
1332 - serializationMimeType(serialization) <<
1333 - " Skipping it";
1334 - continue;
1335 - }
1336 -
1337 - // Now serialize reference data
1338 - QByteArray data_array;
1339 - QTextStream serializationStorage(&data_array,QIODevice::ReadWrite);
1340 -
1341 - bool result = serializer->serialize(
1342 - /*what*/Util::SimpleStatementIterator(referenceStatements),
1343 - /*where*/serializationStorage,
1344 - /*type*/serialization
1345 - );
1346 - QVERIFY(result);
1347 -
1348 - //qDebug() << "Serialization storage: " << data_array;
1349 -
1350 - // Now parse gained text stream back
1351 - QTextStream readStorageStream(&data_array, QIODevice::ReadOnly);
1352 - StatementIterator it = back_parser->parseStream(
1353 - readStorageStream,
1354 - QUrl("http://soprano.sf.net/testdata/"),
1355 - serialization);
1356 -
1357 - QList<Statement> all = it.allStatements();
1358 -
1359 -
1360 - // Now compare recieved with reference
1361 - QCOMPARE( all.count(), referenceStatements.count() );
1362 -
1363 - Q_FOREACH( Statement s, referenceStatements ) {
1364 - bool contains = all.contains(s);
1365 - if ( !contains ) {
1366 - qDebug() << "Not found in parsed: " << s;
1367 - }
1368 -
1369 - QVERIFY( contains );
1370 - }
1371 -
1372 - }
1373 - }
1374 -}
1375 -
1376 -
1377 -#if 0
1378 -void SerializerTest::testEncoding()
1379 -{
1380 - // FIXME: provide test data for all supported encodings (no big problem so far since we only have the raptor parser)
1381 -
1382 - // parse both files, same content, different encodings and compare the results
1383 - const QString utf8File = SOPRANO_TEST_DATA_DIR"/rdf_xml-testdata-utf8.rdf";
1384 - const QString isoFile = SOPRANO_TEST_DATA_DIR"/rdf_xml-testdata-iso8859.rdf";
1385 -
1386 - const Soprano::Parser* parser = PluginManager::instance()->discoverParserForSerialization( SerializationRdfXml );
1387 - if ( parser ) {
1388 - QList<Statement> utf8Statements = parser->parseFile( utf8File, QUrl(), SerializationRdfXml ).allStatements();
1389 - QList<Statement> isoStatements = parser->parseFile( isoFile, QUrl(), SerializationRdfXml ).allStatements();
1390 -
1391 - // brute force comparision, time is not an issue, no need to get inventive. ;)
1392 - foreach( const Statement& s, utf8Statements ) {
1393 - if ( !isoStatements.contains( s ) ) qDebug() << s;
1394 - QVERIFY( isoStatements.contains( s ) );
1395 - }
1396 - foreach( const Statement& s, isoStatements ) {
1397 - if ( !utf8Statements.contains( s ) ) qDebug() << s;
1398 - QVERIFY( utf8Statements.contains( s ) );
1399 - }
1400 - }
1401 -}
1402 -#endif
1403 -
1404 -QTEST_MAIN( SerializerTest )
1405 -
1406 -#include "serializetest.moc"
1407 -
1408 diff -Naur soprano/test/serializetest.h soprano-2.6.51/test/serializetest.h
1409 --- soprano/test/serializetest.h 2011-07-19 18:49:58.000000000 +0200
1410 +++ soprano-2.6.51/test/serializetest.h 1970-01-01 01:00:00.000000000 +0100
1411 @@ -1,52 +0,0 @@
1412 -/*
1413 - * This file is part of Soprano Project.
1414 - *
1415 - * Copyright (C) 2007-2008 Sebastian Trueg <strueg@mandriva.com>
1416 - *
1417 - * This library is free software; you can redistribute it and/or
1418 - * modify it under the terms of the GNU Library General Public
1419 - * License as published by the Free Software Foundation; either
1420 - * version 2 of the License, or (at your option) any later version.
1421 - *
1422 - * This library is distributed in the hope that it will be useful,
1423 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1424 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1425 - * Library General Public License for more details.
1426 - *
1427 - * You should have received a copy of the GNU Library General Public License
1428 - * along with this library; see the file COPYING.LIB. If not, write to
1429 - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
1430 - * Boston, MA 02110-1301, USA.
1431 - */
1432 -
1433 -#ifndef SOPRANO_SERIALIZER_TEST_H
1434 -#define SOPRANO_SERIALIZER_TEST_H
1435 -
1436 -#include <QtCore/QObject>
1437 -#include <QtCore/QList>
1438 -
1439 -#include "statement.h"
1440 -
1441 -
1442 -/* Workflow:
1443 - * 1) Prepare one QList<Statement> with data, used as reference
1444 - * 2) For each serializer:
1445 - * 2.1) Serialize reference to memory
1446 - * 2.2) Parse this memory back to QList<Statement>
1447 - * 2.3) Compare with reference
1448 - */
1449 -class SerializerTest: public QObject
1450 -{
1451 - Q_OBJECT
1452 -
1453 -private Q_SLOTS:
1454 - void init();
1455 - void testSerializer_data();
1456 - void testSerializer();
1457 - //void testEncoding();
1458 - private:
1459 - //QList<Soprano::Statement> referenceStatements;
1460 -};
1461 -
1462 -#endif
1463 -