Backed out 2 changesets (bug 903746) for causing non-unified build bustages on nsIPri...
[gecko.git] / intl / hyphenation / glue / nsHyphenator.h
blob7574d57fdbbebaf7ae237f0917a91c406cc27975
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsHyphenator_h__
7 #define nsHyphenator_h__
9 #include "base/shared_memory.h"
10 #include "mozilla/UniquePtr.h"
11 #include "mozilla/Variant.h"
12 #include "nsCOMPtr.h"
13 #include "nsString.h"
14 #include "nsTArray.h"
16 class nsIURI;
17 struct HyphDic;
18 struct CompiledData;
20 namespace mozilla {
21 template <>
22 class DefaultDelete<const HyphDic> {
23 public:
24 void operator()(const HyphDic* ptr) const;
27 template <>
28 class DefaultDelete<const CompiledData> {
29 public:
30 void operator()(const CompiledData* ptr) const;
32 } // namespace mozilla
34 class nsHyphenator {
35 public:
36 nsHyphenator(nsIURI* aURI, bool aHyphenateCapitalized);
38 NS_INLINE_DECL_REFCOUNTING(nsHyphenator)
40 bool IsValid();
42 nsresult Hyphenate(const nsAString& aText, nsTArray<bool>& aHyphens);
44 void CloneHandle(base::SharedMemoryHandle* aOutHandle, uint32_t* aOutSize);
46 private:
47 ~nsHyphenator() = default;
49 void HyphenateWord(const nsAString& aString, uint32_t aStart, uint32_t aLimit,
50 nsTArray<bool>& aHyphens);
52 mozilla::Variant<const void*, // raw pointer to uncompressed omnijar data
53 mozilla::UniquePtr<base::SharedMemory>, // shmem block
54 mozilla::UniquePtr<const HyphDic> // loaded by mapped_hyph
56 mDict;
57 uint32_t mDictSize; // size of mDict data (not used if type is HyphDic)
58 bool mHyphenateCapitalized;
61 #endif // nsHyphenator_h__