| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 USING_FAST_MALLOC(Collator); | 44 USING_FAST_MALLOC(Collator); |
| 45 | 45 |
| 46 public: | 46 public: |
| 47 enum Result { Equal = 0, Greater = 1, Less = -1 }; | 47 enum Result { Equal = 0, Greater = 1, Less = -1 }; |
| 48 | 48 |
| 49 // From ICU's uloc.h (ULOC_FULLNAME_CAPACITY) | 49 // From ICU's uloc.h (ULOC_FULLNAME_CAPACITY) |
| 50 static const size_t ulocFullnameCapacity = 157; | 50 static const size_t ulocFullnameCapacity = 157; |
| 51 | 51 |
| 52 // Parsing is lenient; e.g. language identifiers (such as "en-US") are | 52 // Parsing is lenient; e.g. language identifiers (such as "en-US") are |
| 53 // accepted, too. | 53 // accepted, too. |
| 54 Collator(const char* locale); | 54 explicit Collator(const char* locale); |
| 55 | 55 |
| 56 ~Collator(); | 56 ~Collator(); |
| 57 void setOrderLowerFirst(bool); | 57 void setOrderLowerFirst(bool); |
| 58 | 58 |
| 59 static std::unique_ptr<Collator> userDefault(); | 59 static std::unique_ptr<Collator> userDefault(); |
| 60 | 60 |
| 61 Result collate(const ::UChar*, size_t, const ::UChar*, size_t) const; | 61 Result collate(const ::UChar*, size_t, const ::UChar*, size_t) const; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 void createCollator() const; | 64 void createCollator() const; |
| 65 void releaseCollator(); | 65 void releaseCollator(); |
| 66 void setEquivalentLocale(const char*, char*); | 66 void setEquivalentLocale(const char*, char*); |
| 67 mutable UCollator* m_collator; | 67 mutable UCollator* m_collator; |
| 68 | 68 |
| 69 char* m_locale; | 69 char* m_locale; |
| 70 char m_equivalentLocale[ulocFullnameCapacity]; | 70 char m_equivalentLocale[ulocFullnameCapacity]; |
| 71 bool m_lowerFirst; | 71 bool m_lowerFirst; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace WTF | 74 } // namespace WTF |
| 75 | 75 |
| 76 using WTF::Collator; | 76 using WTF::Collator; |
| 77 | 77 |
| 78 #endif | 78 #endif |
| OLD | NEW |