diff options
author | neksard <neksard@yandex-team.ru> | 2022-02-10 16:45:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:23 +0300 |
commit | 8f7cf138264e0caa318144bf8a2c950e0b0a8593 (patch) | |
tree | 83bf5c8c8047c42d8475e6095df90ccdc3d1b57f /contrib/libs/icu/i18n/fphdlimp.cpp | |
parent | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (diff) | |
download | ydb-8f7cf138264e0caa318144bf8a2c950e0b0a8593.tar.gz |
Restoring authorship annotation for <neksard@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/icu/i18n/fphdlimp.cpp')
-rw-r--r-- | contrib/libs/icu/i18n/fphdlimp.cpp | 206 |
1 files changed, 103 insertions, 103 deletions
diff --git a/contrib/libs/icu/i18n/fphdlimp.cpp b/contrib/libs/icu/i18n/fphdlimp.cpp index f51bf4bae7..c0a3cc6046 100644 --- a/contrib/libs/icu/i18n/fphdlimp.cpp +++ b/contrib/libs/icu/i18n/fphdlimp.cpp @@ -1,125 +1,125 @@ // © 2016 and later: Unicode, Inc. and others. -// License & terms of use: http://www.unicode.org/copyright.html -/* -******************************************************************************* -* Copyright (C) 2009-2015, International Business Machines Corporation and -* others. All Rights Reserved. -******************************************************************************* -*/ - -#include "unicode/utypes.h" - -#if !UCONFIG_NO_FORMATTING - -#include "fphdlimp.h" -#include "uvectr32.h" - -U_NAMESPACE_BEGIN - -// utility FieldPositionHandler -// base class, null implementation - -FieldPositionHandler::~FieldPositionHandler() { -} - +// License & terms of use: http://www.unicode.org/copyright.html +/* +******************************************************************************* +* Copyright (C) 2009-2015, International Business Machines Corporation and +* others. All Rights Reserved. +******************************************************************************* +*/ + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_FORMATTING + +#include "fphdlimp.h" +#include "uvectr32.h" + +U_NAMESPACE_BEGIN + +// utility FieldPositionHandler +// base class, null implementation + +FieldPositionHandler::~FieldPositionHandler() { +} + void FieldPositionHandler::setShift(int32_t delta) { fShift = delta; -} - - -// utility subclass FieldPositionOnlyHandler - -FieldPositionOnlyHandler::FieldPositionOnlyHandler(FieldPosition& _pos) - : pos(_pos) { -} - -FieldPositionOnlyHandler::~FieldPositionOnlyHandler() { -} - -void -FieldPositionOnlyHandler::addAttribute(int32_t id, int32_t start, int32_t limit) { +} + + +// utility subclass FieldPositionOnlyHandler + +FieldPositionOnlyHandler::FieldPositionOnlyHandler(FieldPosition& _pos) + : pos(_pos) { +} + +FieldPositionOnlyHandler::~FieldPositionOnlyHandler() { +} + +void +FieldPositionOnlyHandler::addAttribute(int32_t id, int32_t start, int32_t limit) { if (pos.getField() == id && (!acceptFirstOnly || !seenFirst)) { seenFirst = TRUE; pos.setBeginIndex(start + fShift); pos.setEndIndex(limit + fShift); - } -} - -void -FieldPositionOnlyHandler::shiftLast(int32_t delta) { - if (delta != 0 && pos.getField() != FieldPosition::DONT_CARE && pos.getBeginIndex() != -1) { - pos.setBeginIndex(delta + pos.getBeginIndex()); - pos.setEndIndex(delta + pos.getEndIndex()); - } -} - -UBool -FieldPositionOnlyHandler::isRecording(void) const { - return pos.getField() != FieldPosition::DONT_CARE; -} - + } +} + +void +FieldPositionOnlyHandler::shiftLast(int32_t delta) { + if (delta != 0 && pos.getField() != FieldPosition::DONT_CARE && pos.getBeginIndex() != -1) { + pos.setBeginIndex(delta + pos.getBeginIndex()); + pos.setEndIndex(delta + pos.getEndIndex()); + } +} + +UBool +FieldPositionOnlyHandler::isRecording(void) const { + return pos.getField() != FieldPosition::DONT_CARE; +} + void FieldPositionOnlyHandler::setAcceptFirstOnly(UBool acceptFirstOnly) { this->acceptFirstOnly = acceptFirstOnly; } + - -// utility subclass FieldPositionIteratorHandler - -FieldPositionIteratorHandler::FieldPositionIteratorHandler(FieldPositionIterator* posIter, - UErrorCode& _status) +// utility subclass FieldPositionIteratorHandler + +FieldPositionIteratorHandler::FieldPositionIteratorHandler(FieldPositionIterator* posIter, + UErrorCode& _status) : iter(posIter), vec(NULL), status(_status), fCategory(UFIELD_CATEGORY_UNDEFINED) { - if (iter && U_SUCCESS(status)) { - vec = new UVector32(status); - } -} - + if (iter && U_SUCCESS(status)) { + vec = new UVector32(status); + } +} + FieldPositionIteratorHandler::FieldPositionIteratorHandler( UVector32* vec, UErrorCode& status) : iter(nullptr), vec(vec), status(status), fCategory(UFIELD_CATEGORY_UNDEFINED) { } -FieldPositionIteratorHandler::~FieldPositionIteratorHandler() { - // setData adopts the vec regardless of status, so it's safe to null it - if (iter) { - iter->setData(vec, status); - } - // if iter is null, we never allocated vec, so no need to free it - vec = NULL; -} - -void -FieldPositionIteratorHandler::addAttribute(int32_t id, int32_t start, int32_t limit) { +FieldPositionIteratorHandler::~FieldPositionIteratorHandler() { + // setData adopts the vec regardless of status, so it's safe to null it + if (iter) { + iter->setData(vec, status); + } + // if iter is null, we never allocated vec, so no need to free it + vec = NULL; +} + +void +FieldPositionIteratorHandler::addAttribute(int32_t id, int32_t start, int32_t limit) { if (vec && U_SUCCESS(status) && start < limit) { - int32_t size = vec->size(); + int32_t size = vec->size(); vec->addElement(fCategory, status); - vec->addElement(id, status); + vec->addElement(id, status); vec->addElement(start + fShift, status); vec->addElement(limit + fShift, status); - if (!U_SUCCESS(status)) { - vec->setSize(size); - } - } -} - -void -FieldPositionIteratorHandler::shiftLast(int32_t delta) { - if (U_SUCCESS(status) && delta != 0) { - int32_t i = vec->size(); - if (i > 0) { - --i; - vec->setElementAt(delta + vec->elementAti(i), i); - --i; - vec->setElementAt(delta + vec->elementAti(i), i); - } - } -} - -UBool -FieldPositionIteratorHandler::isRecording(void) const { - return U_SUCCESS(status); -} - -U_NAMESPACE_END - -#endif /* !UCONFIG_NO_FORMATTING */ + if (!U_SUCCESS(status)) { + vec->setSize(size); + } + } +} + +void +FieldPositionIteratorHandler::shiftLast(int32_t delta) { + if (U_SUCCESS(status) && delta != 0) { + int32_t i = vec->size(); + if (i > 0) { + --i; + vec->setElementAt(delta + vec->elementAti(i), i); + --i; + vec->setElementAt(delta + vec->elementAti(i), i); + } + } +} + +UBool +FieldPositionIteratorHandler::isRecording(void) const { + return U_SUCCESS(status); +} + +U_NAMESPACE_END + +#endif /* !UCONFIG_NO_FORMATTING */ |