]>
Commit | Line | Data |
---|---|---|
1 | /******************************************************************** | |
2 | * COPYRIGHT: | |
3 | * Copyright (c) 2002-2006, International Business Machines Corporation and | |
4 | * others. All Rights Reserved. | |
5 | ********************************************************************/ | |
6 | ||
7 | /* Created by weiv 05/09/2002 */ | |
8 | ||
9 | #ifndef U_TESTFW_DATAMAP | |
10 | #define U_TESTFW_DATAMAP | |
11 | ||
12 | #include "unicode/resbund.h" | |
13 | #include "unicode/testtype.h" | |
14 | ||
15 | ||
16 | ||
17 | U_NAMESPACE_BEGIN | |
18 | class Hashtable; | |
19 | U_NAMESPACE_END | |
20 | ||
21 | /** Holder of test data and settings. Allows addressing of items by name. | |
22 | * For test cases, names are defined in the "Headers" section. For settings | |
23 | * and info data, names are keys in data. Currently, we return scalar strings | |
24 | * and integers and arrays of strings and integers. Arrays should be deposited | |
25 | * of by the user. | |
26 | */ | |
27 | class T_CTEST_EXPORT_API DataMap { | |
28 | public: | |
29 | virtual ~DataMap(); | |
30 | ||
31 | protected: | |
32 | DataMap(); | |
33 | int32_t utoi(const UnicodeString &s) const; | |
34 | ||
35 | ||
36 | public: | |
37 | /** get the string from the DataMap. Addressed by name | |
38 | * @param key name of the data field. | |
39 | * @return a string containing the data | |
40 | */ | |
41 | virtual const UnicodeString getString(const char* key, UErrorCode &status) const = 0; | |
42 | ||
43 | /** get the string from the DataMap. Addressed by name | |
44 | * parses a bundle string into an integer | |
45 | * @param key name of the data field. | |
46 | * @return an integer containing the data | |
47 | */ | |
48 | virtual int32_t getInt(const char* key, UErrorCode &status) const = 0; | |
49 | ||
50 | /** | |
51 | * Get a signed integer without runtime parsing. | |
52 | * @param key name of the data field. | |
53 | * @param status UErrorCode in/out parameter | |
54 | * @return the integer | |
55 | */ | |
56 | virtual int32_t getInt28(const char* key, UErrorCode &status) const = 0; | |
57 | ||
58 | /** | |
59 | * Get an unsigned integer without runtime parsing. | |
60 | * @param key name of the data field. | |
61 | * @param status UErrorCode in/out parameter | |
62 | * @return the integer | |
63 | */ | |
64 | virtual uint32_t getUInt28(const char* key, UErrorCode &status) const = 0; | |
65 | ||
66 | /** | |
67 | * Get a vector of integers without runtime parsing. | |
68 | * @param length output parameter for the length of the vector | |
69 | * @param key name of the data field. | |
70 | * @param status UErrorCode in/out parameter | |
71 | * @return the integer vector, do not delete | |
72 | */ | |
73 | virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const = 0; | |
74 | ||
75 | /** | |
76 | * Get binary data without runtime parsing. | |
77 | * @param length output parameter for the length of the data | |
78 | * @param key name of the data field. | |
79 | * @param status UErrorCode in/out parameter | |
80 | * @return the binary data, do not delete | |
81 | */ | |
82 | virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const = 0; | |
83 | ||
84 | /** get an array of strings from the DataMap. Addressed by name. | |
85 | * The user must dispose of it after usage, using delete. | |
86 | * @param key name of the data field. | |
87 | * @return a string array containing the data | |
88 | */ | |
89 | virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const = 0; | |
90 | ||
91 | /** get an array of integers from the DataMap. Addressed by name. | |
92 | * The user must dispose of it after usage, using delete. | |
93 | * @param key name of the data field. | |
94 | * @return an integer array containing the data | |
95 | */ | |
96 | virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const = 0; | |
97 | ||
98 | // ... etc ... | |
99 | }; | |
100 | ||
101 | // This one is already concrete - it is going to be instantiated from | |
102 | // concrete data by TestData children... | |
103 | class T_CTEST_EXPORT_API RBDataMap : public DataMap{ | |
104 | private: | |
105 | Hashtable *fData; | |
106 | ||
107 | public: | |
108 | virtual ~RBDataMap(); | |
109 | ||
110 | public: | |
111 | RBDataMap(); | |
112 | ||
113 | RBDataMap(UResourceBundle *data, UErrorCode &status); | |
114 | RBDataMap(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); | |
115 | ||
116 | public: | |
117 | void init(UResourceBundle *data, UErrorCode &status); | |
118 | void init(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); | |
119 | ||
120 | virtual const ResourceBundle *getItem(const char* key, UErrorCode &status) const; | |
121 | ||
122 | virtual const UnicodeString getString(const char* key, UErrorCode &status) const; | |
123 | virtual int32_t getInt28(const char* key, UErrorCode &status) const; | |
124 | virtual uint32_t getUInt28(const char* key, UErrorCode &status) const; | |
125 | virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const; | |
126 | virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const; | |
127 | ||
128 | virtual int32_t getInt(const char* key, UErrorCode &status) const; | |
129 | ||
130 | virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const; | |
131 | virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const; | |
132 | ||
133 | // ... etc ... | |
134 | }; | |
135 | ||
136 | ||
137 | #endif | |
138 |