• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 
16 #include "i18n_breakIterator_impl.h"
17 #include <memory>
18 #include "i18n_hilog.h"
19 
20 namespace OHOS {
21 namespace Global {
22 namespace I18n {
CBreakIterator(std::string localeTag)23 CBreakIterator::CBreakIterator(std::string localeTag)
24 {
25     brkiter_ = std::make_unique<I18nBreakIterator>(localeTag);
26     if (brkiter_ == nullptr) {
27         HILOG_ERROR_I18N("Create I18nBreakIterator fail");
28     }
29 }
30 
SetLineBreakText(const char * text)31 void CBreakIterator::SetLineBreakText(const char* text)
32 {
33     brkiter_->SetText(text);
34 }
35 
GetLineBreakText()36 std::string CBreakIterator::GetLineBreakText()
37 {
38     std::string res;
39     brkiter_->GetText(res);
40     return res;
41 }
42 
current()43 int32_t CBreakIterator::current()
44 {
45     return brkiter_->Current();
46 }
47 
first()48 int32_t CBreakIterator::first()
49 {
50     return brkiter_->First();
51 }
52 
last()53 int32_t CBreakIterator::last()
54 {
55     return brkiter_->Last();
56 }
57 
next(int32_t number)58 int32_t CBreakIterator::next(int32_t number)
59 {
60     return brkiter_->Next(number);
61 }
62 
previous()63 int32_t CBreakIterator::previous()
64 {
65     return brkiter_->Previous();
66 }
67 
following(int32_t offset)68 int32_t CBreakIterator::following(int32_t offset)
69 {
70     return brkiter_->Following(offset);
71 }
72 
IsBoundary(int32_t offset)73 bool CBreakIterator::IsBoundary(int32_t offset)
74 {
75     return brkiter_->IsBoundary(offset);
76 }
77 }  // namespace I18n
78 }  // namespace Global
79 }  // namespace OHOS