1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 2002-2006, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 /* Created by weiv 05/09/2002 */
11 #ifndef U_TESTFW_DATAMAP
12 #define U_TESTFW_DATAMAP
14 #include "unicode/resbund.h"
15 #include "unicode/testtype.h"
23 /** Holder of test data and settings. Allows addressing of items by name.
24 * For test cases, names are defined in the "Headers" section. For settings
25 * and info data, names are keys in data. Currently, we return scalar strings
26 * and integers and arrays of strings and integers. Arrays should be deposited
29 class T_CTEST_EXPORT_API DataMap
{
35 int32_t utoi(const UnicodeString
&s
) const;
39 /** get the string from the DataMap. Addressed by name
40 * @param key name of the data field.
41 * @return a string containing the data
43 virtual const UnicodeString
getString(const char* key
, UErrorCode
&status
) const = 0;
45 /** get the string from the DataMap. Addressed by name
46 * parses a bundle string into an integer
47 * @param key name of the data field.
48 * @return an integer containing the data
50 virtual int32_t getInt(const char* key
, UErrorCode
&status
) const = 0;
53 * Get a signed integer without runtime parsing.
54 * @param key name of the data field.
55 * @param status UErrorCode in/out parameter
58 virtual int32_t getInt28(const char* key
, UErrorCode
&status
) const = 0;
61 * Get an unsigned integer without runtime parsing.
62 * @param key name of the data field.
63 * @param status UErrorCode in/out parameter
66 virtual uint32_t getUInt28(const char* key
, UErrorCode
&status
) const = 0;
69 * Get a vector of integers without runtime parsing.
70 * @param length output parameter for the length of the vector
71 * @param key name of the data field.
72 * @param status UErrorCode in/out parameter
73 * @return the integer vector, do not delete
75 virtual const int32_t *getIntVector(int32_t &length
, const char *key
, UErrorCode
&status
) const = 0;
78 * Get binary data without runtime parsing.
79 * @param length output parameter for the length of the data
80 * @param key name of the data field.
81 * @param status UErrorCode in/out parameter
82 * @return the binary data, do not delete
84 virtual const uint8_t *getBinary(int32_t &length
, const char *key
, UErrorCode
&status
) const = 0;
86 /** get an array of strings from the DataMap. Addressed by name.
87 * The user must dispose of it after usage, using delete.
88 * @param key name of the data field.
89 * @return a string array containing the data
91 virtual const UnicodeString
* getStringArray(int32_t& count
, const char* key
, UErrorCode
&status
) const = 0;
93 /** get an array of integers from the DataMap. Addressed by name.
94 * The user must dispose of it after usage, using delete.
95 * @param key name of the data field.
96 * @return an integer array containing the data
98 virtual const int32_t* getIntArray(int32_t& count
, const char* key
, UErrorCode
&status
) const = 0;
103 // This one is already concrete - it is going to be instantiated from
104 // concrete data by TestData children...
105 class T_CTEST_EXPORT_API RBDataMap
: public DataMap
{
110 virtual ~RBDataMap();
115 RBDataMap(UResourceBundle
*data
, UErrorCode
&status
);
116 RBDataMap(UResourceBundle
*headers
, UResourceBundle
*data
, UErrorCode
&status
);
119 void init(UResourceBundle
*data
, UErrorCode
&status
);
120 void init(UResourceBundle
*headers
, UResourceBundle
*data
, UErrorCode
&status
);
122 virtual const ResourceBundle
*getItem(const char* key
, UErrorCode
&status
) const;
124 virtual const UnicodeString
getString(const char* key
, UErrorCode
&status
) const;
125 virtual int32_t getInt28(const char* key
, UErrorCode
&status
) const;
126 virtual uint32_t getUInt28(const char* key
, UErrorCode
&status
) const;
127 virtual const int32_t *getIntVector(int32_t &length
, const char *key
, UErrorCode
&status
) const;
128 virtual const uint8_t *getBinary(int32_t &length
, const char *key
, UErrorCode
&status
) const;
130 virtual int32_t getInt(const char* key
, UErrorCode
&status
) const;
132 virtual const UnicodeString
* getStringArray(int32_t& count
, const char* key
, UErrorCode
&status
) const;
133 virtual const int32_t* getIntArray(int32_t& count
, const char* key
, UErrorCode
&status
) const;