]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/symtable.h
ICU-3.13.tar.gz
[apple/icu.git] / icuSources / common / symtable.h
1 /*
2 **********************************************************************
3 * Copyright (c) 2000, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 02/04/00 aliu Creation.
8 **********************************************************************
9 */
10 #ifndef SYMTABLE_H
11 #define SYMTABLE_H
12
13 #include "unicode/utypes.h"
14 #include "unicode/uobject.h"
15
16 U_NAMESPACE_BEGIN
17
18 class ParsePosition;
19 class UnicodeFunctor;
20 class UnicodeSet;
21 class UnicodeString;
22
23 /**
24 * An interface that maps strings to objects. This interface defines
25 * both lookup protocol and parsing. This allows different components
26 * to share a symbol table and to handle name parsing uniformly. It
27 * is expected that client parse code look for the SYMBOL_REF
28 * character and, when seen, attempt to parse the characters after it
29 * using parseReference().
30 *
31 * <p>Currently, RuleBasedTransliterator and UnicodeSet use this
32 * interface to share variable definitions.
33 */
34 class SymbolTable /* not : public UObject because this is an interface/mixin class */ {
35 public:
36
37 /**
38 * The character preceding a symbol reference name.
39 */
40 enum { SYMBOL_REF = 0x0024 /*$*/ };
41
42 /**
43 * Destructor.
44 */
45 virtual inline ~SymbolTable() {};
46
47 /**
48 * Lookup the characters associated with this string and return it.
49 * Return <tt>NULL</tt> if no such name exists. The resultant
50 * string may have length zero.
51 */
52 virtual const UnicodeString* lookup(const UnicodeString& s) const = 0;
53
54 /**
55 * Lookup the UnicodeMatcher associated with the given character, and
56 * return it. Return <tt>null</tt> if not found.
57 */
58 virtual const UnicodeFunctor* lookupMatcher(UChar32 ch) const = 0;
59
60 /**
61 * Parse a symbol reference name from the given string, starting
62 * at the given position. If no valid symbol reference name is
63 * found, return an empty string.
64 * @param text the text to parse for the name
65 * @param pos on entry, the index of the first character to parse.
66 * This is the character following the SYMBOL_REF character. On
67 * exit, the index after the last parsed character.
68 * @param limit the index after the last character to be parsed.
69 * @return the parsed name or an empty string.
70 */
71 virtual UnicodeString parseReference(const UnicodeString& text,
72 ParsePosition& pos, int32_t limit) const = 0;
73 };
74 U_NAMESPACE_END
75
76
77 #endif