diff -Naur soprano/backends/redland/redlandqueryresult.cpp soprano-2.6.51/backends/redland/redlandqueryresult.cpp --- soprano/backends/redland/redlandqueryresult.cpp 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/backends/redland/redlandqueryresult.cpp 2011-06-05 10:38:25.000000000 +0200 @@ -77,10 +77,9 @@ d->model = model; const char** names = 0; - int number = librdf_query_results_get_bindings_count(d->result); if ( !librdf_query_results_get_bindings( d->result, &names, 0 ) ) { - for ( int i = 0; i < number; i++ ) { - d->names.append( QString::fromUtf8( names[i] ) ); + for ( ; *names; names++ ) { + d->names.append( QString::fromUtf8( *names ) ); } } } diff -Naur soprano/ChangeLog soprano-2.6.51/ChangeLog --- soprano/ChangeLog 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/ChangeLog 2011-06-05 10:38:25.000000000 +0200 @@ -2,8 +2,6 @@ * Use the new Virtuoso parameter XAnyNormalization to use normalized accents for full-text searching by default. * Updated NAO Vocabulary namespace to include changes from SDO 0.7. * Added method LiteralValue::fromVariant which provides some useful type conversions. - * Fixed incorrect binding names counting in redland queries - * Ported Raptor serializer and parser plugins to Raptor2. 2.6.1 * Let onto2vocabularyclass convert dots in entity names to underscores to create valid C++ names. diff -Naur soprano/cmake/modules/FindRaptor.cmake soprano-2.6.51/cmake/modules/FindRaptor.cmake --- soprano/cmake/modules/FindRaptor.cmake 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/cmake/modules/FindRaptor.cmake 2011-06-05 10:38:25.000000000 +0200 @@ -5,13 +5,9 @@ # RAPTOR_LIBRARIES - Link these to use Raptor # RAPTOR_INCLUDE_DIR - Include directory for using Raptor # RAPTOR_DEFINITIONS - Compiler switches required for using Raptor -# -# Capabilities -# RAPTOR_HAVE_TRIG - Set if raptor has TRIG +# RAPTOR_VERSION - The Raptor version string -# (c) 2007-2011 Sebastian Trueg -# (c) 2011 Artem Serebriyskiy -# (c) 2011 Michael Jansen +# (c) 2007-2009 Sebastian Trueg # # Based on FindFontconfig Copyright (c) 2006,2007 Laurent Montel, # @@ -19,83 +15,89 @@ # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -MACRO ( FIND_RAPTOR libname libhints includehints ) - find_library_with_debug( - RAPTOR_LIBRARIES - WIN32_DEBUG_POSTFIX d - NAMES ${libname} - HINTS ${libhints}) - find_path( - RAPTOR_INCLUDE_DIR raptor.h - HINTS ${includehints} - PATH_SUFFIXES ${libname}) -ENDMACRO () - - - -# Check if we have cached results in case the last round was successful. -if ( NOT( RAPTOR_INCLUDE_DIR AND RAPTOR_LIBRARIES ) OR NOT RAPTOR_FOUND ) - - include(FindLibraryWithDebug) - include(MacroEnsureVersion) - find_package(PkgConfig) - - # Vy default look for version 2.0 - if (NOT Raptor_FIND_VERSION ) - set( Raptor_FIND_VERSION "2.0") - set( Raptor_FIND_VERSION_MAJOR "2" ) - set( Raptor_FIND_VERSION_MINOR "0" ) - endif () - - if ( Raptor_FIND_VERSION_MAJOR EQUAL "2" ) - - if ( NOT WIN32 ) - pkg_check_modules(PC_RAPTOR2 QUIET raptor2) - if ( PC_RAPTOR2_FOUND ) - set(RAPTOR_DEFINITIONS ${PC_RAPTOR2_CFLAGS_OTHER}) - set(RAPTOR_VERSION ${PC_RAPTOR2_VERSION} CACHE STRING "Raptor Version found" ) - endif () - endif () - find_raptor( raptor2 "${PC_RAPTOR2_LIBDIR};${PC_RAPTOR2_LIBRARY_DIRS}" "${PC_RAPTOR2_INCLUDEDIR};${PC_RAPTOR2_INCLUDE_DIRS}") - - elseif ( Raptor_FIND_VERSION_MAJOR EQUAL "1" ) - - if ( NOT WIN32 ) - pkg_check_modules(PC_RAPTOR QUIET raptor) - if ( PC_RAPTOR_FOUND ) - set(RAPTOR_DEFINITIONS ${PC_RAPTOR_CFLAGS_OTHER}) - set(RAPTOR_VERSION ${PC_RAPTOR_VERSION} CACHE STRING "Raptor Version found" ) - endif () - endif () - find_raptor( raptor "${PC_RAPTOR_LIBDIR};${PC_RAPTOR_LIBRARY_DIRS}" "${PC_RAPTOR_INCLUDEDIR};${PC_RAPTOR_INCLUDE_DIRS}") - - else () - - message( FATAL_ERROR "No idea how to check for version : ${Raptor_FIND_VERSION}") - - endif() - - if (RAPTOR_VERSION) - MACRO_ENSURE_VERSION("1.4.16" ${RAPTOR_VERSION} RAPTOR_HAVE_TRIG) - endif (RAPTOR_VERSION) - - mark_as_advanced(RAPTOR_INCLUDE_DIR RAPTOR_LIBRARIES) - -endif () # Check for cached values - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - Raptor - VERSION_VAR RAPTOR_VERSION - REQUIRED_VARS RAPTOR_LIBRARIES RAPTOR_INCLUDE_DIR) - -mark_as_advanced(RAPTOR_VERSION) - -if (NOT RAPTOR_FOUND AND Raptor_FIND_VERSION_MAJOR EQUAL "2" AND NOT Raptor_FIND_QUIET ) - pkg_check_modules(PC_RAPTOR QUIET raptor) - if (PC_RAPTOR_FOUND) - message( STATUS "You have raptor1 version ${PC_RAPTOR_VERSION} installed. Please update." ) - endif () -endif () +INCLUDE(MacroEnsureVersion) + +if(WINCE) +FIND_PROGRAM( + RAPTOR_CONFIG + NAMES raptor-config + PATHS ${HOST_BINDIR} NO_DEFAULT_PATH + ) +else(WINCE) +FIND_PROGRAM( + RAPTOR_CONFIG + NAMES raptor-config + ) +endif(WINCE) + +if(RAPTOR_CONFIG) + EXECUTE_PROCESS( + COMMAND ${RAPTOR_CONFIG} --version + OUTPUT_VARIABLE RAPTOR_VERSION + ) + if(RAPTOR_VERSION) + STRING(REPLACE "\n" "" RAPTOR_VERSION ${RAPTOR_VERSION}) + + MACRO_ENSURE_VERSION("1.4.16" ${RAPTOR_VERSION} RAPTOR_HAVE_TRIG) + + # extract include paths from raptor-config + EXECUTE_PROCESS( + COMMAND ${RAPTOR_CONFIG} --cflags + OUTPUT_VARIABLE raptor_CFLAGS_ARGS) + STRING( REPLACE " " ";" raptor_CFLAGS_ARGS ${raptor_CFLAGS_ARGS} ) + FOREACH( _ARG ${raptor_CFLAGS_ARGS} ) + IF(${_ARG} MATCHES "^-I") + STRING(REGEX REPLACE "^-I" "" _ARG ${_ARG}) + STRING( REPLACE "\n" "" _ARG ${_ARG} ) + LIST(APPEND raptor_INCLUDE_DIRS ${_ARG}) + ENDIF(${_ARG} MATCHES "^-I") + ENDFOREACH(_ARG) + + # extract lib paths from raptor-config + EXECUTE_PROCESS( + COMMAND ${RAPTOR_CONFIG} --libs + OUTPUT_VARIABLE raptor_CFLAGS_ARGS) + STRING( REPLACE " " ";" raptor_CFLAGS_ARGS ${raptor_CFLAGS_ARGS} ) + FOREACH( _ARG ${raptor_CFLAGS_ARGS} ) + IF(${_ARG} MATCHES "^-L") + STRING(REGEX REPLACE "^-L" "" _ARG ${_ARG}) + LIST(APPEND raptor_LIBRARY_DIRS ${_ARG}) + ENDIF(${_ARG} MATCHES "^-L") + ENDFOREACH(_ARG) + endif(RAPTOR_VERSION) +else(RAPTOR_CONFIG) + SET(RAPTOR_VERSION "1.0.0") +endif(RAPTOR_CONFIG) + +find_path(RAPTOR_INCLUDE_DIR raptor.h + PATHS + ${redland_INCLUDE_DIRS} + ${raptor_INCLUDE_DIRS} + /usr/X11/include + PATH_SUFFIXES redland + ) + +find_library(RAPTOR_LIBRARIES NAMES raptor libraptor + PATHS + ${raptor_LIBRARY_DIRS} + ) + +if (RAPTOR_INCLUDE_DIR AND RAPTOR_LIBRARIES) + set(RAPTOR_FOUND TRUE) +endif (RAPTOR_INCLUDE_DIR AND RAPTOR_LIBRARIES) + +if (RAPTOR_FOUND) + set(RAPTOR_DEFINITIONS ${raptor_CFLAGS}) + if (NOT Raptor_FIND_QUIETLY) + message(STATUS "Found Raptor ${RAPTOR_VERSION}: libs - ${RAPTOR_LIBRARIES}; includes - ${RAPTOR_INCLUDE_DIR}") + endif (NOT Raptor_FIND_QUIETLY) +else (RAPTOR_FOUND) + if (Raptor_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find Raptor") + endif (Raptor_FIND_REQUIRED) +endif (RAPTOR_FOUND) + +mark_as_advanced(RAPTOR_INCLUDE_DIR_TMP + RAPTOR_INCLUDE_DIR + RAPTOR_LIBRARIES) diff -Naur soprano/CMakeLists.txt soprano-2.6.51/CMakeLists.txt --- soprano/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200 @@ -7,7 +7,7 @@ ################## Soprano version ################################ set(CMAKE_SOPRANO_VERSION_MAJOR 2) set(CMAKE_SOPRANO_VERSION_MINOR 6) -set(CMAKE_SOPRANO_VERSION_RELEASE 52) +set(CMAKE_SOPRANO_VERSION_RELEASE 51) set(CMAKE_SOPRANO_VERSION_STRING "${CMAKE_SOPRANO_VERSION_MAJOR}.${CMAKE_SOPRANO_VERSION_MINOR}.${CMAKE_SOPRANO_VERSION_RELEASE}") diff -Naur soprano/parsers/raptor/CMakeLists.txt soprano-2.6.51/parsers/raptor/CMakeLists.txt --- soprano/parsers/raptor/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/parsers/raptor/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200 @@ -13,11 +13,13 @@ raptorparser.cpp ) +configure_file(raptor-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/raptor-config.h) + qt4_automoc(${raptor_parser_SRC}) -add_library(soprano_raptorparser MODULE ${raptor_parser_SRC}) +add_library(soprano_raptorparser MODULE ${raptor_parser_SRC}) -TARGET_LINK_LIBRARIES(soprano_raptorparser soprano raptor2 ${RAPTOR_LIBRARIES}) +TARGET_LINK_LIBRARIES(soprano_raptorparser soprano ${RAPTOR_LIBRARIES}) set_target_properties(soprano_raptorparser PROPERTIES DEFINE_SYMBOL MAKE_RAPTORPARSER_LIB diff -Naur soprano/parsers/raptor/raptor-config.h.cmake soprano-2.6.51/parsers/raptor/raptor-config.h.cmake --- soprano/parsers/raptor/raptor-config.h.cmake 1970-01-01 01:00:00.000000000 +0100 +++ soprano-2.6.51/parsers/raptor/raptor-config.h.cmake 2011-06-05 10:38:25.000000000 +0200 @@ -0,0 +1 @@ +#cmakedefine RAPTOR_HAVE_TRIG diff -Naur soprano/parsers/raptor/raptorparser.cpp soprano-2.6.51/parsers/raptor/raptorparser.cpp --- soprano/parsers/raptor/raptorparser.cpp 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/parsers/raptor/raptorparser.cpp 2011-06-05 10:38:25.000000000 +0200 @@ -3,7 +3,7 @@ * This file is part of Soprano Project * * Copyright (C) 2006 Duncan Mac-Vicar - * Copyright (C) 2007,2011 Sebastian Trueg + * Copyright (C) 2007 Sebastian Trueg * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -22,13 +22,14 @@ */ #include "raptorparser.h" +#include "raptor-config.h" #include "util/simplestatementiterator.h" #include "statement.h" #include "locator.h" #include "error.h" -#include +#include #include #include @@ -39,71 +40,88 @@ #include +namespace { + class RaptorInitHelper + { + public: + RaptorInitHelper() { + raptor_init(); + } + ~RaptorInitHelper() { + raptor_finish(); + } + }; +} + Q_EXPORT_PLUGIN2(soprano_raptorparser, Soprano::Raptor::Parser) namespace { - void raptorLogHandler(void *userData,raptor_log_message *message) + // for some strange reason raptor <= 1.4.15 can only handle application/turtle when parsing + // and application/x-turtle when serializing, but not the other way around + QString mimeTypeString( Soprano::RdfSerialization s, const QString& userSerialization ) + { +#ifndef RAPTOR_HAVE_TRIG + if ( s == Soprano::SerializationTurtle ) { + return "application/turtle"; // x-turtle does not work.... + } + else +#endif + { + return serializationMimeType( s, userSerialization ); + } + } + + + void raptorMessageHandler( void* userData, raptor_locator* locator, const char* message ) { Soprano::Raptor::Parser* p = static_cast( userData ); - if ( message->locator ) { - p->setError( Soprano::Error::ParserError( Soprano::Error::Locator( message->locator->line, message->locator->column, message->locator->byte ), - QString::fromUtf8( message->text ), + if ( locator ) { + p->setError( Soprano::Error::ParserError( Soprano::Error::Locator( locator->line, locator->column, locator->byte ), + QString::fromUtf8( message ), Soprano::Error::ErrorParsingFailed ) ); } else { - p->setError( Soprano::Error::Error( QString::fromUtf8( message->text ), Soprano::Error::ErrorUnknown ) ); + p->setError( Soprano::Error::Error( QString::fromUtf8( message ), Soprano::Error::ErrorUnknown ) ); } } - Soprano::Node convertNode( raptor_term * term ) - { - if(!term) { - return Soprano::Node(); - } - switch( term->type ) { - case RAPTOR_TERM_TYPE_URI: { - return Soprano::Node::createResourceNode( - QString::fromUtf8( ( char* )raptor_uri_as_string( term->value.uri ) ) ); - } - - case RAPTOR_TERM_TYPE_BLANK: { - return Soprano::Node::createBlankNode( - QString::fromUtf8( ( const char* )(term->value.blank.string) ) ); - } - - case RAPTOR_TERM_TYPE_LITERAL: { - if ( term->value.literal.datatype ) { - return Soprano::Node::createLiteralNode( - Soprano::LiteralValue::fromString( - QString::fromUtf8( ( const char* )term->value.literal.string ), - QString::fromUtf8( - ( char* )raptor_uri_as_string(term->value.literal.datatype ) ) - ) - ); + Soprano::Node convertNode( const void* data, raptor_identifier_type type, + raptor_uri* objectLiteralDatatype = 0, const unsigned char* objectLiteralLanguage = 0 ) + { + switch( type ) { + case RAPTOR_IDENTIFIER_TYPE_RESOURCE: + case RAPTOR_IDENTIFIER_TYPE_PREDICATE: + case RAPTOR_IDENTIFIER_TYPE_ORDINAL: + return Soprano::Node::createResourceNode( QString::fromUtf8( ( char* )raptor_uri_as_string( ( raptor_uri* )data ) ) ); + + case RAPTOR_IDENTIFIER_TYPE_ANONYMOUS: + return Soprano::Node::createBlankNode( QString::fromUtf8( ( const char* )data ) ); + + case RAPTOR_IDENTIFIER_TYPE_LITERAL: + case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: + if ( objectLiteralDatatype ) { + return Soprano::Node::createLiteralNode( Soprano::LiteralValue::fromString( QString::fromUtf8( ( const char* )data ), + QString::fromUtf8( ( char* )raptor_uri_as_string( objectLiteralDatatype ) ) ) ); } else { - return Soprano::Node::createLiteralNode( - Soprano::LiteralValue::createPlainLiteral( - QString::fromUtf8( ( const char* )term->value.literal.string ), - QString::fromUtf8( ( const char* )term->value.literal.language ) ) ); + return Soprano::Node::createLiteralNode( Soprano::LiteralValue::createPlainLiteral( QString::fromUtf8( ( const char* )data ), + QString::fromUtf8( ( const char* )objectLiteralLanguage ) ) ); } - } default: return Soprano::Node(); } - - // make gcc shut up - return Soprano::Node(); } + Soprano::Statement convertTriple( const raptor_statement* triple ) { - return Soprano::Statement( convertNode( triple->subject ), - convertNode( triple->predicate ), - convertNode( triple->object ), - convertNode( triple->graph ) ); + return Soprano::Statement( convertNode( triple->subject, triple->subject_type ), + convertNode( triple->predicate, triple->predicate_type ), + convertNode( triple->object, triple->object_type, + triple->object_literal_datatype, + triple->object_literal_language ) ); } @@ -114,48 +132,47 @@ }; - void raptorTriplesHandler( void* userData, raptor_statement* triple ) + void raptorTriplesHandler( void* userData, const raptor_statement* triple ) { - Q_ASSERT(userData); ParserData* pd = static_cast( userData ); - pd->statements.append( convertTriple( triple ) ); + Soprano::Statement s = convertTriple( triple ); +// qDebug() << "got triple: " << s; + s.setContext( pd->currentContext ); + pd->statements.append( s ); } -} -class Soprano::Raptor::Parser::Private -{ -public: - raptor_world * world; - mutable QMutex mutex; -}; + void raptorGraphHandler( void* userData, raptor_uri* graph ) + { + Soprano::Node context = Soprano::Node::createResourceNode( QString::fromUtf8( ( char* )raptor_uri_as_string( graph ) ) ); + ParserData* pd = static_cast( userData ); + pd->currentContext = context; +// qDebug() << "got graph: " << context; + } +} Soprano::Raptor::Parser::Parser() : QObject(), - Soprano::Parser( "raptor" ), - d(new Private()) + Soprano::Parser( "raptor" ) { - d->world = raptor_new_world(); - raptor_world_open(d->world); - Q_ASSERT(d->world); } Soprano::Raptor::Parser::~Parser() { - raptor_free_world(d->world); - delete d; } Soprano::RdfSerializations Soprano::Raptor::Parser::supportedSerializations() const { - return( SerializationRdfXml - |SerializationNTriples - |SerializationTurtle - |SerializationTrig - ); + return( SerializationRdfXml + |SerializationNTriples + |SerializationTurtle +#ifdef RAPTOR_HAVE_TRIG + |SerializationTrig +#endif + ); } @@ -163,14 +180,13 @@ const QString& userSerialization ) const { // create the parser - const QString mimeType = Soprano::serializationMimeType( serialization, userSerialization ); + QString mimeType = mimeTypeString( serialization, userSerialization ); raptor_parser* parser = 0; if ( serialization == Soprano::SerializationNTriples ) { - parser = raptor_new_parser(d->world,"ntriples"); // mimetype for ntriple is text/plain which is useless for the method below + parser = raptor_new_parser( "ntriples" ); // mimetype for ntriple is text/plain which is useless for the method below } else { - parser = raptor_new_parser_for_content( d->world, - 0, + parser = raptor_new_parser_for_content( 0, mimeType.toLatin1().data(), 0, 0, @@ -178,14 +194,16 @@ } if ( !parser ) { - qDebug() << "(Soprano::Raptor::Parser) no parser for serialization " << Soprano::serializationMimeType( serialization, userSerialization ); - setError( QString( "Failed to create parser for serialization %1" ).arg( Soprano::serializationMimeType( serialization, userSerialization ) ) ); + qDebug() << "(Soprano::Raptor::Parser) no parser for serialization " << mimeTypeString( serialization, userSerialization ); + setError( QString( "Failed to create parser for serialization %1" ).arg( mimeTypeString( serialization, userSerialization ) ) ); return 0; } - // set the error handling method + // set the erro handling method Parser* that = const_cast( this ); - raptor_world_set_log_handler(d->world, that, raptorLogHandler); + raptor_set_fatal_error_handler( parser, that, raptorMessageHandler ); + raptor_set_error_handler( parser, that, raptorMessageHandler ); + raptor_set_warning_handler( parser, that, raptorMessageHandler ); return parser; } @@ -205,6 +223,48 @@ setError( QString( "Could not open file %1 for reading." ).arg( filename ) ); return StatementIterator(); } + +// clearError(); + +// raptor_parser* parser = createParser( serialization, userSerialization ); +// if ( !parser ) { +// return StatementIterator(); +// } + +// // prepare the container for the parsed data +// QList statements; +// raptor_set_statement_handler( parser, &statements, raptorTriplesHandler ); + +// // start the atual parsing +// QUrl uri( QUrl::fromLocalFile( filename ) ); +// if ( uri.scheme().isEmpty() ) { +// // we need to help the stupid librdf file url handling +// uri.setScheme("file"); +// } +// raptor_uri* raptorBaseUri = 0; +// if ( !baseUri.toString().isEmpty() ) { +// raptorBaseUri = raptor_new_uri( (unsigned char *) baseUri.toString().toUtf8().data() ); +// } +// raptor_uri* raptorUri = raptor_new_uri( (unsigned char *) uri.toString().toUtf8().data() ); +// if ( !raptorUri ) { +// setError( QLatin1String( "Internal: Failed to create raptor_uri instance for '%1'" ).arg( uri ) ); +// return StatementIterator(); +// } + +// int r = raptor_parse_uri( parser, raptorUri, raptorBaseUri ); + +// raptor_free_parser( parser ); +// raptor_free_uri( raptorUri ); +// if ( raptorBaseUri ) { +// raptor_free_uri( raptorBaseUri ); +// } + +// if ( r == 0 ) { +// return SimpleStatementIterator( statements ); +// } +// else { +// return StatementIterator(); +// } } @@ -219,12 +279,14 @@ } -Soprano::StatementIterator Soprano::Raptor::Parser::parseStream( QTextStream& stream, - const QUrl& baseUri, - RdfSerialization serialization, - const QString& userSerialization ) const +Soprano::StatementIterator +Soprano::Raptor::Parser::parseStream( QTextStream& stream, + const QUrl& baseUri, + RdfSerialization serialization, + const QString& userSerialization ) const { - QMutexLocker lock( &d->mutex ); + QMutexLocker lock( &m_mutex ); + RaptorInitHelper raptorInitHelper; clearError(); @@ -235,19 +297,22 @@ // prepare the container for the parsed data ParserData data; - raptor_parser_set_statement_handler( parser, &data, raptorTriplesHandler ); + raptor_set_statement_handler( parser, &data, raptorTriplesHandler ); +#ifdef RAPTOR_HAVE_TRIG + raptor_set_graph_handler( parser, &data, raptorGraphHandler ); +#endif // start the atual parsing raptor_uri* raptorBaseUri = 0; if ( baseUri.isValid() ) { - raptorBaseUri = raptor_new_uri( d->world,(unsigned char *) baseUri.toString().toUtf8().data() ); + raptorBaseUri = raptor_new_uri( (unsigned char *) baseUri.toString().toUtf8().data() ); } else { - raptorBaseUri = raptor_new_uri( d->world, (unsigned char *) "http://soprano.sourceforge.net/dummyBaseUri" ); + raptorBaseUri = raptor_new_uri( (unsigned char *) "http://soprano.sourceforge.net/dummyBaseUri" ); } clearError(); - if ( raptor_parser_parse_start( parser, raptorBaseUri ) != 0 ) { + if ( raptor_start_parse( parser, raptorBaseUri ) ) { if ( !lastError() ) { ErrorCache::setError( QLatin1String( "Failed to start parsing." ) ); } @@ -266,10 +331,7 @@ while ( !dev->atEnd() ) { qint64 r = dev->read( buf.data(), buf.size() ); if ( r <= 0 || - raptor_parser_parse_chunk( parser, ( const unsigned char* )buf.data(), r, 0 ) ) { - // parse_chunck return failure code. - // Call it with END=true and then free - raptor_parser_parse_chunk(parser,0,0,/*END=*/1); + raptor_parse_chunk( parser, ( const unsigned char* )buf.data(), r, 0 ) ) { raptor_free_parser( parser ); if ( raptorBaseUri ) { raptor_free_uri( raptorBaseUri ); @@ -282,10 +344,7 @@ while ( !stream.atEnd() ) { QString buf = stream.read( bufSize ); QByteArray utf8Data = buf.toUtf8(); - if ( raptor_parser_parse_chunk( parser, ( const unsigned char* )utf8Data.data(), utf8Data.length(), 0 ) ) { - // parse_chunck return failure code. - // Call it with END=true and then free - raptor_parser_parse_chunk(parser,0,0,/*END=*/1); + if ( raptor_parse_chunk( parser, ( const unsigned char* )utf8Data.data(), utf8Data.length(), 0 ) ) { raptor_free_parser( parser ); if ( raptorBaseUri ) { raptor_free_uri( raptorBaseUri ); @@ -294,8 +353,7 @@ } } } - // Call parse_chunk with END=true - raptor_parser_parse_chunk( parser, 0, 0, 1 ); + raptor_parse_chunk( parser, 0, 0, 1 ); raptor_free_parser( parser ); if ( raptorBaseUri ) { diff -Naur soprano/parsers/raptor/raptorparser.h soprano-2.6.51/parsers/raptor/raptorparser.h --- soprano/parsers/raptor/raptorparser.h 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/parsers/raptor/raptorparser.h 2011-06-05 10:38:25.000000000 +0200 @@ -29,11 +29,13 @@ #include "parser.h" -#include +#include + namespace Soprano { namespace Raptor { - class Parser : public QObject, public Soprano::Parser { + class Parser : public QObject, public Soprano::Parser + { Q_OBJECT Q_INTERFACES(Soprano::Parser) @@ -41,7 +43,7 @@ Parser(); ~Parser(); - RdfSerializations supportedSerializations() const; + RdfSerializations supportedSerializations() const; StatementIterator parseFile( const QString& filename, const QUrl& baseUri, @@ -62,10 +64,7 @@ raptor_parser* createParser( RdfSerialization serialization, const QString& userSerialization = QString() ) const; - class Private; - Private * d; - - + mutable QMutex m_mutex; }; } } diff -Naur soprano/serializers/raptor/CMakeLists.txt soprano-2.6.51/serializers/raptor/CMakeLists.txt --- soprano/serializers/raptor/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/serializers/raptor/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200 @@ -9,8 +9,13 @@ ${RAPTOR_INCLUDE_DIR} ) +include(CheckFunctionExists) set(CMAKE_REQUIRED_INCLUDES ${RAPTOR_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${RAPTOR_LIBRARIES}) +check_function_exists( raptor_new_iostream_from_handler2 HAVE_IOSTREAM_HANDLER2 ) +if(HAVE_IOSTREAM_HANDLER2) + add_definitions(-DHAVE_IOSTREAM_HANDLER2) +endif(HAVE_IOSTREAM_HANDLER2) set(raptor_serializer_SRC raptorserializer.cpp diff -Naur soprano/serializers/raptor/raptorserializer.cpp soprano-2.6.51/serializers/raptor/raptorserializer.cpp --- soprano/serializers/raptor/raptorserializer.cpp 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/serializers/raptor/raptorserializer.cpp 2011-06-05 10:38:25.000000000 +0200 @@ -38,135 +38,54 @@ class RaptorInitHelper { public: - raptor_world* world; - RaptorInitHelper() { - world = raptor_new_world(); - raptor_world_open(world); + raptor_init(); } ~RaptorInitHelper() { - raptor_free_world(world); + raptor_finish(); } }; - /* Probably unnecessary for serializer*/ - /* - QString mimeTypeString( Soprano::RdfSerialization s, const QString& userSerialization ) - { - if ( s == Soprano::SerializationTurtle ) { - return "application/turtle"; // x-turtle does not work.... - } - else { - return serializationMimeType( s, userSerialization ); - } - }*/ - - raptor_term * convertNode( raptor_world * world, const Soprano::Node& node) + bool convertNode( const Soprano::Node& node, const void** data, raptor_identifier_type* type, raptor_uri** dataType = 0, const unsigned char** lang = 0 ) { - raptor_term * answer = 0; - /* According to documentation, raptor_new_term family takes copy of - * all given input parameters - */ if ( node.isResource() ) { - raptor_uri * uri = raptor_new_uri(world, ( const unsigned char* )node.uri().toEncoded().data() ); - answer = raptor_new_term_from_uri(world,uri); - - raptor_free_uri(uri); + *data = raptor_new_uri( ( const unsigned char* )node.uri().toEncoded().data() ); + *type = RAPTOR_IDENTIFIER_TYPE_RESOURCE; + return true; } else if ( node.isBlank() ) { - answer = raptor_new_term_from_blank( - world, (const unsigned char*)node.identifier().toUtf8().data() ); + *data = qstrdup( node.identifier().toUtf8().data() ); + *type = RAPTOR_IDENTIFIER_TYPE_ANONYMOUS; + return true; } else if ( node.isLiteral() ) { - // Because QByteArray.data() is valid as long as QByteArray itself is - // alive, we store langBA ( and others _x_BA untill function exits - - //const unsigned char * literal = 0; - QByteArray langBA; - const unsigned char * lang = 0; - raptor_uri * datatype = 0; - + *data = qstrdup( node.toString().toUtf8().data() ); if ( node.literal().isPlain() ) { if ( !node.language().isEmpty() ) - langBA = node.language().toUtf8(); - lang = ( const unsigned char* )( langBA.constData() ); + *lang = ( unsigned char* )qstrdup( ( const char* )node.language().toUtf8().data() ); } else { - datatype = raptor_new_uri( world, ( const unsigned char* )node.dataType().toEncoded().data() ); + *dataType = raptor_new_uri( ( const unsigned char* )node.dataType().toEncoded().data() ); } - - // Now we costructs statement - answer = raptor_new_term_from_literal(world,(const unsigned char*)node.literal().toByteArray().constData(),datatype,lang); - - // And free unnecessary resources - if ( datatype) - raptor_free_uri(datatype); - + *type = RAPTOR_IDENTIFIER_TYPE_LITERAL; + return true; } - return answer; + return false; } - raptor_statement* convertStatement(raptor_world * world, const Soprano::Statement& statement ) + raptor_statement* convertStatement( const Soprano::Statement& statement ) { - // Get terms - raptor_term * subject_term = 0, *object_term = 0, * predicate_term = 0; - raptor_term * graph_term = 0; - - subject_term = convertNode(world,statement.subject()); - if ( !subject_term) { - qDebug() << "Failed to convert subject to raptor_term"; - return 0; - } - - predicate_term = convertNode(world,statement.predicate()); - if (!predicate_term) { - qDebug() << "Failed to convert predicate to raptor_term"; - raptor_free_term(subject_term); - return 0; - } - - object_term = convertNode(world,statement.object()); - if (!object_term) { - qDebug() << "Failed to convert object to raptor_term"; - raptor_free_term(subject_term); - raptor_free_term(predicate_term); - return 0; - } - - if ( !statement.context().isEmpty() ) { - graph_term = convertNode(world,statement.context()); - if(!graph_term) { - qDebug() << "Failed to convert graph/context to raptor_term. Node is" << statement.context(); - raptor_free_term(subject_term); - raptor_free_term(predicate_term); - raptor_free_term(object_term); - return 0; - } - } - - - raptor_statement* s = raptor_new_statement_from_nodes( - world, - subject_term, - predicate_term, - object_term, - graph_term); - - if (!s) { - qDebug() << "Failed to build raptor_statement from terms"; - raptor_free_term(subject_term); - raptor_free_term(predicate_term); - raptor_free_term(object_term); - raptor_free_term(graph_term); - } - + raptor_statement* s = new raptor_statement; + memset( s, 0, sizeof( raptor_statement ) ); + convertNode( statement.subject(), &s->subject, &s->subject_type ); + convertNode( statement.predicate(), &s->predicate, &s->predicate_type ); + convertNode( statement.object(), &s->object, &s->object_type, &s->object_literal_datatype, &s->object_literal_language ); return s; } - /* void free_node( const void* data, raptor_identifier_type type ) { switch( type ) { @@ -190,7 +109,6 @@ free( ( char* )s->object_literal_language ); delete s; } - */ int raptorIOStreamWriteByte( void* data, const int byte ) @@ -203,7 +121,6 @@ else { ( *s ) << ( char )byte; } - //qDebug() << "Write char:" << (char)(byte); return 0; } @@ -223,7 +140,6 @@ raptorIOStreamWriteByte( data, p[i] ); } } - //qDebug() << "Write string: " << p; break; } default: @@ -237,36 +153,15 @@ Q_EXPORT_PLUGIN2(soprano_raptorserializer, Soprano::Raptor::Serializer) - -/* We can not rely on RaptorInitHelper anymore because - * we need raptor_world in supportedUserSerializations. - * Instead of constantly creating new raptor_world just to - * detect user supported serializations, it is easier to - * embed raptor_world into class. - * And we can not declare raptor_world as a member of - * Serializer directly, because raptor_world is a typedef, - * not a class. So it can not be forward declarated - */ -class Soprano::Raptor::Serializer::Private -{ - public: - raptor_world * world; -}; - Soprano::Raptor::Serializer::Serializer() : QObject(), Soprano::Serializer( "raptor" ) { - this->d = new Private(); - this->d->world = raptor_new_world(); - raptor_world_open(d->world); } Soprano::Raptor::Serializer::~Serializer() { - raptor_free_world(d->world); - delete d; } @@ -279,19 +174,17 @@ QStringList Soprano::Raptor::Serializer::supportedUserSerializations() const { QStringList sl; - const raptor_syntax_description * serializer_descr = 0; - for ( int i = 0; 1; ++i ) { - serializer_descr = - raptor_world_get_serializer_description(d->world,i); - - /* raptor_world_get_serializer_description will return - * NULL when conter runs out of bonds and there is no - * more serializers - */ - if (!serializer_descr) - break; - - sl << QString::fromUtf8( serializer_descr->names[0] ); + int i = 0; + const char* name = 0; + const char* label = 0; + const char* mimeType = 0; + const unsigned char* uri = 0; + while ( !raptor_serializers_enumerate( i, + &name, + &label, + &mimeType, + &uri ) ) { + sl << QString::fromUtf8( name ); ++i; } return sl; @@ -305,43 +198,28 @@ { clearError(); - raptor_world * world = this->d->world; + RaptorInitHelper raptorHelper; raptor_serializer* serializer = 0; - QString mimeType = serializationMimeType(serialization,userSerialization); - if ( serialization == SerializationRdfXml ) { - serializer = raptor_new_serializer( world, "rdfxml-abbrev" ); // we always want the abbreviated xmlrdf + serializer = raptor_new_serializer( "rdfxml-abbrev" ); // we always want the abbreviated xmlrdf } else { - const raptor_syntax_description * serializer_descr = 0; for ( int i = 0; 1; ++i ) { - serializer_descr = - raptor_world_get_serializer_description(world,i); - - /* raptor_world_get_serializer_description will return - * NULL when conter runs out of bonds and there is no - * more serializers - */ - if (!serializer_descr) + const char* syntax_name = 0; + const char* syntax_label = 0; + const char* mime_type = 0; + const unsigned char* uri_string = 0; + if ( raptor_serializers_enumerate( i, + &syntax_name, + &syntax_label, + &mime_type, + &uri_string ) ) break; - - /* In serializer_descr->mime_types we have a array of pairs - * (mime_type,Q) of mime_type for this syntax. It looks like - * we can ignore Q value in this case - * Acording to documentation, this array can have zero elements - */ - for( int mt_number = 0; mt_number < serializer_descr->mime_types_count; - mt_number++) - { - const char * mime_type_N = serializer_descr->mime_types[mt_number].mime_type; - if ( !qstrcmp( serializationMimeType( serialization, userSerialization ).toLatin1().data(), mime_type_N ) ) { - serializer = raptor_new_serializer( world, serializer_descr->names[0] ); - break; - } - } - if ( serializer ) + if ( !qstrcmp( serializationMimeType( serialization, userSerialization ).toLatin1().data(), mime_type ) ) { + serializer = raptor_new_serializer( syntax_name ); break; + } } } @@ -354,8 +232,8 @@ QHash namespaces = prefixes(); for ( QHash::const_iterator pfit = namespaces.constBegin(); pfit != namespaces.constEnd(); ++pfit ) { - raptor_uri* ns = raptor_new_uri( world,reinterpret_cast( pfit.value().toEncoded().data() ) ); - raptor_serializer_set_namespace( serializer, + raptor_uri* ns = raptor_new_uri( reinterpret_cast( pfit.value().toEncoded().data() ) ); + raptor_serialize_set_namespace( serializer, ns, ( unsigned char* )pfit.key().toLatin1().data() ); raptor_free_uri( ns ); @@ -363,53 +241,42 @@ bool success = true; - raptor_iostream_handler raptorStreamHandler; - // ATTENTION: Raptor documentation is incorrect! Always set - // version to 2 and raptor_iostream_calculate_modes internal - // call will correctly determine operation mode ( read,write,readwrite) - raptorStreamHandler.version = 2; - raptorStreamHandler.init = 0; - raptorStreamHandler.finish = 0; - raptorStreamHandler.write_byte = raptorIOStreamWriteByte; - raptorStreamHandler.write_bytes = raptorIOStreamWriteBytes; - raptorStreamHandler.write_end = 0; - raptorStreamHandler.read_bytes = 0; - raptorStreamHandler.read_eof = 0; - - raptor_iostream* raptorStream = raptor_new_iostream_from_handler( - world, - &stream, - &raptorStreamHandler - ); - - if (!raptorStream) { - qDebug() << "Can not create raptor iostream"; - raptor_free_serializer(serializer); - return false; - } +#ifdef HAVE_IOSTREAM_HANDLER2 + raptor_iostream_handler2 raptorStreamHandler = { + 2, + 0, + 0, + raptorIOStreamWriteByte, + raptorIOStreamWriteBytes, + 0, + 0, + 0 + }; + raptor_iostream* raptorStream = raptor_new_iostream_from_handler2( &stream, + &raptorStreamHandler ); +#else + raptor_iostream_handler raptorStreamHandler = { + 0, + 0, + raptorIOStreamWriteByte, + raptorIOStreamWriteBytes, + 0 + }; + raptor_iostream* raptorStream = raptor_new_iostream_from_handler( &stream, + &raptorStreamHandler ); +#endif // raptor_serialize_start takes ownership of raptorStream - raptor_serializer_start_to_iostream( serializer,0, raptorStream ); + raptor_serialize_start( serializer, 0, raptorStream ); while ( it.next() ) { - raptor_statement * rs = convertStatement(world, *it ); - if (rs) { - //qDebug() << "Serializing statement: " << *it; - raptor_serializer_serialize_statement(serializer, rs ); - raptor_free_statement( rs ); - } - else { - qDebug() << "Fail to convert Soprano::Statement " << - *it << - " to raptor_statement"; - success = false; - break; - } + raptor_statement* rs = convertStatement( *it ); + raptor_serialize_statement( serializer, rs ); + free_statement( rs ); } - raptor_serializer_serialize_end( serializer ); + raptor_serialize_end( serializer ); raptor_free_serializer( serializer ); - raptor_free_iostream(raptorStream); return success; } diff -Naur soprano/serializers/raptor/raptorserializer.h soprano-2.6.51/serializers/raptor/raptorserializer.h --- soprano/serializers/raptor/raptorserializer.h 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/serializers/raptor/raptorserializer.h 2011-06-05 10:38:25.000000000 +0200 @@ -28,6 +28,7 @@ #include "serializer.h" + namespace Soprano { namespace Raptor { class Serializer : public QObject, public Soprano::Serializer @@ -46,12 +47,6 @@ QTextStream& stream, RdfSerialization serialization, const QString& userSerialization = QString() ) const; - private: - /* See source file comments, that explain why it is necessary to - * use Private class and RaptorInitHelper is not succifient anymore - */ - class Private; - Private * d; }; } } diff -Naur soprano/soprano/inference/inferenceruleset.cpp soprano-2.6.51/soprano/inference/inferenceruleset.cpp --- soprano/soprano/inference/inferenceruleset.cpp 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/soprano/inference/inferenceruleset.cpp 2011-06-05 10:38:25.000000000 +0200 @@ -27,10 +27,7 @@ #include #include -#ifdef Q_OS_WIN -#include -#include -#endif + class Soprano::Inference::RuleSet::Private : public QSharedData { @@ -141,22 +138,5 @@ RuleParser parser; parser.parseFile( path ); -#ifdef Q_OS_WIN - // Additionally try to look up the rules based on the runtime Path if - // they can not be found at the install prefix - if (!parser.rules().count()) { - path = QDir( QCoreApplication::applicationDirPath() ).absoluteFilePath( ".." ); - path += "/share/soprano/rules/"; - - switch( set ) { - case RDFS: - path += "rdfs.rules"; - break; - case NRL: - path += "nrl.rules"; - break; - } - } -#endif return parser.rules(); } diff -Naur soprano/soprano/sopranodirs.cpp soprano-2.6.51/soprano/sopranodirs.cpp --- soprano/soprano/sopranodirs.cpp 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/soprano/sopranodirs.cpp 2011-06-05 10:38:25.000000000 +0200 @@ -28,12 +28,8 @@ #include #include -#ifdef Q_OS_WIN -static inline QString getWinPrefix() -{ - // returns the parent directory of the application - return QDir( QCoreApplication::applicationDirPath() ).absoluteFilePath( ".." ); -} + +#if defined _WIN32 || defined _WIN64 #define PATH_SEPARATOR ';' #else #define PATH_SEPARATOR ':' @@ -127,8 +123,6 @@ paths << QLatin1String( SOPRANO_PREFIX"/lib"SOPRANO_LIB_SUFFIX ); #ifdef Q_OS_WIN paths << QLatin1String( SOPRANO_PREFIX"/bin" ); - paths << getWinPrefix() + QLatin1String( "/bin" ); - paths << getWinPrefix() + QLatin1String( "/lib"SOPRANO_LIB_SUFFIX ); #else paths << QLatin1String( "/usr/lib"SOPRANO_LIB_SUFFIX ); paths << QLatin1String( "/usr/local/lib"SOPRANO_LIB_SUFFIX ); @@ -142,9 +136,6 @@ { QStringList paths; paths << QLatin1String( SOPRANO_PREFIX"/share" ) -#ifdef Q_OS_WIN - << getWinPrefix() + QLatin1String( "/share" ) -#endif << Soprano::envDirList( "SOPRANO_DIRS" ) << Soprano::envDirList( "XDG_DATA_DIRS" ); return paths; @@ -155,9 +146,6 @@ { QStringList paths; paths << QLatin1String( SOPRANO_PREFIX"/bin" ) -#ifdef Q_OS_WIN - << getWinPrefix() + QLatin1String( "/bin" ) -#endif << envDirList( "PATH" ); return paths; } diff -Naur soprano/test/CMakeLists.txt soprano-2.6.51/test/CMakeLists.txt --- soprano/test/CMakeLists.txt 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/test/CMakeLists.txt 2011-06-05 10:38:25.000000000 +0200 @@ -135,12 +135,6 @@ target_link_libraries(parsertest soprano ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY}) add_test(parsertest ${EXECUTABLE_OUTPUT_PATH}/parsertest) -# serializer test -qt4_automoc(serializetest serializetest.cpp) -add_executable(serializertest serializetest.cpp) -target_link_libraries(serializertest soprano ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY}) -add_test(serializertest ${EXECUTABLE_OUTPUT_PATH}/serializertest) - # Error test qt4_automoc(errortest errortest.cpp) add_executable(errortest errortest.cpp) diff -Naur soprano/test/serializetest.cpp soprano-2.6.51/test/serializetest.cpp --- soprano/test/serializetest.cpp 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/test/serializetest.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,167 +0,0 @@ -/* - * This file is part of Soprano Project. - * - * Copyright (C) 2007-2008 Sebastian Trueg - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "serializetest.h" -#include "config-testdata.h" - -#include "serializer.h" -#include "parser.h" -#include "pluginmanager.h" -#include "statementiterator.h" -#include "simplestatementiterator.h" -#include "statement.h" -#include "vocabulary.h" - -#include -#include -#include - - -using namespace Soprano; - -#include "testdata.h" - - -void SerializerTest::init() -{ -#if 0 - // Init reference statements list - const Parser * parser = PluginManager::instance()->discoverParserForSerialization(SerializationTrig); - QVERIFY(parser); - StatementIterator refIt = parser->parseFile( - SOPRANO_TEST_DATA_DIR"/trig-testdata.trig", - QUrl("http://soprano.sf.net/testdata/"), - SerializationTrig); - this->referenceStatements = refIt.allStatements(); -#endif -} - -Q_DECLARE_METATYPE( Soprano::RdfSerialization ) - -void SerializerTest::testSerializer_data() -{ - - QTest::addColumn( "serialization" ); - QTest::addColumn( "withContext" ); - - QTest::newRow("rdf_xml") << SerializationRdfXml << false; - QTest::newRow("turtle") << SerializationTurtle << false; - QTest::newRow("trig") << SerializationTrig << true; -} - - - -void SerializerTest::testSerializer() -{ - QFETCH( RdfSerialization, serialization ); - QFETCH( bool, withContext ); - - //qDebug() << "Serialization: " << serializationMimeType(serialization); - QList serializers = PluginManager::instance()->allSerializers(); - - - /* Step 1 - create reference statements */ - QList referenceStatements = testData(withContext); - //QList testStatements = testData( withContext ); - - Q_FOREACH( const Serializer * serializer, serializers ) { - if ( serializer->supportsSerialization( serialization ) ) { - // Find if we have Parser for this serialization, to parse data back. - // If not, then oops ) - const Parser * back_parser = PluginManager::instance()->discoverParserForSerialization(serialization); - if ( !back_parser ) { - qDebug() << "We can not found parser for" << - serializationMimeType(serialization) << - " Skipping it"; - continue; - } - - // Now serialize reference data - QByteArray data_array; - QTextStream serializationStorage(&data_array,QIODevice::ReadWrite); - - bool result = serializer->serialize( - /*what*/Util::SimpleStatementIterator(referenceStatements), - /*where*/serializationStorage, - /*type*/serialization - ); - QVERIFY(result); - - //qDebug() << "Serialization storage: " << data_array; - - // Now parse gained text stream back - QTextStream readStorageStream(&data_array, QIODevice::ReadOnly); - StatementIterator it = back_parser->parseStream( - readStorageStream, - QUrl("http://soprano.sf.net/testdata/"), - serialization); - - QList all = it.allStatements(); - - - // Now compare recieved with reference - QCOMPARE( all.count(), referenceStatements.count() ); - - Q_FOREACH( Statement s, referenceStatements ) { - bool contains = all.contains(s); - if ( !contains ) { - qDebug() << "Not found in parsed: " << s; - } - - QVERIFY( contains ); - } - - } - } -} - - -#if 0 -void SerializerTest::testEncoding() -{ - // FIXME: provide test data for all supported encodings (no big problem so far since we only have the raptor parser) - - // parse both files, same content, different encodings and compare the results - const QString utf8File = SOPRANO_TEST_DATA_DIR"/rdf_xml-testdata-utf8.rdf"; - const QString isoFile = SOPRANO_TEST_DATA_DIR"/rdf_xml-testdata-iso8859.rdf"; - - const Soprano::Parser* parser = PluginManager::instance()->discoverParserForSerialization( SerializationRdfXml ); - if ( parser ) { - QList utf8Statements = parser->parseFile( utf8File, QUrl(), SerializationRdfXml ).allStatements(); - QList isoStatements = parser->parseFile( isoFile, QUrl(), SerializationRdfXml ).allStatements(); - - // brute force comparision, time is not an issue, no need to get inventive. ;) - foreach( const Statement& s, utf8Statements ) { - if ( !isoStatements.contains( s ) ) qDebug() << s; - QVERIFY( isoStatements.contains( s ) ); - } - foreach( const Statement& s, isoStatements ) { - if ( !utf8Statements.contains( s ) ) qDebug() << s; - QVERIFY( utf8Statements.contains( s ) ); - } - } -} -#endif - -QTEST_MAIN( SerializerTest ) - -#include "serializetest.moc" - diff -Naur soprano/test/serializetest.h soprano-2.6.51/test/serializetest.h --- soprano/test/serializetest.h 2011-07-19 18:49:58.000000000 +0200 +++ soprano-2.6.51/test/serializetest.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,52 +0,0 @@ -/* - * This file is part of Soprano Project. - * - * Copyright (C) 2007-2008 Sebastian Trueg - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef SOPRANO_SERIALIZER_TEST_H -#define SOPRANO_SERIALIZER_TEST_H - -#include -#include - -#include "statement.h" - - -/* Workflow: - * 1) Prepare one QList with data, used as reference - * 2) For each serializer: - * 2.1) Serialize reference to memory - * 2.2) Parse this memory back to QList - * 2.3) Compare with reference - */ -class SerializerTest: public QObject -{ - Q_OBJECT - -private Q_SLOTS: - void init(); - void testSerializer_data(); - void testSerializer(); - //void testEncoding(); - private: - //QList referenceStatements; -}; - -#endif -