Like.h
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 terralib/dataaccess/query/Like.h
22 
23  \brief It is intended to encode a character string comparison operator with pattern matching.
24 */
25 
26 #ifndef __TERRALIB_DATAACCESS_INTERNAL_LIKE_H
27 #define __TERRALIB_DATAACCESS_INTERNAL_LIKE_H
28 
29 // TerraLib
30 #include "Function.h"
31 
32 namespace te
33 {
34  namespace da
35  {
36  /*!
37  \class Like
38 
39  \brief It is intended to encode a character string comparison operator with pattern matching.
40 
41  \sa Function
42  */
44  {
45  public:
46 
48 
49  /*!
50  \brief Constructor.
51 
52  \param str The operator will take the expression ownership.
53  */
55  const std::string& pattern,
56  const std::string& wildCard = "%",
57  const std::string& singleChar = "_",
58  const std::string& escapeChar = "\\");
59 
60  /*! \brief Constructor. */
61  Like(const Expression& str,
62  const std::string& pattern,
63  const std::string& wildCard = "%",
64  const std::string& singleChar = "_",
65  const std::string& escapeChar = "\\");
66 
67  /*! \brief Destructor. */
68  ~Like();
69 
70  /*! \brief Copy constructor. */
71  Like(const Like& rhs);
72 
73  /*! Assignment operator. */
74  Like& operator=(const Like& rhs);
75 
76  /*! \brief It creates a new copy of this expression. */
77  Expression* clone() const;
78 
79  /*!
80  \brief It returns the string expression to be compared with the like operator.
81 
82  \return The string expression to be compared with the like operator.
83  */
85 
86  /*!
87  \brief It sets the string expression to be compared with the like operator.
88 
89  \param str The string expression to be compared with the like operator.
90  */
91  void setString(Expression* str);
92 
93  /*!
94  \brief It returns the pattern used in the comparison.
95 
96  \return The pattern used in the comparison.
97  */
99 
100  /*!
101  \brief It sets the pattern to be used in the comparison.
102 
103  \param p The pattern to be used in the comparison.
104  */
105  void setPattern(const std::string& p);
106 
107  /*!
108  \brief It sets the wild character.
109 
110  \param w The wild character.
111  */
112  void setWildCard(const std::string& w);
113 
114  /*!
115  \brief It returns the wild character.
116 
117  \return The wild character.
118  */
119  const std::string& getWildCard() const;
120 
121  /*!
122  \brief It sets the wild single character.
123 
124  \param s The wild single character.
125  */
126  void setSingleChar(const std::string& s);
127 
128  /*!
129  \brief It returns the single wild character.
130 
131  \return The single wild character.
132  */
133  const std::string& getSingleChar() const;
134 
135  /*!
136  \brief It sets the escape character.
137 
138  \param e The escape character.
139  */
140  void setEscapeChar(const std::string& e);
141 
142  /*!
143  \brief It returns the escape character.
144 
145  \return The escape character.
146  */
147  const std::string& getEscapeChar() const;
148 
149  private:
150 
151  std::string m_wildCard; //!< The wild card character matches zero or more characters.
152  std::string m_singleChar; //!< The single char character matches exactly one character.
153  std::string m_escapeChar; //!< The escape char character is used to escape the meaning of the wild card, single char and escape char itself.
154  };
155 
156  } // end namespace da
157 } // end namespace te
158 
159 #endif // __TERRALIB_DATAACCESS_INTERNAL_LIKE_H
160 
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::da::Like::Like
TE_DEFINE_VISITABLE Like(Expression *str, const std::string &pattern, const std::string &wildCard="%", const std::string &singleChar="_", const std::string &escapeChar="\\")
Constructor.
te::da::Like
It is intended to encode a character string comparison operator with pattern matching.
Definition: Like.h:44
te::da::Like::setPattern
void setPattern(const std::string &p)
It sets the pattern to be used in the comparison.
te::da::Like::m_wildCard
std::string m_wildCard
The wild card character matches zero or more characters.
Definition: Like.h:151
te::da::Like::clone
Expression * clone() const
It creates a new copy of this expression.
te::da::Like::getString
Expression * getString() const
It returns the string expression to be compared with the like operator.
Function.h
Symbology Encoding functions.
te::da::Like::m_escapeChar
std::string m_escapeChar
The escape char character is used to escape the meaning of the wild card, single char and escape char...
Definition: Like.h:153
te::da::Like::getEscapeChar
const std::string & getEscapeChar() const
It returns the escape character.
te::da::Function
A class that models a Function expression.
Definition: Function.h:48
te::da::Like::getSingleChar
const std::string & getSingleChar() const
It returns the single wild character.
TEDATAACCESSEXPORT
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97
te::da::LiteralString
This class models a string Literal value.
Definition: LiteralString.h:47
te::da::Like::~Like
~Like()
Destructor.
te::da::Expression
This is an abstract class that models a query expression.
Definition: Expression.h:48
TE_DEFINE_VISITABLE
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
te::da::Like::Like
Like(const Like &rhs)
Copy constructor.
te::da::Like::setString
void setString(Expression *str)
It sets the string expression to be compared with the like operator.
te::da::Like::getWildCard
const std::string & getWildCard() const
It returns the wild character.
te::da::Like::setEscapeChar
void setEscapeChar(const std::string &e)
It sets the escape character.
te::da::Like::getPattern
te::da::LiteralString * getPattern() const
It returns the pattern used in the comparison.
te::da::Like::Like
Like(const Expression &str, const std::string &pattern, const std::string &wildCard="%", const std::string &singleChar="_", const std::string &escapeChar="\\")
Constructor.
te::da::Like::operator=
Like & operator=(const Like &rhs)
te::da::Like::setWildCard
void setWildCard(const std::string &w)
It sets the wild character.
te::da::Like::m_singleChar
std::string m_singleChar
The single char character matches exactly one character.
Definition: Like.h:152
te::da::Like::setSingleChar
void setSingleChar(const std::string &s)
It sets the wild single character.