[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/nepomuk/query
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2011-01-20 17:22:50
Message-ID: 20110120172250.541F6AC8B9 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1215994 by trueg:
Better detection for number literals
M +15 -10 queryparser.cpp
--- trunk/KDE/kdelibs/nepomuk/query/queryparser.cpp #1215993:1215994
@@ -1,6 +1,6 @@
/*
This file is part of the Nepomuk KDE project.
- Copyright (C) 2007-2010 Sebastian Trueg <trueg@kde.org>
+ Copyright (C) 2007-2011 Sebastian Trueg <trueg@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -99,21 +99,26 @@
}
Soprano::LiteralValue createLiteral( const QString& s, bool globbing ) {
+ // 1. check if it is a number
+ QString clearString(s);
+ clearString.remove(QLatin1Char('\''));
+ clearString.remove(QLatin1Char('"'));
+ bool b = false;
+ int i = clearString.toInt( &b );
+ if ( b )
+ return Soprano::LiteralValue( i );
+ double d = clearString.toDouble( &b );
+ if ( b )
+ return Soprano::LiteralValue( d );
+
+ // 2. no number - continue with the original string
+
// no globbing if we have quotes or if there already is a wildcard
if ( s[0] == QLatin1Char('\'') ||
s[0] == QLatin1Char('\"') ) {
return s;
}
- // at this point we should have a string without spaces in it
- bool b = false;
- int i = s.toInt( &b );
- if ( b )
- return Soprano::LiteralValue( i );
- double d = s.toDouble( &b );
- if ( b )
- return Soprano::LiteralValue( d );
-
//
// we can only do query term globbing for strings longer than 3 chars
//
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic