QgsSearchTreeNode Class Reference
[QGIS core library]

A representation of a node in a search tree. More...

#include <qgssearchtreenode.h>

Collaboration diagram for QgsSearchTreeNode:

Collaboration graph
[legend]

List of all members.

Public Types

enum  Type {
  tOperator = 1, tNumber, tColumnRef, tString,
  tNodeList
}
 defines possible types of node More...
enum  Operator {
  opAND = 1, opOR, opNOT, opPLUS,
  opMINUS, opMUL, opDIV, opPOW,
  opSQRT, opSIN, opCOS, opTAN,
  opASIN, opACOS, opATAN, opTOINT,
  opTOREAL, opTOSTRING, opLENGTH, opAREA,
  opID, opISNULL, opISNOTNULL, opEQ,
  opNE, opGT, opLT, opGE,
  opLE, opRegexp, opLike, opILike,
  opIN, opNOTIN, opCONCAT, opLOWER,
  opUPPER, opROWNUM
}
 possible operators More...

Public Member Functions

 QgsSearchTreeNode (Type type)
 constructors
 QgsSearchTreeNode (double number)
 QgsSearchTreeNode (Operator op, QgsSearchTreeNode *left, QgsSearchTreeNode *right)
 QgsSearchTreeNode (QString text, bool isColumnRef)
 QgsSearchTreeNode (const QgsSearchTreeNode &node)
 copy contructor - copies whole tree!
 ~QgsSearchTreeNode ()
 destructor - deletes children nodes (if any)
Type type () const
 returns type of current node
Operator op () const
 node value getters
double number () const
QString columnRef () const
QString string () const
void setOp (Operator op)
 node value setters (type is set also)
void setNumber (double number)
void setColumnRef (const QString &str)
void setString (const QString &str)
QgsSearchTreeNodeLeft ()
 children
QgsSearchTreeNodeRight ()
void setLeft (QgsSearchTreeNode *left)
void setRight (QgsSearchTreeNode *right)
QString makeSearchString ()
 returns search string that should be equal to original parsed string
bool checkAgainst (const QgsFieldMap &fields, QgsFeature &f)
 checks whether the node tree is valid against supplied attributes
bool checkAgainst (const QgsFieldMap &fields, const QgsAttributeMap &attributes, QgsGeometry *geom=0)
bool hasError ()
 checks if there were errors during evaluation
const QString & errorMsg ()
 returns error message
bool getValue (QgsSearchTreeValue &value, QgsSearchTreeNode *node, const QgsFieldMap &fields, QgsFeature &f)
 wrapper around valueAgainst()
bool getValue (QgsSearchTreeValue &value, QgsSearchTreeNode *node, const QgsFieldMap &fields, const QgsAttributeMap &attributes, QgsGeometry *geom=0)
QStringList referencedColumns ()
 return a list of referenced columns in the tree
QList< QgsSearchTreeNode * > columnRefNodes ()
 return a list of all attribute nodes
bool needsGeometry ()
 check whether there are any operators that need geometry (for area, length)
void setCurrentRowNumber (int rownum)
 Set current row number within this tree.
void append (QgsSearchTreeNode *)
 append a node to the list
void append (QList< QgsSearchTreeNode * >)
 append nodelist to the list

Static Public Member Functions

static QString quotedColumnRef (QString name)
 return quoted column reference (in double quotes)

Protected Member Functions

QgsSearchTreeValue valueAgainst (const QgsFieldMap &fields, QgsFeature &f)
 returns scalar value of node
QgsSearchTreeValue valueAgainst (const QgsFieldMap &fields, const QgsAttributeMap &attributes, QgsGeometry *geom=0)
void stripText ()
 strips mText when node is of string type
void stripColRef ()
 strip mText when column reference is quoted
void init ()
 initialize node's internals

Private Attributes

Type mType
 node type
Operator mOp
 data
double mNumber
QString mText
QList< QgsSearchTreeNode * > mNodeList
QString mError
QgsSearchTreeNodemLeft
 children
QgsSearchTreeNodemRight
QgsDistanceAreamCalc
 For length() and area() functions.


Detailed Description

A representation of a node in a search tree.

node in tree of parsed search string node is terminal (has no children) if it's a number, column ref or string non-terminal is only node with operator - with 1 or 2 children

Definition at line 42 of file qgssearchtreenode.h.


Member Enumeration Documentation

defines possible types of node

Enumerator:
tOperator 
tNumber 
tColumnRef 
tString 
tNodeList 

Definition at line 47 of file qgssearchtreenode.h.

possible operators

Enumerator:
opAND 
opOR 
opNOT 
opPLUS 
opMINUS 
opMUL 
opDIV 
opPOW 
opSQRT 
opSIN 
opCOS 
opTAN 
opASIN 
opACOS 
opATAN 
opTOINT 
opTOREAL 
opTOSTRING 
opLENGTH 
opAREA 
opID 
opISNULL 
opISNOTNULL 
opEQ 
opNE 
opGT 
opLT 
opGE 
opLE 
opRegexp 
opLike 
opILike 
opIN 
opNOTIN 
opCONCAT 
opLOWER 
opUPPER 
opROWNUM 

