os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/schriter.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
******************************************************************************
sl@0
     3
*
sl@0
     4
*   Copyright (C) 1998-2005, International Business Machines
sl@0
     5
*   Corporation and others.  All Rights Reserved.
sl@0
     6
*
sl@0
     7
******************************************************************************
sl@0
     8
*
sl@0
     9
* File schriter.h
sl@0
    10
*
sl@0
    11
* Modification History:
sl@0
    12
*
sl@0
    13
*   Date        Name        Description
sl@0
    14
*  05/05/99     stephen     Cleaned up.
sl@0
    15
******************************************************************************
sl@0
    16
*/
sl@0
    17
sl@0
    18
#ifndef SCHRITER_H
sl@0
    19
#define SCHRITER_H
sl@0
    20
sl@0
    21
#include "unicode/utypes.h"
sl@0
    22
#include "unicode/chariter.h"
sl@0
    23
#include "unicode/uchriter.h"
sl@0
    24
sl@0
    25
/**
sl@0
    26
 * \file 
sl@0
    27
 * \brief C++ API: String Character Iterator
sl@0
    28
 */
sl@0
    29
 
sl@0
    30
U_NAMESPACE_BEGIN
sl@0
    31
/**
sl@0
    32
 * A concrete subclass of CharacterIterator that iterates over the
sl@0
    33
 * characters (code units or code points) in a UnicodeString.
sl@0
    34
 * It's possible not only to create an
sl@0
    35
 * iterator that iterates over an entire UnicodeString, but also to
sl@0
    36
 * create one that iterates over only a subrange of a UnicodeString
sl@0
    37
 * (iterators over different subranges of the same UnicodeString don't
sl@0
    38
 * compare equal).
sl@0
    39
 * @see CharacterIterator
sl@0
    40
 * @see ForwardCharacterIterator
sl@0
    41
 * @stable ICU 2.0
sl@0
    42
 */
sl@0
    43
