Path: blob/jdk8u272-b10-aarch32-20201026/jdk/src/share/native/common/unicode/symtable.h
48773 views
// © 2016 and later: Unicode, Inc. and others.1// License & terms of use: http://www.unicode.org/copyright.html2/*3**********************************************************************4* Copyright (c) 2000-2005, International Business Machines5* Corporation and others. All Rights Reserved.6**********************************************************************7* Date Name Description8* 02/04/00 aliu Creation.9**********************************************************************10*/11#ifndef SYMTABLE_H12#define SYMTABLE_H1314#include "unicode/utypes.h"15#include "unicode/uobject.h"1617/**18* \file19* \brief C++ API: An interface that defines both lookup protocol and parsing of20* symbolic names.21*/2223U_NAMESPACE_BEGIN2425class ParsePosition;26class UnicodeFunctor;27class UnicodeSet;28class UnicodeString;2930/**31* An interface that defines both lookup protocol and parsing of32* symbolic names.33*34* <p>A symbol table maintains two kinds of mappings. The first is35* between symbolic names and their values. For example, if the36* variable with the name "start" is set to the value "alpha"37* (perhaps, though not necessarily, through an expression such as38* "$start=alpha"), then the call lookup("start") will return the39* char[] array ['a', 'l', 'p', 'h', 'a'].40*41* <p>The second kind of mapping is between character values and42* UnicodeMatcher objects. This is used by RuleBasedTransliterator,43* which uses characters in the private use area to represent objects44* such as UnicodeSets. If U+E015 is mapped to the UnicodeSet [a-z],45* then lookupMatcher(0xE015) will return the UnicodeSet [a-z].46*47* <p>Finally, a symbol table defines parsing behavior for symbolic48* names. All symbolic names start with the SYMBOL_REF character.49* When a parser encounters this character, it calls parseReference()50* with the position immediately following the SYMBOL_REF. The symbol51* table parses the name, if there is one, and returns it.52*53* @stable ICU 2.854*/55class U_COMMON_API SymbolTable /* not : public UObject because this is an interface/mixin class */ {56public:5758/**59* The character preceding a symbol reference name.60* @stable ICU 2.861*/62enum { SYMBOL_REF = 0x0024 /*$*/ };6364/**65* Destructor.66* @stable ICU 2.867*/68virtual ~SymbolTable();6970/**71* Lookup the characters associated with this string and return it.72* Return <tt>NULL</tt> if no such name exists. The resultant73* string may have length zero.74* @param s the symbolic name to lookup75* @return a string containing the name's value, or <tt>NULL</tt> if76* there is no mapping for s.77* @stable ICU 2.878*/79virtual const UnicodeString* lookup(const UnicodeString& s) const = 0;8081/**82* Lookup the UnicodeMatcher associated with the given character, and83* return it. Return <tt>NULL</tt> if not found.84* @param ch a 32-bit code point from 0 to 0x10FFFF inclusive.85* @return the UnicodeMatcher object represented by the given86* character, or NULL if there is no mapping for ch.87* @stable ICU 2.888*/89virtual const UnicodeFunctor* lookupMatcher(UChar32 ch) const = 0;9091/**92* Parse a symbol reference name from the given string, starting93* at the given position. If no valid symbol reference name is94* found, return the empty string and leave pos unchanged. That is, if the95* character at pos cannot start a name, or if pos is at or after96* text.length(), then return an empty string. This indicates an97* isolated SYMBOL_REF character.98* @param text the text to parse for the name99* @param pos on entry, the index of the first character to parse.100* This is the character following the SYMBOL_REF character. On101* exit, the index after the last parsed character. If the parse102* failed, pos is unchanged on exit.103* @param limit the index after the last character to be parsed.104* @return the parsed name, or an empty string if there is no105* valid symbolic name at the given position.106* @stable ICU 2.8107*/108virtual UnicodeString parseReference(const UnicodeString& text,109ParsePosition& pos, int32_t limit) const = 0;110};111U_NAMESPACE_END112113#endif114115116