00001 // 00002 // TextIterator.h 00003 // 00004 // $Id: //poco/1.3/Foundation/include/Poco/TextIterator.h#1 $ 00005 // 00006 // Library: Foundation 00007 // Package: Text 00008 // Module: TextIterator 00009 // 00010 // Definition of the TextIterator class. 00011 // 00012 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 00013 // and Contributors. 00014 // 00015 // Permission is hereby granted, free of charge, to any person or organization 00016 // obtaining a copy of the software and accompanying documentation covered by 00017 // this license (the "Software") to use, reproduce, display, distribute, 00018 // execute, and transmit the Software, and to prepare derivative works of the 00019 // Software, and to permit third-parties to whom the Software is furnished to 00020 // do so, all subject to the following: 00021 // 00022 // The copyright notices in the Software and this entire statement, including 00023 // the above license grant, this restriction and the following disclaimer, 00024 // must be included in all copies of the Software, in whole or in part, and 00025 // all derivative works of the Software, unless such copies or derivative 00026 // works are solely in the form of machine-executable object code generated by 00027 // a source language processor. 00028 // 00029 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00030 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00031 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 00032 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 00033 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 00034 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00035 // DEALINGS IN THE SOFTWARE. 00036 // 00037 00038 00039 #ifndef Foundation_TextIterator_INCLUDED 00040 #define Foundation_TextIterator_INCLUDED 00041 00042 00043 #include "Poco/Foundation.h" 00044 00045 00046 namespace Poco { 00047 00048 00049 class TextEncoding; 00050 00051 00052 class Foundation_API TextIterator 00070 { 00071 public: 00072 TextIterator(); 00074 00075 TextIterator(const std::string& str, const TextEncoding& encoding); 00079 00080 TextIterator(const std::string::const_iterator& begin, const std::string::const_iterator& end, const TextEncoding& encoding); 00084 00085 TextIterator(const std::string& str); 00087 00088 TextIterator(const std::string::const_iterator& end); 00090 00091 ~TextIterator(); 00093 00094 TextIterator(const TextIterator& it); 00096 00097 TextIterator& operator = (const TextIterator& it); 00099 00100 void swap(TextIterator& it); 00102 00103 int operator * () const; 00107 00108 TextIterator& operator ++ (); 00110 00111 TextIterator operator ++ (int); 00113 00114 bool operator == (const TextIterator& it) const; 00116 00117 bool operator != (const TextIterator& it) const; 00119 00120 private: 00121 const TextEncoding* _pEncoding; 00122 std::string::const_iterator _it; 00123 std::string::const_iterator _end; 00124 }; 00125 00126 00127 // 00128 // inlines 00129 // 00130 inline bool TextIterator::operator == (const TextIterator& it) const 00131 { 00132 return _it == it._it; 00133 } 00134 00135 00136 inline bool TextIterator::operator != (const TextIterator& it) const 00137 { 00138 return _it != it._it; 00139 } 00140 00141 00142 inline void swap(TextIterator& it1, TextIterator& it2) 00143 { 00144 it1.swap(it2); 00145 } 00146 00147 00148 } // namespace Poco 00149 00150 00151 #endif // Foundation_TextIterator_INCLUDED