1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*******************************************************************************
385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho* Copyright (C) 2007-2009, International Business Machines Corporation and
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* others. All Rights Reserved.                                                *
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*******************************************************************************
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* File DTPTNGEN.H
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*******************************************************************************
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "uvector.h"
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef __DTPTNGEN_IMPL_H__
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define __DTPTNGEN_IMPL_H__
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// TODO(claireho): Split off Builder class.
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// TODO(claireho): If splitting off Builder class: As subclass or independent?
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MAX_PATTERN_ENTRIES 52
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MAX_CLDR_FIELD_LEN  60
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MAX_DT_TOKEN        50
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MAX_RESOURCE_FIELD  12
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MAX_AVAILABLE_FORMATS  12
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define NONE          0
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define EXTRA_FIELD   0x10000
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MISSING_FIELD  0x1000
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define MAX_STRING_ENUMERATION  200
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define SINGLE_QUOTE      ((UChar)0x0027)
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define FORWARDSLASH      ((UChar)0x002F)
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define BACKSLASH         ((UChar)0x005C)
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define SPACE             ((UChar)0x0020)
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define QUOTATION_MARK    ((UChar)0x0022)
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define ASTERISK          ((UChar)0x002A)
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define PLUSSITN          ((UChar)0x002B)
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define COMMA             ((UChar)0x002C)
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define HYPHEN            ((UChar)0x002D)
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define DOT               ((UChar)0x002E)
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define COLON             ((UChar)0x003A)
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_A             ((UChar)0x0041)
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_C             ((UChar)0x0043)
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_D             ((UChar)0x0044)
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_E             ((UChar)0x0045)
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_F             ((UChar)0x0046)
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_G             ((UChar)0x0047)
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_H             ((UChar)0x0048)
4785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#define CAP_K             ((UChar)0x004B)
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_L             ((UChar)0x004C)
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_M             ((UChar)0x004D)
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_O             ((UChar)0x004F)
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_Q             ((UChar)0x0051)
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_S             ((UChar)0x0053)
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_T             ((UChar)0x0054)
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_V             ((UChar)0x0056)
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_W             ((UChar)0x0057)
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_Y             ((UChar)0x0059)
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CAP_Z             ((UChar)0x005A)
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOWLINE           ((UChar)0x005F)
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_A             ((UChar)0x0061)
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_C             ((UChar)0x0063)
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_D             ((UChar)0x0064)
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_E             ((UChar)0x0065)
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_F             ((UChar)0x0066)
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_G             ((UChar)0x0067)
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_H             ((UChar)0x0068)
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_I             ((UChar)0x0069)
6785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#define LOW_J             ((UChar)0x006A)
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_K             ((UChar)0x006B)
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_L             ((UChar)0x006C)
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_M             ((UChar)0x006D)
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_N             ((UChar)0x006E)
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_O             ((UChar)0x006F)
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_P             ((UChar)0x0070)
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_Q             ((UChar)0x0071)
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_R             ((UChar)0x0072)
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_S             ((UChar)0x0073)
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_T             ((UChar)0x0074)
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_U             ((UChar)0x0075)
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_V             ((UChar)0x0076)
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_W             ((UChar)0x0077)
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_Y             ((UChar)0x0079)
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define LOW_Z             ((UChar)0x007A)
8385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#define DT_SHORT          -0x102
8485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#define DT_LONG           -0x103
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define DT_NUMERIC         0x100
8685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho#define DT_NARROW         -0x101
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define DT_DELTA           0x10
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst int32_t UDATPG_FRACTIONAL_MASK = 1<<UDATPG_FRACTIONAL_SECOND_FIELD;
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst int32_t UDATPG_SECOND_AND_FRACTIONAL_MASK = (1<<UDATPG_SECOND_FIELD) | (1<<UDATPG_FRACTIONAL_SECOND_FIELD);
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef enum dtStrEnum {
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DT_BASESKELETON,
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DT_SKELETON,
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DT_PATTERN
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}dtStrEnum;
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef struct dtTypeElem {
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UChar                  patternChar;
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UDateTimePatternField  field;
10385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    int16_t                type;
10485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    int16_t                minLen;
10585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    int16_t                weight;
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}dtTypeElem;
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass PtnSkeleton : public UMemory {
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t type[UDATPG_FIELD_COUNT];
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString original[UDATPG_FIELD_COUNT];
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString baseOriginal[UDATPG_FIELD_COUNT];
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnSkeleton();
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnSkeleton(const PtnSkeleton& other);
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool equals(const PtnSkeleton& other);
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString getSkeleton();
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString getBaseSkeleton();
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~PtnSkeleton();
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass PtnElem : public UMemory {
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString basePattern;
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnSkeleton   *skeleton;
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString pattern;
12885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    UBool         skeletonWasSpecified; // if specified in availableFormats, not derived
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnElem       *next;
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnElem(const UnicodeString &basePattern, const UnicodeString &pattern);
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~PtnElem();
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass FormatParser : public UMemory {
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString items[MAX_DT_TOKEN];
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t  itemNumber;
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    FormatParser();
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~FormatParser();
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void set(const UnicodeString& patternString);
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool isQuoteLiteral(const UnicodeString& s) const;
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void getQuoteLiteral(UnicodeString& quote, int32_t *itemIndex);
14685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    int32_t getCanonicalIndex(const UnicodeString& s) { return getCanonicalIndex(s, TRUE); };
14785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    int32_t getCanonicalIndex(const UnicodeString& s, UBool strict);
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool isPatternSeparator(UnicodeString& field);
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void setFilter(UErrorCode &status);
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   typedef enum TokenStatus {
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       START,
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       ADD_TOKEN,
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       SYNTAX_ERROR,
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       DONE
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   } ToeknStatus;
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   TokenStatus status;
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru   virtual TokenStatus setTokens(const UnicodeString& pattern, int32_t startPos, int32_t *len);
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass DistanceInfo : public UMemory {
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t missingFieldMask;
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t extraFieldMask;
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DistanceInfo() {};
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~DistanceInfo() {};
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void clear() { missingFieldMask = extraFieldMask = 0; };
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void setTo(DistanceInfo& other);
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void addMissing(int32_t field) { missingFieldMask |= (1<<field); };
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void addExtra(int32_t field) { extraFieldMask |= (1<<field); };
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass DateTimeMatcher: public UMemory {
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnSkeleton skeleton;
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void getBasePattern(UnicodeString &basePattern);
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString getPattern();
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void set(const UnicodeString& pattern, FormatParser* fp);
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton& skeleton);
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void copyFrom(const PtnSkeleton& skeleton);
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void copyFrom();
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnSkeleton* getSkeletonPtr();
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool equals(const DateTimeMatcher* other) const;
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t getDistance(const DateTimeMatcher& other, int32_t includeMask, DistanceInfo& distanceInfo);
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DateTimeMatcher();
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DateTimeMatcher(const DateTimeMatcher& other);
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~DateTimeMatcher() {};
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t getFieldMask();
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass PatternMap : public UMemory {
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnElem *boot[MAX_PATTERN_ENTRIES];
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PatternMap();
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual  ~PatternMap();
20085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    void  add(const UnicodeString& basePattern, const PtnSkeleton& skeleton, const UnicodeString& value, UBool skeletonWasSpecified, UErrorCode& status);
20185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    const UnicodeString* getPatternFromBasePattern(UnicodeString& basePattern, UBool& skeletonWasSpecified);
20285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    const UnicodeString* getPatternFromSkeleton(PtnSkeleton& skeleton, const PtnSkeleton** specifiedSkeletonPtr = 0);
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void copyFrom(const PatternMap& other, UErrorCode& status);
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnElem* getHeader(UChar baseChar);
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool equals(const PatternMap& other);
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool isDupAllowed;
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnElem*  getDuplicateElem(const UnicodeString &basePattern, const PtnSkeleton& skeleton, PtnElem *baseElem);
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; // end  PatternMap
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass PatternMapIterator : public UMemory {
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PatternMapIterator();
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~PatternMapIterator();
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void set(PatternMap& patternMap);
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnSkeleton* getSkeleton();
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool hasNext();
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DateTimeMatcher& next();
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t bootIndex;
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PtnElem *nodePtr;
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DateTimeMatcher *matcher;
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    PatternMap *patternMap;
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
22685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hoclass DTSkeletonEnumeration : public StringEnumeration {
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DTSkeletonEnumeration(PatternMap &patternMap, dtStrEnum type, UErrorCode& status);
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~DTSkeletonEnumeration();
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static UClassID U_EXPORT2 getStaticClassID(void);
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UClassID getDynamicClassID(void) const;
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual const UnicodeString* snext(UErrorCode& status);
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void reset(UErrorCode& status);
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual int32_t count(UErrorCode& status) const;
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t pos;
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool isCanonicalItem(const UnicodeString& item);
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector *fSkeletons;
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
24185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Hoclass DTRedundantEnumeration : public StringEnumeration {
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    DTRedundantEnumeration();
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~DTRedundantEnumeration();
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static UClassID U_EXPORT2 getStaticClassID(void);
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UClassID getDynamicClassID(void) const;
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual const UnicodeString* snext(UErrorCode& status);
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual void reset(UErrorCode& status);
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual int32_t count(UErrorCode& status) const;
250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void add(const UnicodeString &pattern, UErrorCode& status);
251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t pos;
253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool isCanonicalItem(const UnicodeString& item);
254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector *fPatterns;
255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
260