MCPcopy Index your code
hub / github.com/MapServer/MapServer / BuildExpressionTree

Function BuildExpressionTree

mapogcsld.c:5045–5347  ·  view source on GitHub ↗

/ BuildExpressionTree */ / Build a filter expression node based on mapserver's class */ expression. This is limited to simple expressions like : */ A = B, A < B, A <= B, A > B, A >= B, A != B */ It also handles one level of logical expressions : */ A AND B */ A OR B

Source from the content-addressed store, hash-verified

5043/* NOT A */
5044/************************************************************************/
5045FilterEncodingNode *BuildExpressionTree(char *pszExpression,
5046 FilterEncodingNode *psNode)
5047{
5048 char *apszExpression[20];
5049 int nLength = 0;
5050 /* int bInsideExpression = 0; */
5051 int i =0, nOperators=0;
5052 char *pszFinalExpression = NULL;
5053 int iFinal = 0, iIndiceExp=0, nOpeningBrackets=0;/* nIndice=0; */
5054 /* char szTmp[6]; */
5055 int iExpression = 0;
5056 /* char *pszSimplifiedExpression = NULL; */
5057 char *pszComparionValue=NULL, *pszAttibuteName=NULL;
5058 char *pszAttibuteValue=NULL;
5059 char *pszLeftExpression=NULL, *pszRightExpression=NULL, *pszOperator=NULL;
5060
5061 if (!pszExpression || (nLength = strlen(pszExpression)) <=0)
5062 return NULL;
5063
5064 for (i=0; i<20; i++)
5065 apszExpression[i] = (char *)malloc(sizeof(char)*(nLength+1));
5066
5067 pszFinalExpression = (char *)malloc(sizeof(char)*(nLength+1));
5068 pszFinalExpression[0] = '\0';
5069
5070 iExpression = -1; /* first incremnt will put it to 0; */
5071 iFinal = 0;
5072 iIndiceExp = 0;
5073 nOpeningBrackets = 0;
5074
5075/* -------------------------------------------------------------------- */
5076/* First we check how many logical operators are there : */
5077/* - if none : It means It is a comparision operator (like =, */
5078/* >, >= .... We get the comparison value as well as the */
5079/* attribute and the attribut's value and assign it to the node */
5080/* passed in argument. */
5081/* - if there is one operator, we assign the operator to the */
5082/* node and adds the expressions into the left and right nodes. */
5083/* -------------------------------------------------------------------- */
5084 nOperators = msSLDNumberOfLogicalOperators(pszExpression);
5085 if (nOperators == 0)
5086 {
5087 if (!psNode)
5088 psNode = FLTCreateFilterEncodingNode();
5089
5090 pszComparionValue = msSLDGetComparisonValue(pszExpression);
5091 pszAttibuteName = msSLDGetAttributeName(pszExpression, pszComparionValue);
5092 pszAttibuteValue = msSLDGetAttributeValue(pszExpression, pszComparionValue);
5093 if (pszComparionValue && pszAttibuteName && pszAttibuteValue)
5094 {
5095 psNode->eType = FILTER_NODE_TYPE_COMPARISON;
5096 psNode->pszValue = msStrdup(pszComparionValue);
5097
5098 psNode->psLeftNode = FLTCreateFilterEncodingNode();
5099 psNode->psLeftNode->eType = FILTER_NODE_TYPE_PROPERTYNAME;
5100 psNode->psLeftNode->pszValue = msStrdup(pszAttibuteName);
5101
5102 psNode->psRightNode = FLTCreateFilterEncodingNode();

Callers 2

msSLDApplySLDFunction · 0.85

Calls 10

msSLDGetComparisonValueFunction · 0.85
msSLDGetAttributeNameFunction · 0.85
msSLDGetAttributeValueFunction · 0.85
msStrdupFunction · 0.85
strcasecmpFunction · 0.85
msSLDGetLogicalOperatorFunction · 0.85

Tested by

no test coverage detected