All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Field.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 terralib/dataaccess/query/Field.cpp
22 
23  \brief The Field class can be used to model an expression that takes part of the output items of a SELECT.
24 */
25 
26 // TerraLib
27 #include "Expression.h"
28 #include "Field.h"
29 #include "PropertyName.h"
30 
31 te::da::Field::Field(const Expression& e, const std::string& alias)
32  : m_field(e.clone()),
33  m_alias(0)
34 {
35  m_alias.reset(alias.empty() ? 0 : new std::string(alias));
36 }
37 
38 te::da::Field::Field(Expression* e, std::string* alias)
39  : m_field(e),
40  m_alias(alias)
41 {
42 }
43 
44 te::da::Field::Field(const std::string& propertyName, const std::string& alias)
45  : m_field(0),
46  m_alias(0)
47 {
48  m_field.reset(new PropertyName(propertyName));
49  m_alias.reset(alias.empty() ? 0 : new std::string(alias));
50 }
51 
53  : m_field(0),
54  m_alias(0)
55 {
56  m_field.reset(rhs.m_field.get() ? rhs.m_field->clone() : 0);
57  m_alias.reset(rhs.m_alias.get() ? new std::string(*rhs.m_alias) : 0);
58 }
59 
61 {
62 }
63 
65 {
66  if(this != &rhs)
67  {
68  m_field.reset(rhs.m_field.get() ? rhs.m_field->clone() : 0);
69  m_alias.reset(rhs.m_alias.get() ? new std::string(*rhs.m_alias) : 0);
70  }
71 
72  return *this;
73 }
74 
76 {
77  m_field.reset(e);
78 }
79 
81 {
82  return m_field.get();
83 }
84 
85 void te::da::Field::setAlias(std::string* alias)
86 {
87  m_alias.reset(alias);
88 }
89 
90 std::string* te::da::Field::getAlias() const
91 {
92  return m_alias.get();
93 }
94 
The Field class can be used to model an expression that takes part of the output items of a SELECT...
Definition: Field.h:50
A class that models the name of any property of an object.
A class that models the name of any property of an object.
Definition: PropertyName.h:50
Expression * getExpression() const
It returns the expression set for an output select query.
Definition: Field.cpp:80
~Field()
Destructor.
Definition: Field.cpp:60
This is an abstract class that models a query expression.
Definition: Expression.h:47
Field(const Expression &e, const std::string &alias=std::string(""))
Constructor.
Definition: Field.cpp:31
The Field class can be used to model an expression that takes part of the output items of a SELECT...
std::string * getAlias() const
It returns the alias for the outout expression.
Definition: Field.cpp:90
This is an abstract class that models a query expression.
void setAlias(std::string *alias)
As you know, sometimes is better to give an alias to an output expression.
Definition: Field.cpp:85
std::auto_ptr< Expression > m_field
A valid expression.
Definition: Field.h:123
std::auto_ptr< std::string > m_alias
An alias for the output name.
Definition: Field.h:124
void setExpression(Expression *e)
It sets the an expression that can be used in a Select query.
Definition: Field.cpp:75
Field & operator=(const Field &rhs)
Definition: Field.cpp:64