2
/***************************************************************************
3
soprano.rb - Soprano SPARQL queries over DBus
5
begin : Fri March 14 2008
6
copyright : (C) 2008 by Richard Dale
7
email : richard.j.dale@gmail.com
8
***************************************************************************/
10
/***************************************************************************
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 2 of the License, or *
15
* (at your option) any later version. *
17
***************************************************************************/
22
def self.init_all_classes
23
# Qt::Internal::add_normalize_proc(Proc.new do |classname|
24
# if classname =~ /^Soprano/
25
# now = classname.sub(/^Soprano?(?=[A-Z])/,'Soprano::')
29
getClassList.each do |c|
30
classname = Qt::Internal::normalize_classname(c)
31
id = Qt::Internal::findClass(c);
32
Qt::Internal::insert_pclassid(classname, id)
33
Qt::Internal::cpp_names[classname] = c
34
klass = Qt::Internal::isQObject(c) ? Qt::Internal::create_qobject_class(classname, Soprano) \
35
: Qt::Internal::create_qt_class(classname, Soprano)
36
Qt::Internal::classes[classname] = klass unless klass.nil?
43
method_missing(:type, *args)
49
when Soprano::Node::EmptyNode:
50
str.sub(/>$/, " %s>" % "(empty)")
51
when Soprano::Node::ResourceNode:
52
str.sub(/>$/, " <%s>>" % uri.toString)
53
when Soprano::Node::LiteralNode:
54
if literal.isString && language
55
str.sub(/>$/, ' "%s"@%s>' % [literal.toString, language])
57
str.sub(/>$/, ' "%s"^^<%s>>' % [literal.toString, literal.dataTypeUri.toString])
59
when Soprano::Node::BlankNode:
60
str.sub(/>$/, " _:%s>" % identifier)
67
when Soprano::Node::EmptyNode:
68
pp.text str.sub(/>$/, " %s>" % "(empty)")
69
when Soprano::Node::ResourceNode:
70
pp.text str.sub(/>$/, " <%s>>" % uri.toString)
71
when Soprano::Node::LiteralNode:
72
if literal.isString && language
73
pp.text str.sub(/>$/, ' "%s"@%s>' % [literal.toString, language])
75
pp.text str.sub(/>$/, ' "%s"^^<%s>>' % [literal.toString, literal.dataTypeUri.toString])
77
when Soprano::Node::BlankNode:
78
pp.text str.sub(/>$/, " _:%s>" % identifier)
82
def self.demarshall(arg)
84
type = Qt::Integer.new
88
arg >> type >> value >> language >> dataTypeUri
91
when Soprano::Node::EmptyNode:
92
node = Soprano::Node.new
93
when Soprano::Node::ResourceNode:
94
node = Soprano::Node.new(Qt::Url.new(value))
95
when Soprano::Node::LiteralNode:
96
node = Soprano::Node.new(Soprano::LiteralValue.fromString(value, Qt::Url.new(dataTypeUri)), language)
97
when Soprano::Node::BlankNode:
98
node = Soprano::Node.new(value)
100
node = Soprano::Node.new
107
class Statement < Qt::Base
110
str.sub(/>$/, " valid?=%s, subject=%s, predicate=%s, object=%s, context=%s>" %
111
[isValid, subject.inspect, predicate.inspect, object.inspect, context.inspect])
116
pp.text str.sub(/>$/, " valid?=%s,\n subject=%s,\n predicate=%s,\n object=%s,\n context=%s>" %
117
[isValid, subject.inspect, predicate.inspect, object.inspect, context.inspect])
120
def self.demarshall(arg)
122
subject = Soprano::Node.demarshall(arg)
123
predicate = Soprano::Node.demarshall(arg)
124
object = Soprano::Node.demarshall(arg)
125
context = Soprano::Node.demarshall(arg)
126
statement = Soprano::Statement.new(subject, predicate, object, context)
132
class BindingSet < Qt::Base
133
def self.demarshall(arg)
141
node = Soprano::Node.demarshall(arg)
143
set[name.to_sym] = node
155
class NodeIterator < Qt::Base
159
allNodes.each do |node|
165
class StatementIterator < Qt::Base
169
allStatements.each do |statement|
175
class QueryResultIterator < Qt::Base
179
allBindings.each do |bindingSet|
185
class StorageModel < Qt::Base
186
# executeQuery() is a pure virtual method with an optional
187
# arg. This isn't supported by the smoke code generation
188
# yet, so cater for the optional arg here for now
189
def executeQuery(*args)
191
super(args[0], args[1], nil)
198
class Client < Qt::Base
199
class DBusNodeIterator < Qt::Base
203
allNodes.each do |node|
209
class DBusStatementIterator < Qt::Base
213
allStatements.each do |statement|
219
class DBusQueryResultIterator < Qt::Base
223
allBindings.each do |bindingSet|
232
# kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;