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