os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/symtable.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) 2000-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
*   02/04/00    aliu        Creation.
sl@0
     8
**********************************************************************
sl@0
     9
*/
sl@0
    10
#ifndef SYMTABLE_H
sl@0
    11
#define SYMTABLE_H
sl@0
    12
sl@0
    13
#include "unicode/utypes.h"
sl@0
    14
#include "unicode/uobject.h"
sl@0
    15
sl@0
    16
/**
sl@0
    17
 * \file 
sl@0
    18
 * \brief C++ API: An interface that defines both lookup protocol and parsing of
sl@0
    19
 * symbolic names.
sl@0
    20
 */
sl@0
    21
 
sl@0
    22
U_NAMESPACE_BEGIN
sl@0
    23
sl@0
    24
class ParsePosition;
sl@0
    25
class UnicodeFunctor;
sl@0
    26
class UnicodeSet;
sl@0
    27
class UnicodeString;
sl@0
    28
sl@0
    29
/**
sl@0
    30
 * An interface that defines both lookup protocol and parsing of
sl@0
    31
 * symbolic names.
sl@0
    32
 *
sl@0
    33
 * <p>A symbol table maintains two kinds of mappings.  The first is
sl@0
    34
 * between symbolic names and their values.  For example, if the
sl@0
    35
 * variable with the name "start" is set to the value "alpha"
sl@0
    36
 * (perhaps, though not necessarily, through an expression such as
sl@0
    37
 * "$start=alpha"), then the call lookup("start") will return the
sl@0
    38
 * char[] array ['a', 'l', 'p', 'h', 'a'].
sl@0
    39
 *
sl@0
    40
 * <p>The second kind of mapping is between character values and
sl@0
    41
 * UnicodeMatcher objects.  This is used by RuleBasedTransliterator,
sl@0
    42
 * which uses characters in the private use area to represent objects
sl@0
    43
 * such as UnicodeSets.  If U+E015 is mapped to the UnicodeSet [a-z],
sl@0
    44
 * then lookupMatcher(0xE015) will return the UnicodeSet [a-z].
sl@0
    45
 *
sl@0
    46
 * <p>Finally, a symbol table defines parsing behavior for symbolic
sl@0
    47
 * names.  All symbolic names start with the SYMBOL_REF character.
sl@0
    48
 * When a parser encounters this character, it calls parseReference()
sl@0
    49
 * with the position immediately following the SYMBOL_REF.  The symbol
sl@0
    50
 * table parses the name, if there is one, and returns it.
sl@0
    51
 *
sl@0
    52
 * @stable ICU 2.8
sl@0
    53
 */
sl@0
    54
class U_COMMON_API SymbolTable /* not : public UObject because this is an interface/mixin class */ {
sl@0
    55
public:
sl@0
    56
sl@0
    57
    /**
sl@0
    58
     * The character preceding a symbol reference name.
sl@0
    59
     * @stable ICU 2.8
sl@0
    60
     */
sl@0
    61
    enum { SYMBOL_REF = 0x0024 /*$*/ };
sl@0
    62
sl@0
    63
    /**
sl@0
    64
     * Destructor.
sl@0
    65
     * @stable ICU 2.8
sl@0
    66
     */
sl@0
    67
    virtual ~SymbolTable();
sl@0
    68
sl@0
    69
    /**
sl@0
    70
     * Lookup the characters associated with this string and return it.
sl@0
    71
     * Return <tt>NULL</tt> if no such name exists.  The resultant
sl@0
    72
     * string may have length zero.
sl@0
    73
     * @param s the symbolic name to lookup
sl@0
    74
     * @return a string containing the name's value, or <tt>NULL</tt> if
sl@0
    75
     * there is no mapping for s.
sl@0
    76
     * @stable ICU 2.8
sl@0
    77
     */
sl@0
    78
    virtual const UnicodeString* lookup(const UnicodeString& s) const = 0;
sl@0
    79
sl@0
    80
    /**
sl@0
    81
     * Lookup the UnicodeMatcher associated with the given character, and
sl@0
    82
     * return it.  Return <tt>NULL</tt> if not found.
sl@0
    83
     * @param ch a 32-bit code point from 0 to 0x10FFFF inclusive.
sl@0
    84
     * @return the UnicodeMatcher object represented by the given
sl@0
    85
     * character, or NULL if there is no mapping for ch.
sl@0
    86
     * @stable ICU 2.8
sl@0
    87
     */
sl@0
    88
    virtual const UnicodeFunctor* lookupMatcher(UChar32 ch) const = 0;
sl@0
    89
sl@0
    90
    /**
sl@0
    91
     * Parse a symbol reference name from the given string, starting
sl@0
    92
     * at the given position.  If no valid symbol reference name is
sl@0
    93
     * found, return the empty string and leave pos unchanged.  That is, if the
sl@0
    94
     * character at pos cannot start a name, or if pos is at or after
sl@0
    95
     * text.length(), then return an empty string.  This indicates an
sl@0
    96
     * isolated SYMBOL_REF character.
sl@0
    97
     * @param text the text to parse for the name
sl@0
    98
     * @param pos on entry, the index of the first character to parse.
sl@0
    99
     * This is the character following the SYMBOL_REF character.  On
sl@0
   100
     * exit, the index after the last parsed character.  If the parse
sl@0
   101
     * failed, pos is unchanged on exit.
sl@0
   102
     * @param limit the index after the last character to be parsed.
sl@0
   103
     * @return the parsed name, or an empty string if there is no
sl@0
   104
     * valid symbolic name at the given position.
sl@0
   105
     * @stable ICU 2.8
sl@0
   106
     */
sl@0
   107
    virtual UnicodeString parseReference(const UnicodeString& text,
sl@0
   108
                                         ParsePosition& pos, int32_t limit) const = 0;
sl@0
   109
};
sl@0
   110
U_NAMESPACE_END
sl@0
   111
sl@0
   112
#endif