Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 2002-2006, 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"
17 U_NAMESPACE_BEGIN
18 class Hashtable;
19 U_NAMESPACE_END
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
25 * of by the user.
26 */
27 class T_CTEST_EXPORT_API DataMap {
28 public:
29 virtual ~DataMap();
31 protected:
32 DataMap();
33 int32_t utoi(const UnicodeString &s) const;
36 public:
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
40 */
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
47 */
48 virtual int32_t getInt(const char* key, UErrorCode &status) const = 0;
50 /**
51 * Get a signed integer without runtime parsing.
52 * @param key name of the data field.
53 * @param status UErrorCode in/out parameter
54 * @return the integer
55 */
56 virtual int32_t getInt28(const char* key, UErrorCode &status) const = 0;
58 /**
59 * Get an unsigned integer without runtime parsing.
60 * @param key name of the data field.
61 * @param status UErrorCode in/out parameter
62 * @return the integer
63 */
64 virtual uint32_t getUInt28(const char* key, UErrorCode &status) const = 0;
66 /**
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
72 */
73 virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const = 0;
75 /**
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
81 */
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
88 */
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
95 */
96 virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const = 0;
98 // ... etc ...
99 };
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{
104 private:
105 Hashtable *fData;
107 public:
108 virtual ~RBDataMap();
110 public:
111 RBDataMap();
113 RBDataMap(UResourceBundle *data, UErrorCode &status);
114 RBDataMap(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status);
116 public:
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;
133 // ... etc ...
134 };
137 #endif