1 /* 2 * Copyright (c) 2023 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_MATCHED_NUMBER_INFO_H 16 #define OHOS_GLOBAL_MATCHED_NUMBER_INFO_H 17 18 #include <unicode/regex.h> 19 20 namespace OHOS { 21 namespace Global { 22 namespace I18n { 23 class MatchedNumberInfo { 24 public: MatchedNumberInfo()25 MatchedNumberInfo() : _begin(-1), _end(-1) {} MatchedNumberInfo(int begin,int end,icu::UnicodeString & content)26 MatchedNumberInfo(int begin, int end, icu::UnicodeString& content) : _begin(begin), _end(end), content(content) {} ~MatchedNumberInfo()27 ~MatchedNumberInfo() {} 28 SetBegin(int begin)29 void SetBegin(int begin) 30 { 31 this->_begin = begin; 32 } 33 GetBegin()34 int GetBegin() 35 { 36 return _begin; 37 } 38 SetEnd(int end)39 void SetEnd(int end) 40 { 41 this->_end = end; 42 } 43 GetEnd()44 int GetEnd() 45 { 46 return _end; 47 } 48 SetContent(icu::UnicodeString & content)49 void SetContent(icu::UnicodeString& content) 50 { 51 this->content = content; 52 } 53 GetContent()54 icu::UnicodeString GetContent() 55 { 56 return content; 57 } 58 59 bool operator<(const MatchedNumberInfo& info) const 60 { 61 if (_begin < info._begin) { 62 return true; 63 } else if (_begin == info._begin && _end < info._end) { 64 return true; 65 } else if (_begin == info._begin && _end == info._end && content < info.content) { 66 return true; 67 } 68 return false; 69 } 70 71 private: 72 // Start position of the phone number 73 int _begin; 74 // End position of the phone number 75 int _end; 76 // content of the phone number 77 icu::UnicodeString content; 78 }; 79 } // namespace I18n 80 } // namespace Global 81 } // namespace OHOS 82 #endif