diff options
Diffstat (limited to '')
-rw-r--r-- | src/pcrepp/pcre2pp.hh | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/pcrepp/pcre2pp.hh b/src/pcrepp/pcre2pp.hh index 59a2cf1..ae39871 100644 --- a/src/pcrepp/pcre2pp.hh +++ b/src/pcrepp/pcre2pp.hh @@ -46,14 +46,6 @@ namespace lnav { namespace pcre2pp { -std::string quote(const char* unquoted); - -inline std::string -quote(const std::string& unquoted) -{ - return quote(unquoted.c_str()); -} - class code; struct capture_builder; class matcher; @@ -108,6 +100,8 @@ public: uint32_t get_capacity() const { return this->md_ovector_count; } + std::string to_string() const; + private: friend matcher; friend code; @@ -254,11 +248,20 @@ public: template<typename T, std::size_t N> static code from_const(const T (&str)[N], int options = 0) { - return from(string_fragment::from_const(str), options).unwrap(); + auto res = from(string_fragment::from_const(str), options); + + if (res.isErr()) { + fprintf(stderr, "failed to compile constant regex: %s\n", str); + fprintf(stderr, " %s\n", res.unwrapErr().get_message().c_str()); + } + + return res.unwrap(); } const std::string& get_pattern() const { return this->p_pattern; } + std::string to_string() const { return this->p_pattern; } + named_captures get_named_captures() const; const char* get_name_for_capture(size_t index) const; |