| OLD | NEW |
| 1 /** | 1 /** |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 2001-2012, International Business Machines Corporation. | 3 * Copyright (C) 2001-2014, International Business Machines Corporation. |
| 4 * All Rights Reserved. | 4 * All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "unicode/utypes.h" | 8 #include "unicode/utypes.h" |
| 9 | 9 |
| 10 #if !UCONFIG_NO_SERVICE | 10 #if !UCONFIG_NO_SERVICE |
| 11 | 11 |
| 12 #include "serv.h" | 12 #include "serv.h" |
| 13 #include "umutex.h" | 13 #include "umutex.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 result.remove(0, n+1); | 95 result.remove(0, n+1); |
| 96 } | 96 } |
| 97 return result; | 97 return result; |
| 98 } | 98 } |
| 99 | 99 |
| 100 #ifdef SERVICE_DEBUG | 100 #ifdef SERVICE_DEBUG |
| 101 UnicodeString& | 101 UnicodeString& |
| 102 ICUServiceKey::debug(UnicodeString& result) const | 102 ICUServiceKey::debug(UnicodeString& result) const |
| 103 { | 103 { |
| 104 debugClass(result); | 104 debugClass(result); |
| 105 result.append(" id: "); | 105 result.append((UnicodeString)" id: "); |
| 106 result.append(_id); | 106 result.append(_id); |
| 107 return result; | 107 return result; |
| 108 } | 108 } |
| 109 | 109 |
| 110 UnicodeString& | 110 UnicodeString& |
| 111 ICUServiceKey::debugClass(UnicodeString& result) const | 111 ICUServiceKey::debugClass(UnicodeString& result) const |
| 112 { | 112 { |
| 113 return result.append("ICUServiceKey"); | 113 return result.append((UnicodeString)"ICUServiceKey"); |
| 114 } | 114 } |
| 115 #endif | 115 #endif |
| 116 | 116 |
| 117 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ICUServiceKey) | 117 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ICUServiceKey) |
| 118 | 118 |
| 119 /* | 119 /* |
| 120 ****************************************************************** | 120 ****************************************************************** |
| 121 */ | 121 */ |
| 122 | 122 |
| 123 ICUServiceFactory::~ICUServiceFactory() {} | 123 ICUServiceFactory::~ICUServiceFactory() {} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 result.setToBogus(); | 163 result.setToBogus(); |
| 164 } | 164 } |
| 165 return result; | 165 return result; |
| 166 } | 166 } |
| 167 | 167 |
| 168 #ifdef SERVICE_DEBUG | 168 #ifdef SERVICE_DEBUG |
| 169 UnicodeString& | 169 UnicodeString& |
| 170 SimpleFactory::debug(UnicodeString& toAppendTo) const | 170 SimpleFactory::debug(UnicodeString& toAppendTo) const |
| 171 { | 171 { |
| 172 debugClass(toAppendTo); | 172 debugClass(toAppendTo); |
| 173 toAppendTo.append(" id: "); | 173 toAppendTo.append((UnicodeString)" id: "); |
| 174 toAppendTo.append(_id); | 174 toAppendTo.append(_id); |
| 175 toAppendTo.append(", visible: "); | 175 toAppendTo.append((UnicodeString)", visible: "); |
| 176 toAppendTo.append(_visible ? "T" : "F"); | 176 toAppendTo.append(_visible ? (UnicodeString)"T" : (UnicodeString)"F"); |
| 177 return toAppendTo; | 177 return toAppendTo; |
| 178 } | 178 } |
| 179 | 179 |
| 180 UnicodeString& | 180 UnicodeString& |
| 181 SimpleFactory::debugClass(UnicodeString& toAppendTo) const | 181 SimpleFactory::debugClass(UnicodeString& toAppendTo) const |
| 182 { | 182 { |
| 183 return toAppendTo.append("SimpleFactory"); | 183 return toAppendTo.append((UnicodeString)"SimpleFactory"); |
| 184 } | 184 } |
| 185 #endif | 185 #endif |
| 186 | 186 |
| 187 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleFactory) | 187 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SimpleFactory) |
| 188 | 188 |
| 189 /* | 189 /* |
| 190 ****************************************************************** | 190 ****************************************************************** |
| 191 */ | 191 */ |
| 192 | 192 |
| 193 ServiceListener::~ServiceListener() {} | 193 ServiceListener::~ServiceListener() {} |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 if (U_FAILURE(status)) { | 612 if (U_FAILURE(status)) { |
| 613 return result; | 613 return result; |
| 614 } | 614 } |
| 615 | 615 |
| 616 { | 616 { |
| 617 Mutex mutex(&lock); | 617 Mutex mutex(&lock); |
| 618 const Hashtable* map = getVisibleIDMap(status); | 618 const Hashtable* map = getVisibleIDMap(status); |
| 619 if (map != NULL) { | 619 if (map != NULL) { |
| 620 ICUServiceKey* fallbackKey = createKey(matchID, status); | 620 ICUServiceKey* fallbackKey = createKey(matchID, status); |
| 621 | 621 |
| 622 for (int32_t pos = -1;;) { | 622 for (int32_t pos = UHASH_FIRST;;) { |
| 623 const UHashElement* e = map->nextElement(pos); | 623 const UHashElement* e = map->nextElement(pos); |
| 624 if (e == NULL) { | 624 if (e == NULL) { |
| 625 break; | 625 break; |
| 626 } | 626 } |
| 627 | 627 |
| 628 const UnicodeString* id = (const UnicodeString*)e->key.pointer; | 628 const UnicodeString* id = (const UnicodeString*)e->key.pointer; |
| 629 if (fallbackKey != NULL) { | 629 if (fallbackKey != NULL) { |
| 630 if (!fallbackKey->isFallbackOf(*id)) { | 630 if (!fallbackKey->isFallbackOf(*id)) { |
| 631 continue; | 631 continue; |
| 632 } | 632 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 const Hashtable* m = getVisibleIDMap(status); | 754 const Hashtable* m = getVisibleIDMap(status); |
| 755 if (U_FAILURE(status)) { | 755 if (U_FAILURE(status)) { |
| 756 return result; | 756 return result; |
| 757 } | 757 } |
| 758 ncthis->dnCache = new DNCache(locale); | 758 ncthis->dnCache = new DNCache(locale); |
| 759 if (dnCache == NULL) { | 759 if (dnCache == NULL) { |
| 760 status = U_MEMORY_ALLOCATION_ERROR; | 760 status = U_MEMORY_ALLOCATION_ERROR; |
| 761 return result; | 761 return result; |
| 762 } | 762 } |
| 763 | 763 |
| 764 int32_t pos = -1; | 764 int32_t pos = UHASH_FIRST; |
| 765 const UHashElement* entry = NULL; | 765 const UHashElement* entry = NULL; |
| 766 while ((entry = m->nextElement(pos)) != NULL) { | 766 while ((entry = m->nextElement(pos)) != NULL) { |
| 767 const UnicodeString* id = (const UnicodeString*)entry->key.point
er; | 767 const UnicodeString* id = (const UnicodeString*)entry->key.point
er; |
| 768 ICUServiceFactory* f = (ICUServiceFactory*)entry->value.pointer; | 768 ICUServiceFactory* f = (ICUServiceFactory*)entry->value.pointer; |
| 769 UnicodeString dname; | 769 UnicodeString dname; |
| 770 f->getDisplayName(*id, locale, dname); | 770 f->getDisplayName(*id, locale, dname); |
| 771 if (dname.isBogus()) { | 771 if (dname.isBogus()) { |
| 772 status = U_MEMORY_ALLOCATION_ERROR; | 772 status = U_MEMORY_ALLOCATION_ERROR; |
| 773 } else { | 773 } else { |
| 774 dnCache->cache.put(dname, (void*)id, status); // share point
er with visibleIDMap | 774 dnCache->cache.put(dname, (void*)id, status); // share point
er with visibleIDMap |
| 775 if (U_SUCCESS(status)) { | 775 if (U_SUCCESS(status)) { |
| 776 continue; | 776 continue; |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 delete dnCache; | 779 delete dnCache; |
| 780 ncthis->dnCache = NULL; | 780 ncthis->dnCache = NULL; |
| 781 return result; | 781 return result; |
| 782 } | 782 } |
| 783 } | 783 } |
| 784 } | 784 } |
| 785 | 785 |
| 786 ICUServiceKey* matchKey = createKey(matchID, status); | 786 ICUServiceKey* matchKey = createKey(matchID, status); |
| 787 /* To ensure that all elements in the hashtable are iterated, set pos to -1. | 787 /* To ensure that all elements in the hashtable are iterated, set pos to -1. |
| 788 * nextElement(pos) will skip the position at pos and begin the iteration | 788 * nextElement(pos) will skip the position at pos and begin the iteration |
| 789 * at the next position, which in this case will be 0. | 789 * at the next position, which in this case will be 0. |
| 790 */ | 790 */ |
| 791 int32_t pos = -1; | 791 int32_t pos = UHASH_FIRST; |
| 792 const UHashElement *entry = NULL; | 792 const UHashElement *entry = NULL; |
| 793 while ((entry = dnCache->cache.nextElement(pos)) != NULL) { | 793 while ((entry = dnCache->cache.nextElement(pos)) != NULL) { |
| 794 const UnicodeString* id = (const UnicodeString*)entry->value.pointer; | 794 const UnicodeString* id = (const UnicodeString*)entry->value.pointer; |
| 795 if (matchKey != NULL && !matchKey->isFallbackOf(*id)) { | 795 if (matchKey != NULL && !matchKey->isFallbackOf(*id)) { |
| 796 continue; | 796 continue; |
| 797 } | 797 } |
| 798 const UnicodeString* dn = (const UnicodeString*)entry->key.pointer; | 798 const UnicodeString* dn = (const UnicodeString*)entry->key.pointer; |
| 799 StringPair* sp = StringPair::create(*id, *dn, status); | 799 StringPair* sp = StringPair::create(*id, *dn, status); |
| 800 result.addElement(sp, status); | 800 result.addElement(sp, status); |
| 801 if (U_FAILURE(status)) { | 801 if (U_FAILURE(status)) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 int32_t | 972 int32_t |
| 973 ICUService::getTimestamp() const | 973 ICUService::getTimestamp() const |
| 974 { | 974 { |
| 975 return timestamp; | 975 return timestamp; |
| 976 } | 976 } |
| 977 | 977 |
| 978 U_NAMESPACE_END | 978 U_NAMESPACE_END |
| 979 | 979 |
| 980 /* UCONFIG_NO_SERVICE */ | 980 /* UCONFIG_NO_SERVICE */ |
| 981 #endif | 981 #endif |
| OLD | NEW |