2
* This file is part of Soprano Project.
4
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public License
17
* along with this library; see the file COPYING.LIB. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
22
#include "clientqueryresultiteratorbackend.h"
23
#include "clientconnection.h"
24
#include "clientmodel.h"
26
#include <soprano/bindingset.h>
27
#include <soprano/statement.h>
30
Soprano::Client::ClientQueryResultIteratorBackend::ClientQueryResultIteratorBackend( int itId, ClientModel* client )
31
: m_iteratorId( itId ),
37
Soprano::Client::ClientQueryResultIteratorBackend::~ClientQueryResultIteratorBackend()
43
bool Soprano::Client::ClientQueryResultIteratorBackend::next()
46
bool r = m_model->client()->iteratorNext( m_iteratorId );
47
setError( m_model->client()->lastError() );
51
setError( "Connection to server closed." );
57
Soprano::BindingSet Soprano::Client::ClientQueryResultIteratorBackend::current() const
60
BindingSet s = m_model->client()->queryIteratorCurrent( m_iteratorId );
61
setError( m_model->client()->lastError() );
65
setError( "Connection to server closed." );
71
void Soprano::Client::ClientQueryResultIteratorBackend::close()
74
m_model->closeIterator( m_iteratorId );
75
setError( m_model->client()->lastError() );
78
setError( "Connection to server closed." );
83
Soprano::Statement Soprano::Client::ClientQueryResultIteratorBackend::currentStatement() const
86
Statement s = m_model->client()->queryIteratorCurrentStatement( m_iteratorId );
87
setError( m_model->client()->lastError() );
91
setError( "Connection to server closed." );
97
Soprano::Node Soprano::Client::ClientQueryResultIteratorBackend::binding( const QString &name ) const
99
// FIXME: use an extra method for performance
100
return current()[name];
104
Soprano::Node Soprano::Client::ClientQueryResultIteratorBackend::binding( int offset ) const
106
// FIXME: use an extra method for performance
107
return current()[offset];
111
int Soprano::Client::ClientQueryResultIteratorBackend::bindingCount() const
113
// FIXME: use an extra method for performance
114
return current().count();
118
QStringList Soprano::Client::ClientQueryResultIteratorBackend::bindingNames() const
120
// FIXME: use an extra method for performance
121
return current().bindingNames();
125
bool Soprano::Client::ClientQueryResultIteratorBackend::isGraph() const
128
bool r = m_model->client()->queryIteratorType( m_iteratorId ) == 1;
129
setError( m_model->client()->lastError() );
133
setError( "Connection to server closed." );
139
bool Soprano::Client::ClientQueryResultIteratorBackend::isBinding() const
142
bool r = m_model->client()->queryIteratorType( m_iteratorId ) == 3;
143
setError( m_model->client()->lastError() );
147
setError( "Connection to server closed." );
153
bool Soprano::Client::ClientQueryResultIteratorBackend::isBool() const
156
bool r = m_model->client()->queryIteratorType( m_iteratorId ) == 2;
157
setError( m_model->client()->lastError() );
161
setError( "Connection to server closed." );
167
bool Soprano::Client::ClientQueryResultIteratorBackend::boolValue() const
170
bool r = m_model->client()->queryIteratorBoolValue( m_iteratorId );
171
setError( m_model->lastError() );
175
setError( "Connection to server closed." );