Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/common/unicode/symtable.h
38827 views
/*1**********************************************************************2* Copyright (c) 2000-2005, International Business Machines3* Corporation and others. All Rights Reserved.4**********************************************************************5* Date Name Description6* 02/04/00 aliu Creation.7**********************************************************************8*/9#ifndef SYMTABLE_H10#define SYMTABLE_H1112#include "unicode/utypes.h"13#include "unicode/uobject.h"1415/**16* \file17* \brief C++ API: An interface that defines both lookup protocol and parsing of18* symbolic names.19*/2021U_NAMESPACE_BEGIN2223class ParsePosition;24class UnicodeFunctor;25class UnicodeSet;26class UnicodeString;2728/**29* An interface that defines both lookup protocol and parsing of30* symbolic names.31*32* <p>A symbol table maintains two kinds of mappings. The first is33* between symbolic names and their values. For example, if the34* variable with the name "start" is set to the value "alpha"35* (perhaps, though not necessarily, through an expression such as36* "$start=alpha"), then the call lookup("start") will return the37* char[] array ['a', 'l', 'p', 'h', 'a'].38*39* <p>The second kind of mapping is between character values and40* UnicodeMatcher objects. This is used by RuleBasedTransliterator,41* which uses characters in the private use area to represent objects42* such as UnicodeSets. If U+E015 is mapped to the UnicodeSet [a-z],43* then lookupMatcher(0xE015) will return the UnicodeSet [a-z].44*45* <p>Finally, a symbol table defines parsing behavior for symbolic46* names. All symbolic names start with the SYMBOL_REF character.47* When a parser encounters this character, it calls parseReference()48* with the position immediately following the SYMBOL_REF. The symbol49* table parses the name, if there is one, and returns it.50*51* @stable ICU 2.852*/53class U_COMMON_API SymbolTable /* not : public UObject because this is an interface/mixin class */ {54public:5556/**57* The character preceding a symbol reference name.58* @stable ICU 2.859*/60enum { SYMBOL_REF = 0x0024 /*$*/ };6162/**63* Destructor.64* @stable ICU 2.865*/66virtual ~SymbolTable();6768/**69* Lookup the characters associated with this string and return it.70* Return <tt>NULL</tt> if no such name exists. The resultant71* string may have length zero.72* @param s the symbolic name to lookup73* @return a string containing the name's value, or <tt>NULL</tt> if74* there is no mapping for s.75* @stable ICU 2.876*/77virtual const UnicodeString* lookup(const UnicodeString& s) const = 0;7879/**80* Lookup the UnicodeMatcher associated with the given character, and81* return it. Return <tt>NULL</tt> if not found.82* @param ch a 32-bit code point from 0 to 0x10FFFF inclusive.83* @return the UnicodeMatcher object represented by the given84* character, or NULL if there is no mapping for ch.85* @stable ICU 2.886*/87virtual const UnicodeFunctor* lookupMatcher(UChar32 ch) const = 0;8889/**90* Parse a symbol reference name from the given string, starting91* at the given position. If no valid symbol reference name is92* found, return the empty string and leave pos unchanged. That is, if the93* character at pos cannot start a name, or if pos is at or after94* text.length(), then return an empty string. This indicates an95* isolated SYMBOL_REF character.96* @param text the text to parse for the name97* @param pos on entry, the index of the first character to parse.98* This is the character following the SYMBOL_REF character. On99* exit, the index after the last parsed character. If the parse100* failed, pos is unchanged on exit.101* @param limit the index after the last character to be parsed.102* @return the parsed name, or an empty string if there is no103* valid symbolic name at the given position.104* @stable ICU 2.8105*/106virtual UnicodeString parseReference(const UnicodeString& text,107ParsePosition& pos, int32_t limit) const = 0;108};109U_NAMESPACE_END110111#endif112113114