本文整理汇总了C++中soprano::QueryResultIterator::boolValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResultIterator::boolValue方法的具体用法?C++ QueryResultIterator::boolValue怎么用?C++ QueryResultIterator::boolValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soprano::QueryResultIterator
的用法示例。
在下文中一共展示了QueryResultIterator::boolValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
bool NW::Executive::canProcess( const Nepomuk::Resource & res) const
{
// If no filter set up, then no filter is necessary
if ( d->typeFilters.isEmpty() )
return true;
// Create a query
/*
for( int i = 0; i < d->typeFilters; i++)
{
}*/
static QString unionString = QString( "UNION" );
QStringList queryExactList;
QStringList querySubclassList;
bool currentType = d->typeFilters[0].allowed;
/* General idea - unite consiquent records with same .allowed field into
* one group, and when prepare to switch to another group - create a query
* from accumulated strings, ask it and determine the result.
* Reaching the end of filter list is treated as switching to another group
*/
foreach( const FilterRecord & record, d->typeFilters)
{
if ( record.allowed != currentType ) {
// After this function call, queryExactList will change!
QString query = buildFilterQuery(res.resourceUri(), queryExactList, querySubclassList);
Soprano::QueryResultIterator it = res.manager()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql );
if ( it.next() ) {
// Has answer
if ( it.boolValue() ) {
return currentType;
}
}
else {
// Wow. Ask query doesn't return an answer. May be it is incorrect ?
qCritical() << "Filter query is incorrect. Report a BUG please";
return false;
}
// Clear
queryExactList.clear();
querySubclassList.clear();
// Switch current type
currentType = record.allowed;
}
// Accumulate to the group
if ( record.matchType == ExactMatch or record.matchType == SubclassOrExactMatch ) {
queryExactList << FilterRecord::queryString(ExactMatch, record.typeUrl) << unionString;
}
if ( record.matchType == SubclassOrExactMatch or record.matchType == SubclassMatch ) {
querySubclassList << FilterRecord::queryString(SubclassMatch, record.typeUrl) << unionString;
}
}
// Build for the last group
QString query = buildFilterQuery(res.resourceUri(), queryExactList, querySubclassList);
Soprano::QueryResultIterator it = res.manager()->mainModel()->executeQuery(query, Soprano::Query::QueryLanguageSparql );
if ( it.isBool() ) {
// Has answer
if ( it.boolValue() ) {
return currentType;
}
else {
// return default rule
return d->defaultTypeRule;
}
}
else {
// Wow. Ask query doesn't return an answer. May be it is incorrect ?
qCritical() << "Filter query is incorrect. Report a BUG please";
return false;
}
}