1 /********************************************************************
3 * Copyright (c) 2002-2005, 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"
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
27 class T_CTEST_EXPORT_API DataMap
{
29 virtual ~DataMap() {};
33 int32_t utoi(const UnicodeString
&s
) const;
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
41 virtual const UnicodeString
getString(const char* key
, UErrorCode
&status
) const = 0;
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
48 virtual int32_t getInt(const char* key
, UErrorCode
&status
) const = 0;
51 * Get a signed integer without runtime parsing.
52 * @param key name of the data field.
53 * @param status UErrorCode in/out parameter
56 virtual int32_t getInt28(const char* key
, UErrorCode
&status
) const = 0;
59 * Get an unsigned integer without runtime parsing.
60 * @param key name of the data field.
61 * @param status UErrorCode in/out parameter
64 virtual uint32_t getUInt28(const char* key
, UErrorCode
&status
) const = 0;
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
73 virtual const int32_t *getIntVector(int32_t &length
, const char *key
, UErrorCode
&status
) const = 0;
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
82 virtual const uint8_t *getBinary(int32_t &length
, const char *key
, UErrorCode
&status
) const = 0;
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
89 virtual const UnicodeString
* getStringArray(int32_t& count
, const char* key
, UErrorCode
&status
) const = 0;
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
96 virtual const int32_t* getIntArray(int32_t& count
, const char* key
, UErrorCode
&status
) const = 0;
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
{
108 virtual ~RBDataMap();
113 RBDataMap(UResourceBundle
*data
, UErrorCode
&status
);
114 RBDataMap(UResourceBundle
*headers
, UResourceBundle
*data
, UErrorCode
&status
);
117 void init(UResourceBundle
*data
, UErrorCode
&status
);
118 void init(UResourceBundle
*headers
, UResourceBundle
*data
, UErrorCode
&status
);
120 virtual const ResourceBundle
*getItem(const char* key
, UErrorCode
&status
) const;
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;
128 virtual int32_t getInt(const char* key
, UErrorCode
&status
) const;
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;