Definition at line 57 of file qgssearchtreenode.h.


Constructor & Destructor Documentation

QgsSearchTreeNode::QgsSearchTreeNode ( QgsSearchTreeNode::Type  t  ) 

constructors

Definition at line 41 of file qgssearchtreenode.cpp.

References init(), mLeft, mRight, mType, and tNodeList.

Referenced by QgsSearchTreeNode().

QgsSearchTreeNode::QgsSearchTreeNode ( double  number  ) 

Definition at line 51 of file qgssearchtreenode.cpp.

References init(), mLeft, mNumber, mRight, mType, and tNumber.

QgsSearchTreeNode::QgsSearchTreeNode ( Operator  op,
QgsSearchTreeNode left,
QgsSearchTreeNode right 
)

Definition at line 62 of file qgssearchtreenode.cpp.

References init(), mLeft, mOp, mRight, mType, and tOperator.

QgsSearchTreeNode::QgsSearchTreeNode ( QString  text,
bool  isColumnRef 
)

Definition at line 75 of file qgssearchtreenode.cpp.

References init(), mLeft, mRight, mText, mType, stripColRef(), stripText(), tColumnRef, and tString.

QgsSearchTreeNode::QgsSearchTreeNode ( const QgsSearchTreeNode node  ) 

copy contructor - copies whole tree!

Definition at line 100 of file qgssearchtreenode.cpp.

References init(), mLeft, mNodeList, mNumber, mOp, mRight, mText, mType, and QgsSearchTreeNode().

QgsSearchTreeNode::~QgsSearchTreeNode (  ) 

destructor - deletes children nodes (if any)

Definition at line 125 of file qgssearchtreenode.cpp.

References mCalc, mLeft, mNodeList, and mRight.


Member Function Documentation

Type QgsSearchTreeNode::type (  )  const [inline]

returns type of current node

Definition at line 126 of file qgssearchtreenode.h.

Referenced by checkAgainst().

Operator QgsSearchTreeNode::op (  )  const [inline]

node value getters

Definition at line 129 of file qgssearchtreenode.h.

double QgsSearchTreeNode::number (  )  const [inline]

Definition at line 130 of file qgssearchtreenode.h.

QString QgsSearchTreeNode::columnRef (  )  const [inline]

Definition at line 131 of file qgssearchtreenode.h.

QString QgsSearchTreeNode::string (  )  const [inline]

Definition at line 132 of file qgssearchtreenode.h.

void QgsSearchTreeNode::setOp ( Operator  op  )  [inline]

node value setters (type is set also)

Definition at line 135 of file qgssearchtreenode.h.

void QgsSearchTreeNode::setNumber ( double  number  )  [inline]

Definition at line 136 of file qgssearchtreenode.h.

void QgsSearchTreeNode::setColumnRef ( const QString &  str  )  [inline]

Definition at line 137 of file qgssearchtreenode.h.

void QgsSearchTreeNode::setString ( const QString &  str  )  [inline]

Definition at line 138 of file qgssearchtreenode.h.

QgsSearchTreeNode* QgsSearchTreeNode::Left (  )  [inline]

children

Definition at line 141 of file qgssearchtreenode.h.

QgsSearchTreeNode* QgsSearchTreeNode::Right (  )  [inline]

Definition at line 142 of file qgssearchtreenode.h.

void QgsSearchTreeNode::setLeft ( QgsSearchTreeNode left  )  [inline]

Definition at line 143 of file qgssearchtreenode.h.

void QgsSearchTreeNode::setRight ( QgsSearchTreeNode right  )  [inline]

Definition at line 144 of file qgssearchtreenode.h.

QString QgsSearchTreeNode::makeSearchString (  ) 

bool QgsSearchTreeNode::checkAgainst ( const QgsFieldMap fields,
QgsFeature f 
)

checks whether the node tree is valid against supplied attributes

Note:
attribute and optional geom parameter replaced with feature in 1.6

Definition at line 387 of file qgssearchtreenode.cpp.

References checkAgainst(), QgsSearchTreeValue::compare(), getValue(), QgsSearchTreeValue::isNull(), QgsSearchTreeValue::isNumeric(), makeSearchString(), mError, mLeft, mNodeList, mOp, mRight, mType, opAND, opEQ, opGE, opGT, opILike, opIN, opISNOTNULL, opISNULL, opLE, opLike, opLT, opNE, opNOT, opNOTIN, opOR, opRegexp, QgsDebugMsgLevel, QgsSearchTreeValue::string(), tNodeList, tOperator, and type().

Referenced by checkAgainst(), and QgsRuleBasedRendererV2::Rule::isFilterOK().

bool QgsSearchTreeNode::checkAgainst ( const QgsFieldMap fields,
const QgsAttributeMap attributes,
QgsGeometry geom = 0 
)

Note:
deprecated

Definition at line 378 of file qgssearchtreenode.cpp.

