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/src/TextBufferIterator.cpp | |
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/src/TextBufferIterator.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/TextBufferIterator.cpp | 354 |
1 files changed, 177 insertions, 177 deletions
diff --git a/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp b/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp index 1c0fd6b6bc..7a503081ae 100644 --- a/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp +++ b/contrib/libs/poco/Foundation/src/TextBufferIterator.cpp @@ -1,178 +1,178 @@ -// -// TextBufferIterator.cpp -// -// Library: Foundation -// Package: Text -// Module: TextBufferIterator -// -// Copyright (c) 2010, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/TextBufferIterator.h" -#include "Poco/TextEncoding.h" -#include <algorithm> -#include <cstring> - - -namespace Poco { - - -TextBufferIterator::TextBufferIterator(): - _pEncoding(0), - _it(0), - _end(0) -{ -} - - -TextBufferIterator::TextBufferIterator(const char* begin, const TextEncoding& encoding): - _pEncoding(&encoding), - _it(begin), - _end(begin + std::strlen(begin)) -{ -} - - -TextBufferIterator::TextBufferIterator(const char* begin, std::size_t size, const TextEncoding& encoding): - _pEncoding(&encoding), - _it(begin), - _end(begin + size) -{ -} - - -TextBufferIterator::TextBufferIterator(const char* begin, const char* pEnd, const TextEncoding& encoding): - _pEncoding(&encoding), - _it(begin), - _end(pEnd) -{ -} - - -TextBufferIterator::TextBufferIterator(const char* pEnd): - _pEncoding(0), - _it(pEnd), - _end(pEnd) -{ -} - - -TextBufferIterator::~TextBufferIterator() -{ -} - - -TextBufferIterator::TextBufferIterator(const TextBufferIterator& it): - _pEncoding(it._pEncoding), - _it(it._it), - _end(it._end) -{ -} - - -TextBufferIterator& TextBufferIterator::operator = (const TextBufferIterator& it) -{ - if (&it != this) +// +// TextBufferIterator.cpp +// +// Library: Foundation +// Package: Text +// Module: TextBufferIterator +// +// Copyright (c) 2010, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/TextBufferIterator.h" +#include "Poco/TextEncoding.h" +#include <algorithm> +#include <cstring> + + +namespace Poco { + + +TextBufferIterator::TextBufferIterator(): + _pEncoding(0), + _it(0), + _end(0) +{ +} + + +TextBufferIterator::TextBufferIterator(const char* begin, const TextEncoding& encoding): + _pEncoding(&encoding), + _it(begin), + _end(begin + std::strlen(begin)) +{ +} + + +TextBufferIterator::TextBufferIterator(const char* begin, std::size_t size, const TextEncoding& encoding): + _pEncoding(&encoding), + _it(begin), + _end(begin + size) +{ +} + + +TextBufferIterator::TextBufferIterator(const char* begin, const char* pEnd, const TextEncoding& encoding): + _pEncoding(&encoding), + _it(begin), + _end(pEnd) +{ +} + + +TextBufferIterator::TextBufferIterator(const char* pEnd): + _pEncoding(0), + _it(pEnd), + _end(pEnd) +{ +} + + +TextBufferIterator::~TextBufferIterator() +{ +} + + +TextBufferIterator::TextBufferIterator(const TextBufferIterator& it): + _pEncoding(it._pEncoding), + _it(it._it), + _end(it._end) +{ +} + + +TextBufferIterator& TextBufferIterator::operator = (const TextBufferIterator& it) +{ + if (&it != this) + { + _pEncoding = it._pEncoding; + _it = it._it; + _end = it._end; + } + return *this; +} + + +void TextBufferIterator::swap(TextBufferIterator& it) +{ + std::swap(_pEncoding, it._pEncoding); + std::swap(_it, it._it); + std::swap(_end, it._end); +} + + +int TextBufferIterator::operator * () const +{ + poco_check_ptr (_pEncoding); + poco_assert (_it != _end); + const char* it = _it; + + unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH]; + unsigned char* p = buffer; + + if (it != _end) + *p++ = *it++; + else + *p++ = 0; + + int read = 1; + int n = _pEncoding->queryConvert(buffer, 1); + + while (-1 > n && (_end - it) >= -n - read) + { + while (read < -n && it != _end) + { + *p++ = *it++; + read++; + } + n = _pEncoding->queryConvert(buffer, read); + } + + if (-1 > n) + { + return -1; + } + else + { + return n; + } +} + + +TextBufferIterator& TextBufferIterator::operator ++ () +{ + poco_check_ptr (_pEncoding); + poco_assert (_it != _end); + + unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH]; + unsigned char* p = buffer; + + if (_it != _end) + *p++ = *_it++; + else + *p++ = 0; + + int read = 1; + int n = _pEncoding->sequenceLength(buffer, 1); + + while (-1 > n && (_end - _it) >= -n - read) + { + while (read < -n && _it != _end) + { + *p++ = *_it++; + read++; + } + n = _pEncoding->sequenceLength(buffer, read); + } + while (read < n && _it != _end) { - _pEncoding = it._pEncoding; - _it = it._it; - _end = it._end; - } - return *this; -} - - -void TextBufferIterator::swap(TextBufferIterator& it) -{ - std::swap(_pEncoding, it._pEncoding); - std::swap(_it, it._it); - std::swap(_end, it._end); -} - - -int TextBufferIterator::operator * () const -{ - poco_check_ptr (_pEncoding); - poco_assert (_it != _end); - const char* it = _it; - - unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH]; - unsigned char* p = buffer; - - if (it != _end) - *p++ = *it++; - else - *p++ = 0; - - int read = 1; - int n = _pEncoding->queryConvert(buffer, 1); - - while (-1 > n && (_end - it) >= -n - read) - { - while (read < -n && it != _end) - { - *p++ = *it++; - read++; - } - n = _pEncoding->queryConvert(buffer, read); - } - - if (-1 > n) - { - return -1; - } - else - { - return n; - } -} - - -TextBufferIterator& TextBufferIterator::operator ++ () -{ - poco_check_ptr (_pEncoding); - poco_assert (_it != _end); - - unsigned char buffer[TextEncoding::MAX_SEQUENCE_LENGTH]; - unsigned char* p = buffer; - - if (_it != _end) - *p++ = *_it++; - else - *p++ = 0; - - int read = 1; - int n = _pEncoding->sequenceLength(buffer, 1); - - while (-1 > n && (_end - _it) >= -n - read) - { - while (read < -n && _it != _end) - { - *p++ = *_it++; - read++; - } - n = _pEncoding->sequenceLength(buffer, read); - } - while (read < n && _it != _end) - { - _it++; - read++; - } - - return *this; -} - - -TextBufferIterator TextBufferIterator::operator ++ (int) -{ - TextBufferIterator prev(*this); - operator ++ (); - return prev; -} - - -} // namespace Poco + _it++; + read++; + } + + return *this; +} + + +TextBufferIterator TextBufferIterator::operator ++ (int) +{ + TextBufferIterator prev(*this); + operator ++ (); + return prev; +} + + +} // namespace Poco |