Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * Copyright (C) 1997-2010, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ****************************************************************************** |
michael@0 | 6 | * Date Name Description |
michael@0 | 7 | * 06/23/00 aliu Creation. |
michael@0 | 8 | ****************************************************************************** |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef __UREP_H |
michael@0 | 12 | #define __UREP_H |
michael@0 | 13 | |
michael@0 | 14 | #include "unicode/utypes.h" |
michael@0 | 15 | |
michael@0 | 16 | U_CDECL_BEGIN |
michael@0 | 17 | |
michael@0 | 18 | /******************************************************************** |
michael@0 | 19 | * General Notes |
michael@0 | 20 | ******************************************************************** |
michael@0 | 21 | * TODO |
michael@0 | 22 | * Add usage scenario |
michael@0 | 23 | * Add test code |
michael@0 | 24 | * Talk about pinning |
michael@0 | 25 | * Talk about "can truncate result if out of memory" |
michael@0 | 26 | */ |
michael@0 | 27 | |
michael@0 | 28 | /******************************************************************** |
michael@0 | 29 | * Data Structures |
michael@0 | 30 | ********************************************************************/ |
michael@0 | 31 | /** |
michael@0 | 32 | * \file |
michael@0 | 33 | * \brief C API: Callbacks for UReplaceable |
michael@0 | 34 | */ |
michael@0 | 35 | /** |
michael@0 | 36 | * An opaque replaceable text object. This will be manipulated only |
michael@0 | 37 | * through the caller-supplied UReplaceableFunctor struct. Related |
michael@0 | 38 | * to the C++ class Replaceable. |
michael@0 | 39 | * This is currently only used in the Transliterator C API, see utrans.h . |
michael@0 | 40 | * @stable ICU 2.0 |
michael@0 | 41 | */ |
michael@0 | 42 | typedef void* UReplaceable; |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * A set of function pointers that transliterators use to manipulate a |
michael@0 | 46 | * UReplaceable. The caller should supply the required functions to |
michael@0 | 47 | * manipulate their text appropriately. Related to the C++ class |
michael@0 | 48 | * Replaceable. |
michael@0 | 49 | * @stable ICU 2.0 |
michael@0 | 50 | */ |
michael@0 | 51 | typedef struct UReplaceableCallbacks { |
michael@0 | 52 | |
michael@0 | 53 | /** |
michael@0 | 54 | * Function pointer that returns the number of UChar code units in |
michael@0 | 55 | * this text. |
michael@0 | 56 | * |
michael@0 | 57 | * @param rep A pointer to "this" UReplaceable object. |
michael@0 | 58 | * @return The length of the text. |
michael@0 | 59 | * @stable ICU 2.0 |
michael@0 | 60 | */ |
michael@0 | 61 | int32_t (*length)(const UReplaceable* rep); |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * Function pointer that returns a UChar code units at the given |
michael@0 | 65 | * offset into this text; 0 <= offset < n, where n is the value |
michael@0 | 66 | * returned by (*length)(rep). See unistr.h for a description of |
michael@0 | 67 | * charAt() vs. char32At(). |
michael@0 | 68 | * |
michael@0 | 69 | * @param rep A pointer to "this" UReplaceable object. |
michael@0 | 70 | * @param offset The index at which to fetch the UChar (code unit). |
michael@0 | 71 | * @return The UChar (code unit) at offset, or U+FFFF if the offset is out of bounds. |
michael@0 | 72 | * @stable ICU 2.0 |
michael@0 | 73 | */ |
michael@0 | 74 | UChar (*charAt)(const UReplaceable* rep, |
michael@0 | 75 | int32_t offset); |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * Function pointer that returns a UChar32 code point at the given |
michael@0 | 79 | * offset into this text. See unistr.h for a description of |
michael@0 | 80 | * charAt() vs. char32At(). |
michael@0 | 81 | * |
michael@0 | 82 | * @param rep A pointer to "this" UReplaceable object. |
michael@0 | 83 | * @param offset The index at which to fetch the UChar32 (code point). |
michael@0 | 84 | * @return The UChar32 (code point) at offset, or U+FFFF if the offset is out of bounds. |
michael@0 | 85 | * @stable ICU 2.0 |
michael@0 | 86 | */ |
michael@0 | 87 | UChar32 (*char32At)(const UReplaceable* rep, |
michael@0 | 88 | int32_t offset); |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * Function pointer that replaces text between start and limit in |
michael@0 | 92 | * this text with the given text. Attributes (out of band info) |
michael@0 | 93 | * should be retained. |
michael@0 | 94 | * |
michael@0 | 95 | * @param rep A pointer to "this" UReplaceable object. |
michael@0 | 96 | * @param start the starting index of the text to be replaced, |
michael@0 | 97 | * inclusive. |
michael@0 | 98 | * @param limit the ending index of the text to be replaced, |
michael@0 | 99 | * exclusive. |
michael@0 | 100 | * @param text the new text to replace the UChars from |
michael@0 | 101 | * start..limit-1. |
michael@0 | 102 | * @param textLength the number of UChars at text, or -1 if text |
michael@0 | 103 | * is null-terminated. |
michael@0 | 104 | * @stable ICU 2.0 |
michael@0 | 105 | */ |
michael@0 | 106 | void (*replace)(UReplaceable* rep, |
michael@0 | 107 | int32_t start, |
michael@0 | 108 | int32_t limit, |
michael@0 | 109 | const UChar* text, |
michael@0 | 110 | int32_t textLength); |
michael@0 | 111 | |
michael@0 | 112 | /** |
michael@0 | 113 | * Function pointer that copies the characters in the range |
michael@0 | 114 | * [<tt>start</tt>, <tt>limit</tt>) into the array <tt>dst</tt>. |
michael@0 | 115 | * |
michael@0 | 116 | * @param rep A pointer to "this" UReplaceable object. |
michael@0 | 117 | * @param start offset of first character which will be copied |
michael@0 | 118 | * into the array |
michael@0 | 119 | * @param limit offset immediately following the last character to |
michael@0 | 120 | * be copied |
michael@0 | 121 | * @param dst array in which to copy characters. The length of |
michael@0 | 122 | * <tt>dst</tt> must be at least <tt>(limit - start)</tt>. |
michael@0 | 123 | * @stable ICU 2.1 |
michael@0 | 124 | */ |
michael@0 | 125 | void (*extract)(UReplaceable* rep, |
michael@0 | 126 | int32_t start, |
michael@0 | 127 | int32_t limit, |
michael@0 | 128 | UChar* dst); |
michael@0 | 129 | |
michael@0 | 130 | /** |
michael@0 | 131 | * Function pointer that copies text between start and limit in |
michael@0 | 132 | * this text to another index in the text. Attributes (out of |
michael@0 | 133 | * band info) should be retained. After this call, there will be |
michael@0 | 134 | * (at least) two copies of the characters originally located at |
michael@0 | 135 | * start..limit-1. |
michael@0 | 136 | * |
michael@0 | 137 | * @param rep A pointer to "this" UReplaceable object. |
michael@0 | 138 | * @param start the starting index of the text to be copied, |
michael@0 | 139 | * inclusive. |
michael@0 | 140 | * @param limit the ending index of the text to be copied, |
michael@0 | 141 | * exclusive. |
michael@0 | 142 | * @param dest the index at which the copy of the UChars should be |
michael@0 | 143 | * inserted. |
michael@0 | 144 | * @stable ICU 2.0 |
michael@0 | 145 | */ |
michael@0 | 146 | void (*copy)(UReplaceable* rep, |
michael@0 | 147 | int32_t start, |
michael@0 | 148 | int32_t limit, |
michael@0 | 149 | int32_t dest); |
michael@0 | 150 | |
michael@0 | 151 | } UReplaceableCallbacks; |
michael@0 | 152 | |
michael@0 | 153 | U_CDECL_END |
michael@0 | 154 | |
michael@0 | 155 | #endif |