Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/unirepl.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 **********************************************************************
0005 *   Copyright (c) 2002-2005, International Business Machines Corporation
0006 *   and others.  All Rights Reserved.
0007 **********************************************************************
0008 *   Date        Name        Description
0009 *   01/14/2002  aliu        Creation.
0010 **********************************************************************
0011 */
0012 #ifndef UNIREPL_H
0013 #define UNIREPL_H
0014 
0015 #include "unicode/utypes.h"
0016 
0017 #if U_SHOW_CPLUSPLUS_API
0018 
0019 /**
0020  * \file 
0021  * \brief C++ API: UnicodeReplacer
0022  */
0023 
0024 U_NAMESPACE_BEGIN
0025 
0026 class Replaceable;
0027 class UnicodeString;
0028 class UnicodeSet;
0029 
0030 /**
0031  * <code>UnicodeReplacer</code> defines a protocol for objects that
0032  * replace a range of characters in a Replaceable string with output
0033  * text.  The replacement is done via the Replaceable API so as to
0034  * preserve out-of-band data.
0035  *
0036  * <p>This is a mixin class.
0037  * @author Alan Liu
0038  * @stable ICU 2.4
0039  */
0040 class U_I18N_API UnicodeReplacer /* not : public UObject because this is an interface/mixin class */ {
0041 
0042  public:
0043 
0044     /**
0045      * Destructor.
0046      * @stable ICU 2.4
0047      */
0048     virtual ~UnicodeReplacer();
0049 
0050     /**
0051      * Replace characters in 'text' from 'start' to 'limit' with the
0052      * output text of this object.  Update the 'cursor' parameter to
0053      * give the cursor position and return the length of the
0054      * replacement text.
0055      *
0056      * @param text the text to be matched
0057      * @param start inclusive start index of text to be replaced
0058      * @param limit exclusive end index of text to be replaced;
0059      * must be greater than or equal to start
0060      * @param cursor output parameter for the cursor position.
0061      * Not all replacer objects will update this, but in a complete
0062      * tree of replacer objects, representing the entire output side
0063      * of a transliteration rule, at least one must update it.
0064      * @return the number of 16-bit code units in the text replacing
0065      * the characters at offsets start..(limit-1) in text
0066      * @stable ICU 2.4
0067      */
0068     virtual int32_t replace(Replaceable& text,
0069                             int32_t start,
0070                             int32_t limit,
0071                             int32_t& cursor) = 0;
0072 
0073     /**
0074      * Returns a string representation of this replacer.  If the
0075      * result of calling this function is passed to the appropriate
0076      * parser, typically TransliteratorParser, it will produce another
0077      * replacer that is equal to this one.
0078      * @param result the string to receive the pattern.  Previous
0079      * contents will be deleted.
0080      * @param escapeUnprintable if true then convert unprintable
0081      * character to their hex escape representations, \\uxxxx or
0082      * \\Uxxxxxxxx.  Unprintable characters are defined by
0083      * Utility.isUnprintable().
0084      * @return a reference to 'result'.
0085      * @stable ICU 2.4
0086      */
0087     virtual UnicodeString& toReplacerPattern(UnicodeString& result,
0088                                              UBool escapeUnprintable) const = 0;
0089 
0090     /**
0091      * Union the set of all characters that may output by this object
0092      * into the given set.
0093      * @param toUnionTo the set into which to union the output characters
0094      * @stable ICU 2.4
0095      */
0096     virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const = 0;
0097 };
0098 
0099 U_NAMESPACE_END
0100 
0101 #endif /* U_SHOW_CPLUSPLUS_API */
0102 
0103 #endif