1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/locale/src/mac/nsCollationMacUC.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsCollationMacUC_h_ 1.10 +#define nsCollationMacUC_h_ 1.11 + 1.12 +#include "nsICollation.h" 1.13 +#include "nsCollation.h" 1.14 +#include "mozilla/Attributes.h" 1.15 +#include <Carbon/Carbon.h> 1.16 + 1.17 +// Maximum number of characters for a buffer to remember 1.18 +// the generated collation key. 1.19 +const uint32_t kCacheSize = 128; 1.20 +// According to the documentation, the length of the key should typically be 1.21 +// at least 5 * textLength, but 6* would be safer. 1.22 +const uint32_t kCollationValueSizeFactor = 6; 1.23 + 1.24 +class nsCollationMacUC MOZ_FINAL : public nsICollation { 1.25 + 1.26 +public: 1.27 + nsCollationMacUC(); 1.28 + ~nsCollationMacUC(); 1.29 + 1.30 + // nsISupports interface 1.31 + NS_DECL_ISUPPORTS 1.32 + 1.33 + // nsICollation interface 1.34 + NS_DECL_NSICOLLATION 1.35 + 1.36 +protected: 1.37 + nsresult ConvertLocale(nsILocale* aNSLocale, LocaleRef* aMacLocale); 1.38 + nsresult StrengthToOptions(const int32_t aStrength, 1.39 + UCCollateOptions* aOptions); 1.40 + nsresult EnsureCollator(const int32_t newStrength); 1.41 + 1.42 +private: 1.43 + bool mInit; 1.44 + bool mHasCollator; 1.45 + LocaleRef mLocale; 1.46 + int32_t mLastStrength; 1.47 + CollatorRef mCollator; 1.48 + void *mBuffer; // temporary buffer to generate collation keys 1.49 + uint32_t mBufferLen; // byte length of buffer 1.50 +}; 1.51 + 1.52 +#endif /* nsCollationMacUC_h_ */