1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_GLOBAL_I18N_BREAKITERATOR_H 16 #define OHOS_GLOBAL_I18N_BREAKITERATOR_H 17 18 #include <cstdint> 19 20 #include "iosfwd" 21 #include "unicode/brkiter.h" 22 #include "unicode/unistr.h" 23 24 namespace OHOS { 25 namespace Global { 26 namespace I18n { 27 class I18nBreakIterator { 28 public: 29 explicit I18nBreakIterator(std::string lcoaleTag); 30 virtual ~I18nBreakIterator(); 31 int32_t Current(); 32 int32_t First(); 33 int32_t Last(); 34 int32_t Next(int32_t number); 35 int32_t Next(); 36 int32_t Previous(); 37 int32_t Following(int32_t offset); 38 void SetText(const char* text); 39 void GetText(std::string &str); 40 bool IsBoundary(int32_t offset); 41 protected: 42 virtual icu::BreakIterator* GetBreakIterator(); 43 private: 44 icu::BreakIterator *iter = nullptr; 45 icu::UnicodeString ftext = ""; 46 static constexpr int32_t OFF_BOUND = -1; 47 }; 48 } // namespace I18n 49 } // namespace Global 50 } // namespace OHOS 51 #endif