1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/ctestfw/unicode/datamap.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,138 @@ 1.4 +/******************************************************************** 1.5 + * COPYRIGHT: 1.6 + * Copyright (c) 2002-2006, International Business Machines Corporation and 1.7 + * others. All Rights Reserved. 1.8 + ********************************************************************/ 1.9 + 1.10 +/* Created by weiv 05/09/2002 */ 1.11 + 1.12 +#ifndef U_TESTFW_DATAMAP 1.13 +#define U_TESTFW_DATAMAP 1.14 + 1.15 +#include "unicode/resbund.h" 1.16 +#include "unicode/testtype.h" 1.17 + 1.18 + 1.19 + 1.20 +U_NAMESPACE_BEGIN 1.21 +class Hashtable; 1.22 +U_NAMESPACE_END 1.23 + 1.24 +/** Holder of test data and settings. Allows addressing of items by name. 1.25 + * For test cases, names are defined in the "Headers" section. For settings 1.26 + * and info data, names are keys in data. Currently, we return scalar strings 1.27 + * and integers and arrays of strings and integers. Arrays should be deposited 1.28 + * of by the user. 1.29 + */ 1.30 +class T_CTEST_EXPORT_API DataMap { 1.31 +public: 1.32 + virtual ~DataMap(); 1.33 + 1.34 +protected: 1.35 + DataMap(); 1.36 + int32_t utoi(const UnicodeString &s) const; 1.37 + 1.38 + 1.39 +public: 1.40 + /** get the string from the DataMap. Addressed by name 1.41 + * @param key name of the data field. 1.42 + * @return a string containing the data 1.43 + */ 1.44 + virtual const UnicodeString getString(const char* key, UErrorCode &status) const = 0; 1.45 + 1.46 + /** get the string from the DataMap. Addressed by name 1.47 + * parses a bundle string into an integer 1.48 + * @param key name of the data field. 1.49 + * @return an integer containing the data 1.50 + */ 1.51 + virtual int32_t getInt(const char* key, UErrorCode &status) const = 0; 1.52 + 1.53 + /** 1.54 + * Get a signed integer without runtime parsing. 1.55 + * @param key name of the data field. 1.56 + * @param status UErrorCode in/out parameter 1.57 + * @return the integer 1.58 + */ 1.59 + virtual int32_t getInt28(const char* key, UErrorCode &status) const = 0; 1.60 + 1.61 + /** 1.62 + * Get an unsigned integer without runtime parsing. 1.63 + * @param key name of the data field. 1.64 + * @param status UErrorCode in/out parameter 1.65 + * @return the integer 1.66 + */ 1.67 + virtual uint32_t getUInt28(const char* key, UErrorCode &status) const = 0; 1.68 + 1.69 + /** 1.70 + * Get a vector of integers without runtime parsing. 1.71 + * @param length output parameter for the length of the vector 1.72 + * @param key name of the data field. 1.73 + * @param status UErrorCode in/out parameter 1.74 + * @return the integer vector, do not delete 1.75 + */ 1.76 + virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const = 0; 1.77 + 1.78 + /** 1.79 + * Get binary data without runtime parsing. 1.80 + * @param length output parameter for the length of the data 1.81 + * @param key name of the data field. 1.82 + * @param status UErrorCode in/out parameter 1.83 + * @return the binary data, do not delete 1.84 + */ 1.85 + virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const = 0; 1.86 + 1.87 + /** get an array of strings from the DataMap. Addressed by name. 1.88 + * The user must dispose of it after usage, using delete. 1.89 + * @param key name of the data field. 1.90 + * @return a string array containing the data 1.91 + */ 1.92 + virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const = 0; 1.93 + 1.94 + /** get an array of integers from the DataMap. Addressed by name. 1.95 + * The user must dispose of it after usage, using delete. 1.96 + * @param key name of the data field. 1.97 + * @return an integer array containing the data 1.98 + */ 1.99 + virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const = 0; 1.100 + 1.101 + // ... etc ... 1.102 +}; 1.103 + 1.104 +// This one is already concrete - it is going to be instantiated from 1.105 +// concrete data by TestData children... 1.106 +class T_CTEST_EXPORT_API RBDataMap : public DataMap{ 1.107 +private: 1.108 + Hashtable *fData; 1.109 + 1.110 +public: 1.111 + virtual ~RBDataMap(); 1.112 + 1.113 +public: 1.114 + RBDataMap(); 1.115 + 1.116 + RBDataMap(UResourceBundle *data, UErrorCode &status); 1.117 + RBDataMap(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); 1.118 + 1.119 +public: 1.120 + void init(UResourceBundle *data, UErrorCode &status); 1.121 + void init(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); 1.122 + 1.123 + virtual const ResourceBundle *getItem(const char* key, UErrorCode &status) const; 1.124 + 1.125 + virtual const UnicodeString getString(const char* key, UErrorCode &status) const; 1.126 + virtual int32_t getInt28(const char* key, UErrorCode &status) const; 1.127 + virtual uint32_t getUInt28(const char* key, UErrorCode &status) const; 1.128 + virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const; 1.129 + virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const; 1.130 + 1.131 + virtual int32_t getInt(const char* key, UErrorCode &status) const; 1.132 + 1.133 + virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const; 1.134 + virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const; 1.135 + 1.136 + // ... etc ... 1.137 +}; 1.138 + 1.139 + 1.140 +#endif 1.141 +