intl/icu/source/common/schriter.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2 ******************************************************************************
     3 * Copyright (C) 1998-2012, International Business Machines Corporation and
     4 * others. All Rights Reserved.
     5 ******************************************************************************
     6 *
     7 * File schriter.cpp
     8 *
     9 * Modification History:
    10 *
    11 *   Date        Name        Description
    12 *  05/05/99     stephen     Cleaned up.
    13 ******************************************************************************
    14 */
    16 #include "utypeinfo.h"  // for 'typeid' to work
    18 #include "unicode/chariter.h"
    19 #include "unicode/schriter.h"
    21 U_NAMESPACE_BEGIN
    23 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator)
    25 StringCharacterIterator::StringCharacterIterator()
    26   : UCharCharacterIterator(),
    27     text()
    28 {
    29   // NEVER DEFAULT CONSTRUCT!
    30 }
    32 StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr)
    33   : UCharCharacterIterator(textStr.getBuffer(), textStr.length()),
    34     text(textStr)
    35 {
    36     // we had set the input parameter's array, now we need to set our copy's array
    37     UCharCharacterIterator::text = this->text.getBuffer();
    38 }
    40 StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr,
    41                                                  int32_t textPos)
    42   : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textPos),
    43     text(textStr)
    44 {
    45     // we had set the input parameter's array, now we need to set our copy's array
    46     UCharCharacterIterator::text = this->text.getBuffer();
    47 }
    49 StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr,
    50                                                  int32_t textBegin,
    51                                                  int32_t textEnd,
    52                                                  int32_t textPos)
    53   : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textBegin, textEnd, textPos),
    54     text(textStr)
    55 {
    56     // we had set the input parameter's array, now we need to set our copy's array
    57     UCharCharacterIterator::text = this->text.getBuffer();
    58 }
    60 StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that)
    61   : UCharCharacterIterator(that),
    62     text(that.text)
    63 {
    64     // we had set the input parameter's array, now we need to set our copy's array
    65     UCharCharacterIterator::text = this->text.getBuffer();
    66 }
    68 StringCharacterIterator::~StringCharacterIterator() {
    69 }
    71 StringCharacterIterator&
    72 StringCharacterIterator::operator=(const StringCharacterIterator& that) {
    73     UCharCharacterIterator::operator=(that);
    74     text = that.text;
    75     // we had set the input parameter's array, now we need to set our copy's array
    76     UCharCharacterIterator::text = this->text.getBuffer();
    77     return *this;
    78 }
    80 UBool
    81 StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const {
    82     if (this == &that) {
    83         return TRUE;
    84     }
    86     // do not call UCharCharacterIterator::operator==()
    87     // because that checks for array pointer equality
    88     // while we compare UnicodeString objects
    90     if (typeid(*this) != typeid(that)) {
    91         return FALSE;
    92     }
    94     StringCharacterIterator&    realThat = (StringCharacterIterator&)that;
    96     return text == realThat.text
    97         && pos == realThat.pos
    98         && begin == realThat.begin
    99         && end == realThat.end;
   100 }
   102 CharacterIterator*
   103 StringCharacterIterator::clone() const {
   104     return new StringCharacterIterator(*this);
   105 }
   107 void
   108 StringCharacterIterator::setText(const UnicodeString& newText) {
   109     text = newText;
   110     UCharCharacterIterator::setText(text.getBuffer(), text.length());
   111 }
   113 void
   114 StringCharacterIterator::getText(UnicodeString& result) {
   115     result = text;
   116 }
   117 U_NAMESPACE_END

mercurial