1 /** 2 * Copyright (c) 2025 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 #ifndef PANDA_RUNTIME_REGEXP_H 17 #define PANDA_RUNTIME_REGEXP_H 18 19 #include "plugins/ets/runtime/regexp/regexp_executor.h" 20 #include "plugins/ets/runtime/types/ets_string.h" 21 22 namespace ark::ets { 23 24 class pcre2_code; 25 26 class EtsRegExp { 27 public: 28 void SetFlags(EtsString *flagsStr); 29 bool Compile(const PandaVector<uint8_t> &pattern, const bool isUtf16, const int len); 30 RegExpExecResult Execute(const PandaVector<uint8_t> &str, const int len, const int startOffset); 31 void Destroy(); 32 IsUtf16()33 bool IsUtf16() const 34 { 35 return utf16_; 36 } 37 38 private: 39 void SetFlag(const char &chr); 40 void SetUnicodeFlag(const char &chr); 41 void SetIfNotSet(bool &flag); 42 void ThrowBadFlagsException(); 43 44 void *re_ = nullptr; 45 bool flagGlobal_ = false; // g 46 bool flagMultiline_ = false; // m 47 bool flagCaseInsentitive_ = false; // i 48 bool flagSticky_ = false; // y 49 bool flagUnicode_ = false; // u 50 bool flagVnicode_ = false; // v 51 bool flagDotAll_ = false; // s 52 bool flagIndices_ = false; // d 53 bool utf16_ = false; 54 }; 55 56 } // namespace ark::ets 57 #endif // PANDA_RUNTIME_REGEXP_H