All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PreparedQuery.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/datasource/PreparedQuery.cpp
22 
23  \brief A class that models a prepared query.
24 */
25 
26 // TerraLib
27 #include "../../common/Translator.h"
28 #include "../../datatype/AbstractData.h"
29 #include "../../datatype/ByteArray.h"
30 #include "../../datatype/DateTime.h"
31 #include "../../datatype/SimpleData.h"
32 #include "../../geometry/Geometry.h"
33 #include "../Exception.h"
34 #include "PreparedQuery.h"
35 
37 {
38  switch(ad.getTypeCode())
39  {
40  case te::dt::CHAR_TYPE :
41  {
42  const te::dt::Char& value = static_cast<const te::dt::Char&>(ad);
43 
44  bind(i, value.getValue());
45  }
46  break;
47 
48  case te::dt::UCHAR_TYPE :
49  {
50  const te::dt::UChar& value = static_cast<const te::dt::UChar&>(ad);
51 
52  bind(i, value.getValue());
53  }
54  break;
55 
56  case te::dt::INT16_TYPE :
57  {
58  const te::dt::Int16& value = static_cast<const te::dt::Int16&>(ad);
59 
60  bind(i, value.getValue());
61  }
62  break;
63 
64  case te::dt::INT32_TYPE :
65  {
66  const te::dt::Int32& value = static_cast<const te::dt::Int32&>(ad);
67 
68  bind(i, value.getValue());
69  }
70  break;
71 
72  case te::dt::INT64_TYPE :
73  {
74  const te::dt::Int64& value = static_cast<const te::dt::Int64&>(ad);
75 
76  bind(i, value.getValue());
77  }
78  break;
79 
81  {
82  const te::dt::Boolean& value = static_cast<const te::dt::Boolean&>(ad);
83 
84  bind(i, value.getValue());
85  }
86  break;
87 
88  case te::dt::FLOAT_TYPE :
89  {
90  const te::dt::Float& value = static_cast<const te::dt::Float&>(ad);
91 
92  bind(i, value.getValue());
93  }
94  break;
95 
96  case te::dt::DOUBLE_TYPE :
97  {
98  const te::dt::Double& value = static_cast<const te::dt::Double&>(ad);
99 
100  bind(i, value.getValue());
101  }
102  break;
103 
104  case te::dt::NUMERIC_TYPE :
105  {
106  const te::dt::Numeric& value = static_cast<const te::dt::Numeric&>(ad);
107 
108  bind(i, value.getValue());
109  }
110  break;
111 
112  case te::dt::STRING_TYPE :
113  {
114  const te::dt::String& value = static_cast<const te::dt::String&>(ad);
115 
116  bind(i, value.getValue());
117  }
118  break;
119 
121  {
122  const te::dt::ByteArray& value = static_cast<const te::dt::ByteArray&>(ad);
123 
124  bind(i, value);
125  }
126  break;
127 
128  case te::dt::GEOMETRY_TYPE :
129  {
130  const te::gm::Geometry& value = static_cast<const te::gm::Geometry&>(ad);
131 
132  bind(i, value);
133  }
134  break;
135 
136  case te::dt::DATETIME_TYPE :
137  {
138  const te::dt::DateTime& value = static_cast<const te::dt::DateTime&>(ad);
139 
140  bind(i, value);
141  }
142  break;
143 
144  default :
145  throw Exception(TE_TR("The TerraLib data type is not supported by default prepared query implementation!"));
146  }
147 }
148 
virtual int getTypeCode() const =0
It returns the data type code associated to the data value.
T getValue() const
It returns the associated value.
Definition: SimpleData.h:139
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
A class that models a prepared query.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
A class for representing binary data.
Definition: ByteArray.h:51
virtual void bind(int i, char value)=0
Binds the i-th parameter of the query to a value.