References checkAgainst(), QgsFeature::setAttributeMap(), and QgsFeature::setGeometry().

bool QgsSearchTreeNode::hasError (  )  [inline]

checks if there were errors during evaluation

Definition at line 157 of file qgssearchtreenode.h.

const QString& QgsSearchTreeNode::errorMsg (  )  [inline]

returns error message

Definition at line 160 of file qgssearchtreenode.h.

bool QgsSearchTreeNode::getValue ( QgsSearchTreeValue value,
QgsSearchTreeNode node,
const QgsFieldMap fields,
QgsFeature f 
)

bool QgsSearchTreeNode::getValue ( QgsSearchTreeValue value,
QgsSearchTreeNode node,
const QgsFieldMap fields,
const QgsAttributeMap attributes,
QgsGeometry geom = 0 
)

Note:
deprecated

Definition at line 527 of file qgssearchtreenode.cpp.

References getValue(), QgsFeature::setAttributeMap(), and QgsFeature::setGeometry().

QStringList QgsSearchTreeNode::referencedColumns (  ) 

return a list of referenced columns in the tree

Note:
added in 1.5

Definition at line 325 of file qgssearchtreenode.cpp.

References columnRefNodes().

Referenced by QgsRuleBasedRendererV2::Rule::needsFields().

QList< QgsSearchTreeNode * > QgsSearchTreeNode::columnRefNodes (  ) 

return a list of all attribute nodes

Note:
added in 1.5

Definition at line 338 of file qgssearchtreenode.cpp.

References columnRefNodes(), mLeft, mRight, mType, tColumnRef, and tOperator.

Referenced by columnRefNodes(), and referencedColumns().

bool QgsSearchTreeNode::needsGeometry (  ) 

check whether there are any operators that need geometry (for area, length)

Note:
added in 1.5

Definition at line 359 of file qgssearchtreenode.cpp.

References mLeft, mOp, mRight, mType, needsGeometry(), opAREA, opLENGTH, and tOperator.

Referenced by needsGeometry().

QString QgsSearchTreeNode::quotedColumnRef ( QString  name  )  [static]

return quoted column reference (in double quotes)

Note:
added in 1.5

Definition at line 198 of file qgssearchtreenode.cpp.

void QgsSearchTreeNode::setCurrentRowNumber ( int  rownum  ) 

Set current row number within this tree.

This value is stored only in the nodes being $rownum operator - in mNumber

Note:
added in 1.6

Definition at line 784 of file qgssearchtreenode.cpp.

References mLeft, mNumber, mOp, mRight, mType, opROWNUM, setCurrentRowNumber(), and tOperator.

Referenced by setCurrentRowNumber().

void QgsSearchTreeNode::append ( QgsSearchTreeNode node  ) 

append a node to the list

Note:
added in 1.6

Definition at line 801 of file qgssearchtreenode.cpp.

References mNodeList, mType, and tNodeList.

void QgsSearchTreeNode::append ( QList< QgsSearchTreeNode * >  nodes  ) 

append nodelist to the list

Note:
added in 1.6

Definition at line 807 of file qgssearchtreenode.cpp.

References mNodeList.

QgsSearchTreeValue QgsSearchTreeNode::valueAgainst ( const QgsFieldMap fields,
QgsFeature f 
) [protected]

QgsSearchTreeValue QgsSearchTreeNode::valueAgainst ( const QgsFieldMap fields,
const QgsAttributeMap attributes,
QgsGeometry geom = 0 
) [protected]

Note:
deprecated

Definition at line 573 of file qgssearchtreenode.cpp.

References QgsFeature::setAttributeMap(), QgsFeature::setGeometry(), and valueAgainst().

void QgsSearchTreeNode::stripText (  )  [protected]

strips mText when node is of string type

Definition at line 162 of file qgssearchtreenode.cpp.

References mText.

Referenced by QgsSearchTreeNode().

void QgsSearchTreeNode::stripColRef (  )  [protected]

strip mText when column reference is quoted

Definition at line 189 of file qgssearchtreenode.cpp.

References mText.

Referenced by QgsSearchTreeNode().

void QgsSearchTreeNode::init (  )  [protected]

initialize node's internals

Definition at line 142 of file qgssearchtreenode.cpp.

References mCalc, mNumber, mOp, mType, opAREA, opLENGTH, opROWNUM, QgsDistanceArea::setEllipsoid(), QgsDistanceArea::setProjectionsEnabled(), and tOperator.

Referenced by QgsSearchTreeNode().


Member Data Documentation

double QgsSearchTreeNode::mNumber [private]

QString QgsSearchTreeNode::mText [private]

QString QgsSearchTreeNode::mError [private]

Definition at line 232 of file qgssearchtreenode.h.

Referenced by checkAgainst(), and getValue().

For length() and area() functions.

Definition at line 239 of file qgssearchtreenode.h.

Referenced by init(), valueAgainst(), and ~QgsSearchTreeNode().


The documentation for this class was generated from the following files:

Generated on Sat Feb 4 19:17:51 2012 for Quantum GIS API Documentation by  doxygen 1.5.6