/* * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) * * Website: http://www.ocilib.net * * Copyright (c) 2007-2023 Vincent ROGIER * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "ocilibcpp/types.hpp" // ReSharper disable CppClangTidyCertOop54Cpp namespace ocilib { template CollectionIterator::CollectionIterator() : _elem() { } template CollectionIterator::CollectionIterator(CollectionType *collection, unsigned int pos) : _elem(collection, pos) { } template CollectionIterator::CollectionIterator(const CollectionIterator& other) : _elem(other._elem) { } template CollectionIterator& CollectionIterator::operator = (const CollectionIterator& other) { if (this != &other) { _elem._pos = other._elem._pos; _elem._coll = other._elem._coll; } return *this; } template CollectionIterator& CollectionIterator::operator += (difference_type value) { _elem._pos += static_cast(value); return *this; } template CollectionIterator& CollectionIterator::operator -= (difference_type value) { _elem._pos -= static_cast(value); return *this; } template T& CollectionIterator::operator*() { return _elem; } template T* CollectionIterator::operator->() { return &_elem; } template CollectionIterator& CollectionIterator::operator--() { --_elem._pos; return *this; } template CollectionIterator& CollectionIterator::operator++() { ++*(const_cast(&_elem._pos)); return *this; } template CollectionIterator CollectionIterator::operator++(int) { CollectionIterator res(_elem._coll, _elem._pos); ++(*this); return res; } template CollectionIterator CollectionIterator::operator--(int) { CollectionIterator res(_elem); --(*this); return res; } template CollectionIterator CollectionIterator::operator + (difference_type value) { return CollectionIterator(_elem._coll, _elem._pos + static_cast(value)); } template CollectionIterator CollectionIterator::operator - (difference_type value) { return CollectionIterator(_elem._coll, _elem._pos - static_cast(value)); } template typename CollectionIterator::difference_type CollectionIterator::operator - (const CollectionIterator & other) { return static_cast(_elem._pos - other._elem._pos); } template bool CollectionIterator::operator == (const CollectionIterator& other) { return _elem._pos == other._elem._pos && (static_cast(*_elem._coll)) == (static_cast(*other._elem._coll)); } template bool CollectionIterator::operator != (const CollectionIterator& other) { return !(*this == other); } template bool CollectionIterator::operator > (const CollectionIterator& other) { return _elem._pos > other._elem._pos; } template bool CollectionIterator::operator < (const CollectionIterator& other) { return _elem._pos < other._elem._pos; } template bool CollectionIterator::operator >= (const CollectionIterator& other) { return _elem._pos >= other._elem._pos; } template bool CollectionIterator::operator <= (const CollectionIterator& other) { return _elem._pos <= other._elem._pos; } }