~ubuntu-branches/ubuntu/gutsy/icu/gutsy

« back to all changes in this revision

Viewing changes to source/i18n/xformtrn.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2005-05-21 22:44:31 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: package-import@ubuntu.com-20050521224431-r7rktfhnu1n4tf1g
Tags: 2.1-2.1
Rename icu-doc to icu21-doc. icu-doc is built by the icu28 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
**********************************************************************
3
 
*   Copyright (C) 2001, International Business Machines
4
 
*   Corporation and others.  All Rights Reserved.
5
 
**********************************************************************
6
 
*   Date        Name        Description
7
 
*   05/24/01    aliu        Creation.
8
 
**********************************************************************
9
 
*/
10
 
// THIS CLASS IS CURRENTLY UNUSED
11
 
#if 0
12
 
 
13
 
#include "xformtrn.h"
14
 
#include "unicode/unifilt.h"
15
 
 
16
 
U_NAMESPACE_BEGIN
17
 
 
18
 
/**
19
 
 * Constructs a transliterator.  For use by subclasses.
20
 
 */
21
 
TransformTransliterator::TransformTransliterator(const UnicodeString& id,
22
 
                                                 UnicodeFilter* adoptedFilter) :
23
 
    Transliterator(id, adoptedFilter) {
24
 
}
25
 
 
26
 
/**
27
 
 * Implements {@link Transliterator#handleTransliterate}.
28
 
 * Ignore isIncremental since we don't need the context, and
29
 
 * we work on codepoints.
30
 
 */
31
 
void TransformTransliterator::handleTransliterate(Replaceable& text, UTransPosition& offsets,
32
 
                                                  UBool /*isIncremental*/) const {
33
 
    
34
 
    int32_t start;
35
 
    for (start = offsets.start; start < offsets.limit; ++start) {
36
 
        // Scan for the first character that is != its transform.
37
 
        // If there are none, we fall out without doing anything.
38
 
        UChar32 c = text.charAt(start);
39
 
        if (hasTransform(c)) {
40
 
            // There is a transforming character at start.
41
 
 
42
 
            int32_t len = offsets.limit - start;
43
 
            // assert(len >= 1);
44
 
 
45
 
            // Temporary string used to do transformations
46
 
            UnicodeString str;
47
 
            for (int32_t i=start; i<offsets.limit; ++i) {
48
 
                str.append(text.charAt(i));
49
 
            }
50
 
            
51
 
            // Transform the characters
52
 
            transform(str);
53
 
            text.handleReplaceBetween(start, start + len, str);
54
 
            start += str.length();
55
 
 
56
 
            int32_t lenDelta = str.length() - len;
57
 
            offsets.limit += lenDelta;
58
 
            offsets.contextLimit += lenDelta;
59
 
            offsets.start = offsets.limit;
60
 
            return;
61
 
        }
62
 
    }
63
 
    // assert(start == offsets.limit);
64
 
    offsets.start = offsets.limit;
65
 
}
66
 
 
67
 
U_NAMESPACE_END
68
 
 
69
 
#endif
70
 
// THIS CLASS IS CURRENTLY UNUSED