class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator {
sl@0
    44
public:
sl@0
    45
  /**
sl@0
    46
   * Create an iterator over the UnicodeString referred to by "textStr".
sl@0
    47
   * The UnicodeString object is copied.
sl@0
    48
   * The iteration range is the whole string, and the starting position is 0.
sl@0
    49
   * @param textStr The unicode string used to create an iterator
sl@0
    50
   * @stable ICU 2.0
sl@0
    51
   */
sl@0
    52
  StringCharacterIterator(const UnicodeString& textStr);
sl@0
    53
sl@0
    54
  /**
sl@0
    55
   * Create an iterator over the UnicodeString referred to by "textStr".
sl@0
    56
   * The iteration range is the whole string, and the starting
sl@0
    57
   * position is specified by "textPos".  If "textPos" is outside the valid
sl@0
    58
   * iteration range, the behavior of this object is undefined.
sl@0
    59
   * @param textStr The unicode string used to create an iterator
sl@0
    60
   * @param textPos The starting position of the iteration
sl@0
    61
   * @stable ICU 2.0
sl@0
    62
   */
sl@0
    63
  StringCharacterIterator(const UnicodeString&    textStr,
sl@0
    64
              int32_t              textPos);
sl@0
    65
sl@0
    66
  /**
sl@0
    67
   * Create an iterator over the UnicodeString referred to by "textStr".
sl@0
    68
   * The UnicodeString object is copied.
sl@0
    69
   * The iteration range begins with the code unit specified by
sl@0
    70
   * "textBegin" and ends with the code unit BEFORE the code unit specfied
sl@0
    71
   * by "textEnd".  The starting position is specified by "textPos".  If
sl@0
    72
   * "textBegin" and "textEnd" don't form a valid range on "text" (i.e.,
sl@0
    73
   * textBegin >= textEnd or either is negative or greater than text.size()),
sl@0
    74
   * or "textPos" is outside the range defined by "textBegin" and "textEnd",
sl@0
    75
   * the behavior of this iterator is undefined.
sl@0
    76
   * @param textStr    The unicode string used to create the StringCharacterIterator
sl@0
    77
   * @param textBegin  The begin position of the iteration range
sl@0
    78
   * @param textEnd    The end position of the iteration range
sl@0
    79
   * @param textPos    The starting position of the iteration
sl@0
    80
   * @stable ICU 2.0
sl@0
    81
   */
sl@0
    82
  StringCharacterIterator(const UnicodeString&    textStr,
sl@0
    83
              int32_t              textBegin,
sl@0
    84
              int32_t              textEnd,
sl@0
    85
              int32_t              textPos);
sl@0
    86
sl@0
    87
  /**
sl@0
    88
   * Copy constructor.  The new iterator iterates over the same range
sl@0
    89
   * of the same string as "that", and its initial position is the
sl@0
    90
   * same as "that"'s current position.
sl@0
    91
   * The UnicodeString object in "that" is copied.
sl@0
    92
   * @param that The StringCharacterIterator to be copied
sl@0
    93
   * @stable ICU 2.0
sl@0
    94
   */
sl@0
    95
  StringCharacterIterator(const StringCharacterIterator&  that);
sl@0
    96
sl@0
    97
  /**
sl@0
    98
   * Destructor.
sl@0
    99
   * @stable ICU 2.0
sl@0
   100
   */
sl@0
   101
  virtual ~StringCharacterIterator();
sl@0
   102
sl@0
   103
  /**
sl@0
   104
   * Assignment operator.  *this is altered to iterate over the same
sl@0
   105
   * range of the same string as "that", and refers to the same
sl@0
   106
   * character within that string as "that" does.
sl@0
   107
   * @param that The object to be copied.
sl@0
   108
   * @return the newly created object.
sl@0
   109
   * @stable ICU 2.0
sl@0
   110
   */
sl@0
   111
  StringCharacterIterator&
sl@0
   112
  operator=(const StringCharacterIterator&    that);
sl@0
   113
sl@0
   114
  /**
sl@0
   115
   * Returns true if the iterators iterate over the same range of the
sl@0
   116
   * same string and are pointing at the same character.
sl@0
   117
   * @param that The ForwardCharacterIterator to be compared for equality
sl@0
   118
   * @return true if the iterators iterate over the same range of the
sl@0
   119
   * same string and are pointing at the same character.
sl@0
   120
   * @stable ICU 2.0
sl@0
   121
   */
sl@0
   122
  virtual UBool          operator==(const ForwardCharacterIterator& that) const;
sl@0
   123
sl@0
   124
  /**
sl@0
   125
   * Returns a new StringCharacterIterator referring to the same
sl@0
   126
   * character in the same range of the same string as this one.  The
sl@0
   127
   * caller must delete the new iterator.
sl@0
   128
   * @return the newly cloned object.
sl@0
   129
   * @stable ICU 2.0
sl@0
   130
   */
sl@0
   131
  virtual CharacterIterator* clone(void) const;
sl@0
   132
sl@0
   133
  /**
sl@0
   134
   * Sets the iterator to iterate over the provided string.
sl@0
   135
   * @param newText The string to be iterated over
sl@0
   136
   * @stable ICU 2.0
sl@0
   137
   */
sl@0
   138
  void setText(const UnicodeString& newText);
sl@0
   139
sl@0
   140
  /**
sl@0
   141
   * Copies the UnicodeString under iteration into the UnicodeString
sl@0
   142
   * referred to by "result".  Even if this iterator iterates across
sl@0
   143
   * only a part of this string, the whole string is copied.
sl@0
   144
   * @param result Receives a copy of the text under iteration.
sl@0
   145
   * @stable ICU 2.0
sl@0
   146
   */
sl@0
   147
  virtual void            getText(UnicodeString& result);
sl@0
   148
sl@0
   149
  /**
sl@0
   150
   * Return a class ID for this object (not really public)
sl@0
   151
   * @return a class ID for this object.
sl@0
   152
   * @stable ICU 2.0
sl@0
   153
   */
sl@0
   154
  virtual UClassID         getDynamicClassID(void) const;
sl@0
   155
sl@0
   156
  /**
sl@0
   157
   * Return a class ID for this class (not really public)
sl@0
   158
   * @return a class ID for this class
sl@0
   159
   * @stable ICU 2.0
sl@0
   160
   */
sl@0
   161
  static UClassID   U_EXPORT2 getStaticClassID(void);
sl@0
   162
sl@0
   163
protected:
sl@0
   164
  /**
sl@0
   165
   * Default constructor, iteration over empty string.
sl@0
   166
   * @stable ICU 2.0
sl@0
   167
   */
sl@0
   168
  StringCharacterIterator();
sl@0
   169
sl@0
   170
  /**
sl@0
   171
   * Sets the iterator to iterate over the provided string.
sl@0
   172
   * @param newText The string to be iterated over
sl@0
   173
   * @param newTextLength The length of the String
sl@0
   174
   * @stable ICU 2.0
sl@0
   175
   */
sl@0
   176
  void setText(const UChar* newText, int32_t newTextLength);
sl@0
   177
sl@0
   178
  /**
sl@0
   179
   * Copy of the iterated string object.
sl@0
   180
   * @stable ICU 2.0
sl@0
   181
   */
sl@0
   182
  UnicodeString            text;
sl@0
   183
sl@0
   184
};
sl@0
   185
sl@0
   186
U_NAMESPACE_END
sl@0
   187
#endif