1 /* 2 Copyright (c) DataStax, Inc. 3 4 Licensed under the Apache License, Version 2.0 (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 http://www.apache.org/licenses/LICENSE-2.0 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 17 #ifndef DATASTAX_INTERNAL_ROW_ITERATOR_HPP 18 #define DATASTAX_INTERNAL_ROW_ITERATOR_HPP 19 20 #include "iterator.hpp" 21 #include "row.hpp" 22 23 namespace datastax { namespace internal { namespace core { 24 25 class RowIterator : public Iterator { 26 public: RowIterator(const Row * row)27 RowIterator(const Row* row) 28 : Iterator(CASS_ITERATOR_TYPE_ROW) 29 , row_(row) 30 , index_(-1) {} 31 next()32 virtual bool next() { 33 if (static_cast<size_t>(index_ + 1) >= row_->values.size()) { 34 return false; 35 } 36 ++index_; 37 return true; 38 } 39 column() const40 const Value* column() const { 41 assert(index_ >= 0 && static_cast<size_t>(index_) < row_->values.size()); 42 return &row_->values[index_]; 43 } 44 45 private: 46 const Row* row_; 47 int32_t index_; 48 }; 49 50 }}} // namespace datastax::internal::core 51 52 #endif 53