1 // Copyright 2016 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_INSPECTOR_V8_REGEX_H_ 6 #define V8_INSPECTOR_V8_REGEX_H_ 7 8 #include "include/v8-persistent-handle.h" 9 #include "src/base/macros.h" 10 #include "src/inspector/string-16.h" 11 12 namespace v8 { 13 class RegExp; 14 } 15 16 namespace v8_inspector { 17 18 class V8InspectorImpl; 19 20 enum MultilineMode { MultilineDisabled, MultilineEnabled }; 21 22 class V8Regex { 23 public: 24 V8Regex(V8InspectorImpl*, const String16&, bool caseSensitive, 25 bool multiline = false); 26 V8Regex(const V8Regex&) = delete; 27 V8Regex& operator=(const V8Regex&) = delete; 28 int match(const String16&, int startFrom = 0, 29 int* matchLength = nullptr) const; isValid()30 bool isValid() const { return !m_regex.IsEmpty(); } errorMessage()31 const String16& errorMessage() const { return m_errorMessage; } 32 33 private: 34 V8InspectorImpl* m_inspector; 35 v8::Global<v8::RegExp> m_regex; 36 String16 m_errorMessage; 37 }; 38 39 } // namespace v8_inspector 40 41 #endif // V8_INSPECTOR_V8_REGEX_H_ 42