/************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ConstrainedIterator.cxx,v $ * * $Revision: 1.3 $ * * last change: $Author: rt $ $Date: 2005-09-09 06:28:55 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2005 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ************************************************************************/ // This is a definition file of a template class. It is therefore // included by other files and thus has to be guarded against multiple // inclusion. #ifndef SD_TOOLPANEL_CONSTRAINED_ITERATOR_CXX #define SD_TOOLPANEL_CONSTRAINED_ITERATOR_CXX namespace sd { namespace toolpanel { template ConstrainedIterator::value_type& ConstrainedIterator::operator* (void) { return *maIterator; } template const ConstrainedIterator::value_type& ConstrainedIterator::operator* (void) const { return *maIterator; } template ConstrainedIterator::value_type& ConstrainedIterator::operator-> (void) { return *maIterator; } template const ConstrainedIterator::value_type& ConstrainedIterator::operator-> (void) const { return *maIterator; } template ConstrainedIterator ::ConstrainedIterator (void) : mpContainer (NULL) { } template ConstrainedIterator::ConstrainedIterator ( const Container& rContainer, const Container::iterator& rIterator) : mpContainer(&rContainer), maIterator (rIterator), mpConstraint (NULL) { AdvanceToNextValidElement(); } template ConstrainedIterator::ConstrainedIterator ( const Container& rContainer, const Container::iterator& rIterator, const Constraint& rConstraint) : mpContainer(&rContainer), maIterator (rIterator), mpConstraint (&rConstraint) { AdvanceToNextValidElement(); } template ConstrainedIterator::ConstrainedIterator ( const ConstrainedIterator& rIterator) : mpContainer (rIterator.mpContainer), maIterator (rIterator.maIterator), mpConstraint (rIterator.mpConstraint) { // Everything has been done in the initializer } template ConstrainedIterator& ConstrainedIterator ::operator= (const ConstrainedIterator& rIterator) { mpContainer = rIterator.mpContainer; maIterator = rIterator.maIterator; mpConstraint = rIterator.mpConstraint; AdvanceToNextValidElement(); return *this; } template bool ConstrainedIterator::operator== ( const ConstrainedIterator& aIterator) const { return ! operator!=(aIterator); } template bool ConstrainedIterator::operator!= ( const ConstrainedIterator& aIterator) const { return maIterator != aIterator.maIterator; } template ConstrainedIterator& ConstrainedIterator::operator++ (void) { maIterator++; AdvanceToNextValidElement(); return *this; } template ConstrainedIterator ConstrainedIterator::operator++ (int) { ConstrainedIterator aIterator (*this); ++(*this); return aIterator; } template ConstrainedIterator& ConstrainedIterator::operator-- (void) { maIterator--; AdvanceToPreviousValidElement(); return *this; } template ConstrainedIterator ConstrainedIterator::operator-- (int) { ConstrainedIterator aIterator (*this); --(*this); return aIterator; } template ConstrainedIterator ConstrainedIterator::operator+ (int nValue) const { return ConstrainedIterator (*mpContainer, maIterator+nValue); } template ConstrainedIterator ConstrainedIterator::operator- (int nValue) const { return ConstrainedIterator (*mpContainer, maIterator-nValue); } template void ConstrainedIterator::AdvanceToNextValidElement (void) { if (mpContainer!=NULL && mpConstraint!=NULL) { while (maIterator != mpContainer->end() && ! mpConstraint->operator()(*mpContainer, maIterator)) ++maIterator; } } template void ConstrainedIterator::AdvanceToPreviousValidElement (void) { if (mpContainer!=NULL && mpConstraint!=NULL) { while (maIterator != mpContainer->begin() && ! mpConstraint->operator()(*mpContainer, maIterator)) --maIterator; } } } } // end of namespace ::sd::toolpanel #endif