BinaryComparisonOp.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file BinaryComparisonOp.cpp
22 
23  \brief A class for binary comparison operators.
24  */
25 
26 // TerraLib
27 #include "BinaryComparisonOp.h"
28 #include "Expression.h"
29 #include "Globals.h"
30 
31 // STL
32 #include <cassert>
33 #include<cstring>
34 #include <iterator>
35 
37  : ComparisonOp(opName),
38  m_first(nullptr),
39  m_second(nullptr),
40  m_matchCase(true)
41 {
42 }
43 
45  : ComparisonOp(opName),
46  m_first(f),
47  m_second(s),
48  m_matchCase(true)
49 {
50 }
51 
53 {
54  delete m_first;
55  delete m_second;
56 }
57 
59 {
60  delete m_first;
61  m_first = first;
62 }
63 
65 {
66  return m_first;
67 }
68 
70 {
71  delete m_second;
72  m_second = second;
73 }
74 
76 {
77  return m_second;
78 }
79 
81 {
82  m_matchCase = true;
83 }
84 
86 {
87  m_matchCase = false;
88 }
89 
91 {
93 
94  if(m_name)
95  binComp->setName(m_name);
96 
97  if(m_first)
98  binComp->setFirst(m_first->clone());
99 
100  if(m_second)
101  binComp->setSecond(m_second->clone());
102 
103  m_matchCase?binComp->enableMatchCase():binComp->disableMatchCase();
104 
105  return binComp;
106 
107 }
108 
BinaryComparisonOp(const char *opName=0)
It initializes a new BinaryComparisonOp.
void setName(const char *opName)
It sets the operator name.
Definition: AbstractOp.h:89
virtual ~BinaryComparisonOp()
Virtual destructor.
void enableMatchCase()
It enables the match case flag. So comparisons will be case sensitive.
void setSecond(Expression *second)
It sets the second operand.
void disableMatchCase()
It disables the match case flag. So comparisons will not be case sensitive.
A comparison operator is used to form expressions that evaluate the mathematical comparison between t...
Definition: ComparisonOp.h:49
An static class with global definitions.
void setFirst(Expression *first)
It sets the first operand.
Expression * m_first
first operand (mandatory).
ComparisonOp * clone() const
It creates a new copy of this object.
bool m_matchCase
Optional (default: true).
virtual Expression * clone() const =0
It returns a clone of this object.
This is an abstract class that models a Filter Encoding expression.
Definition: fe/Expression.h:50
Expression * getSecond() const
It returns the second operand.
This is an abstract class that models a Filter Encoding expression.
A class for binary comparison operators.
Expression * m_second
second operand (mandatory).
A class for binary comparison operators.
Expression * getFirst() const
It returns the first operand.
const char * m_name
Operator name.
Definition: AbstractOp.h:123