Add a disabled wrapper for using std regex instead of boost
This commit is contained in:
parent
eb0d03f437
commit
e362eb4f3b
38
src/regex.hh
38
src/regex.hh
|
@ -3,26 +3,50 @@
|
||||||
|
|
||||||
#include "string.hh"
|
#include "string.hh"
|
||||||
|
|
||||||
#if 0
|
#ifdef KAK_USE_STDREGEX
|
||||||
#include <regex>
|
#include <regex>
|
||||||
namespace kak_regex_ns = std;
|
|
||||||
#else
|
#else
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
namespace kak_regex_ns = boost;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
using Regex = kak_regex_ns::regex;
|
#ifdef KAK_USE_STDREGEX
|
||||||
|
// Regex that keeps track of its string representation
|
||||||
|
struct Regex : std::regex
|
||||||
|
{
|
||||||
|
Regex() = default;
|
||||||
|
|
||||||
|
explicit Regex(StringView re, flag_type flags = ECMAScript)
|
||||||
|
: std::regex(re.begin(), re.end(), flags), m_str(re) {}
|
||||||
|
|
||||||
|
template<typename Iterator>
|
||||||
|
Regex(Iterator begin, Iterator end, flag_type flags = ECMAScript)
|
||||||
|
: std::regex(begin, end, flags), m_str(begin, end) {}
|
||||||
|
|
||||||
|
bool empty() const { return m_str.empty(); }
|
||||||
|
bool operator==(const Regex& other) { return m_str == other.m_str; }
|
||||||
|
bool operator!=(const Regex& other) { return m_str != other.m_str; }
|
||||||
|
|
||||||
|
StringView str() const { return m_str; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
String m_str;
|
||||||
|
};
|
||||||
|
namespace regex_ns = std;
|
||||||
|
#else
|
||||||
|
namespace regex_ns = boost;
|
||||||
|
using Regex = boost::regex;
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename Iterator>
|
template<typename Iterator>
|
||||||
using RegexIterator = kak_regex_ns::regex_iterator<Iterator>;
|
using RegexIterator = regex_ns::regex_iterator<Iterator>;
|
||||||
|
|
||||||
template<typename Iterator>
|
template<typename Iterator>
|
||||||
using MatchResults = kak_regex_ns::match_results<Iterator>;
|
using MatchResults = regex_ns::match_results<Iterator>;
|
||||||
|
|
||||||
using RegexError = kak_regex_ns::regex_error;
|
using RegexError = regex_ns::regex_error;
|
||||||
|
|
||||||
String option_to_string(const Regex& re);
|
String option_to_string(const Regex& re);
|
||||||
void option_from_string(StringView str, Regex& re);
|
void option_from_string(StringView str, Regex& re);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user