rasdaman API
oqlquery.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
34 #ifndef _D_OQL_QUERY_
35 #define _D_OQL_QUERY_
36 
37 #include "raslib/error.hh"
38 
39 #include "raslib/odmgtypes.hh"
40 #include "rasodmg/marray.hh"
41 #include "raslib/point.hh"
42 #include "raslib/sinterval.hh"
43 #include "raslib/minterval.hh"
44 
45 template <class T> class r_Set;
46 template <class T> class r_Ref;
47 class r_Ref_Any;
48 
49 //@ManMemo: Module: {\bf rasodmg}
50 
51 /*@Doc:
52 
53  The global function \Ref{r_oql_execute} is used to invoke RasML
54  queries. The query statement is represented through an object
55  of class \Ref{r_OQL_Query} which is the first argument of the function.
56  The constructor gets a parameterized query string where #$i#
57  indicates the i-th parameter. The overloaded stream input
58  operators allows to insert the parameter values to the query, at
59  the same time preserving their respective types. If any of the
60  #$i# are not followed by a right operant construction argument at
61  the point \Ref{r_oql_execute} is called, a \Ref{r_Error} exception object
62  of kind {\tt r_Error_QueryParameterCountInvalid} is thrown.
63  Once a query has been executed via \Ref{r_oql_execute}, the arguments
64  associated with the #$i# parameters are cleared and new arguments
65  must be supplied.
66 
67  The copy constructor and assignment operator copy all the underlying
68  data structures associated with the query, based upon the parameters
69  that have been passed to the query at the point the operation is
70  performed.
71 
72  The stream operators raise a \Ref{r_Error} exception of type
73  {\tt r_Error_QueryParameterCountInvalid} if the number of arguments is
74  exceeded.
75 
76 */
77 
82 {
83 public:
85  r_OQL_Query();
86 
88  r_OQL_Query( const char* s );
89 
91  r_OQL_Query( const r_OQL_Query& q );
92 
94  ~r_OQL_Query();
95 
97  const r_OQL_Query& operator=( const r_OQL_Query& q );
98 
99  //@Man: Stream input operators for every parameter type:
101  r_OQL_Query& operator<<( const char* s ) throw( r_Error );
104  r_OQL_Query& operator<<( r_Char c ) throw( r_Error );
106  r_OQL_Query& operator<<( r_Short s ) throw( r_Error );
108  r_OQL_Query& operator<<( r_UShort us ) throw( r_Error );
110  r_OQL_Query& operator<<( r_Long l ) throw( r_Error );
112  r_OQL_Query& operator<<( r_ULong ul ) throw( r_Error );
114  r_OQL_Query& operator<<( r_Point pt ) throw( r_Error );
116  r_OQL_Query& operator<<( r_Sinterval in ) throw( r_Error );
118  r_OQL_Query& operator<<( r_Minterval in ) throw( r_Error );
120  r_OQL_Query& operator<<( r_GMarray& in ) throw( r_Error );
122 
123 
125  int is_update_query() const;
126 
128  int is_retrieval_query() const;
129 
130  //@Man: Methods for internal use:
132  void reset_query();
135  inline const char* get_query() const;
137  inline const r_Set< r_GMarray* >* get_constants() const;
139  inline const char* get_parameterized_query() const;
141 
142 
143 private:
145  void replaceNextArgument( const char* valueString ) throw( r_Error );
146 
148  char* queryString;
149 
151  char* parameterizedQueryString;
152 
154  r_Set< r_GMarray* >* mddConstants;
155 };
156 
157 
158 
159 
160 //@ManMemo: Module: {\bf rasodmg}
161 
162 /*@Doc:
163  The free standing function \Ref{r_oql_execute} is called to execute a retrieval query.
164  The first parameter, {\tt query}, is a reference to a \Ref{r_OQL_Query} object specifying
165  the query to execute. The second parameter, {\tt result}, is used for returning the
166  result of the query. The query result is of type {\tt r_Set< r_Ref_Any >}.
167 
168  If the function is not called within the scope of an opened database, a \Ref{r_Error}
169  exception of kind {\tt r_Error_DatabaseClosed} is raised. If it is called outside any
170  transaction, the exception is of kind {\tt r_Error_TransactionNotOpen}.
171 
172  A complete list of all possible error kinds is given by the following table.
173 
174  \begin{tabular}{lll}
175  r_Error_ClientUnknown && Client is not known by the server (earlier communication problems).\\
176  r_Error_DatabaseClosed && No database is not opened.\\
177  r_Error_TransactionNotOpen && Call is not within an active transaction.\\
178  r_Error_QueryParameterCountInvalid && At least one of the query parameters is not supplied with a value.\\
179  r_Error_TransferFailed && Other communication problem. \\
180  r_Error_QueryExecutionFailed && The execution of the query failed (further information is available
181  in an error object of type {\tt r_Equery_execution}).\\
182  r_Error_TypeInvalid && Result base type doesn't match the template type. \\
183  \end{tabular}
184 */
185 
186 void r_oql_execute( r_OQL_Query& query, r_Set< r_Ref_Any > &result )
187 throw( r_Error );
188 
189 
190 //@ManMemo: Module: {\bf rasodmg}
191 
192 /*@Doc:
193  The funcetion is used to execute retrieval queries with the result set being
194  of type {\tt r_Set< r_Ref< r_GMarray > >}. The function is supported for
195  compatibility reasons only. We suggest to use the general function
196  \Ref{r_oql_execute} able to maintain query results of any type.
197 */
198 void r_oql_execute( r_OQL_Query& query, r_Set< r_Ref< r_GMarray > > &result )
199 throw( r_Error );
200 
201 
202 //@ManMemo: Module: {\bf rasodmg}
203 
204 /*@Doc:
205  The free standing function \Ref{r_oql_execute} is called to execute an update query.
206  The first parameter, {\tt query}, is a reference to a \Ref{r_OQL_Query} object specifying
207  the query to execute.
208 
209  If the function is not called within the scope of an opened database, a \Ref{r_Error}
210  exception of kind {\tt r_Error_DatabaseClosed} is raised. If it is called outside any
211  transaction, the exception is of kind {\tt r_Error_TransactionNotOpen}.
212 
213  A complete list of all possible error kinds is given by the following table.
214 
215  \begin{tabular}{lll}
216  r_Error_ClientUnknown && Client is not known by the server (earlier communication problems).\\
217  r_Error_DatabaseClosed && No database is not opened.\\
218  r_Error_TransactionNotOpen && Call is not within an active transaction.\\
219  r_Error_QueryParameterCountInvalid && At least one of the query parameters is not supplied with a value.\\
220  r_Error_TransferFailed && Other communication problem. \\
221  r_Error_QueryExecutionFailed && The execution of the query failed (further information is available
222  in an error object of type {\tt r_Equery_execution}).\\
223  \end{tabular}
224 */
225 
226 void r_oql_execute( r_OQL_Query& query )
227 throw( r_Error );
228 
229 #include "rasodmg/oqlquery.icc"
230 
231 #endif
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
242 
243 
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
r_OQL_Query & operator<<(const char *s)
unsigned short r_UShort
Definition: odmgtypes.hh:87
Definition: sinterval.hh:233
unsigned int r_ULong
Definition: odmgtypes.hh:114
Definition: point.hh:59
int is_retrieval_query() const
returns true if the current query is an update one
void r_oql_execute(r_OQL_Query &query, r_Set< r_Ref_Any > &result)
const char * get_parameterized_query() const
gets the parameterized query string
Definition: error.hh:88
const char * get_query() const
gets the expanded query string
const r_OQL_Query & operator=(const r_OQL_Query &q)
assignment operator
Definition: oqlquery.hh:46
int is_update_query() const
returns true if the current query is an update one
Definition: gmarray.hh:66
~r_OQL_Query()
destructor
const r_Set< r_GMarray * > * get_constants() const
get mdd constants
unsigned char r_Char
Definition: odmgtypes.hh:47
Definition: oqlquery.hh:81
int r_Long
Definition: odmgtypes.hh:100
short r_Short
Definition: odmgtypes.hh:74
r_OQL_Query()
default constructor
void reset_query()
resets the expandation of the query string
Definition: minterval.hh:249