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/. */
5 #ifndef mozilla_intl_WordBreaker_h__
6 #define mozilla_intl_WordBreaker_h__
10 #define NS_WORDBREAKER_NEED_MORE_TEXT -1
20 class WordBreaker final
{
22 // WordBreaker is a utility class with only static methods. No need to
24 WordBreaker() = delete;
25 ~WordBreaker() = delete;
27 // Find the word boundary by scanning forward and backward from aPos.
29 // @return WordRange where mBegin equals to the offset to first character in
30 // the word and mEnd equals to the offset to the last character plus 1. mEnd
31 // can be aLen if the desired word is at the end of aText.
33 // If aPos is already at the end of aText or beyond, both mBegin and mEnd
35 static WordRange
FindWord(const char16_t
* aText
, uint32_t aLen
,
38 // Find the next word break opportunity starting from aPos + 1. It can return
39 // aLen if there's no break opportunity between [aPos + 1, aLen - 1].
41 // If aPos is already at the end of aText or beyond, i.e. aPos >= aLen, return
42 // NS_WORDBREAKER_NEED_MORE_TEXT.
44 // DEPRECATED: Use WordBreakIteratorUtf16 instead.
45 static int32_t Next(const char16_t
* aText
, uint32_t aLen
, uint32_t aPos
);
48 enum WordBreakClass
: uint8_t {
53 kWbClassKatakanaLetter
,
54 kWbClassHiraganaLetter
,
55 kWbClassHWKatakanaLetter
,
56 kWbClassScriptioContinua
59 static WordBreakClass
GetClass(char16_t aChar
);
63 } // namespace mozilla
65 #endif /* mozilla_intl_WordBreaker_h__ */