]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/ctestfw/unicode/datamap.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / tools / ctestfw / unicode / datamap.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f
A
3/********************************************************************
4 * COPYRIGHT:
46f4442e 5 * Copyright (c) 2002-2006, International Business Machines Corporation and
b75a7d8f
A
6 * others. All Rights Reserved.
7 ********************************************************************/
8
9/* Created by weiv 05/09/2002 */
10
374ca955
A
11#ifndef U_TESTFW_DATAMAP
12#define U_TESTFW_DATAMAP
b75a7d8f 13
374ca955
A
14#include "unicode/resbund.h"
15#include "unicode/testtype.h"
16
73c04bcf
A
17
18
374ca955
A
19U_NAMESPACE_BEGIN
20class Hashtable;
21U_NAMESPACE_END
b75a7d8f
A
22
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
27 * of by the user.
28 */
374ca955 29class T_CTEST_EXPORT_API DataMap {
b75a7d8f 30public:
46f4442e 31 virtual ~DataMap();
b75a7d8f
A
32
33protected:
46f4442e 34 DataMap();
b75a7d8f
A
35 int32_t utoi(const UnicodeString &s) const;
36
37
38public:
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
42 */
43 virtual const UnicodeString getString(const char* key, UErrorCode &status) const = 0;
44
45 /** get the string from the DataMap. Addressed by name
374ca955 46 * parses a bundle string into an integer
b75a7d8f
A
47 * @param key name of the data field.
48 * @return an integer containing the data
49 */
50 virtual int32_t getInt(const char* key, UErrorCode &status) const = 0;
374ca955
A
51
52 /**
53 * Get a signed integer without runtime parsing.
54 * @param key name of the data field.
55 * @param status UErrorCode in/out parameter
56 * @return the integer
57 */
58 virtual int32_t getInt28(const char* key, UErrorCode &status) const = 0;
59
60 /**
61 * Get an unsigned integer without runtime parsing.
62 * @param key name of the data field.
63 * @param status UErrorCode in/out parameter
64 * @return the integer
65 */
66 virtual uint32_t getUInt28(const char* key, UErrorCode &status) const = 0;
67
68 /**
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
74 */
75 virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const = 0;
76
77 /**
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
83 */
84 virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const = 0;
85
b75a7d8f 86 /** get an array of strings from the DataMap. Addressed by name.
374ca955 87 * The user must dispose of it after usage, using delete.
b75a7d8f
A
88 * @param key name of the data field.
89 * @return a string array containing the data
90 */
91 virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const = 0;
92
93 /** get an array of integers from the DataMap. Addressed by name.
374ca955 94 * The user must dispose of it after usage, using delete.
b75a7d8f
A
95 * @param key name of the data field.
96 * @return an integer array containing the data
97 */
98 virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const = 0;
99
100 // ... etc ...
101};
102
103// This one is already concrete - it is going to be instantiated from
104// concrete data by TestData children...
374ca955 105class T_CTEST_EXPORT_API RBDataMap : public DataMap{
b75a7d8f
A
106private:
107 Hashtable *fData;
108
109public:
110 virtual ~RBDataMap();
111
112public:
113 RBDataMap();
114
115 RBDataMap(UResourceBundle *data, UErrorCode &status);
116 RBDataMap(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status);
117
118public:
119 void init(UResourceBundle *data, UErrorCode &status);
120 void init(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status);
374ca955
A
121
122 virtual const ResourceBundle *getItem(const char* key, UErrorCode &status) const;
123
b75a7d8f 124 virtual const UnicodeString getString(const char* key, UErrorCode &status) const;
374ca955
A
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;
129
b75a7d8f
A
130 virtual int32_t getInt(const char* key, UErrorCode &status) const;
131
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;
134
135 // ... etc ...
136};
137
73c04bcf 138
b75a7d8f
A
139#endif
140