2014-10-13 14:12:33 +02:00
|
|
|
#include "regex.hh"
|
|
|
|
|
|
|
|
#include "exception.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
String option_to_string(const Regex& re)
|
|
|
|
{
|
2015-03-10 20:33:46 +01:00
|
|
|
const auto& str = re.str();
|
2015-04-27 17:39:51 +02:00
|
|
|
return {str.begin(), str.end()};
|
2014-10-13 14:12:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void option_from_string(StringView str, Regex& re)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
re = Regex{str.begin(), str.end()};
|
|
|
|
}
|
|
|
|
catch (RegexError& err)
|
|
|
|
{
|
2015-06-01 20:06:35 +02:00
|
|
|
throw runtime_error(format("unable to create regex: {}", err.what()));
|
2014-10-13 14:12:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|