ICU 76.1: icu::SymbolTable Class Reference

ICU 76.1 76.1

Public Types | Public Member Functions
icu::SymbolTable Class Referenceabstract

An interface that defines both lookup protocol and parsing of symbolic names. More...

`#include <symtable.h>`

## Public Types
enum | { SYMBOL_REF = 0x0024 }
| The character preceding a symbol reference name. More...

## Public Member Functions
virtual | ~SymbolTable ()
| Destructor.
virtual const UnicodeString * | lookup (const UnicodeString &s) const =0
| Lookup the characters associated with this string and return it.
virtual const UnicodeFunctor * | lookupMatcher (UChar32 ch) const =0
| Lookup the UnicodeMatcher associated with the given character, and return it.
virtual UnicodeString | parseReference (const UnicodeString &text, ParsePosition &pos, int32_t limit) const =0
| Parse a symbol reference name from the given string, starting at the given position.

## Detailed Description

An interface that defines both lookup protocol and parsing of symbolic names.

A symbol table maintains two kinds of mappings. The first is between symbolic names and their values. For example, if the variable with the name "start" is set to the value "alpha" (perhaps, though not necessarily, through an expression such as "$start=alpha"), then the call lookup("start") will return the char[] array ['a', 'l', 'p', 'h', 'a'].

The second kind of mapping is between character values and UnicodeMatcher objects. This is used by RuleBasedTransliterator, which uses characters in the private use area to represent objects such as UnicodeSets. If U+E015 is mapped to the UnicodeSet [a-z], then lookupMatcher(0xE015) will return the UnicodeSet [a-z].

Finally, a symbol table defines parsing behavior for symbolic names. All symbolic names start with the SYMBOL_REF character. When a parser encounters this character, it calls parseReference() with the position immediately following the SYMBOL_REF. The symbol table parses the name, if there is one, and returns it.

Stable
  ICU 2.8

Definition at line 59 of file symtable.h.

## Member Enumeration Documentation

## ◆ anonymous enum

anonymous enum

The character preceding a symbol reference name.

Stable
  ICU 2.8

Definition at line 66 of file symtable.h.

## Constructor & Destructor Documentation

## ◆ ~SymbolTable()

virtual icu::SymbolTable::~SymbolTable | ( |  | ) |
| virtual

Destructor.

Stable
  ICU 2.8

## Member Function Documentation

## ◆ lookup()

virtual const UnicodeString * icu::SymbolTable::lookup | ( | const UnicodeString & | s | ) | const
| pure virtual

Lookup the characters associated with this string and return it.

Return `nullptr` if no such name exists. The resultant string may have length zero.

Parameters

  s | the symbolic name to lookup

Returns
  a string containing the name's value, or `nullptr` if there is no mapping for s.

Stable
  ICU 2.8

## ◆ lookupMatcher()

virtual const UnicodeFunctor * icu::SymbolTable::lookupMatcher | ( | UChar32 | ch | ) | const
| pure virtual

Lookup the UnicodeMatcher associated with the given character, and return it.

Return `nullptr` if not found.

Parameters

  ch | a 32-bit code point from 0 to 0x10FFFF inclusive.

Returns
  the UnicodeMatcher object represented by the given character, or nullptr if there is no mapping for ch.

Stable
  ICU 2.8

## ◆ parseReference()

virtual UnicodeString icu::SymbolTable::parseReference | ( | const UnicodeString & | text,
|  | ParsePosition & | pos,
|  | int32_t | limit ) const
| pure virtual

Parse a symbol reference name from the given string, starting at the given position.

If no valid symbol reference name is found, return the empty string and leave pos unchanged. That is, if the character at pos cannot start a name, or if pos is at or after text.length(), then return an empty string. This indicates an isolated SYMBOL_REF character.

Parameters

  text | the text to parse for the name
  pos | on entry, the index of the first character to parse. This is the character following the SYMBOL_REF character. On exit, the index after the last parsed character. If the parse failed, pos is unchanged on exit.
  limit | the index after the last character to be parsed.

Returns
  the parsed name, or an empty string if there is no valid symbolic name at the given position.

Stable
  ICU 2.8

The documentation for this class was generated from the following file:

- common/unicode/symtable.h