diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Foundation/include/Poco/TextBufferIterator.h | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/include/Poco/TextBufferIterator.h')
-rw-r--r-- | contrib/libs/poco/Foundation/include/Poco/TextBufferIterator.h | 290 |
1 files changed, 145 insertions, 145 deletions
diff --git a/contrib/libs/poco/Foundation/include/Poco/TextBufferIterator.h b/contrib/libs/poco/Foundation/include/Poco/TextBufferIterator.h index 32af54c0dd..d8eda84175 100644 --- a/contrib/libs/poco/Foundation/include/Poco/TextBufferIterator.h +++ b/contrib/libs/poco/Foundation/include/Poco/TextBufferIterator.h @@ -1,145 +1,145 @@ -// -// TextBufferIterator.h -// -// Library: Foundation -// Package: Text -// Module: TextBufferIterator -// -// Definition of the TextBufferIterator class. -// -// Copyright (c) 2010, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_TextBufferIterator_INCLUDED -#define Foundation_TextBufferIterator_INCLUDED - - -#include "Poco/Foundation.h" -#include <cstdlib> - - -namespace Poco { - - -class TextEncoding; - - -class Foundation_API TextBufferIterator - /// 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. -{ -public: - TextBufferIterator(); - /// Creates an uninitialized 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(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(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. - - TextBufferIterator(const char* end); - /// Creates an end TextBufferIterator for the given buffer. - - ~TextBufferIterator(); - /// Destroys the TextBufferIterator. - - TextBufferIterator(const TextBufferIterator& it); - /// Copy constructor. - - TextBufferIterator& operator = (const TextBufferIterator& it); - /// Assignment operator. - - void swap(TextBufferIterator& it); - /// Swaps the iterator with another one. - - int operator * () const; - /// Returns the Unicode value of the current character. - /// If there is no valid character at the current position, - /// -1 is returned. - - TextBufferIterator& operator ++ (); - /// Prefix increment operator. - - TextBufferIterator operator ++ (int); - /// Postfix increment operator. - - bool operator == (const TextBufferIterator& it) const; - /// Compares two iterators for equality. - - bool operator != (const TextBufferIterator& it) const; - /// Compares two iterators for inequality. - - TextBufferIterator end() const; - /// Returns the end iterator for the range handled - /// by the iterator. - -private: - const TextEncoding* _pEncoding; - const char* _it; - const char* _end; -}; - - -// -// inlines -// -inline bool TextBufferIterator::operator == (const TextBufferIterator& it) const -{ - return _it == it._it; -} - - -inline bool TextBufferIterator::operator != (const TextBufferIterator& it) const -{ - return _it != it._it; -} - - -inline void swap(TextBufferIterator& it1, TextBufferIterator& it2) -{ - it1.swap(it2); -} - - -inline TextBufferIterator TextBufferIterator::end() const -{ - return TextBufferIterator(_end); -} - - -} // namespace Poco - - -#endif // Foundation_TextBufferIterator_INCLUDED +// +// TextBufferIterator.h +// +// Library: Foundation +// Package: Text +// Module: TextBufferIterator +// +// Definition of the TextBufferIterator class. +// +// Copyright (c) 2010, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef Foundation_TextBufferIterator_INCLUDED +#define Foundation_TextBufferIterator_INCLUDED + + +#include "Poco/Foundation.h" +#include <cstdlib> + + +namespace Poco { + + +class TextEncoding; + + +class Foundation_API TextBufferIterator + /// 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. +{ +public: + TextBufferIterator(); + /// Creates an uninitialized 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(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(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. + + TextBufferIterator(const char* end); + /// Creates an end TextBufferIterator for the given buffer. + + ~TextBufferIterator(); + /// Destroys the TextBufferIterator. + + TextBufferIterator(const TextBufferIterator& it); + /// Copy constructor. + + TextBufferIterator& operator = (const TextBufferIterator& it); + /// Assignment operator. + + void swap(TextBufferIterator& it); + /// Swaps the iterator with another one. + + int operator * () const; + /// Returns the Unicode value of the current character. + /// If there is no valid character at the current position, + /// -1 is returned. + + TextBufferIterator& operator ++ (); + /// Prefix increment operator. + + TextBufferIterator operator ++ (int); + /// Postfix increment operator. + + bool operator == (const TextBufferIterator& it) const; + /// Compares two iterators for equality. + + bool operator != (const TextBufferIterator& it) const; + /// Compares two iterators for inequality. + + TextBufferIterator end() const; + /// Returns the end iterator for the range handled + /// by the iterator. + +private: + const TextEncoding* _pEncoding; + const char* _it; + const char* _end; +}; + + +// +// inlines +// +inline bool TextBufferIterator::operator == (const TextBufferIterator& it) const +{ + return _it == it._it; +} + + +inline bool TextBufferIterator::operator != (const TextBufferIterator& it) const +{ + return _it != it._it; +} + + +inline void swap(TextBufferIterator& it1, TextBufferIterator& it2) +{ + it1.swap(it2); +} + + +inline TextBufferIterator TextBufferIterator::end() const +{ + return TextBufferIterator(_end); +} + + +} // namespace Poco + + +#endif // Foundation_TextBufferIterator_INCLUDED |