Path: blob/master/thirdparty/icu4c/common/chariter.cpp
9902 views
// © 2016 and later: Unicode, Inc. and others.1// License & terms of use: http://www.unicode.org/copyright.html2/*3**********************************************************************4* Copyright (C) 1999-2011, International Business Machines5* Corporation and others. All Rights Reserved.6**********************************************************************7*/89#include "unicode/chariter.h"1011U_NAMESPACE_BEGIN1213ForwardCharacterIterator::~ForwardCharacterIterator() {}14ForwardCharacterIterator::ForwardCharacterIterator()15: UObject()16{}17ForwardCharacterIterator::ForwardCharacterIterator(const ForwardCharacterIterator &other)18: UObject(other)19{}202122CharacterIterator::CharacterIterator()23: textLength(0), pos(0), begin(0), end(0) {24}2526CharacterIterator::CharacterIterator(int32_t length)27: textLength(length), pos(0), begin(0), end(length) {28if(textLength < 0) {29textLength = end = 0;30}31}3233CharacterIterator::CharacterIterator(int32_t length, int32_t position)34: textLength(length), pos(position), begin(0), end(length) {35if(textLength < 0) {36textLength = end = 0;37}38if(pos < 0) {39pos = 0;40} else if(pos > end) {41pos = end;42}43}4445CharacterIterator::CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position)46: textLength(length), pos(position), begin(textBegin), end(textEnd) {47if(textLength < 0) {48textLength = 0;49}50if(begin < 0) {51begin = 0;52} else if(begin > textLength) {53begin = textLength;54}55if(end < begin) {56end = begin;57} else if(end > textLength) {58end = textLength;59}60if(pos < begin) {61pos = begin;62} else if(pos > end) {63pos = end;64}65}6667CharacterIterator::~CharacterIterator() {}6869CharacterIterator::CharacterIterator(const CharacterIterator &that) :70ForwardCharacterIterator(that),71textLength(that.textLength), pos(that.pos), begin(that.begin), end(that.end)72{73}7475CharacterIterator &76CharacterIterator::operator=(const CharacterIterator &that) {77ForwardCharacterIterator::operator=(that);78textLength = that.textLength;79pos = that.pos;80begin = that.begin;81end = that.end;82return *this;83}8485// implementing first[32]PostInc() directly in a subclass should be faster86// but these implementations make subclassing a little easier87char16_t88CharacterIterator::firstPostInc() {89setToStart();90return nextPostInc();91}9293UChar3294CharacterIterator::first32PostInc() {95setToStart();96return next32PostInc();97}9899U_NAMESPACE_END100101102