00001 /* $Id: string_base.h 25979 2013-11-13 21:28:21Z rubidium $ */ 00002 00003 /* 00004 * This file is part of OpenTTD. 00005 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. 00006 * OpenTTD 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. 00007 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. 00008 */ 00009 00010 #ifndef STRING_BASE_H 00011 #define STRING_BASE_H 00012 00013 #include "string_type.h" 00014 00016 class StringIterator { 00017 public: 00019 enum IterType { 00020 ITER_CHARACTER, 00021 ITER_WORD, 00022 }; 00023 00025 static const size_t END = SIZE_MAX; 00026 00031 static StringIterator *Create(); 00032 00033 virtual ~StringIterator() {} 00034 00040 virtual void SetString(const char *s) = 0; 00041 00048 virtual size_t SetCurPosition(size_t pos) = 0; 00049 00054 virtual size_t Next(IterType what = ITER_CHARACTER) = 0; 00055 00060 virtual size_t Prev(IterType what = ITER_CHARACTER) = 0; 00061 00062 protected: 00063 StringIterator() {} 00064 }; 00065 00066 #endif /* STRING_BASE_H */