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