2000-02-08 02:49:15 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
|
|
|
* Copyright (c) 2000, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 02/04/00 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
#ifndef SYMTABLE_H
|
|
|
|
#define SYMTABLE_H
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
2000-05-20 04:40:29 +00:00
|
|
|
class ParsePosition;
|
|
|
|
class UnicodeSet;
|
|
|
|
class UnicodeString;
|
|
|
|
|
2000-02-08 02:49:15 +00:00
|
|
|
/**
|
2000-05-20 04:40:29 +00:00
|
|
|
* An interface that maps strings to objects. This interface defines
|
|
|
|
* both lookup protocol and parsing. This allows different components
|
|
|
|
* to share a symbol table and to handle name parsing uniformly. It
|
|
|
|
* is expected that client parse code look for the SYMBOL_REF
|
|
|
|
* character and, when seen, attempt to parse the characters after it
|
|
|
|
* using parseReference().
|
|
|
|
*
|
|
|
|
* <p>Currently, RuleBasedTransliterator and UnicodeSet use this
|
|
|
|
* interface to share variable definitions.
|
2000-02-08 02:49:15 +00:00
|
|
|
*/
|
|
|
|
class SymbolTable {
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
2000-05-20 04:40:29 +00:00
|
|
|
* The character preceding a symbol reference name.
|
|
|
|
*/
|
|
|
|
enum { SYMBOL_REF = 0x0024 /*$*/ };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lookup the characters associated with this string and return it.
|
|
|
|
* Return <tt>NULL</tt> if no such name exists. The resultant
|
|
|
|
* string may have length zero.
|
|
|
|
*/
|
|
|
|
virtual const UnicodeString* lookup(const UnicodeString& s) const = 0;
|
|
|
|
|
|
|
|
/**
|
2001-11-09 01:22:33 +00:00
|
|
|
* Lookup the UnicodeMatcher associated with the given character, and
|
2000-05-20 04:40:29 +00:00
|
|
|
* return it. Return <tt>null</tt> if not found.
|
|
|
|
*/
|
2001-11-09 01:22:33 +00:00
|
|
|
virtual const UnicodeMatcher* lookupMatcher(UChar32 ch) const = 0;
|
2000-05-20 04:40:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a symbol reference name from the given string, starting
|
|
|
|
* at the given position. If no valid symbol reference name is
|
2000-08-30 20:43:25 +00:00
|
|
|
* found, return an empty string.
|
2000-05-20 04:40:29 +00:00
|
|
|
* @param text the text to parse for the name
|
|
|
|
* @param 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.
|
|
|
|
* @param limit the index after the last character to be parsed.
|
2000-08-30 20:43:25 +00:00
|
|
|
* @return the parsed name or an empty string.
|
2000-02-08 02:49:15 +00:00
|
|
|
*/
|
2000-05-20 04:40:29 +00:00
|
|
|
virtual UnicodeString parseReference(const UnicodeString& text,
|
|
|
|
ParsePosition& pos, int32_t limit) const = 0;
|
2000-02-08 02:49:15 +00:00
|
|
|
};
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2000-02-08 02:49:15 +00:00
|
|
|
|
|
|
|
#endif
|