1 /********************************************************************
3 * Copyright (c) 2002-2004, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 /* Created by weiv 05/09/2002 */
9 #ifndef U_TESTFW_DATAMAP
10 #define U_TESTFW_DATAMAP
12 #include "unicode/resbund.h"
13 #include "unicode/testtype.h"
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
25 class T_CTEST_EXPORT_API DataMap
{
27 virtual ~DataMap() {};
31 int32_t utoi(const UnicodeString
&s
) const;
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
39 virtual const UnicodeString
getString(const char* key
, UErrorCode
&status
) const = 0;
41 /** get the string from the DataMap. Addressed by name
42 * parses a bundle string into an integer
43 * @param key name of the data field.
44 * @return an integer containing the data
46 virtual int32_t getInt(const char* key
, UErrorCode
&status
) const = 0;
49 * Get a signed integer without runtime parsing.
50 * @param key name of the data field.
51 * @param status UErrorCode in/out parameter
54 virtual int32_t getInt28(const char* key
, UErrorCode
&status
) const = 0;
57 * Get an unsigned integer without runtime parsing.
58 * @param key name of the data field.
59 * @param status UErrorCode in/out parameter
62 virtual uint32_t getUInt28(const char* key
, UErrorCode
&status
) const = 0;
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
71 virtual const int32_t *getIntVector(int32_t &length
, const char *key
, UErrorCode
&status
) const = 0;
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
80 virtual const uint8_t *getBinary(int32_t &length
, const char *key
, UErrorCode
&status
) const = 0;
82 /** get an array of strings from the DataMap. Addressed by name.
83 * The user must dispose of it after usage, using delete.
84 * @param key name of the data field.
85 * @return a string array containing the data
87 virtual const UnicodeString
* getStringArray(int32_t& count
, const char* key
, UErrorCode
&status
) const = 0;
89 /** get an array of integers from the DataMap. Addressed by name.
90 * The user must dispose of it after usage, using delete.
91 * @param key name of the data field.
92 * @return an integer array containing the data
94 virtual const int32_t* getIntArray(int32_t& count
, const char* key
, UErrorCode
&status
) const = 0;
99 // This one is already concrete - it is going to be instantiated from
100 // concrete data by TestData children...
101 class T_CTEST_EXPORT_API RBDataMap
: public DataMap
{
106 virtual ~RBDataMap();
111 RBDataMap(UResourceBundle
*data
, UErrorCode
&status
);
112 RBDataMap(UResourceBundle
*headers
, UResourceBundle
*data
, UErrorCode
&status
);
115 void init(UResourceBundle
*data
, UErrorCode
&status
);
116 void init(UResourceBundle
*headers
, UResourceBundle
*data
, UErrorCode
&status
);
118 virtual const ResourceBundle
*getItem(const char* key
, UErrorCode
&status
) const;
120 virtual const UnicodeString
getString(const char* key
, UErrorCode
&status
) const;
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;
126 virtual int32_t getInt(const char* key
, UErrorCode
&status
) const;
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;