QGpCoreTools/ColumnTextIterator.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created: 2011-01-21
00022 **  Authors:
00023 **    Marc Wathelet (ISTerre, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef COLUMNTEXTITERATOR_H
00028 #define COLUMNTEXTITERATOR_H
00029 
00030 #include "QGpCoreToolsDLLExport.h"
00031 #include "ColumnTextParser.h"
00032 
00033 namespace QGpCoreTools {
00034 
00035   class QGPCORETOOLS_EXPORT ColumnTextIterator
00036   {
00037   public:
00038     inline ColumnTextIterator(const ColumnTextParser * parser);
00039     inline ColumnTextIterator(const ColumnTextIterator& o);
00040     ~ColumnTextIterator() {}
00041 
00042     inline void setCurrentSection(int index);
00043     int currentSection() const {return _section;}
00044     int currentRow() const {return _row;}
00045 
00046     void nextRow() {_row++;}
00047     bool atSectionEnd();
00048     bool atEnd() const;
00049 
00050     const ColumnTextParser * parser() const {return _parser;}
00051   private:
00052     const ColumnTextParser * _parser;
00053     int _section, _row, _endSectionRow;
00054   };
00055 
00056   inline ColumnTextIterator::ColumnTextIterator(const ColumnTextParser * parser)
00057   {
00058     _parser=parser;
00059     _section=0;
00060     _row=0;
00061     _endSectionRow=_parser->sectionEndRow(_section);
00062   }
00063 
00064   inline ColumnTextIterator::ColumnTextIterator(const ColumnTextIterator& o)
00065   {
00066     _parser=o._parser;
00067     _section=o._section;
00068     _row=o._row;
00069     _endSectionRow=o._endSectionRow;
00070   }
00071 
00072   inline void ColumnTextIterator::setCurrentSection(int index)
00073   {
00074     _section=index;
00075     _row=_parser->sectionBeginRow(_section);
00076     _endSectionRow=_parser->sectionEndRow(_section);
00077   }
00078 
00079   inline bool ColumnTextIterator::atSectionEnd()
00080   {
00081     if(_row<_endSectionRow) {
00082       return false;
00083     } else {
00084       _section++;
00085       _endSectionRow=_parser->sectionEndRow(_section);
00086       return true;
00087     }
00088   }
00089 
00090   inline bool ColumnTextIterator::atEnd() const
00091   {
00092     if(_row<_parser->rowCount()) {
00093       return false;
00094     } else {
00095       return true;
00096     }
00097   }
00098 
00099 } // namespace QGpCoreTools
00100 
00101 #endif // COLUMNTEXTITERATOR_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines