michael@0: /******************************************************************** michael@0: * COPYRIGHT: michael@0: * Copyright (c) 2002-2006, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ********************************************************************/ michael@0: michael@0: /* Created by weiv 05/09/2002 */ michael@0: michael@0: #ifndef U_TESTFW_DATAMAP michael@0: #define U_TESTFW_DATAMAP michael@0: michael@0: #include "unicode/resbund.h" michael@0: #include "unicode/testtype.h" michael@0: michael@0: michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: class Hashtable; michael@0: U_NAMESPACE_END michael@0: michael@0: /** Holder of test data and settings. Allows addressing of items by name. michael@0: * For test cases, names are defined in the "Headers" section. For settings michael@0: * and info data, names are keys in data. Currently, we return scalar strings michael@0: * and integers and arrays of strings and integers. Arrays should be deposited michael@0: * of by the user. michael@0: */ michael@0: class T_CTEST_EXPORT_API DataMap { michael@0: public: michael@0: virtual ~DataMap(); michael@0: michael@0: protected: michael@0: DataMap(); michael@0: int32_t utoi(const UnicodeString &s) const; michael@0: michael@0: michael@0: public: michael@0: /** get the string from the DataMap. Addressed by name michael@0: * @param key name of the data field. michael@0: * @return a string containing the data michael@0: */ michael@0: virtual const UnicodeString getString(const char* key, UErrorCode &status) const = 0; michael@0: michael@0: /** get the string from the DataMap. Addressed by name michael@0: * parses a bundle string into an integer michael@0: * @param key name of the data field. michael@0: * @return an integer containing the data michael@0: */ michael@0: virtual int32_t getInt(const char* key, UErrorCode &status) const = 0; michael@0: michael@0: /** michael@0: * Get a signed integer without runtime parsing. michael@0: * @param key name of the data field. michael@0: * @param status UErrorCode in/out parameter michael@0: * @return the integer michael@0: */ michael@0: virtual int32_t getInt28(const char* key, UErrorCode &status) const = 0; michael@0: michael@0: /** michael@0: * Get an unsigned integer without runtime parsing. michael@0: * @param key name of the data field. michael@0: * @param status UErrorCode in/out parameter michael@0: * @return the integer michael@0: */ michael@0: virtual uint32_t getUInt28(const char* key, UErrorCode &status) const = 0; michael@0: michael@0: /** michael@0: * Get a vector of integers without runtime parsing. michael@0: * @param length output parameter for the length of the vector michael@0: * @param key name of the data field. michael@0: * @param status UErrorCode in/out parameter michael@0: * @return the integer vector, do not delete michael@0: */ michael@0: virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const = 0; michael@0: michael@0: /** michael@0: * Get binary data without runtime parsing. michael@0: * @param length output parameter for the length of the data michael@0: * @param key name of the data field. michael@0: * @param status UErrorCode in/out parameter michael@0: * @return the binary data, do not delete michael@0: */ michael@0: virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const = 0; michael@0: michael@0: /** get an array of strings from the DataMap. Addressed by name. michael@0: * The user must dispose of it after usage, using delete. michael@0: * @param key name of the data field. michael@0: * @return a string array containing the data michael@0: */ michael@0: virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const = 0; michael@0: michael@0: /** get an array of integers from the DataMap. Addressed by name. michael@0: * The user must dispose of it after usage, using delete. michael@0: * @param key name of the data field. michael@0: * @return an integer array containing the data michael@0: */ michael@0: virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const = 0; michael@0: michael@0: // ... etc ... michael@0: }; michael@0: michael@0: // This one is already concrete - it is going to be instantiated from michael@0: // concrete data by TestData children... michael@0: class T_CTEST_EXPORT_API RBDataMap : public DataMap{ michael@0: private: michael@0: Hashtable *fData; michael@0: michael@0: public: michael@0: virtual ~RBDataMap(); michael@0: michael@0: public: michael@0: RBDataMap(); michael@0: michael@0: RBDataMap(UResourceBundle *data, UErrorCode &status); michael@0: RBDataMap(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); michael@0: michael@0: public: michael@0: void init(UResourceBundle *data, UErrorCode &status); michael@0: void init(UResourceBundle *headers, UResourceBundle *data, UErrorCode &status); michael@0: michael@0: virtual const ResourceBundle *getItem(const char* key, UErrorCode &status) const; michael@0: michael@0: virtual const UnicodeString getString(const char* key, UErrorCode &status) const; michael@0: virtual int32_t getInt28(const char* key, UErrorCode &status) const; michael@0: virtual uint32_t getUInt28(const char* key, UErrorCode &status) const; michael@0: virtual const int32_t *getIntVector(int32_t &length, const char *key, UErrorCode &status) const; michael@0: virtual const uint8_t *getBinary(int32_t &length, const char *key, UErrorCode &status) const; michael@0: michael@0: virtual int32_t getInt(const char* key, UErrorCode &status) const; michael@0: michael@0: virtual const UnicodeString* getStringArray(int32_t& count, const char* key, UErrorCode &status) const; michael@0: virtual const int32_t* getIntArray(int32_t& count, const char* key, UErrorCode &status) const; michael@0: michael@0: // ... etc ... michael@0: }; michael@0: michael@0: michael@0: #endif michael@0: