annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/symtable.h @ 69:33d812a61356

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