Apache Ignite C++
query_fields_cursor.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_FIELDS_CURSOR
24 #define _IGNITE_CACHE_QUERY_FIELDS_CURSOR
25 
26 #include <vector>
27 
28 #include <ignite/common/concurrent.h>
29 
31 #include "ignite/ignite_error.h"
33 #include "ignite/impl/cache/query/query_impl.h"
34 #include "ignite/impl/operations.h"
35 
36 namespace ignite
37 {
38  namespace cache
39  {
40  namespace query
41  {
46  {
47  public:
51  QueryFieldsCursor() : impl(NULL)
52  {
53  // No-op.
54  }
55 
61  QueryFieldsCursor(impl::cache::query::QueryCursorImpl* impl) : impl(impl)
62  {
63  // No-op.
64  }
65 
71  bool HasNext()
72  {
73  IgniteError err;
74 
75  bool res = HasNext(err);
76 
78 
79  return res;
80  }
81 
88  bool HasNext(IgniteError& err)
89  {
90  impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
91 
92  if (impl0)
93  return impl0->HasNext(&err);
94  else
95  {
97  "Instance is not usable (did you check for error?).");
98 
99  return false;
100  }
101  }
102 
109  {
110  IgniteError err;
111 
112  QueryFieldsRow res = GetNext(err);
113 
115 
116  return res;
117  }
118 
126  {
127  impl::cache::query::QueryCursorImpl* impl0 = impl.Get();
128 
129  if (impl0)
130  return impl0->GetNextRow(&err);
131  else
132  {
134  "Instance is not usable (did you check for error?).");
135 
136  return QueryFieldsRow();
137  }
138  }
139 
145  bool IsValid()
146  {
147  return impl.IsValid();
148  }
149 
150  private:
152  ignite::common::concurrent::SharedPointer<impl::cache::query::QueryCursorImpl> impl;
153  };
154  }
155  }
156 }
157 
158 #endif
bool HasNext(IgniteError &err)
Check whether next entry exists.
Definition: query_fields_cursor.h:88
QueryFieldsCursor()
Default constructor.
Definition: query_fields_cursor.h:51
Declares ignite::cache::query::QueryFieldsRow class.
Query fields cursor.
Definition: query_fields_cursor.h:45
static void ThrowIfNeeded(IgniteError &err)
Throw an error if code is not IGNITE_SUCCESS.
Definition: ignite_error.cpp:27
Declares ignite::cache::CacheEntry class.
Ignite error information.
Definition: ignite_error.h:78
bool IsValid()
Check if the instance is valid.
Definition: query_fields_cursor.h:145
QueryFieldsRow GetNext()
Get next entry.
Definition: query_fields_cursor.h:108
Query fields cursor.
Definition: query_fields_row.h:44
Apache Ignite API.
Definition: binary_consts.h:28
bool HasNext()
Check whether next entry exists.
Definition: query_fields_cursor.h:71
Declares ignite::IgniteError class.
QueryFieldsCursor(impl::cache::query::QueryCursorImpl *impl)
Constructor.
Definition: query_fields_cursor.h:61
QueryFieldsRow GetNext(IgniteError &err)
Get next entry.
Definition: query_fields_cursor.h:125
static const int IGNITE_ERR_GENERIC
Generic Ignite error.
Definition: ignite_error.h:112