/******************************************************************** * COPYRIGHT: * Copyright (c) 2007, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #include "unicode/udbgutil.h" #include "unicode/dbgutil.h" #if !UCONFIG_NO_FORMATTING #include "unicode/unistr.h" #include "unicode/ustring.h" #include "ucln.h" #include #include #include UnicodeString **strs = NULL; static const UnicodeString& _fieldString(UDebugEnumType type, int32_t field, UnicodeString& fillin) { const char *str = udbg_enumName(type, field); if(str == NULL) { return fillin.remove(); } else { return fillin = UnicodeString(str, ""); // optimize? } } U_CDECL_BEGIN static void udbg_cleanup(void) { if(strs != NULL) { for(int t=0;t<=UDBG_ENUM_COUNT;t++) { delete [] strs[t]; } delete[] strs; strs = NULL; } } static UBool ctestfw_cleanup(void) { udbg_cleanup(); return TRUE; } static void udbg_register_cleanup(void) { ucln_registerCleanup(UCLN_CTESTFW, ctestfw_cleanup); } U_CDECL_END static void udbg_setup(void) { if(strs == NULL) { udbg_register_cleanup(); //fprintf(stderr,"Initializing string cache..\n"); //fflush(stderr); UnicodeString **newStrs = new UnicodeString*[UDBG_ENUM_COUNT+1]; for(int t=0;t=UDBG_ENUM_COUNT) { // use UDBG_ENUM_COUNT,0 to mean an empty string //fprintf(stderr, "** returning out of range on %d\n",type); //fflush(stderr); return strs[UDBG_ENUM_COUNT][0]; } int32_t count = udbg_enumCount(type); //fprintf(stderr, "enumString [%d,%d]: typecount %d, fieldcount %d\n", type,field,UDBG_ENUM_COUNT,count); //fflush(stderr); if(field<0 || field > count) { return strs[type][count]; } else { return strs[type][field]; } } T_CTEST_API int32_t T_CTEST_EXPORT2 udbg_enumByString(UDebugEnumType type, const UnicodeString& string) { if(type<0||type>=UDBG_ENUM_COUNT) { return -1; } // initialize array udbg_enumString(type,0); // search for(int i=0;i