intl/icu/source/common/unicode/urep.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/unicode/urep.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,155 @@
     1.4 +/*
     1.5 +******************************************************************************
     1.6 +*   Copyright (C) 1997-2010, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +******************************************************************************
     1.9 +*   Date        Name        Description
    1.10 +*   06/23/00    aliu        Creation.
    1.11 +******************************************************************************
    1.12 +*/
    1.13 +
    1.14 +#ifndef __UREP_H
    1.15 +#define __UREP_H
    1.16 +
    1.17 +#include "unicode/utypes.h"
    1.18 +
    1.19 +U_CDECL_BEGIN
    1.20 +
    1.21 +/********************************************************************
    1.22 + * General Notes
    1.23 + ********************************************************************
    1.24 + * TODO
    1.25 + * Add usage scenario
    1.26 + * Add test code
    1.27 + * Talk about pinning
    1.28 + * Talk about "can truncate result if out of memory"
    1.29 + */
    1.30 +
    1.31 +/********************************************************************
    1.32 + * Data Structures
    1.33 + ********************************************************************/
    1.34 +/**
    1.35 + * \file
    1.36 + * \brief C API: Callbacks for UReplaceable
    1.37 + */
    1.38 +/**
    1.39 + * An opaque replaceable text object.  This will be manipulated only
    1.40 + * through the caller-supplied UReplaceableFunctor struct.  Related
    1.41 + * to the C++ class Replaceable.
    1.42 + * This is currently only used in the Transliterator C API, see utrans.h .
    1.43 + * @stable ICU 2.0
    1.44 + */
    1.45 +typedef void* UReplaceable;
    1.46 +
    1.47 +/**
    1.48 + * A set of function pointers that transliterators use to manipulate a
    1.49 + * UReplaceable.  The caller should supply the required functions to
    1.50 + * manipulate their text appropriately.  Related to the C++ class
    1.51 + * Replaceable.
    1.52 + * @stable ICU 2.0
    1.53 + */
    1.54 +typedef struct UReplaceableCallbacks {
    1.55 +
    1.56 +    /**
    1.57 +     * Function pointer that returns the number of UChar code units in
    1.58 +     * this text.
    1.59 +     *
    1.60 +     * @param rep A pointer to "this" UReplaceable object.
    1.61 +     * @return The length of the text.
    1.62 +     * @stable ICU 2.0
    1.63 +     */
    1.64 +    int32_t (*length)(const UReplaceable* rep);
    1.65 +
    1.66 +    /**
    1.67 +     * Function pointer that returns a UChar code units at the given
    1.68 +     * offset into this text; 0 <= offset < n, where n is the value
    1.69 +     * returned by (*length)(rep).  See unistr.h for a description of
    1.70 +     * charAt() vs. char32At().
    1.71 +     *
    1.72 +     * @param rep A pointer to "this" UReplaceable object.
    1.73 +     * @param offset The index at which to fetch the UChar (code unit).
    1.74 +     * @return The UChar (code unit) at offset, or U+FFFF if the offset is out of bounds.
    1.75 +     * @stable ICU 2.0
    1.76 +     */
    1.77 +    UChar   (*charAt)(const UReplaceable* rep,
    1.78 +                      int32_t offset);
    1.79 +
    1.80 +    /**
    1.81 +     * Function pointer that returns a UChar32 code point at the given
    1.82 +     * offset into this text.  See unistr.h for a description of
    1.83 +     * charAt() vs. char32At().
    1.84 +     *
    1.85 +     * @param rep A pointer to "this" UReplaceable object.
    1.86 +     * @param offset The index at which to fetch the UChar32 (code point).
    1.87 +     * @return The UChar32 (code point) at offset, or U+FFFF if the offset is out of bounds.
    1.88 +     * @stable ICU 2.0
    1.89 +     */
    1.90 +    UChar32 (*char32At)(const UReplaceable* rep,
    1.91 +                        int32_t offset);
    1.92 +    
    1.93 +    /**
    1.94 +     * Function pointer that replaces text between start and limit in
    1.95 +     * this text with the given text.  Attributes (out of band info)
    1.96 +     * should be retained.
    1.97 +     *
    1.98 +     * @param rep A pointer to "this" UReplaceable object.
    1.99 +     * @param start the starting index of the text to be replaced,
   1.100 +     * inclusive.
   1.101 +     * @param limit the ending index of the text to be replaced,
   1.102 +     * exclusive.
   1.103 +     * @param text the new text to replace the UChars from
   1.104 +     * start..limit-1.
   1.105 +     * @param textLength the number of UChars at text, or -1 if text
   1.106 +     * is null-terminated.
   1.107 +     * @stable ICU 2.0
   1.108 +     */
   1.109 +    void    (*replace)(UReplaceable* rep,
   1.110 +                       int32_t start,
   1.111 +                       int32_t limit,
   1.112 +                       const UChar* text,
   1.113 +                       int32_t textLength);
   1.114 +    
   1.115 +    /**
   1.116 +     * Function pointer that copies the characters in the range
   1.117 +     * [<tt>start</tt>, <tt>limit</tt>) into the array <tt>dst</tt>.
   1.118 +     *
   1.119 +     * @param rep A pointer to "this" UReplaceable object.
   1.120 +     * @param start offset of first character which will be copied
   1.121 +     * into the array
   1.122 +     * @param limit offset immediately following the last character to
   1.123 +     * be copied
   1.124 +     * @param dst array in which to copy characters.  The length of
   1.125 +     * <tt>dst</tt> must be at least <tt>(limit - start)</tt>.
   1.126 +     * @stable ICU 2.1
   1.127 +     */
   1.128 +    void    (*extract)(UReplaceable* rep,
   1.129 +                       int32_t start,
   1.130 +                       int32_t limit,
   1.131 +                       UChar* dst);
   1.132 +
   1.133 +    /**
   1.134 +     * Function pointer that copies text between start and limit in
   1.135 +     * this text to another index in the text.  Attributes (out of
   1.136 +     * band info) should be retained.  After this call, there will be
   1.137 +     * (at least) two copies of the characters originally located at
   1.138 +     * start..limit-1.
   1.139 +     *
   1.140 +     * @param rep A pointer to "this" UReplaceable object.
   1.141 +     * @param start the starting index of the text to be copied,
   1.142 +     * inclusive.
   1.143 +     * @param limit the ending index of the text to be copied,
   1.144 +     * exclusive.
   1.145 +     * @param dest the index at which the copy of the UChars should be
   1.146 +     * inserted.
   1.147 +     * @stable ICU 2.0
   1.148 +     */
   1.149 +    void    (*copy)(UReplaceable* rep,
   1.150 +                    int32_t start,
   1.151 +                    int32_t limit,
   1.152 +                    int32_t dest);    
   1.153 +
   1.154 +} UReplaceableCallbacks;
   1.155 +
   1.156 +U_CDECL_END
   1.157 +
   1.158 +#endif

mercurial