intl/icu/source/common/chariter.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2 **********************************************************************
     3 *   Copyright (C) 1999-2011, International Business Machines
     4 *   Corporation and others.  All Rights Reserved.
     5 **********************************************************************
     6 */
     8 #include "unicode/chariter.h"
    10 U_NAMESPACE_BEGIN
    12 ForwardCharacterIterator::~ForwardCharacterIterator() {}
    13 ForwardCharacterIterator::ForwardCharacterIterator()
    14 : UObject()
    15 {}
    16 ForwardCharacterIterator::ForwardCharacterIterator(const ForwardCharacterIterator &other)
    17 : UObject(other)
    18 {}
    21 CharacterIterator::CharacterIterator()
    22 : textLength(0), pos(0), begin(0), end(0) {
    23 }
    25 CharacterIterator::CharacterIterator(int32_t length)
    26 : textLength(length), pos(0), begin(0), end(length) {
    27     if(textLength < 0) {
    28         textLength = end = 0;
    29     }
    30 }
    32 CharacterIterator::CharacterIterator(int32_t length, int32_t position)
    33 : textLength(length), pos(position), begin(0), end(length) {
    34     if(textLength < 0) {
    35         textLength = end = 0;
    36     }
    37     if(pos < 0) {
    38         pos = 0;
    39     } else if(pos > end) {
    40         pos = end;
    41     }
    42 }
    44 CharacterIterator::CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position)
    45 : textLength(length), pos(position), begin(textBegin), end(textEnd) {
    46     if(textLength < 0) {
    47         textLength = 0;
    48     }
    49     if(begin < 0) {
    50         begin = 0;
    51     } else if(begin > textLength) {
    52         begin = textLength;
    53     }
    54     if(end < begin) {
    55         end = begin;
    56     } else if(end > textLength) {
    57         end = textLength;
    58     }
    59     if(pos < begin) {
    60         pos = begin;
    61     } else if(pos > end) {
    62         pos = end;
    63     }
    64 }
    66 CharacterIterator::~CharacterIterator() {}
    68 CharacterIterator::CharacterIterator(const CharacterIterator &that) :
    69 ForwardCharacterIterator(that),
    70 textLength(that.textLength), pos(that.pos), begin(that.begin), end(that.end)
    71 {
    72 }
    74 CharacterIterator &
    75 CharacterIterator::operator=(const CharacterIterator &that) {
    76     ForwardCharacterIterator::operator=(that);
    77     textLength = that.textLength;
    78     pos = that.pos;
    79     begin = that.begin;
    80     end = that.end;
    81     return *this;
    82 }
    84 // implementing first[32]PostInc() directly in a subclass should be faster
    85 // but these implementations make subclassing a little easier
    86 UChar
    87 CharacterIterator::firstPostInc(void) {
    88     setToStart();
    89     return nextPostInc();
    90 }
    92 UChar32
    93 CharacterIterator::first32PostInc(void) {
    94     setToStart();
    95     return next32PostInc();
    96 }
    98 U_NAMESPACE_END

mercurial