| Apache Ignite C++

core/include/ignite/cache/query/query_fields_row.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
23 #ifndef _IGNITE_CACHE_QUERY_QUERY_FIELDS_ROW
24 #define _IGNITE_CACHE_QUERY_QUERY_FIELDS_ROW
25
26 #include <vector>
27
28 #include <ignite/common/concurrent.h>
29 #include <ignite/ignite_error.h>
30
31 #include "ignite/cache/cache_entry.h"
32 #include "ignite/impl/cache/query/query_fields_row_impl.h"
33 #include "ignite/impl/operations.h"
34
35 namespace ignite
36 {
37 namespace cache
38 {
39 namespace query
40 {
49 class QueryFieldsRow
50 {
51 public:
57 QueryFieldsRow() : impl(0)
58 {
59 // No-op.
60 }
61
69 QueryFieldsRow(impl::cache::query::QueryFieldsRowImpl* impl) : impl(impl)
70 {
71 // No-op.
72 }
73
83 bool HasNext()
84 {
85 IgniteError err;
86
87 bool res = HasNext(err);
88
89 IgniteError::ThrowIfNeeded(err);
90
91 return res;
92 }
93
104 bool HasNext(IgniteError& err)
105 {
106 impl::cache::query::QueryFieldsRowImpl* impl0 = impl.Get();
107
108 if (impl0)
109 return impl0->HasNext();
110 else
111 {
112 err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
113 "Instance is not usable (did you check for error?).");
114
115 return false;
116 }
117 }
118
132 template<typename T>
133 T GetNext()
134 {
135 IgniteError err;
136
137 T res = GetNext<T>(err);
138
139 IgniteError::ThrowIfNeeded(err);
140
141 return res;
142 }
143
158 template<typename T>
159 T GetNext(IgniteError& err)
160 {
161 impl::cache::query::QueryFieldsRowImpl* impl0 = impl.Get();
162
163 if (impl0)
164 return impl0->GetNext<T>(err);
165 else
166 {
167 err = IgniteError(IgniteError::IGNITE_ERR_GENERIC,
168 "Instance is not usable (did you check for error?).");
169
170 return T();
171 }
172 }
173
189 int32_t GetNextInt8Array(int8_t* dst, int32_t len)
190 {
191 impl::cache::query::QueryFieldsRowImpl* impl0 = impl.Get();
192
193 if (impl0)
194 return impl0->GetNextInt8Array(dst, len);
195 else
196 {
197 throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
198 "Instance is not usable (did you check for error?).");
199 }
200 }
201
213 bool IsValid() const
214 {
215 return impl.IsValid();
216 }
217
218 private:
220 ignite::common::concurrent::SharedPointer<impl::cache::query::QueryFieldsRowImpl> impl;
221 };
222 }
223 }
224 }
225
226 #endif //_IGNITE_CACHE_QUERY_QUERY_FIELDS_ROW
ignite::cache::query::QueryFieldsRow::GetNextInt8Array
int32_t GetNextInt8Array(int8_t *dst, int32_t len)
Get next entry assuming it's an array of 8-byte signed integers.
Definition: core/include/ignite/cache/query/query_fields_row.h:189
ignite::cache::query::QueryFieldsRow::QueryFieldsRow
QueryFieldsRow()
Default constructor.
Definition: core/include/ignite/cache/query/query_fields_row.h:57
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::cache::query::QueryFieldsRow::GetNext
T GetNext(IgniteError &err)
Get next entry.
Definition: core/include/ignite/cache/query/query_fields_row.h:159
ignite::cache::query::QueryFieldsRow::HasNext
bool HasNext(IgniteError &err)
Check whether next entry exists.
Definition: core/include/ignite/cache/query/query_fields_row.h:104
ignite::cache::query::QueryFieldsRow::QueryFieldsRow
QueryFieldsRow(impl::cache::query::QueryFieldsRowImpl *impl)
Constructor.
Definition: core/include/ignite/cache/query/query_fields_row.h:69
ignite::cache::query::QueryFieldsRow::GetNext
T GetNext()
Get next entry.
Definition: core/include/ignite/cache/query/query_fields_row.h:133
ignite::cache::query::QueryFieldsRow::IsValid
bool IsValid() const
Check if the instance is valid.
Definition: core/include/ignite/cache/query/query_fields_row.h:213
ignite::IgniteError::IGNITE_ERR_GENERIC
static const int IGNITE_ERR_GENERIC
Generic Ignite error.
Definition: ignite_error.h:131
cache_entry.h
ignite::cache::query::QueryFieldsRow::HasNext
bool HasNext()
Check whether next entry exists.
Definition: core/include/ignite/cache/query/query_fields_row.h:83
ignite::IgniteError::ThrowIfNeeded
static void ThrowIfNeeded(const IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:27
ignite::cache::query::QueryFieldsRow
Query fields cursor.
Definition: core/include/ignite/cache/query/query_fields_row.h:49
ignite_error.h
ignite::IgniteError
Ignite error information.
Definition: ignite_error.h:94