GridGain C++
core/include/ignite/cache/query/query_fields_cursor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 GridGain Systems, Inc. and Contributors.
3  *
4  * Licensed under the GridGain Community Edition License (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef _IGNITE_CACHE_QUERY_QUERY_FIELDS_CURSOR
23 #define _IGNITE_CACHE_QUERY_QUERY_FIELDS_CURSOR
24 
25 #include <vector>
26 
27 #include <ignite/common/concurrent.h>
28 #include <ignite/ignite_error.h>
29 
32 #include "ignite/impl/cache/query/query_impl.h"
33 #include "ignite/impl/operations.h"
34 
35 namespace ignite
36 {
37  namespace cache
38  {
39  namespace query
40  {
50  {
51  public:
58  QueryFieldsCursor() : impl(0)
59  {
60  // No-op.
61  }
62 
70  QueryFieldsCursor(impl::cache::query::QueryCursorImpl* impl) : impl(impl)
71  {
72  // No-op.
73  }
74 
84  bool HasNext()
85  {
86  IgniteError err;
87 
88  bool res = HasNext(err);
89 
91 
92  return res;
93  }
94 
105  bool HasNext(IgniteError& err)
106  {
107  impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
108 
109  if (impl0)
110  return impl0->HasNext(err);
111  else
112  {
114  "Instance is not usable (did you check for error?).");
115 
116  return false;
117  }
118  }
119 
130  {
131  IgniteError err;
132 
133  QueryFieldsRow res = GetNext(err);
134 
136 
137  return res;
138  }
139 
151  {
152  impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
153 
154  if (impl0)
155  return impl0->GetNextRow(err);
156  else
157  {
159  "Instance is not usable (did you check for error?).");
160 
161  return QueryFieldsRow();
162  }
163  }
164 
176  bool IsValid() const
177  {
178  return impl.IsValid();
179  }
180 
181  private:
183  ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl> impl;
184  };
185  }
186  }
187 }
188 
189 #endif //_IGNITE_CACHE_QUERY_QUERY_FIELDS_CURSOR
ignite
Ignite API.
Definition: cache.h:47
query_fields_row.h
ignite::cache::query::QueryFieldsCursor::QueryFieldsCursor
QueryFieldsCursor()
Default constructor.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:58
ignite::cache::query::QueryFieldsCursor::QueryFieldsCursor
QueryFieldsCursor(impl::cache::query::QueryCursorImpl *impl)
Constructor.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:70
ignite::cache::query::QueryFieldsCursor
Query fields cursor.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:49
ignite::cache::query::QueryFieldsCursor::GetNext
QueryFieldsRow GetNext()
Get next entry.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:129
ignite::IgniteError::IGNITE_ERR_GENERIC
static const int IGNITE_ERR_GENERIC
Generic Ignite error.
Definition: ignite_error.h:130
ignite::cache::query::QueryFieldsCursor::GetNext
QueryFieldsRow GetNext(IgniteError &err)
Get next entry.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:150
cache_entry.h
ignite::cache::query::QueryFieldsCursor::IsValid
bool IsValid() const
Check if the instance is valid.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:176
ignite::cache::query::QueryFieldsCursor::HasNext
bool HasNext()
Check whether next entry exists.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:84
ignite::IgniteError::ThrowIfNeeded
static void ThrowIfNeeded(const IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:26
ignite::cache::query::QueryFieldsCursor::HasNext
bool HasNext(IgniteError &err)
Check whether next entry exists.
Definition: core/include/ignite/cache/query/query_fields_cursor.h:105
ignite::cache::query::QueryFieldsRow
Query fields cursor.
Definition: core/include/ignite/cache/query/query_fields_row.h:48
ignite_error.h
ignite::IgniteError
Ignite error information.
Definition: ignite_error.h:93