Skip to content
Permalink
Browse files
Fix for ticket #323 (diacritics in column name).
Use QgsLogger in QgsSearchTreeNode instead of std::cout.


git-svn-id: http://svn.osgeo.org/qgis/trunk@5939 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Oct 12, 2006
1 parent adb5b48 commit eceb4e8f2d1c67cdb010caa0d4e673b300cb8ff4
Showing with 20 additions and 30 deletions.
  1. +4 −2 src/core/qgssearchstringlexer.ll
  2. +13 −25 src/core/qgssearchtreenode.cpp
  3. +3 −3 src/providers/ogr/qgsogrprovider.cpp
@@ -34,8 +34,10 @@

white [ \t\r\n]+

col_first [A-Za-z_]
col_next [A-Za-z0-9_]
non_ascii [\x80-\xFF]

col_first [A-Za-z_]|{non_ascii}
col_next [A-Za-z0-9_]|{non_ascii}
column_ref {col_first}{col_next}*

dig [0-9]
@@ -16,27 +16,15 @@
* *
***************************************************************************/
/* $Id$ */


#include "qgslogger.h"
#include "qgssearchtreenode.h"
#include <qregexp.h>
#include <qobject.h>
#include <iostream>

// turn on/off debugging of search tree evaulation
#undef DEBUG_TREE_EVAL

#ifdef DEBUG_TREE_EVAL
#define TREE_EVAL(x) std::cout << x;
#define TREE_EVAL2(x,y) std::cout << x << y << std::endl;
#define TREE_EVAL3(x,y,z) std::cout << x << y << z << std::endl;
#define TREE_EVAL4(x,y,z,zz) std::cout << x << y << z << zz << std::endl;
#define EVAL_STR(x) (x.length() ? x : "(empty)")
#else
#define TREE_EVAL(x)
#define TREE_EVAL2(x,y)
#define TREE_EVAL3(x,y,z)
#define TREE_EVAL4(x,y,z,zz)
#endif

QgsSearchTreeNode::QgsSearchTreeNode(double number)
{
@@ -194,7 +182,7 @@ QString QgsSearchTreeNode::makeSearchString()

bool QgsSearchTreeNode::checkAgainst(const std::vector<QgsFeatureAttribute>& attributes)
{
TREE_EVAL2("checkAgainst: ", makeSearchString());
QgsDebugMsgLevel("checkAgainst: " + makeSearchString(), 2);

mError = "";

@@ -275,8 +263,8 @@ bool QgsSearchTreeNode::checkAgainst(const std::vector<QgsFeatureAttribute>& att

QRegExp re(str);
res = re.search(value1.string());
TREE_EVAL4("REGEXP: ", str, " ~ ", value2.string());
TREE_EVAL2(" res: ", res);
QgsDebugMsgLevel("REGEXP: " + str + " ~ " + value2.string(), 2);
QgsDebugMsgLevel(" res: " + res, 2);
return (res != -1);
}

@@ -324,22 +312,22 @@ bool QgsSearchTreeNode::getValue(QgsSearchTreeValue& value, QgsSearchTreeNode* n

QgsSearchTreeValue QgsSearchTreeNode::valueAgainst(const std::vector<QgsFeatureAttribute>& attributes)
{
TREE_EVAL2("valueAgainst: ", makeSearchString());
QgsDebugMsgLevel("valueAgainst: " + makeSearchString(), 2);

switch (mType)
{

case tNumber:
TREE_EVAL2("number: ", mNumber);
QgsDebugMsgLevel("number: " + QString::number(mNumber), 2);
return QgsSearchTreeValue(mNumber);

case tString:
TREE_EVAL2("text: ", EVAL_STR(mText));
QgsDebugMsgLevel("text: " + EVAL_STR(mText), 2);
return QgsSearchTreeValue(mText);

case tColumnRef:
{
TREE_EVAL3("column (", mText, "): ");;
QgsDebugMsgLevel("column (" + mText.lower() + "): ", 2);
// find value for the column
std::vector<QgsFeatureAttribute>::const_iterator it;
for (it = attributes.begin(); it != attributes.end(); it++)
@@ -349,19 +337,19 @@ QgsSearchTreeValue QgsSearchTreeNode::valueAgainst(const std::vector<QgsFeatureA
QString value = (*it).fieldValue();
if ((*it).isNumeric())
{
TREE_EVAL2(" number: ", value.toDouble());
QgsDebugMsgLevel(" number: " + QString::number(value.toDouble()), 2);
return QgsSearchTreeValue(value.toDouble());
}
else
{
TREE_EVAL2(" text: ", EVAL_STR(value));
QgsDebugMsgLevel(" text: " + EVAL_STR(value), 2);
return QgsSearchTreeValue(value);
}
}
}

// else report missing column
TREE_EVAL("ERROR");
QgsDebugMsgLevel("ERROR!", 2);
return QgsSearchTreeValue(1, mText);
}

@@ -424,7 +412,7 @@ int QgsSearchTreeValue::compare(QgsSearchTreeValue& value1, QgsSearchTreeValue&
else
val2 = value2.string().toDouble();

TREE_EVAL4("NUM_COMP: ", val1, " ~ ", val2);
QgsDebugMsgLevel("NUM_COMP: " + QString::number(val1) + " ~ " + QString::number(val2), 2);

if (val1 < val2)
return -1;
@@ -715,7 +715,7 @@ void QgsOgrProvider::getFeatureAttribute(OGRFeature * ogrFet, QgsFeature * f, in
return;
}

QString fld = fldDef->GetNameRef();
QString fld = mEncoding->toUnicode(fldDef->GetNameRef());
QByteArray cstr(ogrFet->GetFieldAsString(attindex));
bool numeric = attributeFields[attindex].isNumeric();

@@ -730,7 +730,7 @@ void QgsOgrProvider::getFeatureAttributes(OGRFeature *ogrFet, QgsFeature *f){
getFeatureAttribute(ogrFet,f,i);
// add the feature attributes to the tree
/*OGRFieldDefn *fldDef = ogrFet->GetFieldDefnRef(i);
QString fld = fldDef->GetNameRef();
QString fld = mEncoding->toUnicode(fldDef->GetNameRef());
// OGRFieldType fldType = fldDef->GetType();
QString val;
@@ -1149,7 +1149,7 @@ bool QgsOgrProvider::changeAttributeValues(std::map<int,std::map<QString,QString
for ( int f = 0; f < fc; f++ ) {
OGRFieldDefn *fd = of->GetFieldDefnRef ( f );

if ( name.compare( fd->GetNameRef() ) == 0 ) {
if ( name.compare( mEncoding->toUnicode(fd->GetNameRef()) ) == 0 ) {
OGRFieldType type = fd->GetType();
switch ( type ) {
case OFTInteger:

0 comments on commit eceb4e8

Please sign in to comment.