michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsCollationMacUC_h_ michael@0: #define nsCollationMacUC_h_ michael@0: michael@0: #include "nsICollation.h" michael@0: #include "nsCollation.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include michael@0: michael@0: // Maximum number of characters for a buffer to remember michael@0: // the generated collation key. michael@0: const uint32_t kCacheSize = 128; michael@0: // According to the documentation, the length of the key should typically be michael@0: // at least 5 * textLength, but 6* would be safer. michael@0: const uint32_t kCollationValueSizeFactor = 6; michael@0: michael@0: class nsCollationMacUC MOZ_FINAL : public nsICollation { michael@0: michael@0: public: michael@0: nsCollationMacUC(); michael@0: ~nsCollationMacUC(); michael@0: michael@0: // nsISupports interface michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsICollation interface michael@0: NS_DECL_NSICOLLATION michael@0: michael@0: protected: michael@0: nsresult ConvertLocale(nsILocale* aNSLocale, LocaleRef* aMacLocale); michael@0: nsresult StrengthToOptions(const int32_t aStrength, michael@0: UCCollateOptions* aOptions); michael@0: nsresult EnsureCollator(const int32_t newStrength); michael@0: michael@0: private: michael@0: bool mInit; michael@0: bool mHasCollator; michael@0: LocaleRef mLocale; michael@0: int32_t mLastStrength; michael@0: CollatorRef mCollator; michael@0: void *mBuffer; // temporary buffer to generate collation keys michael@0: uint32_t mBufferLen; // byte length of buffer michael@0: }; michael@0: michael@0: #endif /* nsCollationMacUC_h_ */