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 21 matching lines...) Expand all Loading... |
32 #include "wtf/FastAllocBase.h" | 32 #include "wtf/FastAllocBase.h" |
33 #include "wtf/Noncopyable.h" | 33 #include "wtf/Noncopyable.h" |
34 #include "wtf/PassOwnPtr.h" | 34 #include "wtf/PassOwnPtr.h" |
35 #include "wtf/WTFExport.h" | 35 #include "wtf/WTFExport.h" |
36 #include "wtf/text/Unicode.h" | 36 #include "wtf/text/Unicode.h" |
37 | 37 |
38 struct UCollator; | 38 struct UCollator; |
39 | 39 |
40 namespace WTF { | 40 namespace WTF { |
41 | 41 |
42 class WTF_EXPORT Collator { | 42 class WTF_EXPORT Collator { |
43 WTF_MAKE_NONCOPYABLE(Collator); WTF_MAKE_FAST_ALLOCATED(Collator); | 43 WTF_MAKE_NONCOPYABLE(Collator); |
44 public: | 44 WTF_MAKE_FAST_ALLOCATED(Collator); |
45 enum Result { Equal = 0, Greater = 1, Less = -1 }; | 45 public: |
| 46 enum Result { Equal = 0, Greater = 1, Less = -1 }; |
46 | 47 |
47 // From ICU's uloc.h (ULOC_FULLNAME_CAPACITY) | 48 // From ICU's uloc.h (ULOC_FULLNAME_CAPACITY) |
48 static const size_t ulocFullnameCapacity = 157; | 49 static const size_t ulocFullnameCapacity = 157; |
49 | 50 |
50 Collator(const char* locale); // Parsing is lenient; e.g. language ident
ifiers (such as "en-US") are accepted, too. | 51 Collator(const char* locale); // Parsing is lenient; e.g. language identifie
rs (such as "en-US") are accepted, too. |
51 ~Collator(); | 52 ~Collator(); |
52 void setOrderLowerFirst(bool); | 53 void setOrderLowerFirst(bool); |
53 | 54 |
54 static PassOwnPtr<Collator> userDefault(); | 55 static PassOwnPtr<Collator> userDefault(); |
55 | 56 |
56 Result collate(const ::UChar*, size_t, const ::UChar*, size_t) const; | 57 Result collate(const ::UChar*, size_t, const ::UChar*, size_t) const; |
57 | 58 |
58 private: | 59 private: |
59 void createCollator() const; | 60 void createCollator() const; |
60 void releaseCollator(); | 61 void releaseCollator(); |
61 void setEquivalentLocale(const char*, char*); | 62 void setEquivalentLocale(const char*, char*); |
62 mutable UCollator* m_collator; | 63 mutable UCollator* m_collator; |
63 | 64 |
64 char* m_locale; | 65 char* m_locale; |
65 char m_equivalentLocale[ulocFullnameCapacity]; | 66 char m_equivalentLocale[ulocFullnameCapacity]; |
66 bool m_lowerFirst; | 67 bool m_lowerFirst; |
67 }; | 68 }; |
| 69 |
68 } | 70 } |
69 | 71 |
70 using WTF::Collator; | 72 using WTF::Collator; |
71 | 73 |
72 #endif | 74 #endif |
OLD | NEW |