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.
michael@0 | 1 | /******************************************************************** |
michael@0 | 2 | * COPYRIGHT: |
michael@0 | 3 | * Copyright (c) 2002-2006, International Business Machines Corporation and |
michael@0 | 4 | * others. All Rights Reserved. |
michael@0 | 5 | ********************************************************************/ |
michael@0 | 6 | |
michael@0 | 7 | /* Created by weiv 05/09/2002 */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef U_TESTFW_DATAMAP |
michael@0 | 10 | #define U_TESTFW_DATAMAP |
michael@0 | 11 | |
michael@0 | 12 | #include "unicode/resbund.h" |
michael@0 | 13 | #include "unicode/testtype.h" |
michael@0 | 14 | |
michael@0 | 15 | |
michael@0 | 16 | |
michael@0 | 17 | U_NAMESPACE_BEGIN |
michael@0 | 18 | class Hashtable; |
michael@0 | 19 | U_NAMESPACE_END |
michael@0 | 20 | |
michael@0 | 21 | /** Holder of test data and settings. Allows addressing of items by name. |
michael@0 | 22 | * For test cases, names are defined in the "Headers" section. For settings |
michael@0 | 23 | * and info data, names are keys in data. Currently, we return scalar strings |
michael@0 | 24 | * and integers and arrays of strings and integers. Arrays should be deposited |
michael@0 | 25 | * of by the user. |
michael@0 | 26 | */ |
michael@0 | 27 | class T_CTEST_EXPORT_API DataMap { |
michael@0 | 28 | public: |
michael@0 | 29 | virtual ~DataMap(); |
michael@0 | 30 | |
michael@0 | 31 | protected: |
michael@0 | 32 | DataMap(); |
michael@0 | 33 | int32_t utoi(const UnicodeString &s) const; |
michael@0 | 34 | |
michael@0 | 35 | |
michael@0 | 36 | public: |
michael@0 | 37 | /** get the string from the DataMap. Addressed by name |
michael@0 | 38 | * @param key name of the data field. |
michael@0 | 39 | * @return a string containing the data |
michael@0 | 40 | */ |
michael@0 | 41 | virtual const UnicodeString getString(const char* key, UErrorCode &status) const = 0; |
michael@0 | 42 | |
michael@0 | 43 | /** get the string from the DataMap. Addressed by name |
michael@0 | 44 | * parses a bundle string into an integer |
michael@0 | 45 | * @param key name of the data field. |
michael@0 | 46 | * @return an integer containing the data |
michael@0 | 47 | */ |
michael@0 | 48 | virtual int32_t getInt(const char* key, UErrorCode &status) const = 0; |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Get a signed integer without runtime parsing. |
michael@0 | 52 | * @param key name of the data field. |
michael@0 | 53 | * @param status UErrorCode in/out parameter |
michael@0 | 54 | * @return the integer |
michael@0 | 55 | */ |
michael@0 | 56 | virtual int32_t getInt28(const char* key, UErrorCode &status) const = 0; |
michael@0 | 57 | |
michael@0 | 58 | /** |
michael@0 | 59 | * Get an unsigned integer without runtime parsing. |
michael@0 | 60 | * @param key name of the data field. |
michael@0 | 61 | * @param status UErrorCode in/out parameter |
michael@0 | 62 | * @return the integer |
michael@0 | 63 | */ |
michael@0 | 64 | virtual uint32_t getUInt28(const char* key, UErrorCode &status) const = 0; |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * Get a vector of integers without runtime parsing. |
michael@0 | 68 | * @param length output parameter for the length of the vector |
michael@0 | 69 | * @param key name of the data field. |
michael@0 | 70 | * @param status UErrorCode in/out parameter |
michael@0 | 71 | * @return the integer vector, do not delete |
michael@0 | 72 | */ |
michael@0 | 73 | virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const = 0; |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * Get binary data without runtime parsing. |
michael@0 | 77 | * @param length output parameter for the length of the data |
michael@0 | 78 | * @param key name of the data field. |
michael@0 | 79 | * @param status UErrorCode in/out parameter |
michael@0 | 80 | * @return the binary data, do not delete |
michael@0 | 81 | */ |
michael@0 | 82 | virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const = 0; |
michael@0 | 83 | |
michael@0 | 84 | /** get an array of strings from the DataMap. Addressed by name. |
michael@0 | 85 | * The user must dispose of it after usage, using delete. |
michael@0 | 86 | * @param key name of the data field. |
michael@0 | 87 | * @return a string array containing the data |
michael@0 | 88 | */ |
michael@0 | 89 | virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const = 0; |
michael@0 | 90 | |
michael@0 | 91 | /** get an array of integers from the DataMap. Addressed by name. |
michael@0 | 92 | * The user must dispose of it after usage, using delete. |
michael@0 | 93 | * @param key name of the data field. |
michael@0 | 94 | * @return an integer array containing the data |
michael@0 | 95 | */ |
michael@0 | 96 | virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const = 0; |
michael@0 | 97 | |
michael@0 | 98 | // ... etc ... |
michael@0 | 99 | }; |
michael@0 | 100 | |
michael@0 | 101 | // This one is already concrete - it is going to be instantiated from |
michael@0 | 102 | // concrete data by TestData children... |
michael@0 | 103 | class T_CTEST_EXPORT_API RBDataMap : public DataMap{ |
michael@0 | 104 | private: |
michael@0 | 105 | Hashtable *fData; |
michael@0 | 106 | |
michael@0 | 107 | public: |
michael@0 | 108 | virtual ~RBDataMap(); |
michael@0 | 109 | |
michael@0 | 110 | public: |
michael@0 | 111 | RBDataMap(); |
michael@0 | 112 | |
michael@0 | 113 | RBDataMap(UResourceBundle *data, UErrorCode &status); |
michael@0 | 114 | RBDataMap(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); |
michael@0 | 115 | |
michael@0 | 116 | public: |
michael@0 | 117 | void init(UResourceBundle *data, UErrorCode &status); |
michael@0 | 118 | void init(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); |
michael@0 | 119 | |
michael@0 | 120 | virtual const ResourceBundle *getItem(const char* key, UErrorCode &status) const; |
michael@0 | 121 | |
michael@0 | 122 | virtual const UnicodeString getString(const char* key, UErrorCode &status) const; |
michael@0 | 123 | virtual int32_t getInt28(const char* key, UErrorCode &status) const; |
michael@0 | 124 | virtual uint32_t getUInt28(const char* key, UErrorCode &status) const; |
michael@0 | 125 | virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const; |
michael@0 | 126 | virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const; |
michael@0 | 127 | |
michael@0 | 128 | virtual int32_t getInt(const char* key, UErrorCode &status) const; |
michael@0 | 129 | |
michael@0 | 130 | virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const; |
michael@0 | 131 | virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const; |
michael@0 | 132 | |
michael@0 | 133 | // ... etc ... |
michael@0 | 134 | }; |
michael@0 | 135 | |
michael@0 | 136 | |
michael@0 | 137 | #endif |
michael@0 | 138 |