regex.cc (647B)
1 #include "regex.hh" 2 #include "string_utils.hh" 3 4 namespace Kakoune 5 { 6 7 Regex::Regex(StringView re, RegexCompileFlags flags) 8 : m_impl{new Impl{}}, 9 m_str{re.str()} 10 { 11 static_cast<CompiledRegex&>(*m_impl) = compile_regex(re, flags); 12 } 13 14 int Regex::named_capture_index(StringView name) const 15 { 16 for (auto capture : m_impl->named_captures) 17 { 18 if (capture.name == name) 19 return capture.index; 20 } 21 return -1; 22 } 23 24 String option_to_string(const Regex& re, Quoting quoting) 25 { 26 return option_to_string(re.str(), quoting); 27 } 28 29 Regex option_from_string(Meta::Type<Regex>, StringView str) 30 { 31 return Regex{str}; 32 } 33 34 }