File Information
Library: Foundation
Package: Text
Header: Poco/TextBufferIterator.h
Description
An unidirectional iterator for iterating over characters in a buffer. The TextBufferIterator uses a TextEncoding object to work with multi-byte character encodings like UTF-8. Characters are reported in Unicode.
Example: Count the number of UTF-8 characters in a buffer.
UTF8Encoding utf8Encoding; char buffer[] = "..."; TextBufferIterator it(buffer, utf8Encoding); TextBufferIterator end(it.end()); int n = 0; while (it != end) { ++n; ++it; }
NOTE: When an UTF-16 encoding is used, surrogate pairs will be reported as two separate characters, due to restrictions of the TextEncoding class.
For iterating over the characters in a std::string, see the TextIterator class.
Member Summary
Member Functions: end, operator !=, operator *, operator ++, operator =, operator ==, swap
Constructors
TextBufferIterator
Creates an uninitialized TextBufferIterator.
TextBufferIterator
TextBufferIterator(
const char * end
);
Creates an end TextBufferIterator for the given buffer.
TextBufferIterator
TextBufferIterator(
const TextBufferIterator & it
);
Copy constructor.
TextBufferIterator
TextBufferIterator(
const char * begin,
const TextEncoding & encoding
);
Creates a TextBufferIterator for the given buffer, which must be 0-terminated. The encoding object must not be deleted as long as the iterator is in use.
TextBufferIterator
TextBufferIterator(
const char * begin,
std::size_t size,
const TextEncoding & encoding
);
Creates a TextBufferIterator for the given buffer with the given size. The encoding object must not be deleted as long as the iterator is in use.
TextBufferIterator
TextBufferIterator(
const char * begin,
const char * end,
const TextEncoding & encoding
);
Creates a TextBufferIterator for the given range. The encoding object must not be deleted as long as the iterator is in use.
Destructor
~TextBufferIterator
Destroys the TextBufferIterator.
Member Functions
end
TextBufferIterator end() const;
Returns the end iterator for the range handled by the iterator.
operator !=
bool operator != (
const TextBufferIterator & it
) const;
Compares two iterators for inequality.
operator *
int operator * () const;
Returns the Unicode value of the current character. If there is no valid character at the current position, -1 is returned.
operator ++
TextBufferIterator & operator ++ ();
Prefix increment operator.
operator ++
TextBufferIterator operator ++ (
int
);
Postfix increment operator.
operator =
TextBufferIterator & operator = (
const TextBufferIterator & it
);
Assignment operator.
operator ==
bool operator == (
const TextBufferIterator & it
) const;
Compares two iterators for equality.
swap
void swap(
TextBufferIterator & it
) noexcept;
Swaps the iterator with another one.